/* ==========================================================================
   MOUVEMENT — couche d'animation du site, 100 % CSS, zéro dépendance.
   Ajoutée le 6 octobre 2026.
   Fichier servi tel quel (public/), chargé par BaseLayout — ne pas l'importer
   dans le bundle Vite : voir le commentaire dans BaseLayout.astro.

   Trois règles, héritées des incidents d'août 2026 (voir accueil.css) :

   1. AUCUN CONTENU NE DÉPEND D'UN SCRIPT POUR S'AFFICHER. Rien ici n'est
      piloté par JavaScript. Navigateur trop ancien, script bloqué, onglet en
      arrière-plan : la page s'affiche exactement comme avant.

   2. LES ANIMATIONS LIÉES AU DÉFILEMENT N'ONT PAS DE MODE DE REMPLISSAGE
      (`animation-fill-mode: none`) dès qu'elles touchent à l'opacité. Hors de
      sa plage, l'élément porte son style normal, donc visible. La plage
      commence à `entry 0%`, l'instant où le bord de l'élément franchit le bas
      de l'écran : l'état de départ n'existe que pendant le défilement, sous
      les yeux du lecteur. Une capture pleine page, un robot d'indexation ou
      un onglet suspendu voient le contenu en entier. Ce n'est pas le
      mécanisme qui a échoué en août : une animation de défilement ne dépend
      pas du temps et ne peut pas « se figer sur sa première image ».

   3. TOUT EST DERRIÈRE `@supports (animation-timeline: view())` ET
      `prefers-reduced-motion: no-preference`. Clientèle de 55 à 70 ans : le
      mouvement accompagne la lecture, il ne la retarde jamais. Seuls
      `transform` et `opacity` sont animés (aucun recalcul de mise en page,
      INP et CLS intacts).
   ========================================================================== */

/* ---- 1. Transitions entre pages ------------------------------------------
   Navigation multipage native (Chrome/Edge 126+, Safari 18.2+). Fondu court
   du contenu, en-tête immobile. Les autres navigateurs changent de page
   normalement. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }

  .header { view-transition-name: entete-site; }

  ::view-transition-old(root) {
    animation: 160ms cubic-bezier(0.4, 0, 1, 1) both vt-sortie;
  }
  ::view-transition-new(root) {
    animation: 280ms cubic-bezier(0, 0, 0.2, 1) 60ms both vt-entree;
  }
}
@keyframes vt-sortie { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-entree { from { opacity: 0; transform: translateY(10px); } }

/* ---- 2. Barre de progression de lecture (pages de contenu) ---------------
   Élément décoratif ajouté par ContentLayout. Invisible sans support. */
.progression-lecture { display: none; }

@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .progression-lecture {
      display: block;
      position: fixed;
      inset: 0 0 auto 0;
      height: 3px;
      z-index: 200;
      pointer-events: none;
      background: linear-gradient(90deg, var(--color-gold), #C8A96E);
      transform-origin: 0 50%;
      transform: scaleX(0);
      animation: progression-lecture linear both;
      animation-timeline: scroll(root block);
    }
  }
}
@keyframes progression-lecture { to { transform: scaleX(1); } }

/* ---- 3. FAQ : ouverture fluide -------------------------------------------
   `::details-content` + `interpolate-size` (Chrome 131+). Ailleurs, le
   <details> s'ouvre d'un coup, comme aujourd'hui. */
@media (prefers-reduced-motion: no-preference) {
  .faq details { interpolate-size: allow-keywords; }
  .faq details::details-content {
    block-size: 0;
    overflow-y: clip;
    transition: block-size 320ms cubic-bezier(0.25, 0, 0, 1),
                content-visibility 320ms allow-discrete;
  }
  .faq details[open]::details-content { block-size: auto; }
  .faq summary::before { transition: transform 240ms ease-out; }
  .faq details[open] summary::before { transform: rotate(180deg); }
}

/* ---- 4. Entrées au défilement — pages de contenu --------------------------
   Titres de section, encadrés et tableaux montent de quelques pixels en
   arrivant à l'écran. Transform seul : aucun risque de masquage. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .article .body h2,
    .article .body h3,
    .article .callout,
    .article .body table,
    .article .faq-section,
    .article .sources {
      animation: monte-leger linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 90%;
    }

    /* Filet or qui se dessine sous chaque H2 */
    .article .body h2 {
      background-image: linear-gradient(var(--color-gold), var(--color-gold));
      background-repeat: no-repeat;
      background-position: 0 100%;
      background-size: 3rem 2px;
      padding-bottom: 0.5rem;
      animation: monte-leger linear both, filet-or linear both;
      animation-timeline: view(), view();
      animation-range: entry 0% entry 90%, entry 40% cover 40%;
    }
  }
}
@keyframes filet-or {
  from { background-size: 0 2px; }
  to   { background-size: 3rem 2px; }
}
@keyframes monte-leger {
  from { transform: translateY(18px); }
  to   { transform: none; }
}

/* ---- 5. Micro-interactions communes -------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .btn-primary,
  .btn-secondary {
    transition: background 200ms ease-out, color 200ms ease-out, transform 200ms ease-out;
  }
  .btn-primary:hover,
  .btn-secondary:hover { transform: translateY(-1px); }
  .btn-primary:active,
  .btn-secondary:active { transform: translateY(0); }
}
