/* ==========================================================================
   Cosmogonie — feuille de styles
   Ordre : polices, jetons, base, grain, héros, séquence, chapitres, HUD,
   versions statiques, épilogue, pied de page, révélations, adaptations,
   mouvement réduit.

   Posé par main.js, lu ici :
   - .chapter : --reveal (0..1), --dir (1 entre par le bas, -1 sort par le haut), .is-visible
   - #sequence : --progress (0..1) ; .sequence.is-static en mouvement réduit
   - <html> : .is-ready (première image dessinée), .reveal-on (révélations actives)
   - [data-reveal] : .is-inview ; .hero__loader : .is-done
   Posé par le script en ligne du <head> : html.js
   ========================================================================== */

/* ---------- Polices (auto-hébergées) ---------- */
@font-face {
  font-family: "Cormorant";
  src: url("/assets/fonts/cormorant.woff2") format("woff2");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Cormorant";
  src: url("/assets/fonts/cormorant-italic.woff2") format("woff2");
  font-weight: 300;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Manrope";
  src: url("/assets/fonts/manrope.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

/* ---------- Jetons ---------- */
:root {
  color-scheme: dark;

  /* Couleurs */
  --bg: #030308;                          /* le vide */
  --ink: #ece8f4;                         /* lumière d’étoile */
  --ink-soft: rgba(236, 232, 244, 0.8);
  --muted: rgba(236, 232, 244, 0.62);     /* contraste ≥ 4,5:1 sur le fond, même sous le halo du héros */
  --line: rgba(236, 232, 244, 0.14);
  --gold: #f3c77a;                        /* la protoétoile */
  --violet: #a78bfa;                      /* la nébuleuse */
  --teal: #5eead4;                        /* glace et océans */

  /* Typographie */
  --serif: "Cormorant", "Cormorant Garamond", Garamond, Georgia, serif;
  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --track: 0.32em;                        /* interlettrage des surtitres */

  /* Rythme */
  --pad: clamp(1.25rem, 4vw, 3.5rem);
  --chapter-bottom: clamp(3rem, 12vh, 8rem);
  --ui-offset: 0px; /* hauteur des barres du navigateur mobile quand elles sont affichées */

  /* Mouvement */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.2, 0.7, 0.1, 1);
}

/* La zone collante fait 100lvh : quand les barres mobiles sont visibles, son
   bas passe dessous. Les textes calés en bas remontent d’autant. */
@supports (height: 100lvh) {
  :root { --ui-offset: calc(100lvh - 100svh); }
}

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 300;
  line-height: 1.6;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden; /* repli pour les navigateurs sans « clip » */
  overflow-x: clip;
}

h1,
h2,
p,
figure,
blockquote { margin: 0; }

img { max-width: 100%; }

a { color: inherit; }

::selection { background: rgba(167, 139, 250, 0.35); color: #fff; }

:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 6px;
  border-radius: 2px;
}

/* Texte réservé aux lecteurs d’écran */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Surtitre : petites capitales espacées (la marge négative recentre l’interlettrage) */
.eyebrow {
  margin-right: calc(-1 * var(--track));
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: var(--track);
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Grain argentique (masque aussi les aplats des WebP) ---------- */
.grain {
  position: fixed;
  inset: -10%;
  z-index: 60;
  pointer-events: none;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.4s steps(6) infinite;
}

@keyframes grain {
  0%, 100% { transform: translate3d(0, 0, 0); }
  20% { transform: translate3d(-3%, 2%, 0); }
  40% { transform: translate3d(2%, -4%, 0); }
  60% { transform: translate3d(-4%, -1%, 0); }
  80% { transform: translate3d(3%, 3%, 0); }
}

/* ==========================================================================
   Héros
   ========================================================================== */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 2.4vh, 1.6rem);
  padding:
    calc(var(--pad) + env(safe-area-inset-top))
    calc(var(--pad) + env(safe-area-inset-right))
    calc(var(--pad) + 5.5rem + env(safe-area-inset-bottom))
    calc(var(--pad) + env(safe-area-inset-left));
  text-align: center;
  isolation: isolate;
  overflow: hidden; /* repli */
  overflow: clip;   /* le titre déborde pendant son accrétion */
  background:
    radial-gradient(ellipse 60% 45% at 50% 55%, rgba(124, 58, 237, 0.18), transparent 70%),
    radial-gradient(ellipse 35% 30% at 50% 60%, rgba(94, 234, 212, 0.07), transparent 70%),
    var(--bg);
}

