/* ============================================================
   Maestà · Duccio di Buoninsegna
   Palette: il buio della navata, l'oro della tavola.
   ============================================================ */

:root {
  /* colore */
  --nave:      #0b0a09;   /* fondo, quasi nero caldo */
  --nave-alta: #141210;   /* superfici sollevate */
  --bordo:     #26221d;   /* hairline */
  --gesso:     #e8e2d6;   /* testo chiaro */
  --gesso-cupo:#8e877b;   /* testo secondario */
  --oro:       #c9a227;   /* l'accento: fondo oro */
  --oro-tenue: #6b5615;   /* oro smorzato */
  --lapis:     #2c3e6b;   /* il blu del manto — usato con parsimonia */

  /* tipo */
  --display: 'Cormorant', Georgia, serif;
  --utility: 'Inter', system-ui, sans-serif;

  /* moto */
  --lento:  1200ms;
  --medio:   520ms;
  --svelto:  240ms;
  --curva:  cubic-bezier(.19, 1, .22, 1);      /* expo out */
  --curva-in: cubic-bezier(.7, 0, .84, 0);

  /* misure di layout: le fasce che l'interfaccia riserva ai bordi.
     il centro della tavola non viene mai invaso.                     */
  --bar-top: 96px;   /* altezza fascia superiore su desktop */
  --bar-bot: 108px;  /* altezza fascia inferiore su desktop */
  --gutter: 44px;    /* margine laterale desktop */
}

/* [maesta] nel sito: il visore copre tutta la finestra, sopra la pagina (template Elementor Canvas: senza header e
   footer del tema, ma il CSS di Astra ed Elementor si carica lo stesso). Le regole di base valgono solo qui dentro,
   e con :where() pesano zero: non battono quelle del visore qui sotto */
:where(#od-maesta, #od-maesta *) { margin: 0; padding: 0; box-sizing: border-box; }

html:has(#od-maesta), body:has(#od-maesta) {
  height: 100%;
  overflow: hidden;
  background: var(--nave);
}
html:has(#od-maesta) { font-size: 100%; }   /* Astra la porta al 91,2%: tutte le misure in rem si rimpicciolirebbero */

/* Astra dà il suo stile a pulsanti, titoli, paragrafi, tabelle e link (button, h1, p…, anche :hover e :focus).
   Qui dentro tornano allo stile di base del browser, come nella pagina a parte: le regole del visore qui sotto,
   che pesano di più, restano. Per questo i pulsanti del visore hanno sempre un id nelle regole (es. #tour .tour-primary) */
:where(#od-maesta) :is(h1, h2, h3, h4, h5, h6, p, a, button, table, th, td),
:where(#od-maesta) :is(a, button):is(:hover, :focus, :focus-visible, :active) {
  all: revert;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
/* revert toglie anche l'effetto dell'attributo hidden (per il browser è un suggerimento dell'HTML, non del suo CSS) */
:where(#od-maesta) :is(h1, h2, h3, h4, h5, h6, p, a, button, table, th, td)[hidden] { display: none; }

#od-maesta {
  position: fixed;
  inset: 0;
  z-index: 9999;                 /* sopra la pagina; la barra di amministrazione di WordPress (99999) resta sopra */
  overflow: hidden;
  background: var(--nave);
  color: var(--gesso);
  font-family: var(--utility);
  line-height: normal;
  -webkit-font-smoothing: antialiased;
}

/* vignettatura: la tavola emerge dal buio */
#od-maesta::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background:
    radial-gradient(ellipse 90% 80% at 50% 45%,
      transparent 40%,
      rgba(0,0,0,.35) 78%,
      rgba(0,0,0,.7) 100%);
}


/* ---------- palcoscenico e rotazione ---------- */

#stage {
  position: absolute;
  inset: 0;
}

#flipper {
  position: absolute;
  inset: 0;
  transition:
    transform var(--lento) var(--curva),
    filter    var(--lento) var(--curva);
}

#stage.flipping        { perspective: 2400px; perspective-origin: 50% 45%; }
#stage.flipping #flipper { transform-style: preserve-3d; }

/* metà rotazione: la tavola si mette di taglio */
#flipper.turning {
  transform: rotateY(-90deg) scale(.88);
  filter: brightness(.35) saturate(.4);
}

#viewer {
  position: absolute;
  inset: 0;
}

/* il velo d'oro che passa nel momento del cambio */
#veil {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(105deg,
    transparent 20%,
    rgba(201,162,39,.13) 44%,
    rgba(201,162,39,.30) 50%,
    rgba(201,162,39,.13) 56%,
    transparent 80%);
  transform: translateX(-30%);
}

#veil.sweep { animation: sweep var(--lento) var(--curva); }

