/* Pannello «Pagine borgo» e vista della pagina dentro l'app.
   Palette di carta, coerente con il quaderno di viaggio: avorio, inchiostro,
   terracotta, oliva. Nessun gradiente decorativo. */

.borghi-page,
.borgo-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 0%, rgba(168, 69, 31, .07), transparent 34%),
    linear-gradient(180deg, #fbf7ef, #f4eee2);
  color: #1b1916;
  padding: clamp(16px, 3vw, 34px) clamp(12px, 3vw, 34px) 70px;
}

.borghi-page-shell,
.borgo-page-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.borghi-page-head,
.borgo-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 2px solid #1b1916;
  margin-bottom: 20px;
}

.borghi-page-eyebrow,
.borgo-page-eyebrow {
  margin: 0 0 8px;
  color: #a8451f;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .24em;
  text-transform: uppercase;
}

.borghi-page-head h1,
.borgo-page-head h1 {
  margin: 0;
  font: 600 clamp(1.8rem, 4.6vw, 3rem)/1.06 "Iowan Old Style", Palatino, Georgia, serif;
  letter-spacing: -.015em;
}

.borghi-page-sub,
.borgo-page-place {
  max-width: 62ch;
  margin: 10px 0 0;
  color: #514a41;
  font-size: .96rem;
  line-height: 1.6;
}

.borgo-page-actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* ── Schede ──────────────────────────────────────────────────── */
.borghi-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.borghi-tab {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid #ded3bf;
  border-radius: 999px;
  background: #fff;
  color: #514a41;
  font: 800 .86rem/1 system-ui, sans-serif;
  cursor: pointer;
}

