/* =====================================================================
   Kit Web3D — feuille de style (aucun framework : ~6 Ko compressés).
   Jetons de design en variables CSS · fond neutre + un seul accent ·
   deux voix typographiques (Jost = fonction, Cormorant italique = voix).
   Contrastes calculés (WCAG AA) : texte #efe6dc sur #0f0d0c = 15,7:1 ;
   texte secondaire #b9ab9c = 8,6:1 ; accent #d0834f = 6,5:1 (6,1:1 sur la surface).
   ===================================================================== */
@font-face {
  font-family: "Jost";
  src: url("../fonts/jost-400-500.woff2") format("woff2");
  font-weight: 400 500; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("../fonts/cormorant-italique-500.woff2") format("woff2");
  font-weight: 500; font-style: italic; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF;
}

:root {
  --fond: #0f0d0c;
  --fond-rgb: 15, 13, 12;
  --surface: #191513;
  --texte: #efe6dc;
  --texte-2: #b9ab9c;
  --accent: #d0834f;
  --ligne: rgba(239, 230, 220, 0.14);
  --courbe: cubic-bezier(0.16, 1, 0.3, 1);     /* même courbe que « signature » côté GSAP */
  --duree: 0.4s;
  --entete: 64px;
  --marge: clamp(20px, 5vw, 72px);
  --rayon: 14px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }   /* sinon `.btn { display: inline-flex }` fait réapparaître un bouton caché */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: var(--entete); }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 400 1rem/1.6 "Jost", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-synthesis: none; -webkit-font-smoothing: antialiased;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.evitement { position: absolute; left: 12px; top: -60px; z-index: 50; padding: 10px 16px; background: var(--texte); color: var(--fond); border-radius: 8px; }
.evitement:focus { top: 12px; }

/* ---------- Typographie ---------- */
h1, h2, h3 { font-weight: 500; line-height: 1.06; letter-spacing: -0.02em; margin: 0 0 0.4em; text-wrap: balance; }
h1 { font-size: clamp(2.6rem, 8.4vw, 6.4rem); }
h2 { font-size: clamp(1.9rem, 5vw, 3.4rem); }
em { font-family: "Cormorant Garamond", Georgia, serif; font-style: italic; font-weight: 500; color: var(--accent); letter-spacing: 0; font-size: 1.08em; }
p { margin: 0 0 1em; max-width: 60ch; text-wrap: pretty; }
code { font: 0.88em/1 ui-monospace, "SFMono-Regular", Menlo, monospace; padding: 0.15em 0.4em; border-radius: 5px; background: rgba(239, 230, 220, 0.08); color: var(--texte); }
.etiquette { font-size: 0.78rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--texte-2); }
.chapo { font-size: clamp(1.05rem, 1.6vw, 1.25rem); color: var(--texte-2); }

/* ---------- En-tête ---------- */
.entete {
  position: fixed; inset: 0 0 auto; z-index: 30; height: var(--entete);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 var(--marge);
  background: linear-gradient(rgba(var(--fond-rgb), 0.9), rgba(var(--fond-rgb), 0));
  view-transition-name: entete;
}
.marque { font-weight: 500; letter-spacing: 0.08em; text-decoration: none; text-transform: uppercase; font-size: 0.9rem; }
.marque em { font-size: 1.15em; text-transform: none; }
.nav { display: flex; align-items: center; gap: clamp(10px, 2.4vw, 28px); }
.nav a { text-decoration: none; font-size: 0.92rem; color: var(--texte-2); padding: 10px 2px; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--texte); }
@media (max-width: 520px) { .nav a.secondaire { display: none; } }

