/* tuyau-v2.css : canalisation fluide (19/11/2026). Remplace le tuyau SVG de signature.js.
   Principe : le tuyau est fait de blocs HTML pleins, un par chapitre. Rien d'autre que transform et opacity ne change
   au défilement : le trait plein est un bloc qui grandit en scaleY (origine en haut), le collier et la branche
   apparaissent en scale/opacité. Aucun recalcul de mise en page, aucun repeint d'un grand SVG.
   Chemin 1 (Safari 26+, Chrome, Edge) : animation liée au défilement par le moteur (animation-timeline: view()),
   elle tourne hors du fil principal, donc sans retard sur le défilement.
   Chemin 2 (navigateurs plus anciens) : tuyau-v2.js écrit le même scaleY, une fois par image.
   Couleurs : variables de :root (--marine, --clair, --vin, --rose), une classe par aplat de chapitre. */

.tv2 { position: absolute; left: 0; top: 0; width: 100%; height: 0; pointer-events: none; z-index: 4; }
.tv2-seg { position: absolute; left: 0; width: calc(var(--x0) + var(--w) + 12px); }
.tv2-seg i { position: absolute; display: block; }

/* une classe par aplat : encre du tuyau et couleur de l'eau */
.tv2-c-clair, .tv2-c-sable { --tv2-ink: var(--marine); --tv2-eau: var(--vin); }
.tv2-c-marine { --tv2-ink: var(--clair); --tv2-eau: var(--rose); }
.tv2-c-vin { --tv2-ink: var(--clair); --tv2-eau: var(--marine); }

/* tuyau fantôme (toujours visible, 15 %) */
.tv2-ghost { left: var(--x0); top: 0; width: var(--w); height: 100%; background: var(--tv2-ink); opacity: 0.15; }

/* trait plein : un bloc de la hauteur du chapitre, mis à l'échelle en hauteur depuis le haut */
.tv2-fill { left: 0; top: 0; width: 100%; height: 100%; transform-origin: 50% 0; transform: scaleY(0); will-change: transform; }
.tv2-out { left: var(--x0); top: 0; width: var(--w); height: 100%; background: var(--tv2-ink); }
.tv2-in { left: calc(var(--x0) + (var(--w) - var(--in)) / 2); top: 0; width: var(--in); height: 100%; background: var(--tv2-eau); }

/* collier en tête de chapitre */
.tv2-collar { left: calc(var(--x0) - 5px); top: 0; width: calc(var(--w) + 10px); height: 10px; background: var(--tv2-ink); opacity: 0; transform: scale(0.5, 1); transition: opacity 0.2s linear, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1); }

/* branche coudée vers le titre : un trait horizontal et un coude à son extrémité */
.tv2-branch { left: var(--cx); top: calc(var(--ty) - var(--bh) / 2); width: var(--bw); height: var(--bh); background: var(--tv2-ink); transform-origin: 0 50%; transform: scaleX(0); transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1); }
.tv2-elbow { left: calc(var(--cx) + var(--bw) - 4px); top: calc(var(--ty) - (var(--w) + 8px) / 2); width: 8px; height: calc(var(--w) + 8px); background: var(--tv2-ink); opacity: 0; transform: scaleY(0.3); transition: opacity 0.15s linear 0.12s, transform 0.2s cubic-bezier(0.22, 1, 0.36, 1) 0.12s; }
.tv2-nobranch .tv2-branch, .tv2-nobranch .tv2-elbow { display: none; }

/* chemin 2 : le script pose .on quand le tuyau a atteint le point */
.tv2-seg.on-collar .tv2-collar { opacity: 1; transform: none; }
.tv2-seg.on-branch .tv2-branch { transform: none; }
.tv2-seg.on-branch .tv2-elbow { opacity: 1; transform: none; }

/* chemin 1 : animations liées au défilement. La ligne de tracé est à 70 % de la hauteur de l'écran :
   le chapitre commence à se dessiner quand son haut passe à 70 % (cover 30vh), il est plein quand son bas y passe. */
@supports (animation-timeline: view()) {
  .tv2-css .tv2-seg { view-timeline: --tv2 block; }
  .tv2-css .tv2-fill, .tv2-css .tv2-collar, .tv2-css .tv2-branch, .tv2-css .tv2-elbow {
    animation-timing-function: linear; animation-fill-mode: both; animation-duration: 1ms; animation-timeline: --tv2;
  }
  .tv2-css .tv2-fill { animation-name: tv2-grow; animation-range: cover 30vh cover calc(30vh + var(--h)); }
  .tv2-css .tv2-collar { animation-name: tv2-collar; animation-range: cover 30vh cover calc(30vh + 10px); transition: none; }
  .tv2-css .tv2-branch { animation-name: tv2-branch; animation-range: cover calc(30vh + var(--ty) - 6px) cover calc(30vh + var(--ty) + 14px); transition: none; }
  .tv2-css .tv2-elbow { animation-name: tv2-elbow; animation-range: cover calc(30vh + var(--ty) + 8px) cover calc(30vh + var(--ty) + 22px); transition: none; }
}
@keyframes tv2-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes tv2-collar { from { opacity: 0; transform: scale(0.5, 1); } to { opacity: 1; transform: none; } }
@keyframes tv2-branch { from { transform: scaleX(0); } to { transform: none; } }
@keyframes tv2-elbow { from { opacity: 0; transform: scaleY(0.3); } to { opacity: 1; transform: none; } }

/* mouvement réduit : tuyau entier, rien ne bouge */
@media (prefers-reduced-motion: reduce) {
  .tv2-fill, .tv2-collar, .tv2-branch, .tv2-elbow { animation: none !important; transition: none !important; transform: none !important; opacity: 1 !important; will-change: auto; }
}
.tv2-still .tv2-fill, .tv2-still .tv2-collar, .tv2-still .tv2-branch, .tv2-still .tv2-elbow { animation: none !important; transition: none !important; transform: none !important; opacity: 1 !important; will-change: auto; }

/* Fluidité Safari : les pastilles de communes (.zone-local-chips .city) héritaient d'un flou d'arrière-plan de styles.css
   (backdrop-filter: blur(10px)) alors que leur fond est un aplat opaque (--tuile). Le flou ne se voit pas et coûte une
   passe de rendu par pastille à chaque image du défilement. Même rendu, sans le coût. */
.zone-local-chips .city, .zone-local-chips .city.city-link { backdrop-filter: none; -webkit-backdrop-filter: none; }
