/* Mouvement de la boutique, chargé après les CSS de la maquette C (cercle.css, vues-2.css) sans en changer le dessin.
   Doctrine : n'animer que transform, opacity, filter et clip-path ; 100 à 450 ms (le héros suit le défilement) ;
   une seule courbe, sans dépassement ; les passages de page restent sous 450 ms, sauf le rideau de l'espace (700 ms) ; rien de caché derrière une animation. Sous .calme (robot ou mouvement réduit,
   posé par la mise en page) et sous prefers-reduced-motion, rien ne bouge : les règles nouvelles sont sous
   :root:not(.calme), et les pseudo-éléments des transitions de vue, que « * » n'atteint pas, sont coupés à la fin. */
:root { --ios: cubic-bezier(.32, .72, 0, 1); --glisse: 56px; }
@media (min-width: 761px) { :root { --glisse: 28px; } }

/* ---------- Transitions de page (React <ViewTransition>, src/app/(boutique)/template.tsx) ---------- */
/* Comme une application (04/12) : courtes, sans flou, et jamais deux pages à moitié visibles l'une sur l'autre. La page
   quittée s'efface en 140 ms, la nouvelle arrive juste derrière. Une seule courbe (--ios), aucun dépassement. Les
   transitions ne bloquent rien : ::view-transition laisse passer le doigt à la nouvelle page. */
::view-transition { pointer-events: none; }
/* Sans type (onglets du bas, en-tête, menu) : fondu enchaîné court, la nouvelle page monte de 10 px. */
::view-transition-old(.page) { animation: vt-sort 140ms ease-out both; }
::view-transition-new(.page) { animation: vt-monte 300ms var(--ios) 90ms both; }
/* D'une liste vers une fiche (nav-forward) et par le fil d'Ariane (nav-back) : la page glisse, comme une pile d'écrans. */
::view-transition-old(.nav-forward) { animation: vt-sort 140ms ease-out both, vt-vers-gauche 380ms var(--ios) both; }
::view-transition-new(.nav-forward) { animation: vt-de-droite 380ms var(--ios) 40ms both; }
::view-transition-old(.nav-back) { animation: vt-sort 140ms ease-out both, vt-vers-droite 380ms var(--ios) both; }
::view-transition-new(.nav-back) { animation: vt-de-gauche 380ms var(--ios) 40ms both; }
@keyframes vt-sort { to { opacity: 0; } }
@keyframes vt-monte { from { opacity: 0; transform: translateY(10px); } }
@keyframes vt-vers-gauche { to { transform: translateX(calc(var(--glisse) * -1)); } }
@keyframes vt-vers-droite { to { transform: translateX(var(--glisse)); } }
@keyframes vt-de-droite { from { opacity: 0; transform: translateX(var(--glisse)); } }
@keyframes vt-de-gauche { from { opacity: 0; transform: translateX(calc(var(--glisse) * -1)); } }

/* En-tête, annonce et onglets : ils ne bougent jamais, la page passe dessous. */
.annonce { view-transition-name: annonce; }
.entete { view-transition-name: entete; }
.onglets { view-transition-name: onglets; }
::view-transition-group(annonce), ::view-transition-group(entete), ::view-transition-group(onglets) { animation: none; z-index: 100; }
::view-transition-old(annonce), ::view-transition-old(entete), ::view-transition-old(onglets) { display: none; }
::view-transition-new(annonce), ::view-transition-new(entete), ::view-transition-new(onglets) { animation: none; }

/* Morph : la photo de la carte devient la grande photo de sa page (ui.tsx > Morph). Cadrage gardé, angles arrondis. */
::view-transition-group(.morph) { animation-duration: 420ms; animation-timing-function: var(--ios); z-index: 50; }
::view-transition-image-pair(.morph) { border-radius: var(--r); overflow: clip; }
::view-transition-old(.morph), ::view-transition-new(.morph) { height: 100%; object-fit: cover; }
/* Morph sans partenaire à l'écran (même carte sur les deux pages, l'une hors champ) : elle suit la page. */
::view-transition-old(.morph):only-child { animation: vt-sort 140ms ease-out both; }
::view-transition-new(.morph):only-child { animation: vt-monte 300ms var(--ios) 90ms both; }

@media (prefers-reduced-motion: no-preference) {
  :root:not(.calme) :is(.galerie .galerie__vues, .galerie .provisoire, .galerie .galerie__mention) { animation: vt-monte 280ms var(--ios) 380ms both; }
}

/* Hair Finder (type « quiz », BoutonParam) : la photo de la scène se fond dans la suivante, la question part vers le haut
   et la suivante monte ; la dernière réponse se fond dans la nuance conseillée. */
