/* Il segreto della piramide — base comune alle tre viste */

@font-face { font-family: 'Cinzel'; src: url('/fonts/cinzel.woff2') format('woff2'); font-weight: 400 900; font-display: swap; }
@font-face { font-family: 'Cormorant'; src: url('/fonts/cormorant.woff2') format('woff2'); font-weight: 300 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Cormorant'; src: url('/fonts/cormorant-italic.woff2') format('woff2'); font-weight: 300 700; 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; }

:root {
  --notte: #060a1c;
  --lapis: #0c1642;
  --lapis-2: #142362;
  --lapis-3: #1e3184;
  --oro: #e9c46a;
  --oro-vivo: #f7dc90;
  --oro-scuro: #a87b2a;
  --papiro: #f2e4c0;
  --papiro-2: #e6d2a0;
  --papiro-ombra: #c9ad6f;
  --inchiostro: #2a1b0c;
  --inchiostro-2: #5a4325;
  --faience: #34d6b4;
  --ocra: #ef6c3f;
  --rubino: #c2364a;
  --testo: #f4ecd8;
  --testo-2: #c4bda9;
  --testo-3: #8f8a7c;
  --vetro: rgba(18, 30, 82, 0.55);
  --bordo: rgba(233, 196, 106, 0.22);
  --raggio: 18px;
  --ombra: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font-inciso: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --font-voce: 'Cormorant', 'Cormorant Garamond', 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(120% 90% at 50% 0%, var(--lapis-2) 0%, var(--lapis) 38%, 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; }

/* ─────────── cielo delle tombe ─────────── */
.cielo { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.cielo .stella { fill: var(--oro); opacity: var(--opac, 0.5); }
.cielo .stella.brilla { animation: brilla 5.5s ease-in-out var(--ritardo, 0s) infinite; }
@keyframes brilla { 0%, 100% { opacity: var(--opac, 0.5); } 50% { opacity: 0.08; } }
.velo { position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(80% 60% at 50% 110%, rgba(233, 196, 106, 0.10), transparent 70%),
              linear-gradient(180deg, rgba(6, 10, 28, 0) 40%, rgba(6, 10, 28, 0.75) 100%); }
.scena { position: relative; z-index: 1; }

/* ─────────── fondale vivo (WebGL), comune a telefono e LIM ─────────── */
.fondale-gl { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.gl-vivo .cielo { opacity: 0.8; 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 { letter-spacing: normal; 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 ─────────── */
/* Righe bilanciate: niente parole sole a capo nei titoli e negli occhielli. */
h1, h2, h3, .occhiello { text-wrap: balance; }
p { text-wrap: pretty; }
.inciso { font-family: var(--font-inciso); letter-spacing: 0.06em; font-weight: 700; }
.voce { font-family: var(--font-voce); font-style: italic; font-weight: 500; }
.occhiello { font-family: var(--font-inciso); font-size: 0.72rem; letter-spacing: 0.32em; text-transform: uppercase; color: var(--oro); font-weight: 700; }
.oro-testo {
  background: linear-gradient(180deg, var(--oro-vivo) 0%, var(--oro) 45%, 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));
  /* Il riempimento è trasparente: un text-shadow ereditato trasparirebbe e coprirebbe l'oro. L'alone lo dà il filtro. */
  text-shadow: none !important;
}

/* ─────────── pulsanti ─────────── */
.btn {
  --sfondo: linear-gradient(180deg, var(--oro-vivo), var(--oro) 55%, var(--oro-scuro));
  display: inline-flex; align-items: center; justify-content: center; gap: 0.55em;
  min-height: 52px; padding: 0 1.4em; border: 0; border-radius: 14px;
  background: var(--sfondo); color: var(--inchiostro);
  font-family: var(--font-inciso); font-weight: 800; letter-spacing: 0.08em; font-size: 1rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 -2px 0 rgba(0, 0, 0, 0.2) inset, 0 10px 24px rgba(233, 196, 106, 0.22);
  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.8) brightness(0.6); cursor: not-allowed; box-shadow: none; }
.btn.secondario { --sfondo: rgba(233, 196, 106, 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; }
.btn.pericolo { --sfondo: linear-gradient(180deg, #ff8a6a, var(--ocra) 60%, #b4421f); color: #1b0b05; }
.btn.verde { --sfondo: linear-gradient(180deg, #7ff0d6, var(--faience) 60%, #1a9c82); color: #02231c; }
.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; }

/* ─────────── geroglifici ─────────── */
.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; }
.glifo-tratto { height: 1.35em; }
.glifo-arco { height: 1.3em; }
.glifo-spira { height: 1.4em; }
.glifo-loto { height: 1.75em; }
.numero-egizio.in-linea { font-size: 0.86em; margin: 0 0.15em; color: var(--inchiostro); }
.numero-egizio.sequenza { gap: 0.18em; }
.dato { display: inline-flex; flex-wrap: wrap; align-items: flex-end; gap: 0.2em; max-width: 100%; }
.dato .cifre { white-space: nowrap; }
.dato .cifre { font-family: var(--font-ui); font-style: normal; font-size: 0.82em; color: var(--inchiostro-2); }

/* ─────────── emblemi ─────────── */
.emblema, .seshat { display: block; width: 100%; height: 100%; color: var(--colore-dio); }
.seshat { color: var(--oro); }
.aura { filter: drop-shadow(0 0 12px color-mix(in srgb, var(--colore-dio) 60%, transparent)); }

/* ─────────── papiro ─────────── */
.papiro {
  position: relative; color: var(--inchiostro); border-radius: 6px;
  background:
    repeating-linear-gradient(90deg, rgba(120, 90, 40, 0.06) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(0deg, rgba(120, 90, 40, 0.05) 0 1px, transparent 1px 7px),
    radial-gradient(120% 90% at 30% 20%, #fbf1d6 0%, var(--papiro) 45%, var(--papiro-2) 100%);
  box-shadow: 0 0 0 1px rgba(90, 60, 20, 0.25), inset 0 0 40px rgba(150, 110, 50, 0.25), var(--ombra);
}
.papiro::before, .papiro::after {
  content: ''; position: absolute; left: -10px; right: -10px; height: 16px; border-radius: 8px;
  background: linear-gradient(180deg, #e4cd94 0%, #b88f45 45%, #7d5a22 100%);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}
.papiro::before { top: -9px; }
.papiro::after { bottom: -9px; }

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

/* ─────────── 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(8, 14, 40, 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(239, 108, 63, 0.6); }
@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(247, 220, 144, 0.0), 0 10px 24px rgba(233, 196, 106, 0.22); } 50% { box-shadow: 0 0 0 8px rgba(247, 220, 144, 0.18), 0 10px 30px rgba(233, 196, 106, 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); } }
.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; }
}
