/* COMM-IT — design tokens condivisi (tema chiaro = default, scuro via toggle).
   Palette e font allineati all'app (lib/theme.ts): paper #F7F4EF, ink #1B1815,
   orange #E8622E; font logo = Special Elite (la "Olivetti Lettera 32"),
   serif = Newsreader, mono/label = Space Mono.
   NB: i font si caricano via <link> nel <head> di ogni pagina (prima di theme.css),
   non più via @import qui — l'@import era render-blocking a catena. */

:root {              /* CHIARO — default, palette app LIGHT */
  --bg:        #F7F4EF;   /* paper */
  --surface:   #FFFFFF;   /* card, topbar */
  --surface-2: #F1ECE3;   /* input, blocchi tenui (inputBg) */
  --text:      #1B1815;   /* ink */
  --text-2:    #6B6258;   /* bodyAlt */
  --muted:     #6F675C;   /* metaGray — AA su paper/surface2 (era #8A8278, 3.4:1) */
  --border:    #E7E1D8;   /* hairline */
  --orange:    #B23A0E;   /* AA in tema chiaro (era #E8622E; brand esatto pinnato sotto) */
  --on-orange: #FFFFFF;   /* testo su arancio (come l'app) */
  --topbar-bg: rgba(247,244,239,0.85);
  --hero-a:    #FFF6F1;   /* alto gradiente hero */
  --hero-b:    #F7F4EF;
  --hero-glow: rgba(232,98,46,0.10);
  --shadow:    rgba(27,24,21,0.12);
  --green:     #1F8A5B;
  --banner-bg: #FBEDE6;
  --banner-tx: #1B1815;
  --device:    #201B16;   /* cornice mockup telefono (scura in entrambi i temi) */
  --err:       #C0392B;
  --f-serif:   'Newsreader', Georgia, 'Times New Roman', serif;
  --f-mono:    'Space Mono', ui-monospace, 'Courier New', monospace;
  --f-logo:    'Special Elite', 'Courier New', monospace;
}

:root[data-theme="dark"] {   /* SCURO — tema storico del sito, conservato */
  --bg:        #0d0d0d;
  --surface:   #141414;
  --surface-2: #1a1a1a;
  --text:      #F2EFEA;
  --text-2:    #b8b8b8;
  --muted:     #8a8a8a;
  --border:    #222222;
  --orange:    #E8622E;
  --on-orange: #0d0d0d;
  --topbar-bg: rgba(13,13,13,0.85);
  --hero-a:    #1a0a00;
  --hero-b:    #0d0d0d;
  --hero-glow: rgba(232,98,46,0.12);
  --shadow:    rgba(0,0,0,0.55);
  --green:     #3DBA7E;
  --banner-bg: #1a0a00;
  --banner-tx: #ffffff;
  --device:    #000000;
  --err:       #ff8a80;
}

/* Marchio COMM·IT nel font dell'app (typewriter). */
.wordmark, .nav-logo, footer .brand { font-family: var(--f-logo); }

/* Toggle tema (sole/luna). Un solo handler in theme.js via delega eventi. */
.theme-toggle {
  background: none; border: 1px solid var(--border); color: var(--text);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1; padding: 0; transition: border-color .2s, color .2s;
}
.theme-toggle:hover { border-color: var(--orange); color: var(--orange); }
.theme-toggle .i-dark { display: none; }
.theme-toggle .i-light { display: inline; }
:root[data-theme="dark"] .theme-toggle .i-dark { display: inline; }
:root[data-theme="dark"] .theme-toggle .i-light { display: none; }

@media (prefers-reduced-motion: reduce) {
  * , *::before, *::after { transition-duration: .001ms !important; }
}

