/* ==========================================================================
   AKELION — Page Dynafilter® : scène 3D pilotée par le défilement
   Complète style.css et components.css
   ========================================================================== */

/* --------------------------------------------------------------------------
   Scrollytelling — scène 3D épinglée
   -------------------------------------------------------------------------- */

.scrolly {
  position: relative;
  /* 4 chapitres + marge de confort. Repli vh pour les navigateurs sans svh. */
  height: 580vh;
  height: 580svh;
}

.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(72% 55% at 62% 42%, rgba(61, 59, 122, 0.42), transparent 68%),
    radial-gradient(40% 38% at 58% 50%, rgba(195, 210, 0, 0.09), transparent 72%),
    linear-gradient(180deg, var(--navy-850), var(--navy-900) 55%, var(--navy-950));
}


.stage__canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 1.2s var(--ease-out);
}

.stage__canvas.is-ready { opacity: 1; }

/* Repli statique si WebGL indisponible ou modèle en échec */
.stage__poster {
  position: absolute;
  z-index: 1;
  inset: 0;
  margin: auto;
  width: min(88%, 60rem);
  height: auto;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.8s var(--ease-out);
  pointer-events: none;
}
.stage__poster.is-shown { opacity: 0.9; }

/* --- Voiles de lisibilité, persistants ---
   Ils vivent dans la scène et non dans les chapitres : le fond bleu ne
   disparaît donc plus pendant les fondus enchaînés de texte. */

.stage__scrim {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.7s var(--ease-out);
}

.stage__scrim--side {
  opacity: 1;
  background: linear-gradient(
    90deg,
    rgba(8, 8, 26, 0.90) 0%,
    rgba(8, 8, 26, 0.84) 30%,
    rgba(8, 8, 26, 0.62) 48%,
    rgba(8, 8, 26, 0.22) 64%,
    transparent 80%
  );
}

.stage__scrim--foot {
  opacity: 0;
  background: linear-gradient(
    0deg,
    rgba(8, 8, 26, 0.90) 0%,
    rgba(8, 8, 26, 0.64) 26%,
    rgba(8, 8, 26, 0.22) 46%,
    transparent 64%
  );
}

/* Dernier chapitre : le texte passe en bas, les voiles permutent.
   Le voile latéral s'éteint complètement — sinon il assombrit la moitié
   gauche de la scène, précisément là où le motoréducteur se déploie en vue
   éclatée. Le voile bas suffit à garder le texte lisible. */
.stage.is-low .stage__scrim--side { opacity: 0; }
.stage.is-low .stage__scrim--foot { opacity: 1; }

/* --- Chapitres textuels superposés --- */

