/* RC88 · «Il territorio»: Personaggi, Parchi e natura, Sapori, Rievocazioni.
   Un unico linguaggio visivo per quattro mondi: carta avorio, inchiostro
   caldo, oro e un colore d'accento per sezione. */

.territorio-page {
  --ter-paper: #fffdf8;
  --ter-paper-2: #fbf4e6;
  --ter-ink: #2c241c;
  --ter-ink-soft: #6f6152;
  --ter-line: rgba(83, 61, 32, .18);
  --ter-gold: #a56a18;
  --ter-shadow: 0 14px 34px rgba(63, 39, 12, .10);
  --ter-radius: 20px;
  min-height: 100vh;
  background: linear-gradient(180deg, #fdf8ee 0%, #f7efdf 100%);
  color: var(--ter-ink);
}

.territorio-page[hidden],
.ter-hub[hidden],
.ter-sheet[hidden],
[data-ter-media][hidden],
[data-ter-photo][hidden] {
  display: none !important;
}

.territorio-page button {
  font-family: inherit;
}

.ter-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(12px, 2.6vw, 26px) clamp(12px, 3vw, 28px) 70px;
}

/* ── Barra superiore ─────────────────────────────────────────────────── */

.ter-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 12px;
  border: 1px solid var(--ter-line);
  border-radius: 16px;
  background: rgba(255, 253, 248, .94);
  box-shadow: 0 8px 20px rgba(63, 39, 12, .06);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.ter-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--ter-line);
  border-radius: 999px;
  background: #fff;
  color: #5c4326;
  font: 800 12.5px/1 system-ui, sans-serif;
  cursor: pointer;
}

.ter-back:hover { background: #fff7e4; transform: translateY(-1px); }
.ter-back:focus-visible { outline: 3px solid rgba(165, 106, 24, .38); outline-offset: 2px; }

.ter-brand {
  margin: 0;
  color: var(--ter-ink);
  font: 800 13px/1.2 system-ui, sans-serif;
  letter-spacing: .02em;
}

.ter-brand span {
  display: inline-block;
  margin-right: 6px;
  padding: 3px 7px;
  border-radius: 7px;
  background: var(--ter-ink);
  color: #ffe7b8;
  font-weight: 900;
  letter-spacing: .08em;
}

.ter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.ter-tab {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--ter-line);
  border-radius: 999px;
  background: #fff;
  color: #5c4326;
  font: 800 12.5px/1.15 system-ui, sans-serif;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}

.ter-tab:hover { background: #fff6e2; transform: translateY(-1px); }

.ter-tab[aria-current="page"] {
  border-color: var(--ter-accent, var(--ter-gold));
  background: var(--ter-accent, var(--ter-gold));
  color: #fff;
  box-shadow: 0 8px 18px rgba(63, 39, 12, .18);
}

.ter-tab:focus-visible { outline: 3px solid rgba(165, 106, 24, .4); outline-offset: 2px; }

/* ── Testata di sezione ──────────────────────────────────────────────── */

.ter-hero {
  margin: 22px 0 18px;
  padding: clamp(20px, 3.6vw, 34px);
  border: 1px solid var(--ter-line);
  border-left: 6px solid var(--ter-accent, var(--ter-gold));
  border-radius: var(--ter-radius);
  background:
    radial-gradient(circle at 88% 12%, rgba(255, 214, 138, .38), transparent 42%),
    linear-gradient(150deg, #fffdf8 0%, #fdf5e4 62%, #f7e8c9 100%);
  box-shadow: var(--ter-shadow);
}

.ter-kicker {
  margin: 0 0 8px;
  color: var(--ter-accent, var(--ter-gold));
  font: 900 11px/1 system-ui, sans-serif;
  letter-spacing: .16em;
}

.ter-hero-title {
  margin: 0;
  color: var(--ter-ink);
  font: 900 clamp(1.7rem, 4.6vw, 2.9rem)/1.02 Georgia, serif;
}

.ter-hero-lead {
  max-width: 68ch;
  margin: 12px 0 0;
  color: #5f5142;
  font: 500 clamp(.98rem, 1.5vw, 1.08rem)/1.6 system-ui, sans-serif;
}

.ter-count {
  margin: 14px 0 0;
  color: var(--ter-accent, var(--ter-gold));
  font: 900 11.5px/1 system-ui, sans-serif;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* ── Ricerca e filtri ────────────────────────────────────────────────── */

.ter-toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.ter-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--ter-line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(63, 39, 12, .05);
}

.ter-search span { color: var(--ter-gold); font-size: 1.1rem; }

.ter-search input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  border: 0;
  background: transparent;
  color: var(--ter-ink);
  font: 600 15px/1 system-ui, sans-serif;
}

.ter-search input:focus { outline: none; }
.ter-search:focus-within { border-color: var(--ter-gold); box-shadow: 0 0 0 3px rgba(165, 106, 24, .16); }

.ter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ter-chip {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--ter-line);
  border-radius: 999px;
  background: #fff;
  color: #5c4326;
  font: 800 12px/1 system-ui, sans-serif;
  cursor: pointer;
}