.borghi-tab:hover { border-color: #a8451f; color: #a8451f; }
.borghi-tab.is-active { background: #1b1916; border-color: #1b1916; color: #fbf7ef; }
.borghi-tab:focus-visible { outline: 3px solid rgba(168, 69, 31, .3); outline-offset: 2px; }

.borghi-tab-bodies { display: grid; gap: 18px; }
.borghi-tab-panel[hidden] { display: none; }

.borghi-block {
  display: grid;
  gap: 12px;
  padding: clamp(16px, 2.4vw, 24px);
  border: 1px solid #ded3bf;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(51, 35, 17, .06);
}

.borghi-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.borghi-block h2 {
  margin: 0;
  font: 600 clamp(1.15rem, 2.4vw, 1.5rem)/1.15 "Iowan Old Style", Palatino, Georgia, serif;
}

.borghi-lead { margin: 0; color: #514a41; font-size: .95rem; line-height: 1.6; }
.borghi-hint { margin: 0; color: #746658; font-size: .84rem; line-height: 1.5; }
.borghi-count { color: #55603f; font-size: .78rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }

/* ── Campi ───────────────────────────────────────────────────── */
.borghi-filters {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 12px;
}

.borghi-field { display: grid; gap: 7px; }
.borghi-field span {
  color: #514a41;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.borghi-field input,
.borghi-field select {
  min-height: 46px;
  width: 100%;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid #ded3bf;
  border-radius: 11px;
  background: #fdfbf6;
  color: #1b1916;
  font: 600 .95rem/1 system-ui, sans-serif;
}

.borghi-field input:focus-visible,
.borghi-field select:focus-visible {
  outline: 3px solid rgba(168, 69, 31, .25);
  border-color: #a8451f;
}

.borghi-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #514a41;
  font-size: .88rem;
  line-height: 1.45;
}

.borghi-check input { width: 19px; height: 19px; margin-top: 2px; accent-color: #a8451f; flex: 0 0 auto; }

/* ── Elenco dei borghi ───────────────────────────────────────── */
.borghi-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
}

.borghi-item {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid #ded3bf;
  border-radius: 12px;
  background: #fdfbf6;
  color: #1b1916;
  text-align: left;
  cursor: pointer;
}

.borghi-item:hover { border-color: #a8451f; background: #fff; }
.borghi-item.is-active { border-color: #1b1916; background: #1b1916; color: #fbf7ef; }
.borghi-item.is-active .borghi-item-meta { color: #cbbfa9; }
.borghi-item:focus-visible { outline: 3px solid rgba(168, 69, 31, .3); outline-offset: 2px; }
.borghi-item-name { font: 600 1.02rem/1.2 "Iowan Old Style", Palatino, Georgia, serif; }
.borghi-item-meta { color: #746658; font-size: .76rem; font-weight: 700; letter-spacing: .03em; }

.borghi-tag {
  justify-self: start;
  margin-top: 2px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .64rem;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.borghi-tag-ricca { background: #e6efe0; color: #3f4d2c; }
.borghi-tag-media { background: #f4ead2; color: #7a5a17; }
.borghi-tag-minima { background: #f0e7e2; color: #7a5348; }

.borghi-more { justify-self: start; }
.borghi-empty { margin: 0; color: #746658; font-size: .92rem; }

/* ── Anteprima ───────────────────────────────────────────────── */
.borghi-snippet {
  display: grid;
  gap: 3px;
  padding: 14px 16px;
  border: 1px solid #ded3bf;
  border-radius: 12px;
  background: #fdfbf6;
}

.borghi-snippet-url { margin: 0; color: #3f4d2c; font-size: .76rem; font-weight: 700; }
.borghi-snippet-title { margin: 0; color: #1a0dab; font-size: 1.02rem; font-weight: 600; line-height: 1.3; }
.borghi-snippet-text { margin: 0; color: #514a41; font-size: .86rem; line-height: 1.5; }

.borghi-preview {
  border: 1px solid #ded3bf;
  border-radius: 14px;
  background: #fbf7ef;
  overflow: hidden;
  min-height: 220px;
}

.borghi-frame {
  display: block;
  width: 100%;
  height: min(74vh, 760px);
  border: 0;
  background: #fbf7ef;
}

.borghi-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.borghi-status { min-height: 20px; margin: 0; color: #746658; font-size: .84rem; font-weight: 750; }
.borghi-status[data-state="success"] { color: #28724e; }
.borghi-status[data-state="error"] { color: #a53f2c; }

.borghi-details { border-top: 1px solid #ded3bf; padding-top: 10px; }
.borghi-details summary { cursor: pointer; color: #514a41; font-size: .84rem; font-weight: 850; }

.borghi-pre,
.borghi-details pre,
.borghi-code {
  display: block;
  width: 100%;
  margin: 8px 0 0;
  padding: 12px 14px;
  border: 1px solid #ded3bf;
  border-radius: 11px;
  background: #f7f3ea;
  color: #2f2a24;
  font: 500 .78rem/1.5 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.borghi-code { resize: vertical; }

.borghi-qr { display: grid; justify-items: center; gap: 8px; padding: 14px; background: #fdfbf6; border: 1px solid #ded3bf; border-radius: 14px; }
.borghi-qr img { width: 220px; height: 220px; image-rendering: pixelated; }

.borghi-steps { margin: 0; padding-left: 20px; display: grid; gap: 10px; }
.borghi-steps li { color: #514a41; font-size: .92rem; line-height: 1.5; }
.borghi-steps strong { display: block; color: #1b1916; font: 600 1.05rem/1.25 "Iowan Old Style", Palatino, Georgia, serif; }

.borghi-related { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.borghi-related li { padding: 12px 14px; border: 1px solid #ded3bf; border-radius: 12px; background: #fdfbf6; }
.borghi-related strong { display: block; font: 600 1rem/1.25 "Iowan Old Style", Palatino, Georgia, serif; }
.borghi-related span { display: block; margin-top: 4px; color: #746658; font-size: .8rem; line-height: 1.45; }

/* ── La pagina borgo dentro l'app ────────────────────────────── */
.borgo-page-preview {
  margin: 0 -12px;
  background: #fbf7ef;
  color: #1b1916;
  font-family: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  font-size: 16.5px;
  line-height: 1.66;
  border-top: 1px solid #ded3bf;
}

.borgo-page-preview a { color: #a8451f; text-decoration: none; }
.borgo-page-preview a:hover { text-decoration: underline; }
.borgo-page-preview img { max-width: 100%; display: block; }
.borgo-page-preview h1,
.borgo-page-preview h2,
.borgo-page-preview h3 {
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-weight: 600;
  line-height: 1.16;
  margin: 0;
}
.borgo-page-preview p { margin: 0 0 .9em; }

.borgo-page-qr {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 20px 0 0;
  padding: 14px 16px;
  border: 1px dashed #a8451f;
  border-radius: 14px;
  background: #fff;
}
.borgo-page-qr img { width: 120px; height: 120px; image-rendering: pixelated; }
.borgo-page-qr p { margin: 0; color: #514a41; font-size: .86rem; line-height: 1.5; }

.borgo-empty {
  display: grid;
  gap: 14px;
  justify-items: start;
  padding: 26px;
  border: 1px solid #ded3bf;
  border-radius: 18px;
  background: #fff;
}
.borgo-empty p { margin: 0; color: #514a41; }

/* ── Foglio A4 da stampare ───────────────────────────────────── */
.borghi-sheet-preview { border: 1px solid #ded3bf; border-radius: 14px; background: #f7f3ea; padding: 12px; }

.borgo-sheet {
  background: #fff;
  color: #1b1916;
  padding: 22px;
  border-radius: 10px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.borgo-sheet-head { border-bottom: 2px solid #1b1916; padding-bottom: 12px; margin-bottom: 16px; }
.borgo-sheet-kicker { margin: 0 0 6px; color: #a8451f; font-size: 10.5px; font-weight: 900; letter-spacing: .24em; }
.borgo-sheet h1 { margin: 0; font: 600 clamp(1.6rem, 4vw, 2.3rem)/1.05 "Iowan Old Style", Palatino, Georgia, serif; }
.borgo-sheet-place { margin: 6px 0 0; color: #514a41; font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; }

.borgo-sheet-body { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.borgo-sheet-text p { margin: 0 0 10px; font-size: 14.5px; line-height: 1.6; color: #514a41; }
.borgo-sheet-text ul { margin: 0; padding-left: 18px; color: #55603f; font-size: 13px; font-weight: 700; }
.borgo-sheet-qr { display: grid; justify-items: center; gap: 8px; text-align: center; }
.borgo-sheet-qr img { width: 190px; height: 190px; image-rendering: pixelated; }
.borgo-sheet-hint { margin: 0; color: #514a41; font-size: 11.5px; line-height: 1.45; }
.borgo-sheet-url { margin: 0; color: #a8451f; font-size: 11.5px; font-weight: 800; word-break: break-all; }
.borgo-sheet-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 10px;
  border-top: 1px solid #ded3bf;
  color: #746658;
  font-size: 10.5px;
}

@media (max-width: 620px) {
  .borghi-filters { grid-template-columns: 1fr; }
  .borghi-list { grid-template-columns: 1fr; max-height: 320px; }
  .borgo-sheet-body { grid-template-columns: 1fr; }
  .borghi-actions .button { flex: 1 1 150px; }
  .borghi-tab { flex: 1 1 auto; justify-content: center; }
}

/* Alla stampa resta solo il foglio: vale solo quando il pannello è aperto,
   così la stampa della guida da viaggio non viene toccata. */
@media print {
  html.is-borghi-open body * { visibility: hidden !important; }
  html.is-borghi-open .borgo-sheet,
  html.is-borghi-open .borgo-sheet * { visibility: visible !important; }
  html.is-borghi-open .borgo-sheet {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    padding: 0;
    border-radius: 0;
  }
  html.is-borghi-open .borgo-sheet-qr img { width: 230px; height: 230px; }
  @page { size: A4; margin: 16mm; }
}