/* Image 1 de la séquence, la nébuleuse encore lointaine : mise au point puis respiration lente */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: url("/assets/frames/frame-001.webp?v=2") center / cover no-repeat;
  opacity: 0.6;
  -webkit-mask-image: radial-gradient(ellipse 75% 70% at 50% 50%, #000 35%, transparent 85%);
  mask-image: radial-gradient(ellipse 75% 70% at 50% 50%, #000 35%, transparent 85%);
  animation:
    hero-focus 3.2s var(--ease-out) both,
    hero-breathe 18s ease-in-out 3.2s infinite alternate;
}

/* Fondu vers la séquence : le bas du héros rejoint le noir du haut de la séquence */
.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 38%;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(3, 3, 8, 0), var(--bg));
}

@keyframes hero-focus {
  from { opacity: 0; transform: scale(1.14); }
  to { opacity: 0.6; transform: scale(1); }
}

@keyframes hero-breathe {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

.hero .eyebrow { animation: rise 1.6s var(--ease-out) 0.1s both; }

/* Titre : les lettres se condensent comme la matière d’un nuage (accrétion).
   L’interlettrage se resserre, le flou se dissipe ; le retrait gauche compense
   l’espace ajouté après la dernière lettre pour garder le mot centré. */
.hero__title {
  padding: 0.06em 0.08em 0.18em;
  margin-bottom: -0.12em;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(3.4rem, 15.5vw, 13rem);
  line-height: 0.86;
  letter-spacing: -0.02em;
  color: var(--ink);
  animation: accretion 2.8s var(--ease-out) 0.3s both;
}

.hero__title em { font-style: italic; }

@supports (background-clip: text) or (-webkit-background-clip: text) {
  .hero__title {
    background: linear-gradient(180deg, #fff 18%, #d9d0f7 62%, #9383d8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
  }

  /* Le débord de l’italique reste doré (marges négatives : aucun effet sur la mise en page) */
  .hero__title em {
    padding: 0 0.08em 0 0.1em;
    margin: 0 -0.08em 0 -0.1em;
    background: linear-gradient(180deg, #ffe9bd 8%, var(--gold) 52%, #c98a4f 100%);
    -webkit-background-clip: text;
    background-clip: text;
  }
}

@keyframes accretion {
  from {
    opacity: 0;
    letter-spacing: 0.34em;
    padding-left: 0.42em;
    filter: blur(16px);
  }
  to {
    opacity: 1;
    letter-spacing: -0.02em;
    padding-left: 0.08em;
    filter: none;
  }
}

.hero__lede {
  max-width: 30rem;
  font-size: clamp(0.98rem, 0.9rem + 0.35vw, 1.12rem);
  color: var(--ink-soft);
  text-wrap: balance;
  animation: rise 1.6s var(--ease-out) 1s both;
}

@keyframes rise {
  from { opacity: 0; transform: translate3d(0, 18px, 0); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Chargeur : un trait et un pourcentage. Masqué sans JavaScript. */
.hero__loader {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  margin-top: clamp(0.4rem, 2vh, 1.2rem);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: opacity 1.1s ease 0.5s;
}

html.js .hero__loader { display: flex; }

.hero__loader > * { animation: fade-in 1.2s ease 1.4s backwards; }

.hero__loader.is-done { opacity: 0; }

.hero__loader-bar {
  position: relative;
  width: 7.5rem;
  height: 1px;
  overflow: hidden;
  background: var(--line);
}

#loader-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--violet), var(--gold));
  transition: transform 0.5s var(--ease-out);
}

#loader-text { margin-right: -0.2em; }

/* Invitation à descendre */
.scroll-cue {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(1.4rem + env(safe-area-inset-bottom));
  width: max-content;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
  transition: color 0.6s ease;
  animation: fade-in 1.4s ease 1.8s backwards;
}

.scroll-cue__label { margin-right: -0.36em; }

.scroll-cue__line {
  display: block;
  width: 1px;
  height: 3.2rem;
  background: linear-gradient(var(--ink), rgba(236, 232, 244, 0));
  transform-origin: top;
  animation: cue 2.4s var(--ease-soft) infinite;
}

.scroll-cue:hover,
.scroll-cue:focus-visible,
.hero__loader.is-done ~ .scroll-cue { color: var(--ink); }

@keyframes cue {
  0% { transform: scaleY(0); opacity: 1; }
  60% { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1); opacity: 0; }
}

/* ==========================================================================
   Séquence
   ========================================================================== */
.sequence {
  position: relative;
  height: 760vh;
}

.sequence__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100lvh;
  overflow: hidden;
  isolation: isolate;
  background: var(--bg);
}

/* Canevas principal : fondu d’entrée dès que la première image est dessinée */
#cosmos {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1.6s var(--ease-out);
}

html.is-ready #cosmos { opacity: 1; }

/* Champ d’étoiles en surimpression (mode « écran » : le noir reste transparent) */
.stars {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 2.4s ease 0.4s;
}

html.is-ready .stars { opacity: 1; }

/* Voile : vignette douce et deux rideaux pilotés par --progress (posé sur #sequence) */
.sequence__veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 80% 75% at 50% 50%, rgba(3, 3, 8, 0) 58%, rgba(3, 3, 8, 0.6) 100%);
}