/* didascalia del passaggio recto → verso durante il percorso */
#passaggio {
  position: absolute;
  inset: 0;
  z-index: 8;
  margin: auto;
  width: max-content;
  height: max-content;
  max-width: calc(100vw - 2 * var(--gutter));
  padding: 34px 64px 38px;
  text-align: center;
  background: rgba(11,10,9,.55);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border: 1px solid var(--bordo);
  border-radius: 20px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--medio) ease;
}
#passaggio.visibile { opacity: 1; }
#passaggio .eyebrow { display: block; color: var(--oro); margin-bottom: 18px; }
.passaggio-titolo {
  font-family: var(--display);
  font-size: clamp(2.8rem, 7vw, 5rem);
  font-weight: 300;
  line-height: 1;
  color: var(--gesso);
  text-shadow: 0 2px 30px rgba(0,0,0,.8);
  transform: translateY(14px);
  transition: transform var(--lento) var(--curva);
}
.passaggio-sotto {
  margin-top: 10px;
  font-family: var(--display);
  font-size: clamp(1.1rem, 2.2vw, 1.6rem);
  font-style: italic;
  font-weight: 300;
  color: var(--gesso-cupo);
  text-shadow: 0 2px 20px rgba(0,0,0,.8);
}
#passaggio.visibile .passaggio-titolo { transform: none; }

@keyframes sweep {
  0%   { opacity: 0; transform: translateX(-35%); }
  45%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(35%); }
}


/* ============================================================
   FASCE DELL'INTERFACCIA
   Top-bar e bottom-bar riservano spazio ai bordi: il centro
   resta sempre libero per la tavola.
   ============================================================ */

/* ---------- fascia superiore ---------- */

#maesta-testata {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;   /* titolo in alto: lascia scoperti gli apostoli */
  min-height: var(--bar-top);
  /* in alto il riquadro di "Maestà" (h1::before, 8px sopra il testo) parte alla stessa altezza di quello di
     Recto · Verso (#faces::before, alto 64px e centrato nella barra) */
  padding: calc(var(--bar-top) / 2 - 32px + 8px) var(--gutter) 12px;
  animation: rise var(--lento) var(--curva) both;
  animation-delay: 200ms;
}

.eyebrow {
  font-size: .625rem;
  font-weight: 500;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gesso-cupo);
  margin-bottom: 8px;
}

#maesta-testata h1 {
  font-family: var(--display);
  font-size: clamp(2rem, 4vw, 3.1rem);
  font-weight: 300;
  line-height: .95;
  letter-spacing: .01em;
  color: var(--gesso);
  margin-bottom: 6px;
}

/* torna al sito: il logo del menu del sito a sinistra del titolo, poi un filo come quello tra Recto e Verso.
   Alto più o meno come "Maestà" (--logo-h); su telefono solo lo stemma, la parte sinistra del logo */
#maesta-testata .titolo { display: flex; align-items: center; gap: 20px; --logo-h: 40px; }
#torna-sito {
  flex: none;
  display: block;
  height: var(--logo-h);
  margin-bottom: 6px;                 /* come il margine sotto h1: il logo resta a metà del titolo */
  overflow: hidden;
  opacity: .85;
  transition: opacity var(--medio) var(--curva);
}
#torna-sito img { display: block; height: 100%; width: auto; max-width: none; }
#torna-sito:hover, #torna-sito:focus-visible { opacity: 1; }
#maesta-testata .titolo-filo {
  flex: none;
  width: 1px;
  height: calc(var(--logo-h) * .8);
  margin-bottom: 6px;
  background: var(--bordo);
}

.attribution {
  font-family: var(--display);
  font-style: italic;
  font-size: .95rem;
  font-weight: 400;
  color: var(--gesso-cupo);
}
.attribution span { color: var(--oro-tenue); font-style: normal; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}


/* ---------- recto / verso ---------- */

#faces {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 11;
  display: flex;
  align-items: center;
  min-height: var(--bar-top);
  padding: 0 calc(var(--gutter) - 12px);
  animation: rise var(--lento) var(--curva) both;
  animation-delay: 340ms;
}

#faces button {
  position: relative;
  padding: 12px 22px 11px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--gesso-cupo);
  transition: color var(--medio) var(--curva);
}

#faces button:hover { color: var(--gesso); }

.face-label {
  display: block;
  font-family: var(--display);
  font-size: 1.24rem;
  font-weight: 400;
  line-height: 1.1;
}

.face-desc {
  display: block;
  font-size: .6rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  margin-top: 5px;
  opacity: .6;
}

/* filo d'oro sotto la faccia attiva */
#faces button::after {
  content: '';
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 4px;
  height: 1px;
  background: var(--oro);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--medio) var(--curva);
}

#faces button.active { color: var(--gesso); }
#faces button.active::after { transform: scaleX(1); }
#faces button.active .face-desc { opacity: 1; color: var(--oro-tenue); }

.face-divider {
  width: 1px;
  align-self: center;
  height: 34px;
  background: var(--bordo);
}

/* "i": l'introduzione della faccia che si sta guardando (app.js, infoBtn) */
#faces .face-info {
  display: grid; place-items: center;
  width: 30px; height: 30px; margin-left: 10px; padding: 0;
  border: 1px solid var(--oro-tenue); border-radius: 50%;
  font-family: var(--display); font-size: 1.15rem; font-style: italic; line-height: 1;
  color: var(--gesso-cupo);
  transition: color var(--medio) var(--curva), border-color var(--medio) var(--curva);
}
#faces .face-info::after { display: none; }
#faces .face-info:hover { color: var(--gesso); border-color: var(--oro); }
#faces .face-info[hidden] { display: none; }


