/* Tunnel de contact : plus vivant. Titres mot à mot, choix qui répondent au clic, étapes qui glissent dans le sens du parcours,
   compteur qui tourne, résultat qui s'écrit, et une petite scène à l'envoi (enveloppe, avion en papier, confettis).
   Tout est désactivé avec « réduire les animations ». */
.tunnel-actif .tunnel fieldset { animation: none; }
.tunnel-compteur b { display: inline-block; min-width: 1ch; }
.tunnel-compteur b.change { animation: compteur-roule .55s cubic-bezier(.2, .9, .25, 1); }
@keyframes compteur-roule { 0% { transform: translateY(70%); opacity: 0; } 100% { transform: none; opacity: 1; } }
.tunnel-filet { position: relative; overflow: visible; }
.tunnel-filet i { transition: transform .8s cubic-bezier(.34, 1.4, .5, 1); position: relative; }
.tunnel-filet i::after { content: ""; position: absolute; right: -1px; top: -3px; width: 7px; height: 7px; border-radius: 50%; background: var(--peche); box-shadow: 0 0 14px 3px rgba(243, 163, 149, .7); }

@media (prefers-reduced-motion: no-preference) {
  /* étapes : elles glissent dans le sens du parcours */
  .etape.entre-avant { animation: etape-avant .65s cubic-bezier(.2, .9, .25, 1) both; }
  .etape.entre-arriere { animation: etape-arriere .65s cubic-bezier(.2, .9, .25, 1) both; }
  .etape.sort { animation: etape-sort .3s cubic-bezier(.5, 0, .9, .4) both; pointer-events: none; }
  @keyframes etape-avant { from { opacity: 0; transform: translate3d(54px, 0, 0); } to { opacity: 1; transform: none; } }
  @keyframes etape-arriere { from { opacity: 0; transform: translate3d(-54px, 0, 0); } to { opacity: 1; transform: none; } }
  @keyframes etape-sort { to { opacity: 0; transform: translate3d(-40px, 0, 0); } }

  /* titres : mot à mot, qui montent */
  .tunnel legend .mot { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .1em; margin-bottom: -.1em; }
  .tunnel legend .mot > span { display: inline-block; }
  .etape:not([hidden]) legend { animation: none; }
  .etape:not([hidden]) legend .mot > span { animation: mot-monte .8s cubic-bezier(.2, .9, .25, 1) backwards; animation-delay: calc(var(--i, 0) * 70ms + 60ms); }
  @keyframes mot-monte { from { transform: translate3d(0, 105%, 0) rotate(3deg); } to { transform: none; } }

  /* choix : arrivée en cascade, réponse au clic */
  .choix-item { overflow: hidden; isolation: isolate; }
  .choix-item::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(243, 163, 149, .2), rgba(243, 163, 149, 0)); transform: scaleX(0); transform-origin: left; transition: transform .5s cubic-bezier(.2, .9, .25, 1); }
  .choix-item:hover::before { transform: scaleX(.35); }
  .choix-item.choisi::before { transform: scaleX(1); transition-duration: .4s; }
  .choix.valide .choix-item:not(.choisi) { opacity: .28; transform: translate3d(0, 0, 0) scale(.985); transition: opacity .35s, transform .35s; }
  .choix-item.choisi { animation: choisi .45s cubic-bezier(.3, 1.6, .5, 1); }
  .choix-item.choisi i { transform: translateX(18px); transition: transform .45s cubic-bezier(.3, 1.6, .5, 1); }
  @keyframes choisi { 0% { transform: scale(1); } 35% { transform: scale(1.015); } 100% { transform: scale(1); } }

  /* champs : trait qui se dessine au focus */
  .champ { position: relative; }
  .champ::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: linear-gradient(90deg, var(--peche), #8A6192); transform: scaleX(0); transform-origin: left; transition: transform .5s cubic-bezier(.2, .9, .25, 1); pointer-events: none; }
  .champ:focus-within::after { transform: scaleX(1); }
  .champs .champ { animation: choix-entree .7s cubic-bezier(.2, .9, .25, 1) backwards; }
  .champs .champ:nth-child(1) { animation-delay: .1s; } .champs .champ:nth-child(2) { animation-delay: .17s; } .champs .champ:nth-child(3) { animation-delay: .24s; }
  .champs .champ:nth-child(4) { animation-delay: .31s; } .champs .champ:nth-child(5) { animation-delay: .38s; } .champs .champ:nth-child(6) { animation-delay: .45s; }
  .resultat:not([hidden]) .resultat-titre { animation: choix-entree .8s cubic-bezier(.2, .9, .25, 1) backwards; }
  .resultat:not([hidden]) .resultat-note { animation: choix-entree .8s .2s cubic-bezier(.2, .9, .25, 1) backwards; }
}