.ter-chip:hover { background: #fff7e4; }

.ter-chip.is-active {
  border-color: var(--ter-gold);
  background: #fdf0cf;
  color: #6b4409;
}

.ter-chip:focus-visible { outline: 3px solid rgba(165, 106, 24, .35); outline-offset: 2px; }

@media (min-width: 720px) {
  .ter-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .ter-search { grid-column: 1 / -1; }
  .ter-chips { grid-column: 1 / -1; }
}

/* ── Griglia delle schede ────────────────────────────────────────────── */

.ter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 14px;
}

.ter-card {
  display: grid;
  gap: 7px;
  padding: 16px 17px 15px;
  border: 1px solid var(--ter-line);
  border-radius: 18px;
  border-top: 4px solid var(--ter-accent, var(--ter-gold));
  background: #fff;
  color: inherit;
  text-align: left;
  box-shadow: 0 8px 20px rgba(63, 39, 12, .07);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.ter-card:hover {
  transform: translateY(-3px);
  border-color: rgba(165, 106, 24, .45);
  box-shadow: 0 16px 32px rgba(63, 39, 12, .14);
}

.ter-card:focus-visible {
  outline: 3px solid var(--ter-accent, var(--ter-gold));
  outline-offset: 3px;
}

.ter-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ter-card-glyph {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--ter-accent, var(--ter-gold)) 16%, #fff);
  color: var(--ter-accent, var(--ter-gold));
  font: 900 14px/1 Georgia, serif;
}

.ter-card-region {
  color: var(--ter-ink-soft);
  font: 850 10.5px/1 system-ui, sans-serif;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.ter-card-name {
  color: var(--ter-ink);
  font: 900 1.18rem/1.12 Georgia, serif;
}

.ter-card-role {
  color: var(--ter-accent, var(--ter-gold));
  font: 800 11.5px/1.3 system-ui, sans-serif;
}

.ter-card-text {
  color: #5f5142;
  font: 500 13.5px/1.5 system-ui, sans-serif;
}

.ter-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  padding-top: 9px;
  border-top: 1px dashed var(--ter-line);
}

.ter-card-period {
  color: var(--ter-ink-soft);
  font: 750 11.5px/1.2 system-ui, sans-serif;
}

.ter-card-arrow {
  color: var(--ter-accent, var(--ter-gold));
  font-weight: 900;
}

/* ── Risultati in altre sezioni, stato vuoto ─────────────────────────── */

.ter-other {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px dashed var(--ter-line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .7);
}

.ter-other > p {
  margin: 0 0 9px;
  color: var(--ter-ink-soft);
  font: 850 11.5px/1 system-ui, sans-serif;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.ter-other-list { display: flex; flex-wrap: wrap; gap: 7px; }

.ter-other-item {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--ter-line);
  border-radius: 999px;
  background: #fff;
  color: #5c4326;
  font: 750 12.5px/1 system-ui, sans-serif;
  cursor: pointer;
}

.ter-other-item:hover { background: #fff6e2; }
.ter-other-item:focus-visible { outline: 3px solid rgba(165, 106, 24, .35); outline-offset: 2px; }

.ter-empty {
  grid-column: 1 / -1;
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 34px 18px;
  border: 1px dashed var(--ter-line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .66);
  text-align: center;
}

.ter-empty p { margin: 0; color: var(--ter-ink-soft); font: 600 14px/1.5 system-ui, sans-serif; }

.ter-reset {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--ter-gold);
  border-radius: 999px;
  background: #fdf0cf;
  color: #6b4409;
  font: 850 12.5px/1 system-ui, sans-serif;
  cursor: pointer;
}

