/* Tape Dynamics · home 3D — token da design-systems/td-base.design.md, versione notte */
:root {
  --bg: #05080e;
  --ink: #eef3f9;
  --ink-2: #b4c2d3;      /* 10.6:1 su --bg */
  --accent: #1570b8;     /* blu del logo: solo fondo, testo bianco sopra (5.2:1) */
  --accent-hover: #0f5a96;
  --electric: #6fb6ff;   /* 8.9:1 su --bg: ok come testo */
  --line: rgba(111, 182, 255, 0.28);
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --gutter: clamp(16px, 5vw, 72px);
}
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--sans); font-size: 16px; line-height: 1.6; background: var(--bg); overflow-x: hidden; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--electric); outline-offset: 3px; }
.skip { position: fixed; top: 8px; left: 8px; z-index: 30; min-height: 44px; padding: 12px 16px; border-radius: 8px; background: var(--accent); color: #fff; text-decoration: none; transform: translateY(-200%); }
.skip:focus { transform: none; }

/* ---------- fondo: la scena 3D dal vivo; senza WebGL2 un fotogramma fisso del render Blender ---------- */
#td3d-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; display: block; }
html.td3d-static #td3d-canvas { display: none; }
html.td3d-static body { background: var(--bg) url(/assets/td3d/hero.jpg) center / cover no-repeat fixed; }
html.td3d-static .td3d-scrim { position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg, rgba(5,8,14,.55) 0%, rgba(5,8,14,.15) 35%, rgba(5,8,14,.25) 60%, rgba(5,8,14,.8) 100%); }

