/* ════════════════════════════════════════════════════════════════════
   base.css — RESET, TIPOGRAFIA DI BASE, UTILITY, ACCESSIBILITÀ
   ─────────────────────────────────────────────────────────────────────
   Nessuno stile di sezione qui: solo fondamenta condivise.
   Mobile-first: i breakpoint allargano, mai restringono.
   ════════════════════════════════════════════════════════════════════ */

/* ── Reset essenziale ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  color: var(--clr-text);
  background: var(--clr-cream);
  overflow-x: hidden;
}

img, svg, video { display: block; max-width: 100%; }
img { height: auto; }

ul[role='list'], ol[role='list'] { list-style: none; }

a { color: var(--clr-accent); }
button { font: inherit; cursor: pointer; background: none; border: none; color: inherit; }

/* Le sezioni ancorate non devono finire sotto la navbar fissa */
[id] { scroll-margin-top: calc(var(--header-h) + 1rem); }

/* ── Tipografia ─────────────────────────────────────────────────── */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 550;
  line-height: var(--leading-tight);
  color: var(--clr-ink);
  text-wrap: balance;
}

h1 { font-size: var(--text-hero); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }

p { max-width: 65ch; } /* misura di lettura confortevole, ovunque */

/* Enfasi "organica" nei titoli (usata via data-i18n-html) */
h1 em, h2 em {
  font-style: italic;
  font-weight: 480;
  color: var(--clr-forest);
}

/* ── Accessibilità ──────────────────────────────────────────────── */

/* Skip link: invisibile finché non riceve focus da tastiera */
.skip-link {
  position: absolute;
  left: var(--space-sm);
  top: -100%;
  z-index: 1000;
  padding: var(--space-xs) var(--space-sm);
  background: var(--clr-ink);
  color: var(--clr-text-on-dark);
  border-radius: var(--radius-soft);
  text-decoration: none;
  transition: top var(--dur-fast);
}
.skip-link:focus { top: var(--space-sm); }

/* Focus visibile, coerente in tutto il sito */
:focus-visible {
  outline: 2px solid var(--clr-focus);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Testo solo per screen reader */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Movimento ridotto: il sito resta completo, solo senza animazioni */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Cursore custom (attivato da main.js solo su puntatori fini) ── */
/* Il puntatore nativo sparisce SOLO quando il cursore custom è
   attivo (html.has-cursor): niente JS → niente regola → mouse normale */
html.has-cursor,
html.has-cursor a,
html.has-cursor button { cursor: none; }

/* ── Utility di layout ──────────────────────────────────────────── */

/* Gabbia orizzontale standard di tutte le sezioni */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

/* Ritmo verticale tra sezioni */
.section { padding-block: var(--space-2xl); }

/* Etichetta maiuscola che apre ogni sezione (tag) — voce monospace,
   come la cartiglia di una tavola tecnica */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--clr-forest);
  margin-bottom: var(--space-sm);
}
/* Linea di quota prima del tag: ambra → blu tecnico (i colori del logo) */
.tag::before {
  content: '';
  width: 1.6rem;
  height: 2px;
  background: linear-gradient(90deg, var(--clr-amber), var(--clr-blueprint));
}
/* Numero progressivo di tavola ("/ 01", "/ 02"…), generato dal CSS:
   aggiungere una sezione aggiorna la numerazione da sola */
body { counter-reset: sec; }
.section { counter-increment: sec; }
.section .tag::after {
  content: '/ 0' counter(sec);
  opacity: 0.45;
}

/* Intestazione di sezione: tag + titolo + (opzionale) intro */
.section-head { margin-bottom: var(--space-lg); }
.section-head .intro {
  margin-top: var(--space-sm);
  font-size: var(--text-lg);
  font-weight: 300;
  color: var(--clr-text-muted);
}

/* ── Scroll reveal (attivato da main.js) ────────────────────────── */
[data-reveal] {
  opacity: 0;
  transform: translateY(22px);
  transition:
    opacity var(--dur-slow) var(--ease-organic),
    transform var(--dur-slow) var(--ease-organic);
}
[data-reveal].is-visible {
  opacity: 1;
  transform: none;
}
/* Stagger naturale per gruppi di card adiacenti */
[data-reveal].is-visible:nth-child(2) { transition-delay: 90ms; }
[data-reveal].is-visible:nth-child(3) { transition-delay: 180ms; }
[data-reveal].is-visible:nth-child(4) { transition-delay: 270ms; }
[data-reveal].is-visible:nth-child(5) { transition-delay: 360ms; }
