/* Il Museo dei Sogni Capovolti: stile dell'interfaccia sopra la scena 3D e della pagina statica. */

@font-face { font-family: "Instrument Serif"; font-style: normal; font-weight: 400; font-display: swap; src: url("font/instrument-serif-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Instrument Serif"; font-style: normal; font-weight: 400; font-display: swap; src: url("font/instrument-serif-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Instrument Serif"; font-style: italic; font-weight: 400; font-display: swap; src: url("font/instrument-serif-corsivo-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Instrument Serif"; font-style: italic; font-weight: 400; font-display: swap; src: url("font/instrument-serif-corsivo-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Jost"; font-style: normal; font-weight: 300 500; font-display: swap; src: url("font/jost-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Jost"; font-style: normal; font-weight: 300 500; font-display: swap; src: url("font/jost-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --notte: #07031a;
  --viola: #3b1a8a;
  --rosa: #ff3fa4;
  --oro: #f2c14e;
  --turchese: #3ee8d6;
  --panna: #f6f1ff;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --sans: "Jost", "Segoe UI", system-ui, sans-serif;
  --avanzamento: 0;
  --barra: 0px;
  --lato: clamp(20px, 5vw, 72px);
}

* { box-sizing: border-box; }
html { background: var(--notte); color: var(--panna); scroll-behavior: auto; }
html.calmo { scroll-behavior: auto; }
body { margin: 0; font-family: var(--sans); font-weight: 300; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
body.bloccato { overflow: hidden; }
html.js:not(.statico) body { cursor: none; }
html.js:not(.statico).tocco body { cursor: auto; }
a { color: inherit; }
button { font: inherit; color: inherit; }
::selection { background: var(--rosa); color: var(--notte); }

/* Barra di scorrimento della pagina: oro su notte. */
html::-webkit-scrollbar { width: 10px; }
html::-webkit-scrollbar-track { background: var(--notte); }
html::-webkit-scrollbar-thumb { background: var(--oro); border: 2px solid var(--notte); border-radius: 8px; }
@supports not selector(::-webkit-scrollbar) { html { scrollbar-color: var(--oro) var(--notte); scrollbar-width: thin; } }

/* ---------- La scena ---------- */
#tela { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }
#scorrimento { height: 1700vh; pointer-events: none; }
html.calmo #scorrimento { height: 1700vh; }

/* ---------- Caricamento ---------- */
#caricamento { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: var(--notte); transition: opacity 1.2s ease, visibility 1.2s; }
#caricamento.via { opacity: 0; visibility: hidden; pointer-events: none; }
#galassia { position: absolute; inset: 0; width: 100%; height: 100%; }
.caricamento-titolo { position: absolute; top: calc(var(--lato) + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); margin: 0; font-family: var(--serif); font-style: italic; font-size: clamp(1.1rem, 2vw, 1.5rem); color: rgba(246, 241, 255, 0.7); white-space: nowrap; }
#percentuale { position: absolute; margin: 0; font-family: var(--serif); font-style: italic; font-size: clamp(6rem, 22vw, 14rem); line-height: 1; color: transparent; opacity: 0; }
html.calmo #percentuale { color: var(--panna); opacity: 1; transition: opacity .5s; }
html.calmo #percentuale.via { opacity: 0; }
#entra { position: absolute; bottom: calc(14vh + env(safe-area-inset-bottom)); left: 50%; transform: translate(-50%, 20px); padding: 14px 38px; border: 1px solid rgba(242, 193, 78, 0.55); border-radius: 999px; background: rgba(7, 3, 26, 0.5); color: var(--panna); font-family: var(--serif); font-size: 1.4rem; letter-spacing: .01em; opacity: 0; transition: opacity .9s ease, transform .9s ease, background .3s, color .3s; cursor: pointer; pointer-events: none; }
#caricamento.pronto #entra { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#entra:hover, #entra:focus-visible { background: var(--oro); color: var(--notte); outline: none; }
.caricamento-nota { position: absolute; bottom: calc(6vh + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); margin: 0; font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; color: rgba(246, 241, 255, 0.45); white-space: nowrap; opacity: 0; transition: opacity 1.2s .4s; }
#caricamento.pronto .caricamento-nota { opacity: 1; }

/* ---------- Testata e comandi ---------- */
.testata { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; padding: calc(16px + env(safe-area-inset-top)) var(--lato) 0; pointer-events: none; mix-blend-mode: screen; }
.marchio { margin: 0; font-family: var(--serif); font-style: italic; font-size: 1.15rem; letter-spacing: .02em; color: rgba(246, 241, 255, 0.85); }
.comandi { display: flex; gap: 10px; pointer-events: auto; }
.comandi button { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 16px; border: 1px solid rgba(246, 241, 255, 0.22); border-radius: 999px; background: rgba(7, 3, 26, 0.35); backdrop-filter: blur(8px); font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; transition: border-color .3s, background .3s; }
.comandi button:hover, .comandi button:focus-visible { border-color: var(--oro); outline: none; }
.comandi button[aria-pressed="true"] { background: rgba(242, 193, 78, 0.16); border-color: rgba(242, 193, 78, 0.6); }
/* Icona dell'audio: un altoparlante, con le onde quando è acceso e la croce quando è spento. */
.altoparlante { width: 20px; height: 20px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
#tasto-audio[aria-pressed="true"] .altoparlante path:first-child { fill: currentColor; }
#tasto-audio[aria-pressed="true"] .muto { display: none; }
#tasto-audio[aria-pressed="false"] .onde { display: none; }
#tasto-schermo svg { width: 16px; height: 16px; display: block; }
#tasto-schermo[hidden] { display: none; }

/* ---------- Testi delle sale (sopra la scena) ---------- */
#sale { position: relative; z-index: 10; pointer-events: none; }
body.bloccato #sale { z-index: 45; }
.sala { position: fixed; inset: 0; display: flex; align-items: flex-end; padding: 0 var(--lato) calc(var(--barra) + 9vh + env(safe-area-inset-bottom)); opacity: 0; visibility: hidden; transition: opacity 1.1s ease, visibility 1.1s; }
.sala.attiva { opacity: 1; visibility: visible; }
.sala-testo { max-width: 46ch; text-shadow: 0 2px 30px rgba(7, 3, 26, 0.8); }
.sala-numero { margin: 0 0 10px; font-size: .78rem; letter-spacing: .22em; text-transform: uppercase; color: var(--oro); }
.sala h1, .sala h2 { margin: 0 0 14px; font-family: var(--serif); font-weight: 400; line-height: .98; letter-spacing: -.01em; }
.sala h1 { font-size: clamp(2.6rem, 7vw, 6.2rem); font-style: italic; }
.sala h2 { font-size: clamp(2.2rem, 5.2vw, 4.6rem); }
.sala-frase { margin: 0; font-size: clamp(1rem, 1.35vw, 1.25rem); color: rgba(246, 241, 255, 0.86); max-width: 40ch; }
.sala.attiva .sala-numero, .sala.attiva h1, .sala.attiva h2, .sala.attiva .sala-frase, .sala.attiva .azioni { animation: sale-su 1.3s cubic-bezier(.2, .7, .2, 1) both; }
.sala.attiva h1, .sala.attiva h2 { animation-delay: .12s; }
.sala.attiva .sala-frase { animation-delay: .28s; }
.sala.attiva .azioni { animation-delay: .45s; }
@keyframes sale-su { from { opacity: 0; transform: translateY(26px); filter: blur(6px); } to { opacity: 1; transform: none; filter: blur(0); } }
.sala-poster { display: none; }
.sala-0 { justify-content: center; text-align: center; transition: opacity 1.1s ease, visibility 1.1s, padding 1s ease; }
body.bloccato .sala-0 { padding-bottom: 32vh; }
.sala-0 .sala-testo { max-width: 60ch; }
.sala-0 .sala-frase { margin: 0 auto; }
.sala.finale { justify-content: center; text-align: center; }
.sala.finale h2 { font-size: clamp(1.6rem, 3vw, 2.6rem); font-style: italic; }
.sala.finale .sala-frase { margin: 0 auto; }
html.poster .testata, html.poster .filo, html.poster #sottotitolo, html.poster .scorri, html.poster #cursore, html.poster .sala, html.poster .barre { display: none; }
.azioni { display: flex; gap: 22px; align-items: center; justify-content: center; margin-top: 30px; pointer-events: auto; flex-wrap: wrap; }
.bottone { display: inline-block; padding: 14px 36px; border: 1px solid var(--oro); border-radius: 999px; background: rgba(242, 193, 78, 0.12); color: var(--panna); font-family: var(--serif); font-size: 1.3rem; text-decoration: none; transition: background .3s, color .3s, transform .3s; }
.bottone:hover, .bottone:focus-visible { background: var(--oro); color: var(--notte); transform: translateY(-2px); outline: none; }
.link { font-size: .82rem; letter-spacing: .14em; text-transform: uppercase; text-decoration: none; color: rgba(246, 241, 255, 0.7); border-bottom: 1px solid rgba(246, 241, 255, 0.25); padding-bottom: 2px; transition: color .3s, border-color .3s; }
.link:hover, .link:focus-visible { color: var(--oro); border-color: var(--oro); outline: none; }

/* ---------- Sottotitoli e barre ---------- */
#sottotitolo { position: fixed; left: 50%; bottom: calc(var(--barra) + 3.2vh + env(safe-area-inset-bottom)); z-index: 15; margin: 0; transform: translate(-50%, 8px); max-width: min(80vw, 60ch); text-align: center; font-family: var(--serif); font-style: italic; font-size: clamp(1.05rem, 1.8vw, 1.55rem); color: rgba(246, 241, 255, 0.92); text-shadow: 0 2px 20px rgba(7, 3, 26, 0.9); opacity: 0; transition: opacity .8s ease, transform .8s ease; pointer-events: none; }
#sottotitolo.visibile { opacity: 1; transform: translate(-50%, 0); }
/* Le barre nere cinematografiche sono state tolte il 15/10/2026 (Loris: la scena deve riempire tutto lo schermo). */
.barre { display: none; }

/* ---------- Il filo di luce ---------- */
.filo { position: fixed; right: calc(var(--lato) * .45); top: 18vh; bottom: 18vh; width: 2px; z-index: 15; background: rgba(246, 241, 255, 0.1); border-radius: 2px; pointer-events: none; /* controllo-trattini:ok, filo verticale di avanzamento */ }
.filo::before { content: ""; position: absolute; left: 0; top: 0; width: 100%; height: calc(var(--avanzamento) * 100%); background: linear-gradient(to bottom, var(--turchese), var(--oro)); border-radius: 2px; box-shadow: 0 0 12px var(--oro); }
.filo-perla { position: absolute; left: 50%; top: calc(var(--avanzamento) * 100%); width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--panna); box-shadow: 0 0 18px 4px rgba(242, 193, 78, 0.7); }

.scorri { position: fixed; left: 50%; bottom: calc(var(--barra) + 2vh + env(safe-area-inset-bottom)); z-index: 15; margin: 0; transform: translateX(-50%); font-size: .72rem; letter-spacing: .3em; text-transform: uppercase; color: rgba(246, 241, 255, 0.55); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; transition: opacity .8s; }
.scorri.nascosto { opacity: 0; }
.scorri-freccia { display: block; width: 1px; height: 34px; background: linear-gradient(to bottom, var(--oro), transparent); animation: scorri 1.8s ease-in-out infinite; /* controllo-trattini:ok, indicatore verticale scorri */ }
@keyframes scorri { 0% { transform: scaleY(0); transform-origin: top; } 50% { transform: scaleY(1); transform-origin: top; } 51% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }
body.bloccato .scorri { opacity: 0; }

/* ---------- Cursore ---------- */
#cursore { position: fixed; inset: 0; z-index: 60; pointer-events: none; opacity: 0; transition: opacity .4s; }
#cursore.visibile { opacity: 1; }
#cursore .sfera, #cursore .scia { position: absolute; top: 0; left: 0; border-radius: 50%; will-change: transform; }
#cursore .sfera { width: 14px; height: 14px; margin: -7px 0 0 -7px; background: var(--panna); box-shadow: 0 0 16px 4px rgba(246, 241, 255, 0.6), 0 0 40px 10px rgba(62, 232, 214, 0.35); transition: width .3s, height .3s, margin .3s, background .3s; mix-blend-mode: screen; }
#cursore .scia { width: 8px; height: 8px; margin: -4px 0 0 -4px; background: var(--turchese); opacity: .55; mix-blend-mode: screen; }
#cursore.premuto .sfera { width: 44px; height: 44px; margin: -22px 0 0 -22px; background: transparent; box-shadow: 0 0 0 2px var(--oro); }
html.sopra-oggetto #cursore .sfera, #cursore.su-link .sfera { width: 30px; height: 30px; margin: -15px 0 0 -15px; background: var(--oro); }

.piede { display: none; }

/* ---------- Meno movimento ---------- */
html.calmo .sala.attiva .sala-numero, html.calmo .sala.attiva h1, html.calmo .sala.attiva h2, html.calmo .sala.attiva .sala-frase, html.calmo .sala.attiva .azioni { animation: none; }
html.calmo .sala, html.calmo #sottotitolo, html.calmo .barre::before, html.calmo .barre::after, html.calmo #caricamento, html.calmo #entra { transition-duration: .01s; }
html.calmo .scorri-freccia { animation: none; }
html.calmo #cursore { display: none; }
html.js.calmo body, html.js.calmo:not(.statico) body { cursor: auto; }

/* ---------- Senza WebGL: la pagina completa, una sala sotto l'altra ---------- */
html.statico body { cursor: auto; overflow: auto; }
html.statico #tela, html.statico #scorrimento, html.statico .barre, html.statico #sottotitolo, html.statico .filo, html.statico .scorri, html.statico #cursore, html.statico #caricamento, html.statico #tasto-audio, html.statico #tasto-schermo { display: none; }
html.statico .testata { position: sticky; mix-blend-mode: normal; background: linear-gradient(to bottom, rgba(7, 3, 26, 0.9), transparent); padding-bottom: 16px; }
html.statico #sale { pointer-events: auto; }
html.statico .sala { position: relative; inset: auto; min-height: 100svh; opacity: 1; visibility: visible; align-items: flex-end; padding: 18vh var(--lato) 12vh; overflow: hidden; isolation: isolate; }
html.statico .sala-poster { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -1; filter: brightness(.6) saturate(1.1); }
html.statico .sala-testo { position: relative; }
html.statico .sala-0, html.statico .sala.finale { align-items: flex-end; text-align: left; }
html.statico .sala-0 .sala-testo, html.statico .sala.finale .sala-testo { margin-top: 0; }
html.statico .sala-0 .sala-frase, html.statico .sala.finale .sala-frase { margin: 0; }
html.statico .azioni { justify-content: flex-start; }
html.statico .piede { display: block; padding: 40px var(--lato); font-size: .85rem; color: rgba(246, 241, 255, 0.55); max-width: 70ch; }

/* ---------- Telefono ---------- */
@media (max-width: 760px) {
  .sala.finale h2 { font-size: 1.5rem; margin-bottom: 8px; }
  .sala.finale .sala-frase { font-size: .95rem; }
  .sala.finale { padding-bottom: calc(var(--barra) + 7vh + env(safe-area-inset-bottom)); }
  .sala.finale .azioni { margin-top: 18px; }
  .marchio { font-size: 1rem; }
  .comandi button span { display: none; }
  .comandi button { padding: 8px 14px; min-width: 44px; justify-content: center; }
  .comandi { gap: 6px; }
  .comandi button { padding: 8px 10px; }
  .sala { padding-bottom: calc(var(--barra) + 11vh + env(safe-area-inset-bottom)); }
  .sala h1 { font-size: clamp(2.4rem, 12vw, 3.6rem); }
  .sala h2 { font-size: clamp(2rem, 10vw, 3rem); }
  .filo { right: 10px; top: 24vh; bottom: 24vh; }
  #sottotitolo { max-width: 88vw; font-size: 1.05rem; bottom: calc(var(--barra) + 4.5vh + env(safe-area-inset-bottom)); }
  body.bloccato .sala-0 { padding-bottom: 36vh; }
  .azioni { gap: 16px; }
}
@media (max-height: 520px) {
  .sala-0 .sala-testo { margin-top: 20vh; }
  .sala h1 { font-size: 2.4rem; }
}
