/* Il Segreto dell'Opus Magnum — base comune alle tre viste.
   Torre alchemica di notte: pietra scura, pergamena, oro antico, rame, luce di candela, vetro delle ampolle;
   accenti verde-vetriolo e blu-solfato. I nomi delle variabili vengono dal motore (piramide, segnale):
   «oro» è l'oro antico, «lapis» la pietra della Torre, «papiro» la pergamena, «faience» il verde vetriolo,
   «ciano» il blu solfato, «ocra» il rame. */

@font-face { font-family: 'Spectral'; src: url('/fonts/spectral.woff2') format('woff2'); font-weight: 300 800; font-style: normal; font-display: swap; }
@font-face { font-family: 'Spectral'; src: url('/fonts/spectral-italic.woff2') format('woff2'); font-weight: 300 800; font-style: italic; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Share Tech Mono'; src: url('/fonts/sharetech.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
  --notte: #090705;
  --lapis: #15110d;
  --lapis-2: #1f1913;
  --lapis-3: #2d241b;
  --pietra: #3a3027;
  --oro: #d9a441;
  --oro-vivo: #f4d389;
  --oro-scuro: #8c6224;
  --rame: #c8733f;
  --candela: #ffbf6b;
  --papiro: #efe1c0;
  --papiro-2: #dcc796;
  --papiro-ombra: #b39866;
  --inchiostro: #2a190c;
  --inchiostro-2: #5c4128;
  --faience: #9bd665;          /* verde vetriolo */
  --vetriolo: #9bd665;
  --ciano: #5cb3ec;            /* blu solfato */
  --solfato: #5cb3ec;
  --ocra: #d9794a;             /* rame acceso */
  --rubino: #d6464f;           /* cinabro */
  --testo: #f2e8d4;
  --testo-2: #c7b697;
  --testo-3: #8d7d64;
  --vetro: rgba(30, 23, 17, 0.72);
  --bordo: rgba(217, 164, 65, 0.26);
  --raggio: 14px;
  --ombra: 0 18px 50px rgba(0, 0, 0, 0.6);
  --font-inciso: 'Spectral', 'Iowan Old Style', Georgia, serif;
  --font-voce: 'Spectral', 'Iowan Old Style', Georgia, serif;
  --font-radio: 'Spectral', 'Iowan Old Style', Georgia, serif;
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --colore-dio: var(--oro);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { background: var(--notte); }
body {
  font-family: var(--font-ui);
  color: var(--testo);
  background:
    radial-gradient(70% 45% at 50% 108%, rgba(255, 150, 60, 0.20) 0%, transparent 70%),
    radial-gradient(50% 40% at 12% 0%, rgba(92, 179, 236, 0.07) 0%, transparent 70%),
    radial-gradient(45% 35% at 92% 8%, rgba(155, 214, 101, 0.05) 0%, transparent 70%),
    radial-gradient(130% 90% at 50% 20%, var(--lapis-2) 0%, var(--lapis) 45%, var(--notte) 100%) fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.intero { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ─────────── polvere d'oro nell'aria (fondale in SVG, senza WebGL) ─────────── */
.cielo { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.cielo .stella { fill: var(--candela); opacity: var(--opac, 0.5); }
.cielo .stella.brilla { animation: brilla 5.5s ease-in-out var(--ritardo, 0s) infinite; }
.cielo .scia { display: none; }
@keyframes brilla { 0%, 100% { opacity: var(--opac, 0.5); } 50% { opacity: 0.06; } }
.velo { position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(80% 55% at 50% 112%, rgba(255, 170, 80, 0.12), transparent 70%),
              linear-gradient(180deg, rgba(9, 7, 5, 0) 40%, rgba(9, 7, 5, 0.7) 100%); }
.scena { position: relative; z-index: 1; }

/* ─────────── fondale vivo (WebGL) ─────────── */
.fondale-gl { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.gl-vivo .cielo { opacity: 0.7; mix-blend-mode: screen; }
/* Il titolo si incide nella pietra: le lettere si avvicinano mentre la luce le trova. */
@keyframes titolo-incide { from { opacity: 0; letter-spacing: 0.28em; filter: blur(8px); transform: translateY(8px); } 60% { opacity: 1; } to { filter: blur(0); transform: none; } }
@keyframes discende { from { opacity: 0; transform: translateY(-26px) scale(0.85); filter: blur(6px); } }
@media (prefers-reduced-motion: reduce) { .fondale-gl { display: none; } }

/* ─────────── tipografia ─────────── */
h1, h2, h3, .occhiello { text-wrap: balance; }
p { text-wrap: pretty; }
.inciso { font-family: var(--font-inciso); letter-spacing: 0.05em; font-weight: 700; font-variant-caps: small-caps; }
.voce { font-family: var(--font-voce); font-style: italic; font-weight: 500; }
.occhiello { font-family: var(--font-inciso); font-size: 0.78rem; letter-spacing: 0.26em; text-transform: uppercase; color: var(--oro); font-weight: 600; }
.oro-testo {
  background: linear-gradient(180deg, #fff0c2 0%, var(--oro-vivo) 30%, var(--oro) 62%, var(--oro-scuro) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 4px var(--notte)) drop-shadow(0 0 10px var(--notte));
  text-shadow: none !important;
}

/* ─────────── pulsanti: foglia d'oro su pietra ─────────── */
.btn {
  --sfondo: linear-gradient(180deg, #ffe7a8 0%, var(--oro-vivo) 18%, var(--oro) 58%, var(--oro-scuro) 100%);
  display: inline-flex; align-items: center; justify-content: center; gap: 0.55em;
  min-height: 52px; padding: 0 1.4em; border: 0; border-radius: 12px;
  background: var(--sfondo); color: var(--inchiostro);
  font-family: var(--font-inciso); font-weight: 700; letter-spacing: 0.05em; font-size: 1.05rem; font-variant-caps: small-caps;
  box-shadow: 0 1px 0 rgba(255, 248, 220, 0.6) inset, 0 -2px 0 rgba(60, 30, 0, 0.3) inset, 0 0 0 1px rgba(90, 55, 15, 0.55), 0 10px 24px rgba(217, 164, 65, 0.2);
  transition: transform 0.12s ease, filter 0.2s ease, box-shadow 0.2s ease;
  user-select: none; touch-action: manipulation; text-decoration: none;
}
.btn:active { transform: translateY(1px) scale(0.985); }
.btn:disabled { filter: grayscale(0.85) brightness(0.55); cursor: not-allowed; box-shadow: none; }
.btn.secondario { --sfondo: rgba(217, 164, 65, 0.08); color: var(--oro-vivo); box-shadow: inset 0 0 0 1.5px var(--bordo); }
.btn.fantasma { --sfondo: transparent; color: var(--testo-2); box-shadow: none; font-family: var(--font-ui); font-weight: 600; letter-spacing: 0; font-variant-caps: normal; }
.btn.pericolo { --sfondo: linear-gradient(180deg, #f2a27a, var(--ocra) 55%, #8a3b1c); color: #1f0b03; }
.btn.verde { --sfondo: linear-gradient(180deg, #d2f2a6, var(--faience) 55%, #4f8a2c); color: #102304; }
.btn.largo { width: 100%; }
.btn .glifo { height: 1.3em; width: auto; }
:focus-visible { outline: 3px solid var(--oro-vivo); outline-offset: 3px; border-radius: 10px; }

/* ─────────── glifi ─────────── */
.numero-egizio { display: inline-flex; align-items: flex-end; gap: 0.32em; vertical-align: middle; line-height: 1; }
.numero-egizio .gruppo { display: inline-grid; grid-template-columns: repeat(var(--col, 1), auto); gap: 0.1em 0.12em; align-items: end; justify-items: center; }
.glifo { display: block; height: 1.6em; width: auto; color: currentColor; overflow: visible; }
.dato { display: inline-flex; flex-wrap: wrap; align-items: flex-end; gap: 0.2em; max-width: 100%; }
.dato .cifre { white-space: nowrap; font-family: var(--font-ui); font-style: normal; font-size: 0.82em; color: var(--inchiostro-2); }

/* ─────────── emblemi: tessere della tavola periodica ─────────── */
.emblema, .seshat { display: block; width: 100%; height: 100%; color: var(--colore-dio); }
.seshat { color: var(--oro); }
.emblema.tessera { overflow: visible; }
.emblema .t-fondo { fill: var(--lapis); }
.emblema .t-tinta { fill: currentColor; opacity: 0.16; }
.emblema .t-bordo { fill: none; stroke: currentColor; stroke-width: 2.6; }
.emblema .t-filo { fill: none; stroke: currentColor; stroke-width: 0.8; opacity: 0.45; }
.emblema .t-simbolo { fill: currentColor; font-family: var(--font-inciso); font-weight: 700; letter-spacing: -0.02em; }
.emblema .t-z { fill: currentColor; font-family: var(--font-inciso); font-weight: 600; opacity: 0.9; }
.aura { filter: drop-shadow(0 0 12px color-mix(in srgb, var(--colore-dio) 60%, transparent)); }

/* ─────────── pergamena ─────────── */
.papiro {
  position: relative; color: var(--inchiostro); border-radius: 4px;
  background:
    radial-gradient(60% 40% at 85% 90%, rgba(120, 70, 20, 0.12), transparent 70%),
    radial-gradient(50% 30% at 10% 15%, rgba(120, 70, 20, 0.10), transparent 70%),
    repeating-linear-gradient(0deg, rgba(110, 75, 30, 0.035) 0 1px, transparent 1px 6px),
    radial-gradient(120% 90% at 35% 25%, #fbf1d8 0%, var(--papiro) 45%, var(--papiro-2) 100%);
  box-shadow: 0 0 0 1px rgba(90, 60, 20, 0.3), inset 0 0 46px rgba(140, 95, 40, 0.32), var(--ombra);
}
.papiro::before, .papiro::after {
  content: ''; position: absolute; left: -10px; right: -10px; height: 15px; border-radius: 8px;
  background: linear-gradient(180deg, #7a4a24 0%, #4a2a12 50%, #2a170a 100%);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 210, 150, 0.25);
}
.papiro::before { top: -8px; }
.papiro::after { bottom: -8px; }

/* ─────────── vetro e schede ─────────── */
.vetro { background: var(--vetro); border: 1px solid var(--bordo); border-radius: var(--raggio); backdrop-filter: blur(14px) saturate(1.15); -webkit-backdrop-filter: blur(14px) saturate(1.15); }

/* ─────────── avvisi ─────────── */
.avvisi { position: fixed; left: 50%; top: max(14px, env(safe-area-inset-top)); transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; width: min(92vw, 520px); pointer-events: none; }
.avviso { pointer-events: auto; padding: 12px 16px; border-radius: 14px; background: rgba(26, 20, 14, 0.97); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--bordo); box-shadow: var(--ombra); animation: entra-alto 0.35s cubic-bezier(.2,.9,.3,1.2); font-size: 0.95rem; }
.avviso.errore { border-color: rgba(217, 121, 74, 0.65); }
@keyframes entra-alto { from { opacity: 0; transform: translateY(-14px) scale(0.98); } }

/* ─────────── animazioni ─────────── */
@keyframes trema { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); } }
@keyframes posa { 0% { transform: translateY(-14px) scale(0.6); opacity: 0; } 60% { transform: translateY(2px) scale(1.08); opacity: 1; } 100% { transform: none; } }
@keyframes respira { 0%, 100% { transform: scale(1); opacity: 0.9; } 50% { transform: scale(1.06); opacity: 1; } }
@keyframes bagliore { 0%, 100% { box-shadow: 0 0 0 0 rgba(244, 211, 137, 0), 0 10px 24px rgba(217, 164, 65, 0.22); } 50% { box-shadow: 0 0 0 8px rgba(244, 211, 137, 0.16), 0 10px 30px rgba(217, 164, 65, 0.45); } }
@keyframes appare { from { opacity: 0; transform: translateY(10px); } }
@keyframes ruota { to { transform: rotate(360deg); } }
@keyframes ruota-centro { from { transform: translate(-50%, -50%) rotate(0deg); } to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes fiamma { 0%, 100% { opacity: 0.85; } 25% { opacity: 1; } 50% { opacity: 0.72; } 75% { opacity: 0.95; } }
.trema { animation: trema 0.5s cubic-bezier(.36,.07,.19,.97) both; }
.appare { animation: appare 0.5s ease both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .cielo .stella.brilla { animation: none; }
}