/* ---------- fascia inferiore: percorso ---------- */

#tour {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--bar-bot);
  padding: 16px var(--gutter);
  pointer-events: none;      /* la fascia non blocca la tavola… */
  animation: rise var(--lento) var(--curva) both;
  animation-delay: 480ms;
}
#tour > * { pointer-events: auto; }   /* …ma i controlli sì */

#tour .tour-primary {
  padding: 14px 40px;
  background: rgba(20,18,16,.72);
  backdrop-filter: blur(20px);
  border: 1px solid var(--oro-tenue);
  border-radius: 999px;
  color: var(--gesso);
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: .02em;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition:
    border-color var(--medio) var(--curva),
    color        var(--medio) var(--curva);
}

#tour .tour-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--oro);
  transform: translateY(101%);
  transition: transform var(--medio) var(--curva);
  z-index: -1;
}

#tour .tour-primary:hover { border-color: var(--oro); color: var(--nave); }
#tour .tour-primary:hover::before { transform: translateY(0); }

#tour-steps {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: rgba(20,18,16,.82);
  backdrop-filter: blur(20px);
  border: 1px solid var(--bordo);
  border-radius: 999px;
  animation: rise var(--medio) var(--curva) both;
}
#tour-steps[hidden] { display: none; }

#tour-steps button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  border-radius: 999px;
  color: var(--gesso-cupo);
  cursor: pointer;
  transition:
    background var(--svelto) ease,
    color      var(--svelto) ease;
}

#tour-steps button svg { width: 19px; height: 19px; }

#tour-steps button:hover:not(:disabled) {
  background: rgba(201,162,39,.11);
  color: var(--oro);
}

#tour-steps button:disabled { opacity: .22; cursor: default; }

#tour-progress {
  min-width: 74px;
  text-align: center;
  font-family: var(--display);
  font-size: 1rem;
  letter-spacing: .06em;
  color: var(--oro);
}

.tour-divider {
  width: 1px;
  height: 22px;
  margin: 0 6px;
  background: var(--bordo);
}

#tour .tour-quiet {
  width: auto !important;
  padding: 0 18px;
  font-family: var(--utility) !important;
  font-size: .7rem !important;
  letter-spacing: .1em;
  text-transform: uppercase;
  white-space: nowrap;
}


/* ---------- pastiglie sul dipinto ---------- */
/* OSD scrive transform sul .hotspot: non toccarlo mai.
   Tutto il moto vive nel figlio .dot                     */
.hotspot {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.hotspot .dot {
  position: relative;
  display: grid;
  place-items: center;
  animation: bloom 900ms var(--curva) both;
}

.hotspot .dot::after {
  content: '';
  width: var(--hs, 13px);
  height: var(--hs, 13px);
  border-radius: 50%;
  border: 1px solid var(--hc, var(--oro));
  background: var(--hc, rgba(201,162,39,.22));
    box-shadow: 0 0 0 1.5px rgba(0,0,0,.5), 0 0 0 3px rgba(232,226,214,.35), 0 2px 10px rgba(0,0,0,.6);
  transition:
    transform  var(--medio) var(--curva),
    background var(--medio) var(--curva),
    box-shadow var(--medio) var(--curva);
}

.hotspot .dot::before {
  content: '';
  position: absolute;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid var(--oro);
  opacity: 0;
}

.hotspot:hover .dot::after {
  transform: scale(1.5);
  background: rgba(201,162,39,.4);
}

.hotspot.active .dot::after {
  background: var(--oro);
  transform: scale(1.35);
  box-shadow: 0 0 0 7px rgba(201,162,39,.14),
              0 0 22px rgba(201,162,39,.5);
}

.hotspot.active .dot::before { animation: pulse 2.4s var(--curva) infinite; }

@keyframes pulse {
  0%   { opacity: .7; transform: scale(1); }
  100% { opacity: 0;  transform: scale(4.2); }
}

@keyframes bloom {
  from { opacity: 0; transform: scale(.3); }
  to   { opacity: 1; transform: scale(1); }
}


/* ---------- pannello di lettura ---------- */

#panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  width: min(430px, 92vw);
  padding: 84px 52px 52px;
  background: rgba(11,10,9,.9);
  backdrop-filter: blur(28px);
  border-left: 1px solid var(--bordo);
  overflow-y: auto;

  transform: translateX(100%);
  transition: transform var(--medio) var(--curva);
}

#panel.open { transform: none; }

#panel::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 1px;
  background: linear-gradient(180deg,
    transparent,
    var(--oro-tenue) 22%,
    var(--oro-tenue) 78%,
    transparent);
  opacity: .55;
}

#panel-grip { display: none; }