.ter-reset:hover { background: #fbe4b3; }
.ter-reset:focus-visible { outline: 3px solid rgba(165, 106, 24, .38); outline-offset: 2px; }

.ter-section-note {
  max-width: 74ch;
  margin: 22px 0 0;
  color: var(--ter-ink-soft);
  font: 500 12px/1.55 system-ui, sans-serif;
}

/* ── Scheda singola ──────────────────────────────────────────────────── */

.ter-sheet {
  margin-top: 20px;
  padding: clamp(18px, 3.4vw, 32px);
  border: 1px solid var(--ter-line);
  border-radius: var(--ter-radius);
  background: #fffdf9;
  box-shadow: var(--ter-shadow);
}

.ter-hub-back {
  min-height: 44px;
  margin-bottom: 16px;
  padding: 0 14px;
  border: 1px solid var(--ter-line);
  border-radius: 999px;
  background: #fff;
  color: #5c4326;
  font: 800 12.5px/1 system-ui, sans-serif;
  cursor: pointer;
}

.ter-hub-back:hover { background: #fff6e2; }
.ter-hub-back:focus-visible { outline: 3px solid rgba(165, 106, 24, .38); outline-offset: 2px; }

.ter-hero-photo {
  position: relative;
  margin: 0 0 20px;
  border-radius: 16px;
  overflow: hidden;
  background: #f1e6d2;
  aspect-ratio: 16 / 7;
}

.ter-hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ter-hero-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(28, 20, 12, 0) 45%, rgba(28, 20, 12, .34) 100%);
  pointer-events: none;
}

.ter-sheet-head {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--ter-line);
}