/* ---------- HUD fisso ---------- */
.hud-top { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: 18px var(--gutter) 28px; gap: 16px; background: linear-gradient(180deg, rgba(5, 8, 14, .96) 0%, rgba(5, 8, 14, .85) 55%, rgba(5, 8, 14, 0) 100%); padding-bottom: 44px; }
.brand { display: inline-flex; align-items: center; min-height: 44px; gap: 10px; text-decoration: none; font-weight: 700; letter-spacing: .14em; font-size: 13px; }
.brand svg { width: 40px; height: auto; display: block; }
.hud-nav { display: flex; align-items: center; gap: 18px; font-family: var(--mono); font-size: 12px; letter-spacing: .08em; }
.hud-nav a { text-decoration: none; color: var(--ink-2); padding: 0 6px; min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
.hud-nav a.btn, .hud-nav a.btn:hover { color: #fff; }
.hud-nav a:hover, .hud-nav a[aria-current="true"] { color: var(--ink); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 12px 22px; border-radius: 9999px;
  background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; font-size: 15px; border: 1px solid rgba(255,255,255,.18);
  transition: background .2s ease, transform .2s ease; }
.btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-sm { min-height: 44px; padding: 8px 16px; font-size: 13px; font-family: var(--sans); letter-spacing: 0; }
.hud-corner { position: fixed; z-index: 5; font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--ink-2); letter-spacing: .06em; pointer-events: none; }
.hud-corner.br { right: var(--gutter); bottom: 18px; text-align: right; }
.hud-corner.bl { left: var(--gutter); bottom: 18px; }
#hud-lines { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 2; pointer-events: none; }
#hud-lines line { stroke: var(--electric); stroke-width: 1; opacity: 0; }
.hud-label { position: fixed; left: 0; top: 0; z-index: 3; opacity: 0; pointer-events: none; font-family: var(--mono); font-size: 12px; line-height: 1.5;
  letter-spacing: .06em; color: var(--ink); white-space: nowrap; padding: 4px 0; border-bottom: 1px solid var(--electric); }
.hud-label .hud-coord { display: block; color: var(--electric); }
html.td3d-static .hud-label, html.td3d-static #hud-lines, html.td3d-static .hud-corner.br { display: none; }
.hud-corner.bl { transition: opacity .4s ease; }
html.td3d-scrolled .hud-corner.bl { opacity: 0; } /* fuori dall'hero non va sotto il testo dei pilastri */

/* ---------- testo che scorre ---------- */
main { position: relative; z-index: 4; }
.act { min-height: 100vh; display: flex; align-items: center; padding: 96px var(--gutter); }
.act.right { justify-content: flex-end; }
.act.center { justify-content: center; text-align: center; }
.panel { max-width: 30rem; text-shadow: 0 1px 2px rgba(5, 8, 14, .6), 0 0 24px rgba(5, 8, 14, .75); }
.kicker { font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--electric); margin: 0 0 14px; }
h1, h2 { font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(2.4rem, 6vw, 5rem); }
h2 { font-size: clamp(1.9rem, 4vw, 3.2rem); }
.lead { color: var(--ink-2); font-size: clamp(1rem, 1.4vw, 1.15rem); margin: 18px 0 0; max-width: 34ch; }
.act.center .lead { margin-left: auto; margin-right: auto; }
.intro { position: relative; align-items: flex-start; justify-content: center; text-align: center; padding-top: 92px; }
.intro .panel { max-width: 44rem; }
.intro h1 { font-size: clamp(1.15rem, 1.9vw, 1.6rem); font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.intro h1 span { display: block; }
.intro .lead { font-size: 15px; margin: 10px auto 0; max-width: 46ch; color: #fff; }
.intro .panel { padding: 18px 28px 22px; background: radial-gradient(ellipse at 50% 45%, rgba(5, 12, 24, .62) 0%, rgba(5, 12, 24, .35) 55%, rgba(5, 12, 24, 0) 78%); text-shadow: 0 1px 2px rgba(5, 12, 24, .8), 0 0 18px rgba(5, 12, 24, .85); }
/* la prima frase arriva col fulmine, la seconda quando il monolite si accende */
html.td3d-gl .intro .panel { opacity: 1; transform: none; }
/* l'hero (loop Blender) c'è subito: le scritte entrano in sequenza al caricamento */
html.td3d-ready .h-a, html.td3d-ready .h-b, html.td3d-ready .intro .lead { animation: heroIn 1s ease both; }
html.td3d-ready .h-a { animation-delay: .1s; } html.td3d-ready .h-b { animation-delay: .6s; } html.td3d-ready .intro .lead { animation-delay: 1.1s; }
/* apertura: le scritte arrivano a scena accesa (td3d-ready), come i testi di igloo */
html.td3d-gl:not(.td3d-ready) .intro .panel { visibility: hidden; }
@keyframes heroIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
html.td3d-gl .intro { min-height: 170vh; }
html.td3d-gl .scroll-cue { position: fixed; transition: opacity .4s ease; }
html.td3d-diving .scroll-cue { opacity: 0; }
.pillar h2 { font-size: clamp(1.5rem, 2.6vw, 2.25rem); line-height: 1.15; }
.pillar .panel { max-width: 32rem; }
.cta h2 { font-size: clamp(1.6rem, 3vw, 2.6rem); line-height: 1.12; }
.cta .panel { max-width: 38rem; }
/* attesa della scena: fermo-immagine del render Blender, poi il canvas in dissolvenza */
html.td3d-gl body { background: var(--bg) url(/assets/td3d/hero.jpg) center / cover no-repeat fixed; }
html.td3d-gl #td3d-canvas { opacity: 0; transition: opacity .8s ease; }
html.td3d-running #td3d-canvas { opacity: 1; }
.intro .kicker { margin-bottom: 8px; }
.scroll-cue { position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); margin: 0; font-family: var(--mono); font-size: 12px; letter-spacing: .2em; color: var(--ink-2); }
.scroll-cue::after { content: ""; display: block; width: 1px; height: 34px; margin: 10px auto 0; background: linear-gradient(var(--electric), transparent); animation: cue 2s ease-in-out infinite; transform-origin: top; }
@keyframes cue { 0%, 100% { transform: scaleY(.3); opacity: .4; } 50% { transform: scaleY(1); opacity: 1; } }
.lead.small { font-size: 14px; margin-top: 10px; }
.intro .panel { max-width: 40rem; opacity: 0; transform: translateY(14px); transition: opacity 1s ease, transform 1s ease; }
html.td3d-ready .intro .panel, html.td3d-static .intro .panel, html.no-js .intro .panel { opacity: 1; transform: none; }
.descend { min-height: 70vh; }
.numbers ul { list-style: none; margin: 32px 0 0; padding: 0; display: grid; gap: 22px; }
.numbers li { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; align-items: baseline; text-align: left; border-top: 1px solid var(--line); padding-top: 14px; }
.numbers strong { font-size: clamp(2rem, 4vw, 3rem); font-weight: 800; letter-spacing: -0.02em; min-width: 3.2ch; }
.numbers span { color: var(--ink-2); }
.cta { min-height: 130vh; } /* coda prima del footer: l'anello completo e la CTA restano visibili */
/* desktop: la scheda sta a sinistra e resta ferma mentre l'anello (a destra) si chiude; la sezione finisce prima del footer */
@media (min-width: 821px) {
  html.td3d-gl .act.cta { min-height: 210vh; justify-content: flex-start; align-items: flex-start; text-align: left; padding-top: 0; padding-bottom: 0; }
  html.td3d-gl .act.cta .panel { position: sticky; top: calc(50vh - 190px); margin: 0; max-width: 34rem; }
  html.td3d-gl .act.cta .lead { margin-left: 0; }
}
@media (min-width: 821px) and (max-width: 1180px) {
  html.td3d-gl .act.cta .panel { max-width: 25rem; } /* a 1024 px la scheda larga finiva dentro l'anello */
}
.descend .panel, .numbers .panel, .cta .panel { background: rgba(5, 8, 14, .66); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  padding: 32px clamp(20px, 3vw, 40px); border-radius: 16px; border: 1px solid var(--line); }
.cta .btn { margin-top: 30px; }

/* ---------- footer: le pagine di sempre ---------- */
.site-foot { position: relative; z-index: 4; background: linear-gradient(180deg, rgba(5,8,14,0) 0%, rgba(5,8,14,.85) 90px, var(--bg) 220px); padding: 140px var(--gutter) 96px; color: var(--ink-2); font-size: 14px; }
.foot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 32px; max-width: 1200px; }
.foot-grid h3 { font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink); margin: 0 0 12px; font-weight: 500; }
.foot-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.foot-grid a { text-decoration: none; }
.foot-grid a:hover { color: var(--ink); text-decoration: underline; }
.foot-legal { margin-top: 40px; font-size: 13px; color: var(--ink-2); }