#panel-close {
  position: absolute;
  top: 30px;
  right: 34px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: none;
  border: none;
  border-radius: 999px;
  color: var(--gesso-cupo);
  cursor: pointer;
  transition: color var(--svelto) ease, background var(--svelto) ease;
}
#panel-close svg { width: 17px; height: 17px; }
#panel-close:hover { color: var(--gesso); background: rgba(255,255,255,.05); }

#panel-numeral {
  display: block;
  font-family: var(--display);
  font-size: 2.7rem;
  font-weight: 300;
  line-height: 1;
  color: var(--oro-tenue);
  margin-bottom: 26px;
}

#panel-title {
  font-family: var(--display);
  font-size: 2.15rem;
  font-weight: 300;
  line-height: 1.14;
  letter-spacing: .005em;
  color: var(--gesso);
  margin-bottom: 26px;
}

.panel-rule {
  width: 46px;
  height: 1px;
  background: var(--oro);
  margin-bottom: 26px;
}

/* introduzione (tappa 0): il nome della faccia al posto del numero, il sottotitolo, la piccola scheda */
#panel-numeral.faccia {
  font-family: var(--utility); font-size: .7rem; font-weight: 500; letter-spacing: .18em; text-transform: uppercase;
  color: var(--oro);
}
#panel-sottotitolo {
  margin: -14px 0 26px;
  font-family: var(--display); font-size: 1.15rem; font-weight: 300; font-style: italic; color: var(--gesso-cupo);
}
#panel-sottotitolo[hidden], #panel-dati[hidden] { display: none; }
#panel-dati { width: 100%; border-collapse: collapse; margin-bottom: 26px; }
#panel-dati th, #panel-dati td { padding: 9px 0; border-bottom: 1px solid var(--bordo); vertical-align: top; text-align: left; }
#panel-dati th {
  width: 38%; padding-right: 16px;
  font: 500 .64rem/1.9 var(--utility); letter-spacing: .12em; text-transform: uppercase; color: var(--gesso-cupo);
}
#panel-dati td { font-size: .86rem; font-weight: 300; line-height: 1.6; color: var(--gesso); }

#panel-text {
  font-size: .935rem;
  font-weight: 300;
  line-height: 1.78;
  color: var(--gesso-cupo);
}
#panel-text p { margin: 0 0 1em; }          /* paragrafi del testo (riga vuota in hotspots.json) */
#panel-text p:last-child { margin-bottom: 0; }
#panel-text strong, #panel-text b { font-weight: 500; }

.reveal { opacity: 0; transform: translateY(16px); }

#panel.open .reveal { animation: reveal 700ms var(--curva) both; }
#panel.open #panel-numeral { animation-delay: 130ms; }
#panel.open #panel-title   { animation-delay: 200ms; }
#panel.open #panel-sottotitolo { animation-delay: 230ms; }
#panel.open #panel-dati    { animation-delay: 300ms; }
#panel.open .panel-rule    { animation-delay: 270ms; }
#panel.open #panel-text    { animation-delay: 330ms; }
#panel.open #panel-link    { animation-delay: 400ms; }

#panel-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 34px;
  padding: 12px 20px;
  border: 1px solid var(--oro-tenue);
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--oro);
  text-decoration: none;
  transition: color var(--svelto) ease, background var(--svelto) ease, border-color var(--svelto) ease;
}
#panel-link[hidden] { display: none; }

/* ---------- scheda completa dell'opera (verso): il pannello si allarga a metà schermo ---------- */
#panel { transition: transform var(--medio) var(--curva), width var(--medio) var(--curva), height var(--medio) var(--curva); }
#panel.larga { width: 50vw; }
#panel.open #panel-scheda { animation-delay: 400ms; }
#panel-scheda {
  margin-top: 34px;
  padding: 12px 20px;
  background: none;
  border: 1px solid var(--oro-tenue);
  border-radius: 999px;
  font: 500 .72rem var(--utility);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--oro);
  cursor: pointer;
  transition: color var(--svelto) ease, background var(--svelto) ease, border-color var(--svelto) ease;
}
#panel-scheda[hidden], #scheda[hidden] { display: none; }
#panel-scheda:hover { color: var(--nave); background: var(--oro); border-color: var(--oro); }

#scheda { margin-top: 38px; padding-top: 30px; border-top: 1px solid var(--bordo); animation: reveal 600ms var(--curva) both; }
#scheda .scheda-attesa { color: var(--gesso-cupo); font-size: .9rem; }
#scheda .scheda-inv {
  font: 500 .7rem var(--utility); letter-spacing: .14em; text-transform: uppercase; color: var(--oro); margin-bottom: 12px;
}
#scheda .scheda-titolo {
  font-family: var(--display); font-size: 1.7rem; font-weight: 300; line-height: 1.2; color: var(--gesso); margin-bottom: 22px;
}
#scheda table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
#scheda th, #scheda td { padding: 11px 0; border-bottom: 1px solid var(--bordo); vertical-align: top; text-align: left; }
#scheda th {
  width: 34%; padding-right: 18px;
  font: 500 .68rem/1.9 var(--utility); letter-spacing: .12em; text-transform: uppercase; color: var(--gesso-cupo);
}
#scheda td { font-size: .9rem; font-weight: 300; line-height: 1.6; color: var(--gesso); }
#scheda h4 {
  font-family: var(--display); font-size: 1.3rem; font-weight: 400; color: var(--gesso);
  margin: 30px 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--oro-tenue);
}
#scheda p { font-size: .9rem; font-weight: 300; line-height: 1.75; color: var(--gesso-cupo); }
#scheda em { font-style: italic; }
#scheda small { font-size: .8rem; }