::view-transition-group(hf-fond) { animation-duration: 560ms; animation-timing-function: var(--ios); }
::view-transition-old(hf-fond), ::view-transition-new(hf-fond) { height: 100%; object-fit: cover; animation-duration: 560ms; }
::view-transition-old(.quiz) { animation: vt-sort 140ms ease-out both, hf-part 240ms var(--ios) both; }
::view-transition-new(.quiz) { animation: hf-arrive 380ms var(--ios) 60ms both; }
@keyframes hf-part { to { transform: translateY(-18px); } }
@keyframes hf-arrive { from { opacity: 0; transform: translateY(22px); } }

/* Fiche : le prix d'avant se fond dans le nouveau quand on change de longueur, de format ou de quantité. */
::view-transition-group(.prix) { animation-duration: 280ms; animation-timing-function: var(--ios); }

/* ---------- Passage entre le site et l'espace cliente (le même geste que l'entrée dans une fiche) ----------
   La photo de l'espace porte un nom : le bandeau (espace.css) et la photo de la connexion. Entre deux pages de l'espace,
   le bandeau se resserre ou s’ouvre (morph), le menu le suit sans se redessiner, le titre se fond et seule la colonne de droite bouge.
   Depuis le site (html[data-passage="espace"], template.tsx), le bandeau se déroule en rideau en se posant (léger
   zoom arrière), puis le titre et la page montent ; vers le site, il se relève. À la connexion, la photo de la page de
   connexion devient le bandeau. */
.ec-bandeau img, .ce__cadre img { view-transition-name: ec-photo; }
.ec-bandeau__texte { view-transition-name: ec-titre; }
.compte__nav { view-transition-name: ec-menu; }
::view-transition-group(ec-photo) { animation-duration: 520ms; animation-timing-function: var(--ios); z-index: 60; }
::view-transition-image-pair(ec-photo) { overflow: clip; }
::view-transition-old(ec-photo), ::view-transition-new(ec-photo) { height: 100%; object-fit: cover; }
::view-transition-new(ec-photo):only-child { animation: ec-rideau 700ms var(--ios) both; }
::view-transition-old(ec-photo):only-child { animation: ec-releve 380ms cubic-bezier(.4, 0, .2, 1) both; }
@keyframes ec-rideau { from { clip-path: inset(0 0 100% 0); transform: scale(1.06); } to { clip-path: inset(0); transform: none; } }
@keyframes ec-releve { from { clip-path: inset(0); } to { clip-path: inset(0 0 100% 0); } }

::view-transition-group(ec-titre) { animation: none; z-index: 61; }
::view-transition-old(ec-titre), ::view-transition-new(ec-titre) { inline-size: auto; }
::view-transition-old(ec-titre) { animation: vt-sort 140ms ease-out both; }
::view-transition-new(ec-titre) { animation: vt-monte 360ms var(--ios) 120ms both; }
html[data-passage="espace"]::view-transition-new(ec-titre) { animation-delay: 320ms; }

::view-transition-group(ec-menu) { animation-duration: 520ms; animation-timing-function: var(--ios); }
::view-transition-old(ec-menu) { display: none; }
::view-transition-new(ec-menu) { animation: none; }
::view-transition-new(ec-menu):only-child { animation: vt-monte 300ms var(--ios) 300ms both; }
::view-transition-old(ec-menu):only-child { display: block; animation: vt-sort 140ms ease-out both; }

/* Depuis le site : la page quittée recule plus franchement, l'espace monte quand le rideau est presque posé. */
html[data-passage="espace"]::view-transition-new(.page) { animation: vt-monte 360ms var(--ios) 300ms both; }
html[data-passage="site"]::view-transition-new(.page) { animation: vt-monte 320ms var(--ios) 160ms both; }

/* ---------- Retour sous le doigt ---------- */
/* Téléphone : pression de 140 ms ; un lien touché reste enfoncé (.presse, Coquille.tsx) jusqu'à la page suivante.
   La propriété scale, et non transform, que le défilement, les révélations et les boutons utilisent déjà. */
