/* chapitres.css — chorégraphie au scroll de l'accueil (plan maître §4.2), sur le balisage de l'UX :
   ouverture (vin) · la cave (papier) · deux rives (sauge → bois) · le carton (bois) · Pierre (vin) · le carnet (vin).
   Les animations suivent le défilement (animation-timeline), sans JavaScript par image ; Lenis pilote le scroll natif.
   Seulement transform, opacity et clip-path. Sans support (Firefox < 159) ou en mouvement réduit : tout est empilé et immobile.
   Les couleurs d'univers (calque fixe, en-tête, pied) sont dans transitions.css. */

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {

    /* 1. Ouverture : en quittant l'écran, le film s'approche, le texte s'éloigne */
    .home-hero { overflow: clip; }
    .home-hero video { animation: mm-film-approche linear both; animation-timeline: view(); animation-range: exit 0% exit 100%; }
    .home-hero .home-hero-copy { animation: mm-texte-eloigne linear both; animation-timeline: view(); animation-range: exit 0% exit 70%; }

    /* 3. Deux rives, en colonnes (≥ 768 px) : la photo reste à l'écran pendant les deux textes ;
          celle d'Israël monte sur celle de France quand on passe au second texte (l'univers passe de sauge à bois). */
    @media (min-width: 768px) {
      html.mm-univers .home-rives { timeline-scope: --mm-rive-israel; }
      html.mm-univers .rive[data-rive="israel"] { view-timeline: --mm-rive-israel block; }
      html.mm-univers .rives-media {
        position: sticky; top: var(--compact-nav-height, 55px); align-self: start;
        height: calc(100svh - var(--compact-nav-height, 55px)); grid-template-rows: minmax(0, 1fr);
      }
      html.mm-univers .rive-photo { grid-area: 1 / 1; min-height: 0; }
      html.mm-univers .rive-photo[data-rive="israel"] {
        animation: mm-rive-monte linear both; animation-timeline: --mm-rive-israel; animation-range: entry 10% entry 70%;
      }
      html.mm-univers .rive-photo[data-rive="israel"] img {
        animation: mm-rive-pose linear both; animation-timeline: --mm-rive-israel; animation-range: entry 10% cover 60%;
      }
    }
    /* au téléphone, empilé : chaque photo s'ouvre comme une fenêtre */
    @media (max-width: 767px) {
      .rive-photo { animation: mm-fenetre linear both; animation-timeline: view(); animation-range: entry 0% entry 90%; }
    }

    /* 4. Le carton : une fenêtre qui s'ouvre ; la photo glisse dans son cadre (niveau « plein » seulement : c'est ce qui coûte) */
    @media (min-width: 768px) {
      .home-carton { animation: mm-fenetre linear both; animation-timeline: view(); animation-range: entry 0% entry 80%; }
      html[data-mm-niveau="plein"] .home-carton picture img { animation: mm-photo-glisse linear both; animation-timeline: view(); animation-range: entry 0% exit 100%; }
    }
    @media (max-width: 767px) {
      .home-carton picture { animation: mm-fenetre linear both; animation-timeline: view(); animation-range: entry 0% entry 90%; }
    }

    /* 5. Pierre : la photo descend plus lentement que la page (niveau « plein ») */
    html[data-mm-niveau="plein"] .ed-home-portrait { overflow: clip; }
    html[data-mm-niveau="plein"] .ed-home-portrait .ed-home-photo { animation: mm-photo-glisse linear both; animation-timeline: view(); animation-range: entry 0% exit 100%; }
  }
}

/* Récits (gabarits du front, editorial.* ; vague 2b). L'ouverture s'approche quand on la quitte, comme le film de l'accueil ;
   les photos de chapitre s'ouvrent comme une fenêtre en entrant et sont entières une fois à l'écran (jamais une bouteille
   coupée au repos) ; la carte d'un chapitre plein cadre monte sur le bas de sa photo. Le texte, lui, est révélé une fois
   (motion.js), les citations et les grandes phrases ligne à ligne. Mouvement réduit ou sans support : immobile. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    #story-view .ed-cover-img { animation: mm-film-approche linear both; animation-timeline: view(); animation-range: exit 0% exit 100%; }
    #story-view .ed-ch-media { animation: mm-fenetre linear both; animation-timeline: view(); animation-range: entry 0% entry 80%; }
    #story-view .ed-ch--plein .ed-ch-carte { animation: mm-carte-monte linear both; animation-timeline: view(); animation-range: entry 0% entry 70%; }
  }
}

@keyframes mm-film-approche { to { transform: scale(1.08); } }
@keyframes mm-carte-monte { from { transform: translateY(var(--mm-d-l)); } }
@keyframes mm-texte-eloigne { to { opacity: 0; transform: translateY(-8vh); } }
@keyframes mm-fenetre { from { clip-path: inset(6% 5% 0 5%); } to { clip-path: inset(0); } }
@keyframes mm-photo-glisse { from { transform: translateY(-5%) scale(1.1); } to { transform: translateY(5%) scale(1.1); } }
@keyframes mm-rive-monte { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0); } }
@keyframes mm-rive-pose { from { transform: scale(1.12); } to { transform: none; } }