/* computer e tablet: con il pannello aperto i pulsanti del percorso stanno al centro dello spazio libero a sinistra */
@media (min-width: 761px) {
  #tour { transition: right var(--medio) var(--curva); }
  body:has(#panel.open) #tour { right: min(430px, 92vw); }
  body:has(#panel.open.larga) #tour { right: 50vw; }
}
#panel-link svg { width: 14px; height: 14px; }
#panel-link:hover { color: var(--nave); background: var(--oro); border-color: var(--oro); }

@keyframes reveal {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}


/* ---------- navigatore OSD ---------- */

.navigator {
  border: 1px solid var(--bordo) !important;
  background: rgba(11,10,9,.7) !important;
  border-radius: 2px;
  overflow: hidden;
}
.displayregion { border: 1px solid var(--oro) !important; }


/* ---------- accessibilità ---------- */

:focus-visible {
  outline: 1px solid var(--oro);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  #flipper.turning { transform: none; filter: brightness(.5); }
}


/* ============================================================
   RESPONSIVE
   ============================================================ */

/* --- tablet / desktop stretto: riduci le fasce e i margini --- */
@media (max-width: 1100px) {
  :root { --gutter: 30px; --bar-top: 88px; --bar-bot: 100px; }
}

/* --- il navigatore OSD dà fastidio su schermi piccoli --- */
@media (max-width: 900px) {
  .navigator { display: none !important; }
}

/* ============================================================
   MOBILE  (≤ 760px)
   L'interfaccia passa a colonna: titolo compatto in alto,
   selettore recto/verso e controlli in basso. Il pannello
   di lettura sale dal fondo come un foglio.
   ============================================================ */
@media (max-width: 760px) {
  :root {
    --gutter: 18px;
    --bar-top: 68px;
    --bar-bot: 150px;
  }

  /* testata compatta: solo il titolo, su una riga */
  #maesta-testata {
    min-height: var(--bar-top);
    padding: 12px var(--gutter);
    max-width: 62vw;         /* lascia respiro al selettore a destra */
  }
  .eyebrow { display: none; }
  #maesta-testata h1 { font-size: 1.7rem; margin-bottom: 2px; }
  /* solo lo stemma: nel logo (321 × 100) occupa i primi 81 px */
  #maesta-testata .titolo { gap: 12px; --logo-h: 32px; }
  #torna-sito { width: calc(var(--logo-h) * .81); margin-bottom: 2px; }
  #maesta-testata .titolo-filo { display: none; }
  .attribution { font-size: .78rem; }

  /* recto/verso resta in alto a destra ma più compatto */
  #faces {
    min-height: var(--bar-top);
    padding: 0 calc(var(--gutter) - 6px);
  }
  #faces button { padding: 8px 12px; }
  .face-label { font-size: .98rem; }
  .face-desc { display: none; }
  #faces button::after { left: 12px; right: 12px; }
  .face-divider { height: 24px; }

  /* la fascia bassa dei controlli */
  #tour {
    min-height: var(--bar-bot);
    padding: 14px var(--gutter) calc(env(safe-area-inset-bottom, 0px) + 18px);
    align-items: flex-end;
  }

  #tour .tour-primary { font-size: 1.05rem; padding: 13px 34px; }

  #tour-steps {
    width: 100%;
    max-width: 420px;
    justify-content: space-between;
    padding: 6px 10px;
  }
  #tour-steps button { width: 44px; height: 44px; }  /* target tocco */
  .tour-divider { display: none; }
  #tour .tour-quiet {
    padding: 0 12px !important;
    font-size: .64rem !important;
  }


  /* pannello di lettura: foglio che sale dal fondo, non a tutta altezza
     così restano visibili sopra un po' di tavola e il contesto        */
  #panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: min(72vh, 560px);
    padding: 40px 26px calc(env(safe-area-inset-bottom, 0px) + 34px);
    border-left: none;
    border-top: 1px solid var(--bordo);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }
  #panel.open { transform: none; }
  /* con la scheda completa il foglio sale quasi fino in cima */
  #panel.larga { width: 100%; height: 90vh; }
  #scheda th { width: 38%; }

  /* il filo d'oro corre sul bordo alto, non su quello sinistro */
  #panel::before {
    top: 0; left: 0; right: 0; bottom: auto;
    width: auto; height: 1px;
    background: linear-gradient(90deg,
      transparent, var(--oro-tenue) 25%, var(--oro-tenue) 75%, transparent);
  }

  /* maniglia del foglio */
  #panel::after {
    content: '';
    position: absolute;
    top: 12px; left: 50%;
    transform: translateX(-50%);
    width: 42px; height: 4px;
    border-radius: 999px;
    background: var(--bordo);
  }

  /* durante il percorso i pulsanti avanti/indietro stanno sopra il foglio
     (il testo del foglio lascia loro spazio in fondo) */
  body.reading #tour { z-index: 25; }
  #panel { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 96px); }

  /* durante il percorso niente fascia scura in basso: il titolo del foglio resta nitido
     (i pulsanti hanno già il loro sfondo) */
  body.reading #tour::before { display: none; }

  /* foglio abbassato: resta fuori solo la cima con numero e titolo (SBIRCIATA in app.js) */
  :root { --sbirciata: 200px; }
  #panel.open.basso { transform: translateY(calc(100% - var(--sbirciata))); overflow: hidden; }
  #panel.basso .panel-inner { cursor: pointer; }
  /* abbassato: restano solo numero e titolo */
  /* (visibility e non opacity: l'animazione di entrata .reveal tiene ferma l'opacità) */
  #panel.basso .panel-rule, #panel.basso #panel-text, #panel.basso #panel-link,
  #panel.basso #panel-scheda, #panel.basso #scheda { visibility: hidden; }

  /* la maniglia: tutta la fascia in cima al foglio si può trascinare (tranne la ×) */
  #panel-grip {
    display: block;
    position: absolute;
    top: 0; left: 0; right: 64px;
    height: 72px;
    z-index: 1;
    touch-action: none;
    cursor: grab;
  }
  #panel::after { width: 48px; height: 5px; background: var(--gesso-cupo); opacity: .55; }

  /* puntini degli hotspot più piccoli e puliti: un punto d'oro con un filo chiaro */
  .hotspot { width: 44px; height: 44px; }
  .hotspot .dot::after {
    width: 11px; height: 11px;
    border: 1.5px solid rgba(232,226,214,.85);
    background: rgba(201,162,39,.9);
    box-shadow: 0 1px 6px rgba(0,0,0,.6);
  }
  .hotspot .dot::before { width: 11px; height: 11px; }
  .hotspot.active .dot::after {
    transform: scale(1.25);
    box-shadow: 0 0 0 5px rgba(201,162,39,.18), 0 1px 8px rgba(0,0,0,.6);
  }
  #passaggio { padding: 26px 34px 30px; }

  #panel-close { top: 20px; right: 20px; }
  #panel-numeral { font-size: 2.1rem; margin-bottom: 14px; }
  #panel-title { font-size: 1.7rem; margin-bottom: 18px; }
  .panel-rule { margin-bottom: 18px; }
  #panel-text { font-size: .92rem; line-height: 1.72; }
}

