/* ═══════════════════════════════════════════════════════════════════
   BASE — reset, typographie, couches globales, défilement virtuel
   ═══════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: auto;              /* le défilement est piloté en JS */
  background: var(--ink-900);
}

body {
  min-height: 100vh;
  /* Visible uniquement si le canvas d'encre ne tourne pas (pas de WebGL2, ou
     mouvement réduit) : la page reste habitée au lieu d'être un aplat noir. */
  background:
    radial-gradient(70% 55% at 85% 0%, color-mix(in srgb, var(--accent) 22%, transparent) 0%, transparent 70%),
    radial-gradient(60% 50% at 8% 100%, color-mix(in srgb, var(--accent-2) 12%, transparent) 0%, transparent 70%),
    radial-gradient(120% 100% at 72% 18%,
      var(--ink-600) 0%, var(--ink-800) 45%, var(--ink-900) 100%);
  background-attachment: fixed;
  color: var(--paper);
  font-family: var(--font-sans);
  font-size: var(--t-body);
  font-weight: 300;
  line-height: 1.6;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Le contenu est translaté en JS ; ce bloc vide restitue la hauteur au document
   pour que la barre de défilement native reste exacte. */
.scroll {
  position: fixed;
  inset: 0 0 auto 0;
  width: 100%;
  z-index: var(--z-content);
  will-change: transform;
}
.scroll__height { width: 1px; pointer-events: none; }

/* Sans JS : on rend la main au défilement natif. */
.no-js .scroll { position: static; }
.no-js .scroll__height { display: none; }
.no-js .loader { display: none; }

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

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; }
ul, ol, dl { list-style: none; }

::selection { background: var(--shu); color: var(--paper-warm); }

/* Barre de défilement native (le défilement virtuel la conserve) */
html { scrollbar-width: thin; scrollbar-color: var(--ink-500) var(--ink-900); }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--ink-900); }
::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--accent), var(--accent-2));
  border: 2px solid var(--ink-900);
  border-radius: 10px;
}

/* ── Typographie ────────────────────────────────────────── */

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: var(--track-tight);
  text-wrap: balance;
}

em { font-style: italic; color: var(--accent); }

.mono {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  font-weight: 400;
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
}

.jp { font-family: var(--font-display); letter-spacing: 0.1em; }
.jp-inline {
  font-family: var(--font-display);
  color: var(--accent);
  letter-spacing: 0.08em;
  padding-inline: 0.15em;
}

/* Chapeau de section : « 01 — Description » */
.rubric {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
  color: var(--fg-dim);
}
.rubric::before {
  content: "";
  width: clamp(1.5rem, 3vw, 3.5rem);
  height: 1px;
  background: var(--accent);
}

/* ── Couches plein écran ────────────────────────────────── */

.layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
.layer--ink { z-index: var(--z-ink); width: 100%; height: 100%; }

/* Grain argentique — animé par pas de 1 frame sur 3 (voir keyframes) */
.layer--grain {
  z-index: var(--z-grain);
  opacity: 0.04;   /* pas de mix-blend-mode : un mélange plein écran coûte cher à chaque frame */
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.6s steps(3) infinite;
}
@keyframes grain {
  0%   { transform: translate3d(0, 0, 0); }
  33%  { transform: translate3d(-2%, 1%, 0); }
  66%  { transform: translate3d(1%, -2%, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

.layer--vignette {
  z-index: var(--z-grain);
  background:
    linear-gradient(to bottom, rgba(0,0,0,0.22) 0%, transparent 9%, transparent 92%, rgba(0,0,0,0.26) 100%),
    radial-gradient(125% 95% at 50% 45%, transparent 52%, rgba(0,0,0,0.62) 100%);
}

/* Progression de lecture : un fil de lumière en haut de l'écran. */
.progress {
  position: fixed;
  top: 0; left: 0;
  z-index: var(--z-progress);
  width: 100%;
  height: 2px;
  background: transparent;
  pointer-events: none;
}
.progress i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--grad-accent);
  box-shadow: 0 0 14px var(--glow), 0 0 4px var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
  will-change: transform;
}

/* ── Utilitaires ────────────────────────────────────────── */

.grad-text {
  background: var(--grad-accent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Surface en verre. Le reflet qui suit le pointeur (--gx / --gy) est posé par
   scripts/fx.js sur tout élément portant [data-glow]. */
[data-glow] { position: relative; }
[data-glow]::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(
    420px circle at var(--gx, 50%) var(--gy, 0%),
    color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%);
  opacity: var(--gon, 0);
  transition: opacity 0.5s var(--ease-out);
}

/* Jeu d'icônes : présent dans le DOM pour <use>, jamais rendu. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ── Découpe typographique (scripts/text.js) ────────────────
   `.m` = masque, `.w` = unité mobile. Le padding/margin compensé évite que
   le masque ne rogne les jambages (g, p, y) et les italiques. */

.m {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  padding-bottom: 0.16em;
  margin-bottom: -0.16em;
  padding-right: 0.05em;
  margin-right: -0.05em;
}
.w {
  display: inline-block;
  will-change: transform;
}

.js .is-split .w {
  transform: translate3d(0, 115%, 0);
  transition: transform 1.05s var(--ease-out);
}
.js .is-split.is-in .w { transform: translate3d(0, 0, 0); }

/* ── États de révélation ────────────────────────────────────
   Les découpes gèrent leur propre masque : leur conteneur reste opaque. */

.js [data-reveal="chars"],
.js [data-reveal="lines"] { opacity: 1; }

.js [data-reveal="fade"] {
  opacity: 0;
  transform: translate3d(0, 1.6rem, 0);
  transition: opacity 1s var(--ease-out), transform 1.2s var(--ease-out);
  transition-delay: var(--d, 0s);
}
.js [data-reveal="fade"].is-in {
  opacity: 1;
  transform: none;
}

.js [data-reveal="row"] {
  opacity: 0;
  transform: translate3d(0, 0.9rem, 0);
  transition: opacity 0.9s var(--ease-out), transform 1s var(--ease-out);
  transition-delay: var(--d, 0s);
}
.js [data-reveal="row"].is-in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .js [data-reveal] { opacity: 1 !important; transform: none !important; }
  .layer--grain { animation: none; }
  .scroll { position: static !important; transform: none !important; }
  .scroll__height { display: none; }
}
