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

/* --------------------------------------------------------------------------
   Scène épinglée
   -------------------------------------------------------------------------- */

.dt-scrolly {
  position: relative;
  /* 4 chapitres + retenue finale. Repli vh pour les navigateurs sans svh. */
  height: 520vh;
  height: 520svh;
}

.dt-stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(70% 56% at 64% 46%, rgba(61, 59, 122, 0.42), transparent 70%),
    radial-gradient(38% 34% at 62% 56%, rgba(195, 210, 0, 0.07), transparent 72%),
    linear-gradient(180deg, var(--navy-850), var(--navy-900) 55%, var(--navy-950));
}

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

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

/* Voile de lisibilité, persistant (pas de clignotement entre chapitres) */
.dt-scrim {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    rgba(8, 8, 26, 0.9) 0%,
    rgba(8, 8, 26, 0.8) 30%,
    rgba(8, 8, 26, 0.44) 48%,
    transparent 66%
  );
  transition: opacity 0.7s var(--ease-out);
}

/* Voile bas, utilisé par le dernier chapitre et en portrait */
.dt-scrim::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background: linear-gradient(
    0deg,
    rgba(8, 8, 26, 0.92) 0%,
    rgba(8, 8, 26, 0.66) 24%,
    rgba(8, 8, 26, 0.2) 42%,
    transparent 58%
  );
  transition: opacity 0.7s var(--ease-out);
}

/* Dernier chapitre : le texte descend, le module éclaté occupe la largeur */
.dt-stage.is-low .dt-scrim { background: transparent; }
.dt-stage.is-low .dt-scrim::after { opacity: 1; }

/* --------------------------------------------------------------------------
   Chapitres
   -------------------------------------------------------------------------- */

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

.dt-chapter {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  /* Dégage la barre de navigation, fixe au-dessus de la scène */
  padding-top: 5rem;
  opacity: 0;
  transition: opacity 0.6s var(--ease-out);
}

.dt-chapter.is-on { opacity: 1; }

/* Seuls les liens du chapitre visible sont cliquables */
.dt-chapter.is-on a { pointer-events: auto; }

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

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

.dt-chapter.is-on .dt-chapter__box { transform: none; }

.dt-chapter__title {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 3.8vw, 3.1rem);
  font-stretch: 108%;
  font-weight: 700;
  letter-spacing: -0.033em;
  line-height: 1.04;
  color: var(--paper);
  margin-bottom: 1.35rem;
  text-wrap: balance;
}

.dt-chapter__title sup { font-size: 0.32em; vertical-align: super; }

.dt-chapter__text {
  color: rgba(215, 216, 226, 0.92);
  font-size: clamp(0.98rem, 1.15vw, 1.08rem);
  line-height: 1.68;
  max-width: 40ch;
}

.dt-chapter__cta { margin-top: 2.25rem; }

.dt-chapter__title,
.dt-chapter__text,
.dt-chapter .eyebrow,
.dt-chapter .chapter__hint {
  text-shadow: 0 1px 12px rgba(8, 8, 26, 0.95), 0 0 34px rgba(8, 8, 26, 0.75);
}

/* Chapitre anatomie : texte en bas, sur une ligne large */
.dt-chapter--low { align-items: flex-end; padding-bottom: clamp(2.5rem, 8vh, 5rem); }
.dt-chapter--low .dt-chapter__box { max-width: 36rem; }
.dt-chapter--low .dt-chapter__title { font-size: clamp(1.7rem, 3vw, 2.5rem); }

/* Repères chiffrés */
.dt-facts { list-style: none; margin: 1.75rem 0 0; padding: 0; display: grid; gap: 0.9rem; }

.dt-facts li {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 1rem;
  align-items: baseline;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line-soft);
}

.dt-facts b {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-stretch: 104%;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--lime);
  white-space: nowrap;
}

.dt-facts span {
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text-muted);
}

/* Étiquettes du wagon présenté : positionnées par dynatank.js, le point
   posé sur la pièce (styles communs dans components.css) */
.dt-callouts { z-index: 3; }
.dt-callouts[hidden] { display: none; }
.dt-callouts .callout { left: 0; top: 0; }

/* Indicateur de progression */
.dt-dots {
  position: absolute;
  z-index: 4;
  right: var(--gutter);
  bottom: 3rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  align-items: flex-end;
}

.dt-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);
}

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


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

@media (max-width: 900px) {
  .dt-scrolly { height: 460vh; height: 460svh; }

  /* 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). */
  .dt-chapter { align-items: flex-start; padding: calc(81px + 1rem) 0 max(1.25rem, env(safe-area-inset-bottom)); }
  .dt-chapter:first-child { align-items: stretch; }
  .dt-chapter:first-child .dt-chapter__inner,
  .dt-chapter:first-child .dt-chapter__box { display: flex; flex-direction: column; }
  .dt-chapter:first-child .dt-chapter__box { flex: 1; min-height: 0; justify-content: flex-end; }
  .dt-chapter .dt-chapter__cta { margin-top: 1.5rem; }
  /* Taille ajustée par main.js (--fit) pour coller le texte aux boutons */
  .dt-chapter:first-child .dt-chapter__title { font-size: calc(1.9rem * var(--fit, 1)); }
  .dt-chapter:first-child .dt-chapter__text { font-size: calc(0.98rem * (0.4 + 0.6 * var(--fit, 1))); }
  .dt-chapter .chapter__hint { display: none; }
  .dt-chapter__box,
  .dt-chapter--low .dt-chapter__box { max-width: none; }
  .dt-chapter__text { max-width: none; }

  /* Texte en haut : le voile part du haut de l'écran */
  .dt-stage .dt-scrim { 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%); }
  .dt-stage .dt-scrim::after { opacity: 0; }

  /* Le compteur de chapitres chevaucherait le surtitre */
  .dt-dots { display: none; }
  .dt-facts { gap: 0.6rem; margin-top: 1.25rem; }
  .dt-facts li { grid-template-columns: 5.5rem 1fr; padding-bottom: 0.55rem; }
}

/* Petits écrans : le texte d'un chapitre doit tenir sous le modèle */
@media (max-width: 560px) {
  .dt-chapter__text { font-size: 0.94rem; line-height: 1.6; }
  .dt-chapter__title { margin-bottom: 0.9rem; }
}

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

/* --------------------------------------------------------------------------
   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) {
  .dt-scrolly { height: auto; }
  .dt-stage { position: relative; height: auto; overflow: visible; }
  .dt-stage__canvas, [data-dt-loader], .dt-dots { display: none; }
  .dt-scrim { display: none; }

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

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

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

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

  /* Le croquis, achevé à la fin du dernier chapitre, reste en place : la
     section suivante monte par-dessus et le recouvre (comme Dynafilter) */
  .dt-chapters { padding-bottom: 100vh; padding-bottom: 100svh; }
  .dt-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);
  }
}