/* --- molto stretto: evita che titolo e selettore collidano --- */
@media (max-width: 420px) {
  #maesta-testata { max-width: 56vw; }
  #maesta-testata h1 { font-size: 1.45rem; }
  .attribution { font-size: .72rem; }
  .face-label { font-size: .9rem; }
}

/* --- landscape mobile: poco spazio verticale, comprimi --- */
@media (max-height: 480px) and (orientation: landscape) {
  :root { --bar-top: 58px; --bar-bot: 84px; }
  #maesta-testata h1 { font-size: 1.4rem; }
  #panel { height: 100%; border-radius: 0; }
  #panel::after { display: none; }
}
/* ---------- leggibilità fasce su immagini chiare ---------- */

/* sfumatura scura dietro l'header + recto/verso, in alto */
#maesta-testata::before,
#faces::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

/* una sola fascia continua in alto, larga quanto lo schermo */
#maesta-testata::before {
  left: 0;
  right: -100vw;              /* si estende oltre l'header fino a coprire anche #faces */
  height: calc(var(--bar-top) + 40px);
  background: linear-gradient(180deg,
    rgba(11,10,9,.72) 0%,
    rgba(11,10,9,.45) 55%,
    transparent 100%);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 60%, transparent 100%);
}

/* #faces non serve una sua sfumatura: è coperto da quella dell'header.
   ma alziamo il suo z-index perché il testo stia sopra il velo */
#faces { z-index: 12; }
#maesta-testata { z-index: 11; }