/* ---------- mobile ---------- */
@media (max-width: 820px) {
  .hud-nav .nav-link { display: none; }
  .hud-corner.bl { display: none; }
  .brand { white-space: nowrap; font-size: 12px; letter-spacing: .1em; }
  .brand svg { width: 34px; }
  .hud-nav { gap: 2px; min-width: 0; }
  .hud-nav a { padding: 0; }
  .hud-nav .btn { white-space: nowrap; padding: 0 14px; font-size: 13px; flex-shrink: 0; margin-left: 6px; }
  .hud-top { background: linear-gradient(180deg, rgba(5, 8, 14, 1) 0%, rgba(5, 8, 14, .96) 70%, rgba(5, 8, 14, 0) 100%); }
  .act, .act.right { justify-content: flex-start; align-items: flex-end; padding-bottom: 12vh; }
  .act.center { justify-content: center; }
  .act.intro { align-items: flex-start; justify-content: center; padding-top: 84px; }
  .panel { background: linear-gradient(180deg, rgba(5,8,14,0) 0%, rgba(5,8,14,.55) 22%); padding-top: 24px; }
}
@media (max-width: 480px) {
  .brand { min-width: 44px; justify-content: center; }
  .brand span { display: none; } /* a 360-390 px non ci stanno marchio, 3 lingue e CTA: resta il monogramma */
}
@media (prefers-reduced-motion: reduce) {
  .h-a, .h-b, .intro .lead { transition: none; animation: none !important; }
  .scroll-cue::after { animation: none; }
  .intro .panel { transition: none; opacity: 1; transform: none; }
  .btn { transition: none; }
}
@media (max-width: 820px) {
  html.td3d-gl body, html.td3d-static body { background-image: url(/assets/td3d/hero-p.jpg); }
  /* finale: pannello in alto, poi una schermata di solo anello prima che salga il footer */
  html.td3d-gl .act.cta { min-height: 175vh; align-items: flex-start; padding-top: 16vh; }
}
html.td3d-gl:not(.td3d-dived) .hud-label, html.td3d-gl:not(.td3d-dived) #hud-lines { visibility: hidden; } /* durante la discesa le etichette dei cristalli non vanno sopra il tuffo */

/* ---------- pulsante musica (testata) ---------- */
.sound-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; min-width: 44px; padding: 0 8px; margin-right: 4px;
  background: none; border: 0; border-radius: 9999px; color: var(--ink-2); font-family: var(--mono); font-size: 12px; letter-spacing: .08em; cursor: pointer; }
.sound-toggle:hover, .sound-toggle.on { color: var(--ink); }
.sound-toggle .eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.sound-toggle .eq i { display: block; width: 2px; height: 4px; background: var(--electric); border-radius: 1px; }
.sound-toggle .eq { opacity: .55; } .sound-toggle.on .eq { opacity: 1; } /* spento: barrette ferme e tenui */
.sound-toggle.on .eq i { animation: eq 1.1s ease-in-out infinite; }
.sound-toggle.on .eq i:nth-child(2) { animation-delay: -.35s; } .sound-toggle.on .eq i:nth-child(3) { animation-delay: -.7s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 12px; } }
@media (max-width: 820px) { .sound-label { display: none; } }
@media (prefers-reduced-motion: reduce) { .sound-toggle.on .eq i { animation: none; height: 10px; } }
/* invito alla musica (22/11): anello che pulsa + freccia sotto il pulsante, finché non lo si tocca o si scorre via dall'apertura */
.sound-toggle { position: relative; }
.sound-toggle.hint::before { content: ''; position: absolute; inset: 6px 2px; border-radius: 9999px; border: 1px solid var(--electric); pointer-events: none; animation: sndRing 1.8s ease-out infinite; }
.sound-toggle.hint::after { content: ''; position: absolute; top: 100%; left: 50%; width: 9px; height: 9px; margin-left: -6px;
  border-left: 2px solid var(--electric); border-top: 2px solid var(--electric); filter: drop-shadow(0 0 6px rgba(111, 182, 255, .9));
  pointer-events: none; transform: translateY(8px) rotate(45deg); animation: sndArrow 1.2s ease-in-out infinite; }