.sequence__veil::before,
.sequence__veil::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
}

/* Rideau haut : plein à l’entrée (raccord avec le héros), il se lève dès le début
   du voyage pour laisser voir la jeune étoile en haut de l’image */
.sequence__veil::before {
  top: 0;
  height: 22%;
  background: linear-gradient(180deg, var(--bg) 0%, rgba(3, 3, 8, 0.5) 35%, rgba(3, 3, 8, 0) 100%);
  opacity: calc(1 - 0.6 * min(1, var(--progress, 0) * 12));
}

/* Rideau bas : léger pendant le voyage, plein à la fin (raccord avec l’épilogue) */
.sequence__veil::after {
  bottom: 0;
  height: 28%;
  background: linear-gradient(0deg, var(--bg) 0%, rgba(3, 3, 8, 0.5) 35%, rgba(3, 3, 8, 0) 100%);
  opacity: calc(0.45 + 0.55 * clamp(0, (var(--progress, 0) - 0.9) * 10, 1));
}

/* ==========================================================================
   Chapitres
   ========================================================================== */

/* Typographie commune : séquence, repli statique, version sans JavaScript */
.chapter {
  --reveal: 0;
  --dir: 1;
}

.chapter__num {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.1rem;
}

.chapter__roman {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.7rem;
  line-height: 1;
  color: var(--gold);
}

.chapter__rule {
  flex: none;
  width: 2.6rem;
  height: 1px;
  background: linear-gradient(90deg, var(--gold), rgba(243, 199, 122, 0.15));
}

.chapter__time {
  font-size: 0.64rem;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: rgba(236, 232, 244, 0.7);
}

.chapter h2,
.nojs__text h2 {
  margin-bottom: 1rem;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(2.3rem, 1.5rem + 2.7vw, 4.2rem);
  line-height: 0.98;
  letter-spacing: -0.012em;
  color: var(--ink);
  text-wrap: balance;
}