/* sfumatura scura dietro i controlli, in basso */
#tour::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(0deg,
    rgba(11,10,9,.70) 0%,
    rgba(11,10,9,.40) 55%,
    transparent 100%);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  -webkit-mask-image: linear-gradient(0deg, #000 60%, transparent 100%);
  mask-image: linear-gradient(0deg, #000 60%, transparent 100%);
  transition: opacity .3s ease-out;
}
/* mouse vicino al bordo in basso o in alto (app.js), fuori dal percorso: via lo sfumato, la tavola si vede pulita */
body.senza-fascia-sotto:not(.reading) #tour::before { opacity: 0; }
body.senza-fascia-sopra:not(.reading) #maesta-testata::before { opacity: 0; }

/* nascondi i pallini durante il percorso / con pannello aperto */
body.reading .hotspot {
  opacity: 0;
  pointer-events: none;
}



/* ============================================================
   LEGGIBILITÀ — override contrasto fasce e controlli
   ============================================================ */

/* fascia alta più scura e più estesa */
#maesta-testata::before {
  height: calc(var(--bar-top) + 70px);
  background: linear-gradient(180deg,
    rgba(11,10,9,.92) 0%,
    rgba(11,10,9,.72) 45%,
    rgba(11,10,9,.35) 75%,
    transparent 100%);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

/* mouse su una figura (app.js): sparisce lo sfumato scuro; se la figura è sotto la scritta, anche quella.
   Si agisce sui figli e sulla fascia, non su #maesta-testata/#faces, che hanno già l'animazione d'entrata */
#maesta-testata::before, #maesta-testata .titolo, #faces button, #faces .face-divider { transition: opacity .3s ease-out; }
body.senza-fascia #maesta-testata::before { opacity: 0; }   /* la fascia è una sola, larga tutto lo schermo */
body.senza-titolo #maesta-testata .titolo { opacity: 0; pointer-events: none; }
body.senza-facce #faces button { opacity: 0; pointer-events: none; }
body.senza-facce #faces .face-divider { opacity: 0; }

/* quando lo sfumato scuro in alto sparisce (mouse vicino al bordo, o su una figura) le scritte chiare finirebbero
   sull'oro della tavola: dietro "Maestà" e dietro Recto · Verso · i compare una piccola pastiglia scura, e la tavola
   resta scoperta tutto intorno. Scurezza → rgba(…, .55) · sfocato → blur */
#faces::before, #maesta-testata .titolo::before {
  content: ''; position: absolute; z-index: -1; pointer-events: none;
  background: rgba(11,10,9,.55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border-radius: 14px;
  opacity: 0; transition: opacity .3s ease-out;
}
#faces::before { inset: auto calc(var(--gutter) - 22px); top: 50%; height: 64px; transform: translateY(-50%); }
#maesta-testata .titolo { position: relative; }
#maesta-testata .titolo::before { inset: -8px -18px -10px; }
body.senza-fascia-sopra:not(.reading) #faces::before,
body.senza-fascia-sopra:not(.reading) #maesta-testata .titolo::before,
body.senza-fascia #faces::before,
body.senza-fascia #maesta-testata .titolo::before { opacity: 1; }
body.senza-facce #faces::before { opacity: 0; }   /* i pulsanti sono nascosti: anche la pastiglia */

/* fascia bassa più scura */
#tour::before {
  background: linear-gradient(0deg,
    rgba(11,10,9,.92) 0%,
    rgba(11,10,9,.70) 45%,
    rgba(11,10,9,.35) 75%,
    transparent 100%);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

/* testo header: ombra per staccarlo sempre dal fondo */
#maesta-testata h1,
.attribution,
.eyebrow {
  text-shadow: 0 1px 12px rgba(0,0,0,.75);
}

/* recto/verso: testo più chiaro anche da inattivo + ombra */
#faces button {
  color: var(--gesso);
  text-shadow: 0 1px 10px rgba(0,0,0,.7);
}
#faces button:not(.active) { opacity: .78; }
.face-desc { opacity: .85; }

/* bottone "Comincia il percorso": fondo più pieno e bordo oro netto */
#tour .tour-primary {
  background: rgba(11,10,9,.9);
  border-color: var(--oro);
  box-shadow: 0 4px 24px rgba(0,0,0,.6);
}

/* pillola dei controlli tappa: più opaca */
#tour-steps {
  background: rgba(11,10,9,.92);
  box-shadow: 0 4px 24px rgba(0,0,0,.55);
}
#tour-steps button { color: var(--gesso); }

/* freccia progressivo più leggibile */
#tour-progress { color: var(--gesso); }


/* ---------- sipario di caricamento iniziale ---------- */
/* copre la formazione a griglia delle tile: nero pieno che
   sfuma rivelando l'opera solo quando è pronta                */
#curtain {
  position: fixed;
  inset: 0;
  z-index: 8;                 /* sopra viewer e vignettatura, sotto le fasce UI */
  background: var(--nave);
  pointer-events: none;
  opacity: 1;
  transition: opacity 1100ms var(--curva);
}
#curtain.lifted { opacity: 0; }


/* ============================================================
   ADATTAMENTI PER IL MOTORE PIXI
   ============================================================ */

/* il canvas PIXI riempie il viewer */
#viewer canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* l'overlay hotspot creato dal motore sta sopra il canvas.
   ogni .hotspot è posizionato via transform dal viewer:
   NON deve avere transizioni sul transform, altrimenti
   "insegue" il movimento con ritardo.                       */
#viewer .hotspot {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}


/* telefono: niente sfocature sulle fasce e sul pulsante. Mentre la fascia compare in dissolvenza
   il telefono non disegna lo sfocato, che poi arriva di colpo a fine animazione (uno scatto).
   In fondo al file perché vinca sulle regole di LEGGIBILITÀ qui sopra. */
@media (max-width: 760px) {
  #maesta-testata::before, #tour::before, #tour .tour-primary {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  #tour .tour-primary { background: rgba(20,18,16,.88); }
}