.chapters {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.chapter {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.6s var(--ease-out);
}

.chapter.is-active { opacity: 1; }
.chapter.is-active a { pointer-events: auto; }

/* Chapitre anatomie : texte ramené en bas pour dégager les callouts */
.chapter--low { align-items: flex-end; padding-bottom: clamp(3rem, 9vh, 6rem); }
.chapter--low .chapter__box { max-width: 27rem; }
.chapter--low .chapter__title { font-size: clamp(1.9rem, 3.6vw, 2.9rem); }


.chapter__inner {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.chapter__box {
  max-width: 33rem;
  transform: translateY(18px);
  transition: transform 0.8s var(--ease-out);
}

.chapter.is-active .chapter__box { transform: none; }


.chapter__title {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 5vw, 3.9rem);
  font-stretch: 110%;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 0.98;
  margin-bottom: 1.4rem;
}

.chapter__title sup { font-size: 0.28em; vertical-align: super; }
.chapter__title em { font-style: normal; color: var(--lime); }

.chapter__text {
  color: rgba(215, 216, 226, 0.92);
  font-size: clamp(1rem, 1.25vw, 1.16rem);
  max-width: 40ch;
}

/* Halo sombre resserré autour des lettres : permet d'alléger le voile */
.chapter__title,
.chapter__text,
.chapter .eyebrow,
.chapter__hint {
  text-shadow: 0 1px 12px rgba(8, 8, 26, 0.95), 0 0 34px rgba(8, 8, 26, 0.75);
}


/* --- Compteur de chapitre --- */

.stage__index {
  position: absolute;
  z-index: 3;
  right: var(--gutter);
  bottom: 3.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  align-items: flex-end;
}

.stage__dot {
  width: 22px;
  height: 2px;
  background: rgba(255, 255, 255, 0.16);
  transition: background 0.4s var(--ease-out), width 0.4s var(--ease-out);
}

.stage__dot.is-on { background: var(--lime); width: 34px; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  /* Téléphone : le texte part du bandeau du site, sans marge perdue.
     Chapitre d'ouverture : texte d'un seul tenant en haut, boutons calés
     en bas de l'écran ; l'image est en fond. Autres chapitres : texte en
     haut, image plus bas (components.css, .stills). */
  .chapter { align-items: flex-start; padding: calc(81px + 1rem) 0 max(1.25rem, env(safe-area-inset-bottom)); }
  .chapter:first-child { align-items: stretch; }
  .chapter:first-child .chapter__inner,
  .chapter:first-child .chapter__box { display: flex; flex-direction: column; }
  .chapter:first-child .chapter__box { flex: 1; min-height: 0; justify-content: flex-end; }
  .chapter .chapter__cta { margin-top: 1.5rem; margin-bottom: 0; }
  /* Taille ajustée par main.js (--fit) pour coller le texte aux boutons */
  .chapter:first-child .chapter__title { font-size: calc(1.9rem * var(--fit, 1)); }
  .chapter:first-child .chapter__text { font-size: calc(1rem * (0.4 + 0.6 * var(--fit, 1))); }
  .chapter .chapter__hint { display: none; }
  .chapter__box { max-width: none; }
  .chapter__text { max-width: none; }

  /* Texte en haut : le voile part du haut de l'écran */
  .stage__scrim--side,
  .stage.is-low .stage__scrim--side { opacity: 0; }
  .stage__scrim--foot { opacity: 1; background: linear-gradient(180deg, rgba(8, 8, 26, 0.88) 0%, rgba(8, 8, 26, 0.6) 30%, rgba(8, 8, 26, 0.2) 50%, transparent 66%); }

  /* Le compteur de chapitres chevaucherait le surtitre */
  .stage__index { display: none; }
}

/* Défilement raccourci sur petits écrans : même récit, moins de course */
@media (max-width: 780px) {
  .scrolly { height: 500vh; height: 500svh; }
}

@media (prefers-reduced-motion: reduce) {
  .chapter__box { transform: none; }
}

/* Appel à l'action dans le chapitre d'ouverture */
.chapter__cta { margin-top: 2.25rem; margin-bottom: 0.5rem; }
.chapter__cta .btn { pointer-events: auto; }

.chapter__title--long { font-size: clamp(1.9rem, 3.8vw, 3.1rem); line-height: 1.04; }

/* --------------------------------------------------------------------------
   Principe : disque membranaire vu de face (assets/js/flux.js)
   -------------------------------------------------------------------------- */

.flux__stage { position: relative; }
.flux__canvas { display: block; width: 100%; height: auto; aspect-ratio: 5 / 4; }

.flux__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.4rem;
  margin: 1.1rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.flux__legend li { display: flex; align-items: center; gap: 0.55rem; }

.flux__key { flex: none; width: 18px; height: 2px; }
.flux__key--raw { background: rgb(120, 150, 240); }
.flux__key--clean { background: rgb(232, 236, 210); }
.flux__key--solid { width: 6px; height: 6px; border-radius: 50%; background: rgb(176, 160, 130); }

.principle__caption strong { color: var(--lime); font-weight: 600; }

/* Le texte de gauche est long : l'animation reste à l'écran pendant la lecture */
@media (min-width: 901px) {
  .principle__figure.flux { position: sticky; top: 6.5rem; align-self: start; }
}

/* --------------------------------------------------------------------------
   Téléphone : défilement continu (main.js, section 10)
   Pas de 3D ni de scène épinglée : les chapitres se suivent comme une page
   normale, séparés par un filet ; le croquis reste fixe en fond pendant
   que le texte défile. Le premier écran garde sa mise en page (texte collé
   aux boutons, voir plus haut).
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .scrolly { height: auto; }
  .stage { position: relative; height: auto; overflow: visible; }
  .stage__canvas, .stage__poster, .stage__loader, .stage__index { display: none; }
  .stage__scrim { display: none; }

  .has-stills .stills {
    position: sticky;
    inset: auto;
    top: 0;
    height: 100vh;
    height: 100svh;
    margin-bottom: -100vh;
    margin-bottom: -100svh;
  }

  .chapters { position: relative; inset: auto; pointer-events: auto; }
  .chapter { position: relative; inset: auto; opacity: 1; }
  .chapter__box { transform: none; }
  .chapter:first-child { height: 100vh; height: 100svh; }

  .chapter + .chapter {
    padding: 3rem 0 3.25rem;
    border-top: 1px solid var(--line-soft);
  }
  .chapter:last-child { padding-bottom: 5rem; }

  /* Texte un peu plus grand que dans la scène épinglée */
  .chapter + .chapter .chapter__title { font-size: 2.3rem; line-height: 1.02; margin-bottom: 1.1rem; }
  .chapter + .chapter .chapter__text { font-size: 1.04rem; line-height: 1.65; }

  /* L'élévation, achevée à la fin du dernier chapitre, reste en place :
     la section suivante monte par-dessus et la recouvre */
  .chapters { padding-bottom: 100vh; padding-bottom: 100svh; }
  .scrolly + .band {
    z-index: 4;
    margin-top: -100vh;
    margin-top: -100svh;
    background: var(--navy-900);
    box-shadow: 0 -30px 60px rgba(8, 8, 26, 0.6);
  }
}