/* ---------- Boutons (cibles ≥ 44 px) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 0 22px;
  border-radius: 999px; border: 1px solid var(--ligne); background: transparent; color: var(--texte);
  font: 500 0.95rem/1 "Jost", system-ui, sans-serif; text-decoration: none; cursor: pointer;
  transition: background var(--duree) var(--courbe), border-color var(--duree) var(--courbe), transform 0.2s var(--courbe);
}
.btn:hover { border-color: var(--texte); }
.btn:active { transform: scale(0.97); }
.btn--plein { background: var(--texte); color: var(--fond); border-color: var(--texte); }
.btn--plein:hover { background: var(--accent); border-color: var(--accent); }
.btn--son { min-height: 44px; padding: 0 16px; font-size: 0.85rem; }
.btn--son .onde { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.btn--son .onde i { width: 2px; height: 6px; background: currentColor; border-radius: 1px; }
.btn--son .onde i:nth-child(2) { height: 11px; }
.btn--son .onde i:nth-child(3) { height: 4px; }
.btn--son[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .btn--son[aria-pressed="true"] .onde i { animation: barre-son 0.9s ease-in-out infinite alternate; }
  .btn--son[aria-pressed="true"] .onde i:nth-child(2) { animation-delay: -0.3s; }
  .btn--son[aria-pressed="true"] .onde i:nth-child(3) { animation-delay: -0.6s; }
}
@keyframes barre-son { to { height: 14px; } }

/* ---------- Scène 3D + affiche (palier 0 et attente) ---------- */
#scene { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; opacity: 0; transition: opacity 1.2s var(--courbe); pointer-events: none; }
.scene-prete #scene { opacity: 1; }
.sans-webgl #scene { display: none; }
/* Affiche 100 % CSS (0 octet d'image) : une sphère cuivre éclairée, même place que la 3D */
.affiche {
  position: fixed; z-index: 0; pointer-events: none; border-radius: 50%;
  width: min(46vw, 62svh); aspect-ratio: 1; left: 70%; top: 50%; transform: translate(-50%, -50%);
  background:
    radial-gradient(circle at 34% 28%, rgba(243, 231, 218, 0.55), transparent 22%),
    radial-gradient(circle at 40% 36%, #d0834f, #6d3a1f 48%, #2b211c 70%, rgba(15, 13, 12, 0) 72%);
  box-shadow: inset -24px -30px 60px rgba(0, 0, 0, 0.55);
  transition: opacity 1.2s var(--courbe);
}
.scene-prete .affiche { opacity: 0; }
@media (max-width: 767px) { .affiche { width: min(70vw, 38svh); left: 50%; top: 28%; } }

/* ---------- Mise en page ---------- */
main { position: relative; z-index: 1; }
.hero {
  min-height: 100svh; display: grid; align-content: center; gap: 4px;
  padding: calc(var(--entete) + 24px) var(--marge) 48px;
}
.hero { position: relative; }
.hero > * { max-width: min(640px, 52vw); position: relative; }
/* Voile derrière la colonne de texte : la poussière 3D ne gêne jamais la lecture */
.hero::before { content: ""; position: absolute; inset: 0; pointer-events: none; max-width: none;
  background: linear-gradient(90deg, rgba(var(--fond-rgb), 0.92) 0%, rgba(var(--fond-rgb), 0.72) 34%, rgba(var(--fond-rgb), 0.3) 48%, rgba(var(--fond-rgb), 0) 60%); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0 18px; }
.palier { font-size: 0.85rem; color: var(--texte-2); }
.palier strong { color: var(--texte); font-weight: 500; }
@media (max-width: 767px) {
  .hero { align-content: end; padding-bottom: 40px; }
  .hero > * { max-width: none; }
  .hero::before { background: linear-gradient(0deg, rgba(var(--fond-rgb), 0.88) 0%, rgba(var(--fond-rgb), 0.62) 30%, rgba(var(--fond-rgb), 0.28) 46%, rgba(var(--fond-rgb), 0.08) 56%, rgba(var(--fond-rgb), 0) 64%); }
}

.recit { position: relative; }
.etape { min-height: 100svh; display: grid; align-content: center; padding: 64px var(--marge); }
.etape > div {
  max-width: 460px; padding: 28px; border-radius: var(--rayon);
  background: rgba(var(--fond-rgb), 0.78); border: 1px solid var(--ligne);
}
.etape:nth-child(odd) > div { justify-self: end; }
@media (max-width: 767px) { .etape { align-content: end; } .etape > div, .etape:nth-child(odd) > div { justify-self: stretch; } }

.corrige { background: var(--fond); padding: 96px var(--marge); border-top: 1px solid var(--ligne); }
.grille { list-style: none; padding: 0; margin: 32px 0 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.grille li { padding: 22px; border: 1px solid var(--ligne); border-radius: var(--rayon); background: var(--surface); }
.grille h3 { font-size: 1.1rem; letter-spacing: 0; line-height: 1.3; }
.grille p { color: var(--texte-2); font-size: 0.95rem; margin: 0; }
.tableau { width: 100%; border-collapse: collapse; margin: 24px 0; font-size: 0.95rem; }
.tableau th, .tableau td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--ligne); vertical-align: top; }
.tableau th { color: var(--texte-2); font-weight: 500; font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; }
.page { padding: calc(var(--entete) + 48px) var(--marge) 64px; max-width: 980px; }
.pied { position: relative; z-index: 1; background: var(--fond); padding: 32px var(--marge) 48px; border-top: 1px solid var(--ligne); color: var(--texte-2); font-size: 0.85rem; }

/* ---------- Mesures (?w3d-stats=1) ---------- */
.mesures { position: fixed; right: 8px; bottom: 8px; z-index: 60; margin: 0; padding: 8px 10px; background: rgba(0, 0, 0, 0.8); color: #9fe39f; font: 11px/1.5 ui-monospace, monospace; border-radius: 6px; }

/* ---------- Anti-flash : masqué seulement si JS + animations autorisées ---------- */
@media (prefers-reduced-motion: no-preference) {
  .anim [data-anim], .anim [data-reveal] { visibility: hidden; }
}

/* ---------- Barre de progression : CSS scroll-driven, 0 JS ---------- */
.progression { position: fixed; inset: 0 0 auto; height: 2px; z-index: 40; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }
@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .progression { animation: progression linear both; animation-timeline: scroll(root); }
  }
}
@keyframes progression { to { transform: scaleX(1); } }

/* ---------- Transitions de page natives (View Transitions, < 400 ms) ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: 0.24s var(--courbe) both page-sort; }
::view-transition-new(root) { animation: 0.36s var(--courbe) both page-entre; }
@keyframes page-sort { to { opacity: 0; transform: translateY(-12px); } }
@keyframes page-entre { from { opacity: 0; transform: translateY(16px); } }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