/* ============================================================
   CONTORNI DEGLI HOTSPOT (al posto dei tondini)
   i poligoni sono in coordinate 0..1 della tavola: lo spessore
   delle linee resta fisso: è moltiplicato per --k (1/zoom, da viewer.js).
   A riposo una traccia leggera; sulla figura attiva (o sotto il
   mouse) un alone dorato fatto di copie larghe e trasparenti del
   contorno: niente filtri, che costano a ogni fotogramma.
   ============================================================ */
/* il velo sta in un svg suo, sfocato: il bordo della figura illuminata è sfumato.
   Sborda dallo schermo così la sfocatura non schiarisce i lati (margine come VELO_MARGINE in viewer.js) */
#viewer svg.velo-svg {
  --velo-margine: 60px;
  position: absolute;
  inset: calc(-1 * var(--velo-margine));
  width: calc(100% + 2 * var(--velo-margine));
  height: calc(100% + 2 * var(--velo-margine));
  pointer-events: none;
  filter: blur(14px);
}
#viewer svg.contorni {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.contorno {
  fill: rgba(201,162,39,0);
  stroke: none;                        /* la linea la fanno le copie sfumate qui sotto */
  pointer-events: visiblePainted;
  cursor: pointer;
}
/* i gruppi non hanno una linea propria: si vedono solo quando sono la tappa */
.contorno--gruppo { pointer-events: none; }

/* la linea sfumata: cinque copie del contorno, dalla più larga e trasparente alla più sottile;
   nessuna è netta, insieme fanno una linea morbida */
.riposo path {
  fill: none;
  stroke-linejoin: round;
  stroke-linecap: round;
  pointer-events: none;
  transition: stroke .3s ease-out;   /* niente transizione sullo spessore: cambia a ogni fotogramma con lo zoom */
}
/* a riposo le figure non hanno linea: si accende solo sotto il mouse (insieme al velo) */
.riposo { opacity: 0; transition: opacity .3s ease-out; }
.riposo.sopra { opacity: 1; }

/* la linea sotto il mouse: spessa, luminosa, sempre morbida.
   Sul fronte più larga e più sfumata, senza il filo netto in mezzo, come nel video (09/11/2026) */
svg.contorni.fronte .riposo .alone-1 { stroke: rgba(232,200,110,.04); stroke-width: calc(46px * var(--k, 1)); }
svg.contorni.fronte .riposo .alone-2 { stroke: rgba(236,206,122,.06); stroke-width: calc(32px * var(--k, 1)); }
svg.contorni.fronte .riposo .alone-3 { stroke: rgba(240,212,135,.08); stroke-width: calc(21px * var(--k, 1)); }
svg.contorni.fronte .riposo .alone-4 { stroke: rgba(246,222,152,.10); stroke-width: calc(12px * var(--k, 1)); }
svg.contorni.fronte .riposo .alone-5 { stroke: rgba(252,232,172,.12); stroke-width: calc(6px * var(--k, 1)); }
.riposo .alone-1 { stroke: rgba(232,200,110,.06); stroke-width: calc(30px * var(--k, 1)); }
.riposo .alone-2 { stroke: rgba(236,206,122,.09); stroke-width: calc(21px * var(--k, 1)); }
.riposo .alone-3 { stroke: rgba(240,212,135,.13); stroke-width: calc(13px * var(--k, 1)); }
.riposo .alone-4 { stroke: rgba(246,222,152,.18); stroke-width: calc(7px * var(--k, 1)); }
.riposo .alone-5 { stroke: rgba(252,232,172,.26); stroke-width: calc(3px * var(--k, 1)); }

/* il titolo dell'hotspot sotto il mouse */
.etichetta-hotspot {
  position: absolute;
  left: 0; top: 0;
  max-width: 260px;
  padding: 6px 12px;
  background: rgba(11,10,9,.82);
  border: 1px solid rgba(201,162,39,.35);
  border-radius: 4px;
  color: var(--gesso);
  font-family: var(--display);
  font-size: 15px;
  line-height: 1.3;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease-out;
  z-index: 5;
}
.etichetta-hotspot.su { opacity: 1; }
body.reading .etichetta-hotspot { display: none; }   /* sulla tappa il titolo c'è già nella scheda */

/* il velo: sotto il mouse scurisce un poco tutto tranne la figura */
.velo {
  fill: rgba(11,10,9,.42);
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s ease-out;
}
.velo.su { opacity: 1; }

/* durante il percorso si vede solo la figura della tappa */
body.reading .contorno:not(.active) { opacity: 0; pointer-events: none; }
body.reading .aloni-riposo { display: none; }

/* ---------- modalità regia (?regia, regia.js): per registrare il video del banner; online non si usa ----------
   niente comandi né fasce scure: solo la tavola */
body.regia #maesta-testata, body.regia #faces, body.regia #tour, body.regia #panel, body.regia #passaggio,
body.regia .etichetta-hotspot { display: none !important; }
body.regia #viewer { cursor: default; }