.sound-toggle.hint .eq { opacity: 1; }
@keyframes sndRing { 0% { transform: scale(.85); opacity: .9; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes sndArrow { 0%, 100% { transform: translateY(12px) rotate(45deg); opacity: .45; } 50% { transform: translateY(4px) rotate(45deg); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sound-toggle.hint::before { animation: none; opacity: .6; } .sound-toggle.hint::after { animation: none; } }

/* variante vulcano (/vulcano/): foto di attesa e di riserva ricavate dalla scena viva */
html[data-theme="vulcano"].td3d-gl body, html[data-theme="vulcano"].td3d-static body { background-image: url(/assets/td3d/hero-vulcano.jpg); }
@media (max-width: 820px) {
  html[data-theme="vulcano"].td3d-gl body, html[data-theme="vulcano"].td3d-static body { background-image: url(/assets/td3d/hero-vulcano-p.jpg); }
}

/* variante albero (/albero/): foto di attesa e di riserva ricavate dalla scena viva */
html[data-theme="albero"].td3d-gl body, html[data-theme="albero"].td3d-static body { background-image: url(/assets/td3d/hero-albero.jpg); }
@media (max-width: 820px) {
  html[data-theme="albero"].td3d-gl body, html[data-theme="albero"].td3d-static body { background-image: url(/assets/td3d/hero-albero-p.jpg); }
}

/* ---------- cartoni dei pilastri (solo pagine IT: pulsante + finestra; motore in /assets/cartoni/) ---------- */
.tdc-open { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 22px; padding: 0 18px 0 14px; border-radius: 9999px;
  background: rgba(5, 8, 14, .45); border: 1px solid var(--line); color: var(--electric); cursor: pointer;
  font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; text-shadow: none;
  transition: border-color .2s ease, color .2s ease, background .2s ease; }
.tdc-open svg { width: 10px; height: 10px; flex: none; fill: currentColor; }
.tdc-open:hover { color: var(--ink); border-color: var(--electric); background: rgba(21, 112, 184, .25); }
html.no-js .tdc-open { display: none; }
html.td-pick, html.td-pick main, html.td-pick .act { cursor: pointer; } /* mouse sopra l'oggetto 3D del pilastro in vista */
html.tdc-lock, html.tdc-lock body { overflow: hidden; }
.tdc-ov { position: fixed; inset: 0; z-index: 100; background: rgba(26, 26, 26, .55); display: flex; align-items: center; justify-content: center; overscroll-behavior: contain; }
.tdc-ov[hidden] { display: none; }
.tdc-box { width: 100vw; height: 100vh; height: 100dvh; background: #05080e; outline: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
@media (min-width: 900px) and (min-height: 600px) {
  .tdc-box { width: calc(100vw - 48px); height: calc(100vh - 48px); height: calc(100dvh - 48px); border-radius: 14px; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
}
@media (prefers-reduced-motion: reduce) { .tdc-open { transition: none; } }
/* apertura come igloo.inc (23/11): finché la scena non gira, fondo pulito e una barra di caratteri al centro
   (scene.js scrive data-load sul body). Se la scena non parte, il fallback td3d-static rimette la foto. */
html.td3d-gl body { background-image: none !important; background-color: var(--bg); } /* niente foto ferma: prima la barra, poi la scena */
html.td3d-gl:not(.td3d-running) body::after { content: attr(data-load); position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 50; font-family: var(--mono, monospace); font-size: 12px; letter-spacing: .18em; color: var(--ink-2, #9fb3c8); pointer-events: none; }
html.td3d-gl:not(.td3d-running) .intro .panel, html.td3d-gl:not(.td3d-running) .scroll-cue { visibility: hidden; }
html.td3d-gl #td3d-canvas { transition-duration: .25s; }
/* telefono lento (td3d-slow dopo 4 s senza scena): testo e bottone visibili subito, la barra di caricamento scende in basso */
html.td3d-slow .intro .panel, html.td3d-slow .scroll-cue { visibility: visible !important; }
html.td3d-slow:not(.td3d-running) body::after { top: auto; bottom: 24px; transform: translateX(-50%); }
