/* ==========================================================================
   Site de Nicolas Dahomais : les effets « prestige » (10 novembre 2026), une couche posée sur
   epure.css et chargée par les quatre pages. Le fil conducteur : l'encre sur le papier. Le trait
   jaune est une encre vivante (encre.js), le portrait apparaît comme une tache d'encre, le fond noir
   monte comme une encre (prestige.js).
   Aucune bibliothèque. Rien ne bouge pour qui a demandé moins d'animations ; sans script, la page
   reste celle d'epure.css.
   Après chaque modification, changer le numéro dans les quatre pages (prestige.css?v=1 → v=2).
   ========================================================================== */
:root {
  --ocre: #E3A600;
  --courbe: cubic-bezier(0.2, 0.8, 0.1, 1);
  --courbe-douce: cubic-bezier(0.6, 0, 0.2, 1);
}

/* --- L'encre vivante du haut de page (encre.js) --------------------------------------------------- */
.ouverture { position: relative; overflow: hidden; isolation: isolate; }
.encre { position: absolute; inset: 0; z-index: -1; display: block; width: 100%; height: 100%; pointer-events: none; }
.encre-active .ouverture .surligne { background: none; animation: none; }

/* --- Le portrait à l'encre (encre.js) --------------------------------------------------------------- */
.portrait { position: relative; }
.portrait-encre { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

/* --- Les mots découpés (prestige.js) -------------------------------------------------------------- */
.mot, .mot-in { display: inline-block; white-space: nowrap; }
.filtres { position: absolute; width: 0; height: 0; overflow: hidden; }

/* --- Les compteurs mécaniques (prestige.js) ------------------------------------------------------- */
.compteur { display: inline-flex; height: 1em; line-height: 1; vertical-align: top; }
.compteur > span { display: block; height: 1em; }
.compteur .fixe { white-space: pre; }
.rouleau { overflow: hidden; }
.rouleau-bande { display: block; transform: translateY(calc(var(--pos, 0) * -1em)); }
.rouleau-bande > span { display: block; height: 1em; text-align: center; }
/* epure.css met en forme tous les span des chiffres (la légende) : pas ceux du compteur */
.chiffres b span, .mini-chiffres b span { margin: 0; font-size: inherit; line-height: 1; color: inherit; }
.chiffres b .compteur, .mini-chiffres b .compteur { display: inline-flex; }

/* --- Les étapes : le compteur ne sert qu'au défilement de côté -------------------------------------- */
.etapes-compteur { display: none; }

@media (prefers-reduced-motion: no-preference) {

  /* --- Le haut de page ----------------------------------------------------------------------------- */
  /* Le grand titre attend le script pour se poser ; s'il ne vient pas, il s'affiche quand même à 1,4 s */
  .js .ouverture .cadre > h1 { opacity: 0; animation: titre-secours 0.01s 1.4s forwards; }
  .js .ouverture .cadre > h1.decoupe { opacity: 1; animation: none; }
  @keyframes titre-secours { to { opacity: 1; } }
  .ouverture h1 .mot.mesure { width: calc(var(--l) * 1em); text-align: center; }
  .ouverture h1.decoupe .mot-in { animation: encrer 1.15s var(--courbe) backwards; animation-delay: calc(40ms + var(--i) * 75ms); }
  @keyframes encrer { from { opacity: 0; filter: blur(16px); transform: translateY(0.3em) scale(1.06); font-weight: 400; } }
  .arrivee-finie .ouverture h1.decoupe .mot-in { animation: none; }
  /* Les trois lignes sous le titre arrivent pendant qu'il se pose, quelles qu'elles soient selon la page */
  .js .ouverture .cadre > h1 + * { animation-delay: 0.5s; }
  .js .ouverture .cadre > h1 + * + * { animation-delay: 0.62s; }
  .js .ouverture .cadre > h1 + * + * + * { animation-delay: 0.74s; }
  /* Sans WebGL, le surligneur ordinaire se trace en même temps que l'encre l'aurait fait :
     0,55 s après le début de l'arrivée du titre (un nouveau nom relance l'animation) */
  .ouverture h1.decoupe .surligne { animation: surligner-titre 0.95s cubic-bezier(0.65, 0, 0.35, 1) 0.55s backwards; }
  @keyframes surligner-titre { from { background-size: 0% 44%; } }
  .arrivee-finie .ouverture h1.decoupe .surligne { animation: none; }

  /* --- Les titres des parties montent mot par mot --------------------------------------------------- */
  .anime .titre.decoupe .mot { clip-path: inset(-0.4em -0.25em -0.18em -0.25em); }
  .anime .titre.decoupe .mot-in { transform: translateY(140%) rotate(3deg); transform-origin: 0 100%; }
  .anime .titre.decoupe.visible .mot-in { transform: none; transition: transform 1.1s var(--courbe); transition-delay: calc(var(--i) * 55ms); }
  .anime .titre.decoupe.fini .mot-in { transition: none; }

  /* --- Les compteurs tournent ------------------------------------------------------------------------ */
  .compteur.roule .rouleau-bande { transition: transform 2s cubic-bezier(0.16, 0.86, 0.14, 1); transition-delay: var(--d, 0s); }
  .compteur.flou .rouleau-bande { filter: url(#flou-vertical); }
  .compteur.fini .rouleau-bande { transition: none; }

  /* --- Les boutons font rouler leur texte au survol --------------------------------------------------- */
  @media (hover: hover) and (pointer: fine) {
    .anime .pilule { overflow: hidden; }
    .pilule-texte { display: inline-block; text-shadow: 0 2.4em currentColor; transition: transform 0.55s var(--courbe-douce); }
    .pilule:hover .pilule-texte, .pilule:focus-visible .pilule-texte { transform: translateY(-2.4em); }
  }

  /* --- Les trois grandes situations s'empilent -------------------------------------------------------- */
  .anime .pile { display: block; }
  .anime .pile .carte-situation {
    position: sticky; top: calc(82px + var(--n, 0) * 12px);
    min-height: 60vh; margin-bottom: 9vh; padding: 40px 24px; justify-content: center; gap: 16px;
    transform-origin: 50% 0; transform: scale(calc(1 - var(--c, 0) * 0.07));
    box-shadow: 0 -16px 40px -30px rgba(17, 17, 17, 0.22);
  }
  .anime .pile .carte-situation:first-child { box-shadow: none; }
  .anime .pile .carte-situation:last-child { margin-bottom: 0; }
  .anime .pile .carte-situation::after {
    content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
    background: var(--encre); opacity: calc(var(--c, 0) * 0.06);
  }
  .anime .pile .carte-situation h3 { max-width: 880px; font-size: clamp(30px, 8.6vw, 36px); font-weight: 800; line-height: 1.08; letter-spacing: -0.035em; }
  .anime .pile .carte-situation p { flex: 0 0 auto; max-width: 560px; font-size: 17px; }
  /* La phrase se lit à mesure qu'on descend : les mots passent du gris à l'encre */
  .anime .phrase.lecture .mot { opacity: clamp(0.13, calc((var(--p, 1) * (var(--nb) + 3) - var(--i)) / 3), 1); }

  /* --- Le certificat se redresse ----------------------------------------------------------------------- */
  .anime .certificat-image { perspective: 1600px; }
  .anime .feuille {
    position: relative; border-radius: 18px; transform-origin: 50% 100%;
    transform:
      translateY(calc((1 - var(--p, 1)) * 80px))
      rotateX(calc((1 - var(--p, 1)) * 54deg))
      rotateZ(calc((1 - var(--p, 1)) * -8deg))
      scale(calc(0.9 + var(--p, 1) * 0.1))
      translateY(-50%) rotateX(var(--ry, 0deg)) rotateY(var(--rx, 0deg)) translateY(50%);
    box-shadow: 0 calc(14px + (1 - var(--p, 1)) * 60px) calc(36px + (1 - var(--p, 1)) * 60px) rgba(17, 17, 17, calc(0.18 - (1 - var(--p, 1)) * 0.1));
    transition: transform 0.7s var(--courbe), box-shadow 0.7s var(--courbe);
  }
  .anime .reflet {
    position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
    background: linear-gradient(105deg, rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, 0.75) 48%, rgba(255, 255, 255, 0) 58%) no-repeat;
    background-size: 300% 100%;
    background-position: calc(var(--p, 1) * 100% - var(--brillance, 0) * 45%) 0;
    mix-blend-mode: soft-light;
    transition: background-position 0.7s var(--courbe);
  }

  /* --- Les neuf étapes défilent de côté (ordinateur, prestige.js pose .defile-h) ---------------------------- */
  .defile-h .section-etapes { height: calc(100vh + var(--longueur, 0) * 1px); padding: 0; }
  .defile-h .etapes-scene {
    position: sticky; top: 0; height: 100vh; overflow: clip;
    display: flex; flex-direction: column; justify-content: center; padding-top: 70px;
  }
  .defile-h .etapes-tete { display: flex; align-items: flex-end; justify-content: space-between; gap: 40px; margin-bottom: 48px; text-align: left; }
  .defile-h .etapes-compteur {
    display: flex; align-items: flex-start; gap: 12px; margin: 0;
    font-weight: 800; letter-spacing: -0.05em; font-variant-numeric: tabular-nums;
  }
  .defile-h .etapes-courante { font-size: 120px; line-height: 0.8; }
  .defile-h .etapes-courante .compteur.roule .rouleau-bande { transition-duration: 0.7s; transition-delay: 0s; }
  .defile-h .etapes-total { padding-top: 4px; font-size: 22px; color: var(--texte-faible); letter-spacing: -0.01em; }
  .defile-h .etapes-fenetre { position: relative; }
  .defile-h .etapes { display: flex; gap: 24px; width: max-content; transform: translate3d(calc(var(--x, 0) * -1px), 0, 0); will-change: transform; }
  .defile-h .etapes li {
    flex: 0 0 380px; min-height: 290px;
    opacity: calc(0.38 + var(--proche, 1) * 0.62);
    transform: translateY(calc((1 - var(--proche, 1)) * 26px)) scale(calc(0.96 + var(--proche, 1) * 0.04));
  }
  .defile-h .etapes li.apparait { animation: none; }
  .defile-h .etapes li .numero { background-size: 0% 45%; transition: background-size 0.6s var(--courbe-douce); }
  .defile-h .etapes li.actif .numero { background-size: 100% 45%; }

  /* --- Le fond noir monte comme une encre ------------------------------------------------------------------ */
  .encre-montante { position: relative; }
  .vague { position: absolute; top: -1px; left: 0; display: block; width: 100%; height: 62px; fill: var(--dessus, var(--grise)); pointer-events: none; }

  /* « Sans courtier » se barre en descendant, « avec moi » arrive */
  .anime .paires .sans s {
    text-decoration: none; -webkit-box-decoration-break: clone; box-decoration-break: clone;
    background: linear-gradient(currentColor, currentColor) no-repeat 0 58% / calc(var(--p, 1) * 100%) 1.5px;
  }
  .anime .paires .avec {
    opacity: clamp(0, calc(var(--p, 1) * 2.2 - 0.9), 1);
    transform: translateY(calc((1 - clamp(0, calc(var(--p, 1) * 2.2 - 0.9), 1)) * 16px));
  }

  /* --- Le « 0 € » prend du poids (police variable) ------------------------------------------------------- */
  .anime .zero {
    font-weight: calc(400 + var(--p, 1) * 500);
    letter-spacing: calc(-0.01em - var(--p, 1) * 0.05em);
    transform: scale(calc(0.84 + var(--p, 1) * 0.16));
  }

  /* --- Les volets s'ouvrent en douceur (navigateurs récents, sinon d'un coup comme avant) ------------------- */
  :root { interpolate-size: allow-keywords; }
  .volet::details-content {
    block-size: 0; overflow-y: clip;
    transition: block-size 0.5s var(--courbe), content-visibility 0.5s allow-discrete;
  }
  .volet[open]::details-content { block-size: auto; }

  /* --- Le pied de page se découvre sous la page (ordinateur, prestige.js pose .rideau) ------------------------ */
  .rideau main { position: relative; z-index: 1; overflow: clip; border-radius: 0 0 48px 48px; background: var(--creme); }
  .rideau .pied { position: sticky; bottom: 0; z-index: 0; }
  .anime .pied-nom span { transform: translateY(calc((1 - var(--p, 1)) * 75%)); }
}

/* --- Le grand nom, en bas du pied de page ------------------------------------------------------------------ */
.pied-nom {
  overflow: clip; margin: 40px 0 0; padding-bottom: 0.04em;
  font-size: 19vw; font-weight: 900; line-height: 0.82; letter-spacing: -0.06em; color: var(--blanc);
}
.pied-nom span { display: inline-block; }
.pied-nom span + span { color: var(--jaune); }

/* ==========================================================================
   Écrans larges
   ========================================================================== */
@media (min-width: 900px) {
  /* Le nom tient sur une ligne, dans la largeur du cadre (8,2 fois la taille de la police) */
  .pied-nom { margin-top: 64px; font-size: min(calc((100vw - 80px) / 8.5), 122px); white-space: nowrap; }
}
@media (min-width: 900px) and (prefers-reduced-motion: no-preference) {
  .anime .entete-cadre { transition: max-width 0.8s var(--courbe), box-shadow 0.5s ease; }
  .anime .entete.reduite .entete-cadre { max-width: 1000px; box-shadow: 0 16px 40px rgba(17, 17, 17, 0.09); }

  .anime .pile .carte-situation { top: calc(116px + var(--n, 0) * 22px); min-height: min(64vh, 600px); margin-bottom: 14vh; padding: 64px 72px; gap: 22px; }
  .anime .pile .carte-situation h3 { font-size: 64px; }
  .anime .pile .carte-situation p { font-size: 20px; }

  .vague { height: 112px; }
}

/* À l'impression : tout est visible et à plat */
@media print {
  .encre, .portrait-encre, .vague, .filtres { display: none !important; }
  .encre-active .ouverture .surligne { background: linear-gradient(var(--jaune), var(--jaune)) no-repeat 0 84% / 100% 44% !important; }
  .js .ouverture .cadre > h1, .mot, .mot-in, .paires .avec, .feuille, .pied-nom span { opacity: 1 !important; transform: none !important; animation: none !important; filter: none !important; }
  .rouleau-bande { transform: translateY(calc(var(--cible, 0) * -1em)) !important; transition: none !important; }
  .defile-h .section-etapes { height: auto !important; }
  .defile-h .etapes-scene { position: static !important; height: auto !important; }
  .defile-h .etapes { flex-wrap: wrap; width: auto !important; transform: none !important; }
  .rideau .pied, .pile .carte-situation { position: static !important; }
}