@media (hover: none) {
  :root:not(.calme) :is(.btn, .carte-lien, .option, .onglets a, .onglets button, .menu a, .fil a, .nav__menu):active,
  :root:not(.calme) .presse { scale: .97; }
  :root:not(.calme) .btn { transition: background-color .3s, color .3s, border-color .3s, transform .3s var(--doux), scale .14s var(--ios); }
  :root:not(.calme) .option { transition: background-color .25s, color .25s, border-color .25s, scale .14s var(--ios); }
  :root:not(.calme) .carte-lien[data-anim] { transition: opacity .55s var(--doux), transform .55s var(--doux), scale .14s var(--ios);
    transition-delay: var(--retard, 0ms), var(--retard, 0ms), 0s; }
  :root:not(.calme) :is(.carte-lien:not([data-anim]), .onglets a, .onglets button, .menu a, .fil a, .nav__menu) { transition: scale .14s var(--ios); }
  /* Le survol collé après un toucher ne fait plus grandir la photo pendant l'attente. */
  :root:not(.calme) :is(a, .carte-lien):hover :is(.zoom-lent img, img.zoom-lent), :root:not(.calme) .look:hover > img { transform: none; }
}
/* Ordinateur : la photo de la carte grandit de 3 % et laisse paraître la nuance portée. */
@media (hover: hover) {
  :root:not(.calme) .produit .zoom-lent img { transition: transform 1.2s var(--doux), opacity .6s var(--sortie); }
  :root:not(.calme) .produit:hover .zoom-lent img { transform: scale(1.03); }
}

/* ---------- Le carnet : la sélection d'une pastille se fond, rien d'autre (aucune sous .calme) ---------- */
:root:not(.calme) .pastille, :root:not(.calme) .pastille::before { transition: background-color .2s ease-out, border-color .2s ease-out, color .2s ease-out; }

/* ---------- Tiroir du panier, menu, feuille Instagram : glissée sans rebond, voile en fondu ---------- */
/* La visibilité tombe à la fin de la glissée : le tiroir et le menu sortent au lieu de disparaître d'un coup. */
:root:not(.calme) :is(.tiroir, .menu) { transition: transform .38s var(--ios), visibility 0s linear .38s; }
:root:not(.calme) :is(.tiroir, .menu).ouvert { transition: transform .38s var(--ios), visibility 0s; }
/* Le voile porte l'attribut hidden : il reste affiché le temps de son fondu (display discret), et part de 0. */
:root:not(.calme) .voile { transition: opacity .32s var(--ios), display .32s allow-discrete; }
@starting-style { :root:not(.calme) .voile.ouvert { opacity: 0; } }
:root:not(.calme) .tel-plein { animation: vt-monte 320ms var(--ios) both; }
@media (max-width: 760px) { :root:not(.calme) .tel-plein { animation: feuille-monte 380ms var(--ios) both; } }
@keyframes feuille-monte { from { transform: translateY(100%); } }

/* ---------- Retour du navigateur ---------- */
/* React rend le Retour et l'Avance d'un bloc, sans transition de vue : le contenu arrive alors en fondu (Coquille.tsx). */
:root:not(.calme) main.retour { animation: vt-retour 320ms var(--ios) both; }
/* Retour du navigateur : la page revient de la gauche, sans jamais passer par le blanc (fondu depuis 0 = écran vide sur Safari). */
@keyframes vt-retour { from { opacity: .55; transform: translateX(calc(var(--glisse) * -.5)); } }

/* ---------- Suivi de commande : le trait de la frise se remplit jusqu'à l'étape en cours ---------- */
/* Le seul mouvement de la page : chaque segment franchi se trace à son tour, de haut en bas (transform seul). */
@media (prefers-reduced-motion: no-preference) {
  :root:not(.calme) .frise__etape--faite::after { transform-origin: top; animation: frise-trace 360ms var(--ios) both; animation-delay: calc(var(--i, 0) * 120ms + 150ms); }
}
@keyframes frise-trace { from { transform: scaleY(0); } }

/* ---------- Le Cercle : la barre de la cagnotte se remplit à l'ouverture, une fois (transform seul) ---------- */
@media (prefers-reduced-motion: no-preference) {
  :root:not(.calme) .cagnotte__piste span { animation: cagnotte-remplit 450ms var(--ios) 150ms both; }
}
@keyframes cagnotte-remplit { from { transform: scaleX(0); } }