.chapter p,
.nojs__text p {
  font-size: clamp(0.95rem, 0.9rem + 0.22vw, 1.08rem);
  line-height: 1.68;
  color: var(--ink-soft);
  text-wrap: pretty;
}

/* Rendu en surimpression, piloté uniquement par --reveal et --dir */
.sequence__sticky .chapter {
  position: absolute;
  left: calc(var(--pad) + env(safe-area-inset-left));
  bottom: calc(var(--chapter-bottom) + var(--ui-offset));
  width: min(27rem, 40vw);
  opacity: var(--reveal);
  transform: translate3d(0, calc((1 - var(--reveal)) * var(--dir) * 30px), 0);
  filter: blur(calc((1 - var(--reveal)) * 6px));
  text-shadow: 0 1px 2px rgba(3, 3, 8, 0.55), 0 0 28px rgba(3, 3, 8, 0.65);
  pointer-events: none;
}

.sequence__sticky .chapter.is-visible {
  will-change: opacity, transform, filter;
  pointer-events: auto;
}

.sequence__sticky .chapter--right {
  left: auto;
  right: calc(var(--pad) + env(safe-area-inset-right));
  text-align: right;
}

.sequence__sticky .chapter--right .chapter__num { justify-content: flex-end; }

/* Voile de lecture : un nuage sombre qui apparaît et disparaît avec le texte */
.sequence__sticky .chapter::before {
  content: "";
  position: absolute;
  inset: -7rem -8rem -6rem;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(3, 3, 8, 0.64), rgba(3, 3, 8, 0.4) 55%, rgba(3, 3, 8, 0));
}

/* Le filet doré se trace à l’entrée, se replie à la sortie */
.sequence__sticky .chapter__rule {
  transform: scaleX(var(--reveal));
  transform-origin: left center;
}

/* Léger décalage du paragraphe : profondeur entre titre et texte */
.sequence__sticky .chapter p {
  transform: translate3d(0, calc((1 - var(--reveal)) * var(--dir) * 14px), 0);
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: calc(env(safe-area-inset-top) + clamp(1.1rem, 3vw, 2.2rem));
  right: calc(var(--pad) + env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  text-shadow: 0 0 12px rgba(3, 3, 8, 0.9);
  opacity: 0;
  transition: opacity 1.2s ease 0.3s;
}

html.is-ready .hud { opacity: 1; }

#hud-frame { color: var(--ink); }

.hud__sep { opacity: 0.45; }

.hud__track {
  position: relative;
  width: 6rem;
  height: 1px;
  margin-left: 0.9rem;
  overflow: hidden;
  background: var(--line);
}

#hud-progress {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, rgba(243, 199, 122, 0.3), var(--gold));
}

/* ==========================================================================
   Versions statiques : mouvement réduit (rempli par main.js) et sans JavaScript
   ========================================================================== */
.sequence.is-static { height: auto; }

.sequence.is-static .sequence__sticky { display: none; }

.sequence__static,
.sequence__nojs {
  display: grid;
  gap: clamp(4.5rem, 12vw, 9rem);
  width: min(100%, 76rem);
  margin-inline: auto;
  padding:
    clamp(4rem, 12vh, 8rem)
    calc(var(--pad) + env(safe-area-inset-right))
    clamp(4rem, 12vh, 8rem)
    calc(var(--pad) + env(safe-area-inset-left));
}

.sequence__static[hidden] { display: none; }

.static-step {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  align-items: end;
  gap: clamp(1.5rem, 4vw, 4rem);
}

.static-step:nth-child(even) > img { order: 2; }

.static-step img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 82vh;
  object-fit: cover;
  background: #0a0a14;
}

/* Toujours visibles : aucune opacité, aucun déplacement, aucun flou */
.static-step .chapter,
.static-step .nojs__text {
  position: static;
  width: auto;
  max-width: 30rem;
  padding-bottom: 0.4rem;
  opacity: 1;
  transform: none;
  filter: none;
  text-align: left;
}

