:root {
  color-scheme: dark;
  --ink: #f7f4ee;
  --muted: rgba(247, 244, 238, 0.76);
  --line: rgba(255, 255, 255, 0.2);
  --panel: rgba(13, 18, 21, 0.58);
  --accent: #f6b44b;
  --accent-ink: #241705;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

/* Le barre di scorrimento, tutte uguali in tutto il sito: sottili, il
   cursore nel rame delle etichette, la guida nel bruno della carta. Dove una
   barra non deve vedersi (menu, strisce del telefono) resta `none`, che vince
   su questa regola perché `*` non pesa niente. */
html {
  scrollbar-color: rgba(217, 154, 118, 0.62) rgb(18, 14, 10);
}

* {
  scrollbar-width: thin;
}

*:not(html) {
  scrollbar-color: rgba(217, 154, 118, 0.55) transparent;
}

/* Safari e i browser senza `scrollbar-color`. */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(217, 154, 118, 0.55); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: rgba(217, 154, 118, 0.85); }
html::-webkit-scrollbar-track { background: rgb(18, 14, 10); }

body {
  margin: 0;
  background: #091014;
  color: var(--ink);
}

a {
  color: inherit;
}

.scroll-experience {
  position: relative;
  /* 8416.4 - 100 = 8316.4vh: aggiunge il rallentamento finale 3×. */
  min-height: 8416.4vh;
  background: #091014;
}

.sticky-stage {
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 560px;
  overflow: hidden;
  isolation: isolate;
  /* Le soste del percorso dimensionano tutto in cqw/cqh: senza questa
     dichiarazione la tipografia degli overlay non si dimensiona. */
  container-type: size;
}

.frame-stage {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(8, 16, 20, 0.88), rgba(8, 16, 20, 0.24)),
    #10191d;
}

.sequence-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.001);
  transition: opacity 90ms linear;
}

.sequence-frame.is-visible {
  opacity: 1;
}

.calibration-debug {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 12;
  width: min(330px, calc(100vw - 24px));
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.76);
  color: #fff;
  font: 12px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
}

.calibration-debug-values {
  min-height: 9.6em;
  margin: 0 0 8px;
  max-height: 58vh;
  overflow: auto;
  color: rgba(255, 255, 255, 0.9);
  font: inherit;
  white-space: pre-wrap;
}

.calibration-copy {
  width: 100%;
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: 700 12px/1 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
}

.calibration-copy:hover,
.calibration-copy:focus-visible {
  background: rgba(255, 255, 255, 0.2);
}

.calibration-stops {
  display: grid;
  gap: 2px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.calibration-stop {
  min-height: 22px;
  padding: 0 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font: 11px/22px ui-monospace, SFMono-Regular, Consolas, monospace;
  text-align: left;
  cursor: pointer;
}

.calibration-stop:hover,
.calibration-stop:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.calibration-stop.is-active {
  background: rgba(192, 139, 74, 0.32);
  color: #fff;
}

.has-load-error /* All'avvio non c'è più il cartellino «Preparazione del percorso»: sembrava un
   messaggio tecnico appoggiato sull'insegna. Resta un filo sottile in cima che
   scorre finché i primi fotogrammi non sono pronti; i testi restano nel DOM per
   i lettori di schermo. Il cartellino torna solo se l'avvio fallisce. */
.loading-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 5;
  height: 2px;
  overflow: hidden;
  background: rgba(247, 241, 228, 0.12);
  transition: opacity 320ms ease, visibility 320ms ease;
}

.loading-panel::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 30%;
  background: #c08b4a;
  animation: filo-avvio 1.4s ease-in-out infinite;
}

@keyframes filo-avvio {
  from { transform: translateX(-100%); }
  to { transform: translateX(340%); }
}