/* Waitlist email (modale home) */
.wl-wrap { margin-top: 20px; }
.wl-intro { font-family: var(--f-mono); font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.wl-form { display: flex; gap: 8px; flex-wrap: wrap; }
.wl-form input[type=email] { flex: 1; min-width: 180px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); font-family: var(--f-mono); font-size: 14px; }
.wl-form input[type=email]:focus { outline: none; border-color: var(--orange); }
.wl-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.wl-btn { padding: 12px 18px; border: none; border-radius: 10px; background: var(--orange); color: var(--on-orange); font-family: var(--f-mono); font-size: 14px; font-weight: 700; cursor: pointer; }
.wl-btn:disabled { opacity: .6; cursor: default; }
.wl-msg { font-family: var(--f-mono); font-size: 13px; margin-top: 10px; min-height: 1em; }
.wl-msg.ok { color: var(--green); }
.wl-msg.err { color: var(--err); }

/* Brand esatto: l'icona-app (quadrato arancio) e il puntino del marchio COMM·IT
   restano #E8622E anche in tema chiaro, dove --orange è scurito per contrasto AA.
   (Le CSS per-pagina caricano dopo theme.css → serve !important per vincere.) */
.icon, .modal-icon { background-color: #E8622E !important; }
.nav-logo span, .brand span, .logo span, .wordmark span { color: #E8622E !important; }

/* ══════════════════════════════════════════════════════════════════
   FX v2 — embossing (letterpress) + profondità 3D + movimento.
   Pilotato da classi messe da motion.js su <html> PRIMA del paint:
     .fx   = rilievo/emboss/tilt statici — sempre attivi
     .anim = animazioni d'ingresso/parallax — solo senza prefers-reduced-motion
   Vive qui (condiviso) → vale per tutte le lingue senza toccare gli
   <style> per-pagina; i selettori .fx/.anim (0,2,0) battono le .classe
   per-pagina (0,1,0) a prescindere dall'ordine di cascata.
   ══════════════════════════════════════════════════════════════════ */
:root{
  --emboss-hi: rgba(255,255,255,.75);
  --emboss-text: 0 1px 0 var(--emboss-hi), 0 2px 4px rgba(27,24,21,.12);
  --raise:    inset 0 1px 0 var(--emboss-hi), inset 0 -1px 0 rgba(27,24,21,.05), 0 2px 6px rgba(27,24,21,.07), 0 14px 32px rgba(27,24,21,.10);
  --raise-hi: inset 0 1px 0 var(--emboss-hi), 0 4px 10px rgba(27,24,21,.10), 0 26px 52px rgba(27,24,21,.16);
}
:root[data-theme="dark"]{
  --emboss-hi: rgba(255,255,255,.06);
  --emboss-text: 0 1px 0 rgba(255,255,255,.05), 0 2px 8px rgba(0,0,0,.6);
  --raise:    inset 0 1px 0 var(--emboss-hi), 0 2px 8px rgba(0,0,0,.45), 0 16px 34px rgba(0,0,0,.55);
  --raise-hi: inset 0 1px 0 var(--emboss-hi), 0 6px 14px rgba(0,0,0,.5), 0 28px 56px rgba(0,0,0,.7);
}

/* embossing tipografico (rilievo stampato) */
.fx h1, .fx .section-title, .fx .nav-logo, .fx footer .brand,
.fx .countries h2, .fx .modal-title, .fx .hero .tagline { text-shadow: var(--emboss-text); }

/* rilievo dei blocchi (carta pressata) */
.fx .feature-card, .fx .trust, .fx .video-wrap,
.fx .lang-count-box, .fx .modal-box, .fx .flag img { box-shadow: var(--raise); }
.fx .device { box-shadow: inset 0 1px 0 var(--emboss-hi), 0 34px 74px var(--shadow); transition: transform .2s ease; }

/* reveal on scroll → vedi blocco "FX v3.2 — reveal DIREZIONALE" in fondo al file.
   (qui restava solo il vecchio fade verticale, ora superato dalle entrate laterali) */

/* 3D tilt sulle card — transform gestito inline da motion.js (niente transform statico = niente blur) */
.fx .feature-card{ transition: opacity .6s ease, transform .16s ease, box-shadow .28s ease, border-color .2s; }
.fx .feature-card:hover{ box-shadow: var(--raise-hi); border-color:var(--orange); }

/* hero: ingresso a cascata + device 3D */
.anim .hero-copy > *{ opacity:0; translate:0 18px; animation: cxHeroIn .8s cubic-bezier(.22,.68,.24,1) forwards; }
.anim .hero-copy > *:nth-child(1){ animation-delay:.10s }
.anim .hero-copy > *:nth-child(2){ animation-delay:.18s }
.anim .hero-copy > *:nth-child(3){ animation-delay:.26s }
.anim .hero-copy > *:nth-child(4){ animation-delay:.34s }
.anim .hero-copy > *:nth-child(5){ animation-delay:.42s }
.anim .hero-copy > *:nth-child(6){ animation-delay:.50s }
.anim .hero-copy > *:nth-child(7){ animation-delay:.58s }
.anim .hero-device{ opacity:0; animation: cxDevIn 1s .42s cubic-bezier(.22,.68,.24,1) forwards; }
@keyframes cxHeroIn { to { opacity:1; translate:0 0; } }
@keyframes cxDevIn { from{opacity:0; transform:translateY(26px) rotateY(-7deg) scale(.98);} to{opacity:1; transform:none;} }

/* parallax hero: motion.js aggiorna --pglow */
.fx .hero::before{ transform:translateX(-50%) translateY(var(--pglow,0)); }

/* embers canvas dietro l'hero (il contenuto .hero-inner ha già z-index:1) */
.cx-embers{ position:absolute; inset:0; z-index:0; pointer-events:none; }

/* ── SPLASH sci-fi (iniettato da motion.js, una volta a sessione; ?intro per rivederlo) ── */
#cx-splash{ position:fixed; inset:0; z-index:3000; display:grid; place-items:center; overflow:hidden;
  background:radial-gradient(ellipse at 50% 38%, var(--hero-a) 0%, var(--bg) 60%);
  transition:opacity .6s ease, translate .6s cubic-bezier(.6,0,.2,1); }
#cx-splash.cx-off{ opacity:0; translate:0 -24px; pointer-events:none; }
#cx-splash::after{ content:''; position:absolute; inset:0; pointer-events:none; box-shadow:inset 0 0 220px rgba(27,24,21,.28); }
:root[data-theme="dark"] #cx-splash::after{ box-shadow:inset 0 0 240px rgba(0,0,0,.75); }
.cx-grid{ position:absolute; inset:-2px; opacity:0; pointer-events:none;
  background:repeating-linear-gradient(90deg, transparent 0 46px, rgba(232,98,46,.10) 46px 47px),
             repeating-linear-gradient(0deg,  transparent 0 46px, rgba(232,98,46,.08) 46px 47px);
  -webkit-mask:radial-gradient(ellipse at 50% 40%, #000 10%, transparent 72%);
          mask:radial-gradient(ellipse at 50% 40%, #000 10%, transparent 72%);
  animation:cxGrid 1.6s ease forwards, cxDrift 9s linear infinite; }
@keyframes cxGrid { from{opacity:0} to{opacity:1} }
@keyframes cxDrift { to { background-position:47px 47px, 47px 47px; } }
.cx-scan{ position:absolute; left:0; right:0; height:2px; top:0; pointer-events:none;
  background:linear-gradient(90deg, transparent, var(--orange), transparent);
  box-shadow:0 0 22px 6px rgba(232,98,46,.5); opacity:0; animation:cxScan 1.1s .2s ease-out forwards; }
@keyframes cxScan { 0%{opacity:0; top:0} 8%{opacity:1} 92%{opacity:1} 100%{opacity:0; top:100%} }
.cx-core{ position:relative; text-align:center; perspective:900px; }
.cx-word{ font-family:var(--f-logo); color:var(--text); line-height:1;
  font-size:clamp(52px,12vw,132px); letter-spacing:2px; transform-origin:50% 100%; opacity:0;
  text-shadow:0 1px 0 var(--emboss-hi), 0 3px 10px rgba(27,24,21,.28);
  animation:cxWord .8s .25s cubic-bezier(.2,.7,.2,1) forwards, cxGlitch .5s .28s steps(2) 2; }
.cx-word span{ color:var(--orange); }
@keyframes cxWord { from{opacity:0; transform:rotateX(24deg) translateY(18px); letter-spacing:14px;}
                    to{opacity:1; transform:rotateX(0) translateY(0); letter-spacing:2px;} }
@keyframes cxGlitch { 0%,100%{text-shadow:0 1px 0 var(--emboss-hi), 0 3px 10px rgba(27,24,21,.28);}
  50%{text-shadow:-2px 0 0 rgba(232,98,46,.9), 2px 0 0 rgba(64,180,200,.7), 0 3px 10px rgba(27,24,21,.28);} }
.cx-rule{ height:3px; width:0; margin:22px auto 0; background:var(--orange);
  box-shadow:0 0 16px rgba(232,98,46,.6); animation:cxRule .6s .95s cubic-bezier(.2,.7,.2,1) forwards; }
@keyframes cxRule { to { width:min(210px,52vw); } }
.cx-tag{ margin-top:16px; font-family:var(--f-mono); font-size:12px; letter-spacing:6px;
  text-transform:uppercase; color:var(--muted); opacity:0; animation:cxTag .6s 1.25s ease forwards; }
@keyframes cxTag { to { opacity:1; } }
.cx-flash{ position:absolute; inset:0; pointer-events:none; opacity:0;
  background:radial-gradient(circle at 50% 45%, rgba(255,255,255,.95), rgba(232,98,46,.5) 30%, transparent 62%);
  animation:cxFlash .55s 1.75s ease-out forwards; }
@keyframes cxFlash { 0%{opacity:0; transform:scale(.6)} 35%{opacity:.95} 100%{opacity:0; transform:scale(1.5)} }
.cx-skip{ position:absolute; top:18px; right:18px; width:34px; height:34px; border-radius:8px;
  background:none; border:1px solid var(--border); color:var(--muted); cursor:pointer; font-size:15px;
  display:flex; align-items:center; justify-content:center; }
.cx-skip:hover{ border-color:var(--orange); color:var(--orange); }
@media (prefers-reduced-motion: reduce){ #cx-splash{ display:none !important; } }

/* grana da pellicola — overlay condiviso sotto la topnav (marries la texture carta) */
.cx-grain{ position:fixed; inset:0; z-index:400; pointer-events:none; opacity:.05; mix-blend-mode:multiply;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>"); }
:root[data-theme="dark"] .cx-grain{ mix-blend-mode:screen; opacity:.06; }

/* dateline live nella topnav */
.cx-clock{ font-family:var(--f-mono); font-size:12px; color:var(--muted); letter-spacing:.5px;
  font-variant-numeric:tabular-nums; white-space:nowrap; }
@media (max-width:640px){ .cx-clock{ display:none; } }

/* ── incisione a secco: wordmark COMM·IT in rilievo profondo (letterpress) ── */
:root{ --emboss-deep: 0 1px 0 rgba(255,255,255,.9), 0 2px 1px rgba(255,255,255,.5), 0 -1px 1px rgba(27,24,21,.18), 0 4px 9px rgba(27,24,21,.24); }
:root[data-theme="dark"]{ --emboss-deep: 0 1px 0 rgba(255,255,255,.08), 0 -1px 2px rgba(0,0,0,.6), 0 6px 16px rgba(0,0,0,.72); }
.fx h1, .fx footer .brand, .fx .modal-title{ text-shadow: var(--emboss-deep); }

/* screenshot: leggera rotazione "sparsa" con profondità (raddrizzano all'hover) */
/* niente scatter permanente: gli shot si posano DRITTI (stabilità dopo l'entrata) */
.fx .shots-row .shot{ transition: transform .3s ease; }
.fx .shots-row .shot:hover{ transform: translateY(-5px); }

/* firma studio: mark ECSoft inciso a secco (tone-on-tone → si fonde sulla carta) */
.ec-mark{ height:34px; width:auto; vertical-align:-11px; margin-right:2px; mix-blend-mode:multiply; }
:root[data-theme="dark"] .ec-mark{ mix-blend-mode:screen; opacity:.55; }

/* ══════════════════════════════════════════════════════════════════════
   FX v3 — BRIO · passaggi a finestra (View Transitions) + reveal AUDACE
   (implosioni/esplosioni). Il reveal è pilotato da `.in` (IntersectionObserver
   in motion.js) con TRANSIZIONI su proprietà INDIPENDENTI (translate/scale/
   rotate/filter): universale (niente feature sperimentali), compone col tilt
   3D (transform) e con lo scatter statico degli shot. 0 dipendenze.
   ══════════════════════════════════════════════════════════════════════ */

/* ── passaggi a finestra: transizioni tra pagine (MPA same-origin, Chrome) ── */
/* @view-transition { navigation: auto; }  — FX "in prova": disattivata in produzione, attiva solo in SITO_preview */
.fx .nav-logo { view-transition-name: cx-logo; } /* wordmark ancorata tra le pagine */
/* foglio di giornale che scorre: la pagina nuova entra da destra e si posa
   sopra la vecchia, che arretra leggermente e sbiadisce */
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) { animation: cx-sheet-out .5s  cubic-bezier(.6,0,.2,1)  both; transform-origin:left center; z-index:1; }
  ::view-transition-new(root) { animation: cx-sheet-in  .64s cubic-bezier(.16,.84,.3,1) both; transform-origin:right center; z-index:2; }
  @keyframes cx-sheet-out {
    to { transform: translateX(-8%) rotate(-.5deg); opacity:.25; filter: blur(3px) contrast(.92); }
  }
  @keyframes cx-sheet-in {
    from { transform: translateX(100%) rotate(1deg); filter: brightness(1.04); }
    to   { transform: translateX(0) rotate(0); filter: none; }
  }
}

/* ── barra di avanzamento scroll (larghezza aggiornata da motion.js) ── */
.cx-progress { position:fixed; top:0; left:0; height:3px; width:100%;
  background:linear-gradient(90deg, var(--orange), #ff9a5c);
  transform-origin:0 50%; transform:scaleX(0); z-index:500; pointer-events:none; }

/* ══════════ FX v3.2 — reveal DIREZIONALE (entrate da destra/sinistra) ══════════
   motion.js aggiunge `.in` quando l'elemento entra nel viewport (e lo toglie quando
   esce → l'entrata si RIGIOCA a ogni passaggio). Ogni tipo entra dal suo lato,
   alternato con :nth-child. Le proprietà translate/scale/rotate sono indipendenti
   da `transform`, così compongono col tilt 3D di motion.js invece di spegnerlo. */
@media (prefers-reduced-motion: no-preference) {
  /* contieni le entrate laterali: niente scrollbar orizzontale mentre volano dentro */
  .anim .features, .anim .shots, .anim .countries,
  .anim .trust, .anim .video-section { overflow-x: clip; }

  /* ── STATO NASCOSTO (fuori campo, in attesa di .in) ── */
  .anim .video-section .section-title, .anim .shots .section-title,
  .anim .features .section-title, .anim .countries h2, .anim .trust .section-title {
    opacity:0; translate:0 20px; scale:1.35; filter:blur(18px); }        /* titoli: implodono a fuoco */

  .anim .video-section .section-sub, .anim .shots .section-sub,
  .anim .features .section-sub, .anim .countries p, .anim .trust .section-sub {
    opacity:0; translate:0 30px; }                                       /* sottotitoli: salgono */

  .anim .video-wrap, .anim .ask-btn { opacity:0; translate:0 48px; scale:.9; }

  /* card / trust / figure entrano ALTERNATE dai due lati (solo scorrimento, niente rotazione) */
  .anim .feature-card, .anim .trust-item, .anim .shot { opacity:0; }
  .anim .feature-card:nth-child(odd),  .anim .trust-item:nth-child(odd)  { translate:-115% 0; scale:.92; }
  .anim .feature-card:nth-child(even), .anim .trust-item:nth-child(even) { translate: 115% 0; scale:.92; }
  .anim .shot:nth-child(odd)  { translate:-125% 0; scale:.72; }
  .anim .shot:nth-child(even) { translate: 125% 0; scale:.72; }

  /* bandiere "try it": entrano alternate destra/sinistra, si posano dritte */
  .anim .flag-item { opacity:0; }
  .anim .flag-item:nth-child(odd)  { translate:-165% 0; }
  .anim .flag-item:nth-child(even) { translate: 165% 0; }

  /* ── .in FA PARTIRE l'animazione giusta (fill:both la tiene a fine corsa) ── */
  .anim .video-section .section-title.in, .anim .shots .section-title.in,
  .anim .features .section-title.in, .anim .countries h2.in, .anim .trust .section-title.in {
    animation: cxTitleIn 1s cubic-bezier(.2,.7,.2,1) both; }
  .anim .video-section .section-sub.in, .anim .shots .section-sub.in,
  .anim .features .section-sub.in, .anim .countries p.in, .anim .trust .section-sub.in {
    animation: cxSubIn .9s cubic-bezier(.2,.7,.2,1) both; }
  .anim .video-wrap.in, .anim .ask-btn.in { animation: cxPopUp .95s cubic-bezier(.34,1.5,.4,1) both; }

  /* card/trust: scorrono dentro dal lato e si posano DRITTE (niente rotazione) */
  .anim .feature-card:nth-child(odd).in,  .anim .trust-item:nth-child(odd).in  { animation: cxSettleLeft  1.25s cubic-bezier(.22,.72,.24,1) both; }
  .anim .feature-card:nth-child(even).in, .anim .trust-item:nth-child(even).in { animation: cxSettleRight 1.25s cubic-bezier(.22,.72,.24,1) both; }
  .anim .shot:nth-child(odd).in  { animation: cxSwoopLeft  1.3s cubic-bezier(.22,.72,.24,1) both; }
  .anim .shot:nth-child(even).in { animation: cxSwoopRight 1.3s cubic-bezier(.22,.72,.24,1) both; }
  .anim .flag-item:nth-child(odd).in  { animation: cxDanceLeft  1.35s cubic-bezier(.24,.68,.3,1) both; }
  .anim .flag-item:nth-child(even).in { animation: cxDanceRight 1.35s cubic-bezier(.24,.68,.3,1) both; }
}

@keyframes cxTitleIn { from{opacity:0; translate:0 20px; scale:1.35; filter:blur(18px);} 60%{opacity:1; filter:blur(0);} to{opacity:1; translate:0 0; scale:1; filter:none;} }
@keyframes cxSubIn   { from{opacity:0; translate:0 30px;} to{opacity:1; translate:0 0;} }
@keyframes cxPopUp   { from{opacity:0; translate:0 48px; scale:.9;} to{opacity:1; translate:0 0; scale:1;} }
/* scorrono dentro dal lato e si posano DRITTE — nessuna rotazione, mai storto */
@keyframes cxSettleLeft {
  0%  {opacity:0; translate:-115% 0; scale:.92;}
  100%{opacity:1; translate:0 0; scale:1;} }
@keyframes cxSettleRight {
  0%  {opacity:0; translate:115% 0; scale:.92;}
  100%{opacity:1; translate:0 0; scale:1;} }
@keyframes cxSwoopLeft {
  0%  {opacity:0; translate:-125% 0; scale:.72;}
  100%{opacity:1; translate:0 0; scale:1;} }
@keyframes cxSwoopRight {
  0%  {opacity:0; translate:125% 0; scale:.72;}
  100%{opacity:1; translate:0 0; scale:1;} }
@keyframes cxDanceLeft {
  0%{opacity:0; translate:-165% 0;} 100%{opacity:1; translate:0 0;} }
@keyframes cxDanceRight {
  0%{opacity:0; translate:165% 0;} 100%{opacity:1; translate:0 0;} }

/* hero device: implosione d'ingresso — ridefinisce cxDevIn v2, più audace */
@keyframes cxDevIn {
  from { opacity:0; transform: translateY(42px) rotateY(-11deg) scale(1.12); filter: blur(7px); }
  60%  { opacity:1; filter: blur(0); }
  to   { opacity:1; transform: none; }
}
