/*
 * GOODEV — mouvement.
 * Tout est natif : animations CSS à l'arrivée, révélation à l'entrée dans
 * l'écran (classe posée par site.js), transitions entre pages (View Transitions).
 * On n'anime que transform et opacity. Sous « réduire les animations », rien
 * de ce fichier ne joue : le contenu est simplement là.
 */

@keyframes rise {
  from {
    transform: translateY(108%);
  }

  to {
    transform: none;
  }
}

@keyframes rise-fade {
  from {
    opacity: 0;
    transform: translateY(1.25rem);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes draw {
  from {
    stroke-dashoffset: 1000;
  }

  to {
    stroke-dashoffset: 0;
  }
}

@keyframes pop {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes page-out {
  to {
    opacity: 0;
  }
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
  }
}

/* ---------- Mots découpés par site.js (titre de couverture) ---------- */

/* Un mot = un masque (.w) et son contenu (.w__i) qui monte de derrière le masque. */
.w {
  display: inline-block;
  padding-block: 0.14em;
  margin-block: -0.14em;
  overflow: hidden;
  overflow: clip;
  vertical-align: top;
}

.w__i {
  display: inline-block;
}

/* Tant que le titre n'est pas découpé, on ne le montre pas : pas de double apparition.
   Si le script n'arrive jamais, theme-init.js pose .split-timeout et le texte s'affiche. */
.js [data-split="rise"]:not(.is-split) {
  visibility: hidden;
}

.js.split-timeout [data-split="rise"] {
  visibility: visible;
}

@media (prefers-reduced-motion: no-preference) {
  /* ---------- Arrivée de la couverture ---------- */

  [data-split="rise"].is-split .w__i {
    animation: rise var(--dur-reveal) var(--ease-out) both;
  }

  .enter {
    animation: rise-fade var(--dur-reveal) var(--ease-out) both;
  }

  .d-0 { animation-delay: 80ms; }
  .d-1 { animation-delay: 130ms; }
  .d-2 { animation-delay: 180ms; }
  .d-3 { animation-delay: 230ms; }
  .d-4 { animation-delay: 280ms; }
  .d-5 { animation-delay: 330ms; }
  .d-6 { animation-delay: 380ms; }
  .d-7 { animation-delay: 430ms; }
  .d-8 { animation-delay: 480ms; }
  .d-9 { animation-delay: 530ms; }
  .d-10 { animation-delay: 580ms; }
  .d-11 { animation-delay: 630ms; }
  .d-12 { animation-delay: 680ms; }
  .d-13 { animation-delay: 730ms; }
  .d-14 { animation-delay: 780ms; }
  .d-15 { animation-delay: 830ms; }
  .d-late { animation-delay: 950ms; }
  .d-later { animation-delay: 1100ms; }
  .d-last { animation-delay: 1250ms; }

  /* ---------- Au défilement ---------- */

  /* site.js pose .is-in quand le bloc entre dans l'écran : il monte une fois, puis reste.
     Même filet que pour le titre : sans script au bout de 2,5 s, tout s'affiche. */
  .js:not(.split-timeout) .reveal:not(.is-in) {
    opacity: 0;
  }

  .reveal.is-in {
    animation: rise-fade var(--dur-reveal) var(--ease-out) both;
  }

  /* Les schémas se tracent quand leur bloc entre dans l'écran, puis les aplats se posent. */
  /* Les pointillés gardent leur motif : ils apparaissent avec les aplats, sans se tracer. */
  .reveal.is-in .schema__line:not(.schema__line--dash) {
    stroke-dasharray: 1000;
    animation: draw 1.8s var(--ease) 0.2s both;
  }

  .reveal.is-in .schema__line--dash,
  .reveal.is-in .schema__fill,
  .reveal.is-in .schema__dot,
  .reveal.is-in .schema__label {
    animation: pop var(--dur-long) var(--ease) 1.1s both;
  }

  /* ---------- D'une page à l'autre ---------- */

  /* Navigateurs sans transition native entre pages (site.js pose .vt-fallback) :
     la page entre en fondu, et s'efface au clic sur un lien interne. */
  .vt-fallback main {
    animation: page-in 380ms var(--ease-out) both;
  }

  .vt-fallback.is-leaving main,
  .vt-fallback.is-leaving .site-footer {
    opacity: 0;
    transition: opacity 150ms var(--ease);
  }

  @view-transition {
    navigation: auto;
  }

  ::view-transition-old(root) {
    animation: page-out 180ms var(--ease) both;
  }

  ::view-transition-new(root) {
    animation: page-in 380ms var(--ease-out) both;
  }
}
