/* base.css — token, font, reset, livelli, nav, preloader, componenti comuni */

@font-face { font-family: 'Anton'; src: url('../assets/fonts/anton.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../assets/fonts/inter-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../assets/fonts/inter-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('../assets/fonts/mono.woff2') format('woff2'); font-display: swap; }

:root {
  --ink: #0c0c0d;          /* 60% dominante scuro */
  --ink-2: #16161a;
  --paper: #ecebe5;        /* 30% secondario */
  --muted: #8b8a86;
  --accent: #f2d21b;       /* 10% solo azioni e momenti chiave */
  --line: rgba(236, 235, 229, .14);
  --display: 'Anton', 'Impact', sans-serif;
  --text: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --pad: clamp(18px, 3vw, 40px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ink); color: var(--paper);
  font: 400 16px/1.5 var(--text);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
body:not(.is-ready) { overflow: hidden; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
ul, ol, dl, dd { margin: 0; padding: 0; list-style: none; }
.sr-only, .hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.mono { font: 400 11px/1.3 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
::selection { background: var(--accent); color: var(--ink); }

/* ── livelli: back (sotto il canvas) · canvas · front (sopra) ─────────── */
.webgl { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 1; pointer-events: none; }
.layer-back { position: absolute; z-index: 0; }
.layer-front { position: relative; z-index: 2; }
/* sticky crea sempre uno stacking context: per avere testo sotto e sopra
   il canvas nella stessa scena servono DUE elementi sticky sovrapposti */
.pin { position: sticky; top: 0; height: 100vh; height: 100svh; }
.pin--back { z-index: 0; }
.pin--front { z-index: 2; margin-top: -100vh; margin-top: -100svh; }

.line-mask { display: block; overflow: hidden; padding: .14em 0 .04em; margin-top: -.14em; }
.line { display: block; will-change: transform; }

/* ── nav ─────────────────────────────────────────────────────────────── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 18px var(--pad); transition: color .3s;
}
.nav::before {
  content: ""; position: absolute; inset: 0 0 -24px; z-index: -1; pointer-events: none;
  background: linear-gradient(to bottom, var(--ink) 35%, transparent); transition: opacity .3s;
}
body.is-light-nav .nav::before { background: linear-gradient(to bottom, var(--paper) 35%, transparent); }
.nav__logo { font: 400 26px/1 var(--display); letter-spacing: .02em; text-decoration: none; }
.nav__logo sup { font: 400 9px var(--mono); }
.nav__links { display: flex; gap: 28px; }
.nav__links a { font: 500 13px var(--text); text-decoration: none; opacity: .75; transition: opacity .2s; }
.nav__links a:hover { opacity: 1; }
.nav__right { display: flex; align-items: center; gap: 18px; }
.nav__progress { position: absolute; left: var(--pad); right: var(--pad); bottom: 0; height: 1px; background: var(--line); }
.nav__progress span { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; }
body.is-light-nav .nav { color: var(--ink); }
body.is-light-nav .nav .mono { color: #5b5a56; }

/* ── bottoni ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 52px; padding: 0 26px; border: 0; border-radius: 999px;
  background: var(--accent); color: var(--ink); cursor: pointer;
  font: 500 15px var(--text); text-decoration: none;
  transition: transform .2s ease, box-shadow .2s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 30px -10px rgba(242, 210, 27, .6); }
.btn:focus-visible, .variant:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn--small { height: 38px; padding: 0 16px; font-size: 13px; }

/* ── preloader ───────────────────────────────────────────────────────── */
.preloader {
  position: fixed; inset: 0; z-index: 50; background: var(--ink);
  display: grid; place-items: end start; padding: var(--pad); clip-path: inset(0 0 0 0);
}
.preloader__inner { display: grid; gap: 10px; width: 100%; }
.preloader__num { font: 400 clamp(90px, 22vw, 320px)/.85 var(--display); color: var(--paper); font-variant-numeric: tabular-nums; }
.preloader__track { height: 2px; background: var(--line); }
.preloader__bar { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; }

/* ── toast ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 20; translate: -50% 20px;
  padding: 14px 20px; border-radius: 12px; background: var(--paper); color: var(--ink);
  font: 500 14px var(--text); opacity: 0; pointer-events: none; transition: opacity .3s, translate .3s;
}
.toast.is-visible { opacity: 1; translate: -50% 0; }

/* fallback senza WebGL / modello: la pagina resta completa e leggibile */
.no-webgl .webgl { display: none; }

@media (max-width: 900px) {
  .nav__links { display: none; }
  .nav__right .mono { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; scroll-behavior: auto !important; }
}