/* ---------- Calme et mouvement réduit : les pseudo-éléments des transitions de vue aussi ---------- */
html.calme::view-transition-group(*), html.calme::view-transition-image-pair(*),
html.calme::view-transition-old(*), html.calme::view-transition-new(*) { animation: none !important; }
html.calme::view-transition-old(*) { display: none; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-image-pair(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  ::view-transition-old(*) { display: none; }
}

/* ---------- Vivant : défilement, survol, pression, glisser (03/12, « plus d'effets, une impression d'app ») ----------
   Seulement transform/scale/translate, opacity et clip-path. Les animations liées au défilement sont sous
   @supports (animation-timeline: view()) : un navigateur qui ne sait pas les jouer montre tout, tout de suite. Rien sous
   .calme ni en mouvement réduit. Les photos s'animent avec la propriété scale, le survol garde transform : ils s'ajoutent. */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    /* Les photos se dévoilent par le bas en entrant à l'écran, puis se posent. */
    :root:not(.calme) :is(.cq-produit__photo, .cq-entree__photo, .nu-tuile__photo, .nu-famille__photo, .nu-intro__photo, .nu-etapes__photo,
      .fi-avantages__photo, .fi-recompenses__photo, .fi-parrainage figure, .hf-carte__photo, .guide__mini, .bande-nuance__media) {
      animation: vivant-devoile linear both; animation-timeline: view(); animation-range: entry 0% cover 32%;
    }
    :root:not(.calme) :is(.cq-produit__photo, .cq-entree__photo, .nu-intro__photo, .nu-etapes__photo, .fi-avantages__photo,
      .fi-recompenses__photo, .fi-parrainage figure, .hf-carte__photo) img {
      animation: vivant-pose linear both; animation-timeline: view(); animation-range: entry 0% cover 45%;
    }
    /* Les grandes photos glissent un peu moins vite que la page (parallaxe douce). */
    :root:not(.calme) :is(.cq-recit__photo img, .nu-bandeau > img, .nu-ouverture__photo img, .fi-ouverture__photo img) {
      scale: 1.1; animation: vivant-parallaxe linear both; animation-timeline: view(); animation-range: cover;
    }
    /* Les titres de section montent en se dévoilant. */
    :root:not(.calme) :is(.cq-tete, .cq-section > .cq-titre, .nu-titre, .fi-titre, .hf-aussi > h2, .cq-citation, .guide__longueur) {
      animation: vivant-monte linear both; animation-timeline: view(); animation-range: entry 0% entry 90%;
    }
  }
}
@keyframes vivant-devoile { from { clip-path: inset(14% 0 0 0); } to { clip-path: inset(0); } }
@keyframes vivant-pose { from { scale: 1.12; } to { scale: 1; } }
@keyframes vivant-parallaxe { from { translate: 0 -4%; } to { translate: 0 4%; } }
@keyframes vivant-monte { from { opacity: 0; translate: 0 22px; } to { opacity: 1; translate: 0 0; } }

/* Survol (souris) : la photo de la carte grandit, le lien se retrace, le bouton reçoit un voile qui glisse. */
@media (hover: hover) {
  :root:not(.calme) :is(.cq-produit__photo, .cq-entree__photo, .fi-avantages__photo, .fi-recompenses__photo, .hf-carte__photo, .nu-intro__photo) img { transition: transform 1.2s var(--doux); }
  :root:not(.calme) :is(.cq-produit, .cq-entree, .fi-avantages li, .fi-recompenses li, .hf-carte, .nu-intro):hover img { transform: scale(1.045); }
  :root:not(.calme) .cq-lien:hover { animation: vivant-trace .5s var(--ios); }
  :root:not(.calme) .cq-btn { position: relative; overflow: hidden; isolation: isolate; }
  :root:not(.calme) .cq-btn::after { content: ''; position: absolute; inset: 0; z-index: -1; background: rgba(255, 253, 250, .14); transform: translateX(-101%); transition: transform .5s var(--ios); }
  :root:not(.calme) .cq-btn:hover:not(:disabled)::after { transform: none; }
}
@keyframes vivant-trace { from { text-decoration-color: transparent; text-underline-offset: 10px; } to { text-decoration-color: var(--or); text-underline-offset: 6px; } }

/* Pression (doigt et souris) : tout ce qui se touche s'enfonce un instant, comme une app. */
:root:not(.calme) :is(.cq-btn, .guide__vignette, .guide__nuances button, .nu-tuile, .hf-choix, .teintes a, .teintes button, .nu-pastille, .cq-onglets a, .bienvenue__non) {
  transition-property: background, color, border-color, box-shadow, transform, scale; transition-duration: .3s, .3s, .3s, .3s, .3s, .14s; transition-timing-function: var(--sortie), var(--sortie), var(--sortie), var(--sortie), var(--sortie), var(--ios);
}
:root:not(.calme) :is(.cq-btn, .guide__vignette, .guide__nuances button, .nu-tuile, .hf-choix, .teintes a, .teintes button, .nu-pastille, .cq-onglets a, .bienvenue__non):active:not(:disabled) { scale: .97; }

/* Glisser à la souris (Coquille.tsx) : pendant la glissée, ni aimantation ni sélection de texte. */
.glisse { scroll-snap-type: none !important; cursor: grabbing; user-select: none; }
.glisse * { pointer-events: none; }

/* Barre d'onglets du téléphone : l'icône de l'onglet ouvert se pose à son arrivée (sans rebond). */
:root:not(.calme) .onglets [aria-current="page"] svg { animation: vivant-onglet .35s var(--ios); }
@keyframes vivant-onglet { from { scale: .8; opacity: .6; } to { scale: 1; opacity: 1; } }