.static-step .chapter__num { justify-content: flex-start; }

/* ==========================================================================
   Épilogue
   ========================================================================== */
.outro {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.4rem, 3vh, 2rem);
  padding:
    clamp(8rem, 26vh, 16rem)
    calc(var(--pad) + env(safe-area-inset-right))
    clamp(7rem, 22vh, 13rem)
    calc(var(--pad) + env(safe-area-inset-left));
  text-align: center;
  background: radial-gradient(ellipse 55% 42% at 50% 46%, rgba(243, 199, 122, 0.07), transparent 70%);
}

/* Le soleil de la dernière image, réduit à un point de lumière */
.outro__star {
  position: relative;
  display: block;
  width: 5px;
  height: 5px;
  margin-bottom: clamp(0.6rem, 3vh, 2rem);
  border-radius: 50%;
  background: #fff4dc;
  box-shadow:
    0 0 6px 1px rgba(243, 199, 122, 0.9),
    0 0 22px 6px rgba(243, 199, 122, 0.3);
}

.outro__star::after {
  content: "";
  position: absolute;
  inset: -22px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(243, 199, 122, 0.28), rgba(243, 199, 122, 0));
  animation: star-pulse 5s ease-in-out infinite alternate;
}

@keyframes star-pulse {
  from { opacity: 0.55; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1.15); }
}

.outro__lead {
  max-width: 32rem;
  font-size: clamp(0.98rem, 0.92rem + 0.3vw, 1.12rem);
  line-height: 1.7;
  color: var(--muted);
  text-wrap: balance;
}

.outro__figure {
  display: grid;
  justify-items: center;
  gap: 1.4rem;
}

.outro__quote {
  max-width: 46rem;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(2rem, 1.2rem + 3.2vw, 3.6rem);
  line-height: 1.12;
  color: var(--ink);
  text-wrap: balance;
}

.outro__cite {
  margin-right: -0.3em;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
}

.outro__cite cite { font-style: normal; }

.outro__back { margin-top: clamp(1.5rem, 5vh, 3rem); }

.outro__again {
  display: inline-block;
  padding: 0.3rem 0 0.45rem;
  border-bottom: 1px solid rgba(236, 232, 244, 0.2);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
  transition: color 0.4s ease, border-color 0.4s ease;
}

.outro__again:hover,
.outro__again:focus-visible {
  color: var(--ink);
  border-color: var(--gold);
}

/* ---------- Pied de page ---------- */
.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem 1.5rem;
  padding:
    1.6rem
    calc(var(--pad) + env(safe-area-inset-right))
    calc(1.6rem + env(safe-area-inset-bottom))
    calc(var(--pad) + env(safe-area-inset-left));
  border-top: 1px solid rgba(236, 232, 244, 0.08);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ==========================================================================
   Révélations au défilement
   Masquées seulement sous html.reveal-on (posée par main.js) : sans script,
   tout reste visible. Cascade via data-reveal-delay (secondes).
   ========================================================================== */
html.reveal-on [data-reveal] {
  opacity: 0;
  transform: translate3d(0, 1.6rem, 0);
  filter: blur(6px);
  transition:
    opacity 1.2s var(--ease-out),
    transform 1.5s var(--ease-out),
    filter 1.2s var(--ease-out);
  transition-delay: var(--reveal-delay, 0s);
}

html.reveal-on [data-reveal].is-inview {
  opacity: 1;
  transform: none;
  filter: none;
}

[data-reveal-delay="0.1"] { --reveal-delay: 0.1s; }
[data-reveal-delay="0.15"] { --reveal-delay: 0.15s; }
[data-reveal-delay="0.2"] { --reveal-delay: 0.2s; }
[data-reveal-delay="0.3"] { --reveal-delay: 0.3s; }
[data-reveal-delay="0.45"] { --reveal-delay: 0.45s; }
[data-reveal-delay="0.6"] { --reveal-delay: 0.6s; }
[data-reveal-delay="0.75"] { --reveal-delay: 0.75s; }