.loading-panel > * {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.has-load-error .loading-panel {
  left: 50%;
  right: auto;
  top: 50%;
  width: min(420px, calc(100vw - 40px));
  height: auto;
  padding: 24px;
  border: 1px solid rgba(255, 132, 108, 0.7);
  border-radius: 8px;
  background: rgba(9, 16, 20, 0.78);
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
}

.has-load-error .loading-panel::after { display: none; }

.has-load-error .loading-panel > * {
  position: static;
  width: auto;
  height: auto;
  clip-path: none;
  white-space: normal;
}

.loading-panel.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.loading-panel strong {
  display: block;
  margin: 6px 0 10px;
  font-size: 1.6rem;
  line-height: 1.1;
}

.loading-kicker,
.section-label {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.overlay-root {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.narrative-overlay {
  position: absolute;
  width: min(520px, calc(100vw - 40px));
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms linear;
  will-change: opacity, transform;
}

.narrative-overlay.is-active {
  pointer-events: auto;
}

.narrative-overlay h1 {
  margin: 0 0 14px;
  font-size: clamp(2.6rem, 7vw, 6.6rem);
  line-height: 0.94;
  font-weight: 780;
}

.narrative-overlay p {
  margin: 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.45vw, 1.28rem);
  line-height: 1.55;
}

.variant-card,
.variant-button,
.variant-finalCta {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.variant-card h1,
.variant-button h1,
.variant-finalCta h1 {
  font-size: clamp(2rem, 4vw, 4rem);
}

.position-left {
  left: clamp(20px, 7vw, 108px);
  top: 50%;
}

.position-right {
  right: clamp(20px, 7vw, 108px);
  top: 48%;
}

.position-center {
  left: 50%;
  top: 50%;
  text-align: center;
  transform: translate3d(-50%, 0, 0);
}

.position-center p {
  margin-inline: auto;
}

.position-bottom {
  left: 50%;
  bottom: clamp(92px, 13vh, 150px);
}

.position-bottom,
.position-center {
  translate: -50% 0;
}

.cta-button,
.text-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin-top: 22px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 760;
  text-decoration: none;
}

.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 34px;
  z-index: 6;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.88rem;
  transform: translateX(-50%);
  transition: opacity 240ms ease;
}

.scroll-cue::after {
  content: "";
  display: block;
  width: 1px;
  height: 30px;
  margin: 10px auto 0;
  background: currentColor;
  animation: cue 1.6s ease-in-out infinite;
}

.scroll-cue.is-hidden {
  opacity: 0;
}

.progress-shell {
  position: absolute;
  left: 50%;
  bottom: 22px;
  z-index: 6;
  width: min(420px, calc(100vw - 48px));
  transform: translateX(-50%);
}

.progress-bar {
  position: relative;
  height: 2px;
  background: rgba(255, 255, 255, 0.22);
}

.progress-fill {
  position: absolute;
  inset: 0;
  transform: scaleX(0);
  transform-origin: left;
  background: var(--accent);
}

.progress-dot {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  background: #11191d;
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.progress-dot.is-active {
  background: var(--accent);
  border-color: var(--accent);
}


@keyframes cue {
  0%,
  100% {
    transform: scaleY(0.45);
    transform-origin: top;
  }
  50% {
    transform: scaleY(1);
    transform-origin: top;
  }
}

@media (max-width: 760px) {
  .scroll-experience {
    /* 7456.85 - 100 = 7356.85vh: stesso fattore della variante desktop. */
    min-height: 7456.85vh;
  }

  .sticky-stage {
    min-height: 100svh;
  }

  .stage-vignette {
    background:
      linear-gradient(180deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.64)),
      radial-gradient(circle at 50% 36%, rgba(0, 0, 0, 0) 28%, rgba(0, 0, 0, 0.36));
  }

  .narrative-overlay,
  .position-left,
  .position-right,
  .position-center,
  .position-bottom {
    left: 20px;
    right: 20px;
    top: auto;
    bottom: 82px;
    width: auto;
    text-align: left;
    translate: 0 0;
  }

  .narrative-overlay h1,
  .variant-card h1,
  .variant-button h1,
  .variant-finalCta h1 {
    font-size: clamp(2rem, 12vw, 3.5rem);
  }

  .variant-title {
    padding: 0;
  }

  .cta-button {
    width: 100%;
    min-height: 54px;
  }

  .calibration-debug {
    position: fixed;
    top: max(8px, env(safe-area-inset-top));
    right: 8px;
    z-index: 40;
    width: min(260px, calc(100vw - 16px));
    max-height: min(46dvh, 360px);
    overflow: auto;
    padding: 8px;
    font-size: 10px;
  }

  .calibration-debug-values {
    min-height: 0;
    margin-bottom: 6px;
  }

  .calibration-debug .calibration-stops {
    display: none;
  }

  .calibration-debug .calibration-copy {
    min-height: 30px;
  }
}

/* Nel bundle perf la lista delle soste non e' una metrica e ruberebbe spazio
   al HUD; i seek restano disponibili dalla rail. */
.calibration-debug .calibration-stops {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .scroll-cue::after,
  .loading-panel::after {
    animation: none;
  }

  .narrative-overlay,
  .loading-panel {
    transition: none;
  }
}

/* ══ Telefono coricato: l'invito a rigirarlo ═══════════════════════ */
/* Costruito da main.js quando la sequenza non parte affatto. Sta sopra a tutto
   perché sotto non c'è niente: il percorso non è stato nemmeno chiesto. */
.ruota {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: #0d0a07;
  overflow: hidden;
}

.ruota-sfondo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Scura e un po' fuori fuoco: è uno sfondo, non il soggetto. Il soggetto è
     la frase, e l'insegna dietro dice soltanto dove si sta per entrare. */
  filter: brightness(0.42) saturate(0.8) blur(1px);
}

.ruota-testo {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 0 32px;
  text-align: center;
  color: #f7f1e4;
}

.ruota-mono {
  font: 400 22px/1 var(--font-titoli, 'Bodoni Moda', serif);
  letter-spacing: 0.08em;
  opacity: 0.72;
  margin-bottom: 6px;
}

.ruota-testo strong {
  font: 400 clamp(26px, 5.4vw, 40px) / 1.05 var(--font-titoli, 'Bodoni Moda', serif);
}

.ruota-nota {
  font: 400 14px/1.5 var(--font-testo, 'Instrument Sans', sans-serif);
  color: rgba(247, 241, 228, 0.72);
}

/* Il sito in testo (src/seo/testoSito.js): con JavaScript sta fuori schermo,
   per i lettori di schermo e i motori di ricerca, come .sosta-solo-lettori.
   Senza JavaScript lo rende visibile il <noscript> di index.html. */
.testo-sito {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Il primo Tab della pagina: compare solo quando ha il fuoco. */
.salta-al-testo {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 10000;
  padding: 10px 14px;
  background: #1a6e70;
  color: #f4efe6;
  border-radius: 4px;
  transform: translateY(-200%);
}
.salta-al-testo:focus-visible {
  transform: none;
}