.ter-sheet-kicker {
  margin: 0 0 8px;
  color: var(--ter-accent, var(--ter-gold));
  font: 900 10.5px/1 system-ui, sans-serif;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.ter-sheet-head h2 {
  margin: 0;
  color: var(--ter-ink);
  font: 900 clamp(1.7rem, 4.4vw, 2.7rem)/1.04 Georgia, serif;
}

.ter-sheet-role {
  margin: 8px 0 0;
  color: var(--ter-accent, var(--ter-gold));
  font: 800 13.5px/1.35 system-ui, sans-serif;
}

.ter-sheet-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.ter-sheet-meta span {
  padding: 6px 10px;
  border: 1px solid var(--ter-line);
  border-radius: 999px;
  background: #fff7e6;
  color: #6b5a46;
  font: 800 11px/1 system-ui, sans-serif;
  letter-spacing: .04em;
}

.ter-sheet-lead {
  max-width: 72ch;
  margin: 18px 0 4px;
  color: #4a3d30;
  font: 500 clamp(1rem, 1.6vw, 1.14rem)/1.62 Georgia, serif;
}

.ter-sheet-body { margin-top: 6px; }

.ter-block {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid rgba(83, 61, 32, .1);
}

.ter-block h3 {
  margin: 0 0 14px;
  color: var(--ter-ink);
  font: 900 clamp(1.2rem, 2.6vw, 1.5rem)/1.1 Georgia, serif;
}

.ter-block h4 {
  margin: 0 0 7px;
  color: var(--ter-accent, var(--ter-gold));
  font: 850 12px/1.2 system-ui, sans-serif;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.ter-block p {
  max-width: 74ch;
  margin: 0 0 16px;
  color: #3f342a;
  font: 500 clamp(.98rem, 1.45vw, 1.06rem)/1.72 Georgia, serif;
}

.ter-block p:last-child { margin-bottom: 0; }

/* Fatti in breve */
.ter-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin: 0;
}

.ter-facts > div {
  padding: 12px 14px;
  border: 1px solid var(--ter-line);
  border-left: 3px solid var(--ter-accent, var(--ter-gold));
  border-radius: 12px;
  background: #fff;
}

.ter-facts dt {
  margin-bottom: 4px;
  color: var(--ter-ink-soft);
  font: 850 10px/1.2 system-ui, sans-serif;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.ter-facts dd {
  margin: 0;
  color: var(--ter-ink);
  font: 750 13.5px/1.35 system-ui, sans-serif;
}

/* Luoghi */
.ter-places {
  display: grid;
  gap: 10px;
}

.ter-place {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  padding: 12px;
  border: 1px solid var(--ter-line);
  border-radius: 14px;
  background: #fff;
}

.ter-place-photo {
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #f1e6d2;
  min-height: 96px;
}

.ter-place-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.ter-place-body { display: grid; gap: 6px; align-content: start; }
.ter-place-body strong { color: var(--ter-ink); font: 900 15px/1.2 Georgia, serif; }
.ter-place-body p { margin: 0; color: var(--ter-ink-soft); font: 500 12.5px/1.45 system-ui, sans-serif; }

.ter-place-open {
  justify-self: start;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--ter-accent, var(--ter-gold));
  border-radius: 999px;
  background: transparent;
  color: var(--ter-accent, var(--ter-gold));
  font: 850 12px/1 system-ui, sans-serif;
  cursor: pointer;
}

.ter-place-open:hover { background: var(--ter-accent, var(--ter-gold)); color: #fff; }
.ter-place-open:focus-visible { outline: 3px solid rgba(165, 106, 24, .35); outline-offset: 2px; }

/* Rimandi incrociati */
.ter-crosses {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}

.ter-cross {
  display: grid;
  gap: 4px;
  padding: 13px 14px;
  border: 1px solid var(--ter-line);
  border-left: 4px solid var(--ter-accent, var(--ter-gold));
  border-radius: 12px;
  background: #fff;
  color: inherit;
  text-align: left;
  cursor: pointer;
  position: relative;
}

.ter-cross:hover { background: #fffaf0; transform: translateY(-1px); }
.ter-cross:focus-visible { outline: 3px solid rgba(165, 106, 24, .35); outline-offset: 2px; }

.ter-cross-section {
  color: var(--ter-accent, var(--ter-gold));
  font: 850 9.5px/1 system-ui, sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.ter-cross-name { color: var(--ter-ink); font: 900 14px/1.2 Georgia, serif; }
.ter-cross-why { color: var(--ter-ink-soft); font: 500 12px/1.4 system-ui, sans-serif; padding-right: 16px; }
.ter-cross-arrow { position: absolute; right: 12px; bottom: 12px; color: var(--ter-accent, var(--ter-gold)); font-weight: 900; }

/* Collegamenti all'app */
.ter-app-links { display: flex; flex-wrap: wrap; gap: 8px; }

.ter-app-link {
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--ter-ink);
  border-radius: 999px;
  background: var(--ter-ink);
  color: #fff7e4;
  font: 850 12.5px/1.2 system-ui, sans-serif;
  cursor: pointer;
}

.ter-app-link:hover { background: #463c32; transform: translateY(-1px); }
.ter-app-link:focus-visible { outline: 3px solid rgba(165, 106, 24, .45); outline-offset: 3px; }

/* Fonti */
.ter-sources {
  margin-top: 28px;
  padding: 16px 18px;
  border: 1px dashed rgba(83, 61, 32, .28);
  border-radius: 14px;
  background: #fbf4e6;
}

.ter-sources h3 {
  margin: 0 0 10px;
  color: #6b4409;
  font: 900 11px/1 system-ui, sans-serif;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.ter-sources ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }

.ter-sources a {
  color: #6b4409;
  font: 700 12.5px/1.4 system-ui, sans-serif;
  text-decoration: underline;
  text-underline-offset: 3px;
  word-break: break-word;
}

.ter-sources a:hover { color: #a56a18; }
.ter-sources a:focus-visible { outline: 3px solid rgba(165, 106, 24, .4); outline-offset: 2px; }

.ter-source-note {
  margin: 12px 0 0;
  color: #7a6a56;
  font: 500 11.5px/1.5 system-ui, sans-serif;
}

/* ── Telefono ────────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .ter-topbar { position: static; }
  .ter-tabs { margin-left: 0; width: 100%; }
  .ter-tab { flex: 1 1 46%; }
  .ter-grid { grid-template-columns: 1fr; }
  .ter-place { grid-template-columns: 92px minmax(0, 1fr); }
  .ter-sheet { padding: 16px 14px; border-radius: 16px; }
  .ter-hero { padding: 18px 16px; border-radius: 16px; }
  .ter-block p { font-size: 1rem; }
  .ter-app-link { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .ter-card, .ter-tab, .ter-app-link, .ter-cross { transition: none; }
  .ter-card:hover, .ter-app-link:hover, .ter-cross:hover { transform: none; }
}