/* bouton d'envoi : état « en cours » */
.tunnel .bouton.envoi-encours { pointer-events: none; opacity: 1; }
.tunnel .bouton.envoi-encours::after { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: tourne .7s linear infinite; }
.tunnel .bouton.envoi-encours span[aria-hidden] { display: none; }
@keyframes tourne { to { transform: rotate(360deg); } }

/* ---------- Scène d'envoi : seule, centrée et grande, puis la confirmation s'écrit ---------- */
.tunnel.part { animation: formulaire-part .55s cubic-bezier(.5, 0, .9, .4) forwards; pointer-events: none; }
@keyframes formulaire-part { to { opacity: 0; transform: translate3d(0, -26px, 0) scale(.98); } }
.confirmation.avec-scene > .label, .confirmation.avec-scene > .confirmation-texte, .confirmation.avec-scene > .lien { opacity: 0; }
.confirmation.revele > .label, .confirmation.revele > .confirmation-texte, .confirmation.revele > .lien { opacity: 1; }
.envoi-scene { position: relative; width: 100%; height: min(520px, 62vh); margin: 0 auto; color: var(--peche); display: grid; place-items: center; }
.envoi-scene svg { position: absolute; left: 50%; top: 50%; width: min(330px, 70vw); height: auto; aspect-ratio: 150 / 112; transform: translate(-50%, -50%); overflow: visible; }
.envoi-scene .corps { fill: rgba(243, 163, 149, .14); stroke: currentColor; stroke-width: 2.6; stroke-linejoin: round; }
.envoi-scene .rabat { fill: rgba(243, 163, 149, .26); stroke: currentColor; stroke-width: 2.6; stroke-linejoin: round; transform-box: view-box; transform-origin: 75px 12px; }
.envoi-scene .lettre { fill: #F3EEEA; stroke: currentColor; stroke-width: 2; }
.envoi-scene .avion { opacity: 0; filter: drop-shadow(0 10px 18px rgba(243, 163, 149, .35)); }
.envoi-scene .avion path { fill: currentColor; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.envoi-scene .avion .pli { fill: rgba(26, 18, 16, .3); stroke: none; }
.envoi-scene .halo { position: absolute; left: 50%; top: 50%; width: min(520px, 90vw); aspect-ratio: 1; margin: calc(min(520px, 90vw) / -2) 0 0 calc(min(520px, 90vw) / -2); border-radius: 50%; background: radial-gradient(closest-side, rgba(243, 163, 149, .28), rgba(138, 97, 146, .12) 55%, transparent 72%); opacity: 0; pointer-events: none; }
.envoi-scene .coche { position: absolute; left: 50%; top: 50%; width: clamp(96px, 16vw, 140px); height: auto; aspect-ratio: 1; margin: 0; transform: translate(-50%, -50%); opacity: 0; }
.envoi-scene .coche circle { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-dasharray: 190; stroke-dashoffset: 190; }
.envoi-scene .coche path { fill: none; stroke: currentColor; stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 50; stroke-dashoffset: 50; }

@media (prefers-reduced-motion: no-preference) {
  /* chronologie : enveloppe 0-1 s · pliage 1 s · avion 1,2-3 s · coche 3 s · sortie 4,1 s */
  .envoi-scene.go .halo { animation: halo 3.6s .2s ease-out forwards; }
  .envoi-scene.go .enveloppe { animation: env-entre .9s cubic-bezier(.3, 1.5, .5, 1) both, env-part .5s 1.05s cubic-bezier(.6, 0, .9, .5) forwards; }
  .envoi-scene.go .rabat { animation: rabat-ferme .6s .45s cubic-bezier(.4, 0, .2, 1) both; }
  .envoi-scene.go .lettre { animation: lettre-entre .6s .2s cubic-bezier(.3, 1.2, .5, 1) both; }
  .envoi-scene.go .avion { animation: avion-vole 1.9s 1.2s cubic-bezier(.4, 0, .5, 1) forwards; }
  .envoi-scene.go .coche { animation: coche-apparait .6s 3.05s cubic-bezier(.3, 1.5, .5, 1) forwards; }
  .envoi-scene.go .coche circle { animation: dessine .7s 3.1s ease-out forwards; }
  .envoi-scene.go .coche path { animation: dessine .45s 3.65s ease-out forwards; }
  .envoi-scene.fin { animation: scene-sort .55s cubic-bezier(.5, 0, .9, .4) forwards; }
  .confirmation.revele > .label, .confirmation.revele > .confirmation-texte, .confirmation.revele > .lien { animation: choix-entree .9s cubic-bezier(.2, .9, .25, 1) backwards; }
  .confirmation.revele > .confirmation-texte { animation-delay: .15s; } .confirmation.revele > .lien { animation-delay: .35s; }
  @keyframes halo { 0% { opacity: 0; transform: scale(.5); } 35% { opacity: 1; transform: scale(1); } 100% { opacity: .0; transform: scale(1.25); } }
  @keyframes env-entre { from { opacity: 0; transform: translate(-50%, -30%) rotate(-12deg) scale(.4); } to { opacity: 1; transform: translate(-50%, -50%); } }
  @keyframes env-part { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(.35) rotate(8deg); } }
  @keyframes rabat-ferme { from { transform: perspective(500px) rotateX(180deg); } to { transform: perspective(500px) rotateX(0); } }
  @keyframes lettre-entre { from { transform: translate3d(0, -40px, 0); opacity: 0; } to { transform: none; opacity: 1; } }
  @keyframes avion-vole {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(.3) rotate(-8deg); }
    10%  { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(-12deg); }
    28%  { transform: translate(-58%, -44%) scale(1.1) rotate(-26deg); }
    55%  { transform: translate(calc(-50% + 18vw), calc(-50% - 16vh)) scale(1.05) rotate(-18deg); }
    80%  { opacity: 1; transform: translate(calc(-50% + 46vw), calc(-50% - 44vh)) scale(.7) rotate(-26deg); }
    100% { opacity: 0; transform: translate(calc(-50% + 70vw), calc(-50% - 68vh)) scale(.4) rotate(-30deg); }
  }
  @keyframes coche-apparait { from { opacity: 0; transform: translate(-50%, -50%) scale(.5); } to { opacity: 1; transform: translate(-50%, -50%); } }
  @keyframes dessine { to { stroke-dashoffset: 0; } }
  @keyframes scene-sort { to { opacity: 0; transform: scale(.88) translate3d(0, -20px, 0); } }
}
@media (prefers-reduced-motion: reduce) { .envoi-scene { height: 120px; } .envoi-scene .enveloppe, .envoi-scene .avion, .envoi-scene .halo { display: none; } .envoi-scene .coche { opacity: 1; } .envoi-scene .coche circle, .envoi-scene .coche path { stroke-dashoffset: 0; } .confirmation.avec-scene > .label, .confirmation.avec-scene > .confirmation-texte, .confirmation.avec-scene > .lien { opacity: 1; } }
.confettis { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 60; pointer-events: none; }