/* ==========================================================================
   Adaptations
   ========================================================================== */

/* Écran en portrait : on passe au jeu d’images mobile */
@media (max-aspect-ratio: 3/4) {
  .hero::before { background-image: url("/assets/frames-m/frame-001.webp?v=2"); }
}

/* Écrans étroits ou portrait : chapitres en bas, sur toute la largeur */
@media (max-width: 720px), (max-aspect-ratio: 3/4) {
  .sequence__sticky .chapter,
  .sequence__sticky .chapter--right {
    left: calc(var(--pad) + env(safe-area-inset-left));
    right: calc(var(--pad) + env(safe-area-inset-right));
    bottom: calc(1.75rem + env(safe-area-inset-bottom) + var(--ui-offset));
    width: auto;
    max-width: 34rem;
    text-align: left;
  }

  .sequence__sticky .chapter--right .chapter__num { justify-content: flex-start; }

  /* Voile de lecture en bandeau, du texte jusqu’au bas de l’écran */
  .sequence__sticky .chapter::before {
    inset: -9rem -3rem -60vh;
    background: linear-gradient(180deg, rgba(3, 3, 8, 0) 0, rgba(3, 3, 8, 0.62) 8rem, rgba(3, 3, 8, 0.84) 13rem);
  }
}

/* Mobile */
@media (max-width: 720px) {
  :root { --track: 0.28em; }

  .sequence { height: 560vh; }

  .hero { gap: 1.1rem; }

  .hud {
    gap: 0.3rem;
    font-size: 0.62rem;
  }

  .hud__track {
    width: 3.5rem;
    margin-left: 0.6rem;
  }

  .static-step {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }

  .static-step:nth-child(even) > img { order: 0; }

  .outro { padding-block: clamp(6rem, 18vh, 10rem) clamp(5rem, 16vh, 9rem); }

  .footer {
    flex-direction: column;
    justify-content: center;
    text-align: center;
  }
}

/* Téléphone couché ou fenêtre très basse : typographie compacte, légendes latérales */
@media (max-height: 500px) and (orientation: landscape) {
  .sequence { height: 760vh; }

  .hero {
    gap: 0.8rem;
    padding-bottom: calc(var(--pad) + 3.5rem + env(safe-area-inset-bottom));
  }

  .hero__title { font-size: clamp(2.8rem, 24vh, 7rem); }

  .scroll-cue__line { height: 1.6rem; }

  .sequence__sticky .chapter {
    left: calc(var(--pad) + env(safe-area-inset-left));
    right: auto;
    bottom: calc(1rem + env(safe-area-inset-bottom) + var(--ui-offset));
    width: min(24rem, 46vw);
    max-width: none;
    text-align: left;
  }

  .sequence__sticky .chapter--right {
    left: auto;
    right: calc(var(--pad) + env(safe-area-inset-right));
    text-align: right;
  }

  .sequence__sticky .chapter--right .chapter__num { justify-content: flex-end; }

  .sequence__sticky .chapter::before {
    inset: -5rem -6rem -4rem;
    background: radial-gradient(closest-side, rgba(3, 3, 8, 0.7), rgba(3, 3, 8, 0.45) 55%, rgba(3, 3, 8, 0));
  }

  .sequence__sticky .chapter__num { margin-bottom: 0.6rem; }

  .sequence__sticky .chapter h2 {
    margin-bottom: 0.5rem;
    font-size: clamp(1.6rem, 1rem + 2.4vw, 2.4rem);
  }

  .sequence__sticky .chapter p {
    font-size: 0.86rem;
    line-height: 1.55;
  }
}

/* ==========================================================================
   Mouvement réduit : aucune animation, tout est visible.
   (main.js remplace alors la séquence par sa version statique.)
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
}
