/* Animations d'Argos (chantier Stargate, 28/10/2026) : chargé par les pages Ventes et Pilotage marketing, avec shine-anim.js.
   Règles : seul l'affichage bouge (jamais un chiffre, un calcul ou un filtre), glissements et fondus seulement (la carte graphique s'en charge),
   de 0,2 à 0,6 s, rien en boucle sauf le gabarit de chargement. Tout est coupé par le réglage « Réduire les animations » et par celui du système.
   Démos et explications : artefact « Argos en mouvement ». */

/* 1 · Tuiles : chiffres à largeur fixe, pour que la tuile ne tremble pas pendant qu'ils défilent */
.tile .value { font-variant-numeric: tabular-nums; }

/* 2 · Barres qui poussent depuis l'axe, mois par mois ; la courbe N-1 se trace ensuite */
.anim-mois { transform-box: fill-box; transform-origin: 50% 100%; animation: anim-pousse .55s cubic-bezier(.2,.8,.2,1) backwards; animation-delay: calc(var(--i, 0) * 25ms); transition: opacity .2s; }
.anim-trace { stroke-dasharray: var(--long); animation: anim-trace .8s ease-out .3s backwards; transition: opacity .2s; }
.anim-point { animation: anim-apparait .3s ease-out backwards; animation-delay: calc(.5s + var(--i, 0) * 25ms); transition: opacity .2s; }
@keyframes anim-pousse { from { transform: scaleY(0); } }
@keyframes anim-trace { from { stroke-dashoffset: var(--long); } }
@keyframes anim-apparait { from { opacity: 0; } }
/* Barres horizontales et barre d'objectif : elles se remplissent depuis la gauche */
.hb .fill, .hb .stack, .obj-barre .fait { transform-origin: left center; animation: anim-remplir .6s cubic-bezier(.2,.8,.2,1) backwards; }
.hbars > .hb:nth-child(2) .fill, .hbars > .hb:nth-child(2) .stack { animation-delay: 40ms; }
.hbars > .hb:nth-child(3) .fill, .hbars > .hb:nth-child(3) .stack { animation-delay: 80ms; }
.hbars > .hb:nth-child(4) .fill, .hbars > .hb:nth-child(4) .stack { animation-delay: 120ms; }
.hbars > .hb:nth-child(5) .fill, .hbars > .hb:nth-child(5) .stack { animation-delay: 160ms; }
.hbars > .hb:nth-child(n+6) .fill, .hbars > .hb:nth-child(n+6) .stack { animation-delay: 200ms; }
@keyframes anim-remplir { from { transform: scaleX(0); } }
/* Camembert : il arrive en tournant légèrement */
.pie-wrap svg { animation: anim-donut .55s cubic-bezier(.2,.8,.2,1) backwards; }
@keyframes anim-donut { from { opacity: 0; transform: rotate(-20deg) scale(.94); } }

/* 3 · Survol qui éclaire : le mois survolé reste net, les autres s'estompent */
svg.anim-focus .anim-mois:not(.on) { opacity: .32; }
.hb { transition: opacity .2s; }
.hbars:has(.hb:hover) .hb:not(:hover) { opacity: .42; }
.pie-wrap .part { transform-box: view-box; transform-origin: 50% 50%; transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .2s; }
.pie-wrap svg:has(.part:hover) .part:not(:hover) { opacity: .45; }
.pie-wrap svg .part:hover { opacity: 1; transform: scale(1.035); }

/* 4 · Légende qui éclaire une famille (sans rien retirer des totaux) */
.legend > span { border-radius: 999px; padding: 1px 7px; margin: -1px -7px; transition: background .15s; }
.legend > span.anim-on { background: var(--bar-track, rgba(60,60,67,0.08)); }
svg .anim-eteint { opacity: .16; transition: opacity .2s; }

/* 5 et 6 · Arrivée d'un onglet : en cascade la première fois, en fondu ensuite */
.anim-cascade { animation: anim-monte .4s cubic-bezier(.2,.8,.2,1) backwards; animation-delay: calc(var(--i, 0) * 40ms); }
.anim-arrive { animation: anim-arrive .28s cubic-bezier(.2,.8,.2,1) backwards; }
@keyframes anim-monte { from { opacity: 0; transform: translateY(14px) scale(.985); } }
@keyframes anim-arrive { from { opacity: 0; transform: translateY(6px); } }

/* 7 · Info-bulle qui glisse d'un mois à l'autre au lieu de sauter */
.tip.anim-glisse { transition: left .12s cubic-bezier(.2,.8,.2,1), top .12s cubic-bezier(.2,.8,.2,1); }

/* 8 · Tri des tableaux au clic sur l'en-tête */
th.anim-triable { cursor: pointer; user-select: none; transition: color .15s; }
th.anim-triable:hover { color: var(--ink, #0b0b0b); }
th.anim-triable:focus-visible { outline: none; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent, #2a78d6) 55%, transparent); border-radius: 6px; }
th.anim-triable[aria-sort="descending"]::after, th.anim-triable[aria-sort="ascending"]::after { display: inline-block; margin-left: 4px; font-size: 9px; color: var(--accent, #2a78d6); }
th.anim-triable[aria-sort="descending"]::after { content: "▼"; }
th.anim-triable[aria-sort="ascending"]::after { content: "▲"; }

/* 9 · Bouton qui montre « en cours » puis une coche ; petite confirmation en bas de l'écran */
.anim-ico { display: inline-grid; width: 14px; height: 14px; margin-right: 5px; vertical-align: -2px; flex: none; }
.btn.anim-btn .anim-ico { margin-right: 0; }
.anim-ico svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.anim-rond { stroke-dasharray: .65 .35; transform-origin: 12px 12px; opacity: 0; }
.anim-coche { stroke-dasharray: 1; stroke-dashoffset: 1; }
.anim-btn[data-anim-etat="cours"] .anim-rond { opacity: 1; animation: anim-tourne .8s linear infinite; }
.anim-btn[data-anim-etat="fait"] { color: var(--good, #006300); }
.anim-btn[data-anim-etat="fait"] .anim-coche, .anim-toast.vu .anim-coche { animation: anim-coche .4s cubic-bezier(.2,.8,.2,1) .05s forwards; }
.anim-btn[data-anim-etat="erreur"] { color: var(--bad, #b42828); }
@keyframes anim-tourne { to { transform: rotate(360deg); } }
@keyframes anim-coche { to { stroke-dashoffset: 0; } }
.anim-toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 60; display: flex; align-items: center; gap: 4px;
  padding: 10px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--ink, #0b0b0b); pointer-events: none;
  background: var(--glass-strong, rgba(255,255,255,0.85)); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-edge-2, rgba(255,255,255,0.25)); box-shadow: 0 12px 32px rgba(15,20,40,0.18);
  opacity: 0; transform: translate(-50%, 12px); transition: opacity .2s, transform .35s cubic-bezier(.34,1.56,.64,1); }
.anim-toast.vu { opacity: 1; transform: translate(-50%, 0); }
.anim-toast .anim-ico { color: var(--good, #006300); width: 16px; height: 16px; }
@media (max-width: 900px) { .anim-toast { bottom: calc(92px + env(safe-area-inset-bottom, 0px)); } }

/* 10 · Gabarit gris pendant le premier chargement d'une carte (remplacé par le contenu dès qu'il arrive) */
.anim-gabarit { display: grid; gap: 10px; padding: 6px 0; }
.anim-gabarit i { display: block; height: 14px; border-radius: 7px; background: var(--grid, rgba(60,60,67,0.12)); position: relative; overflow: hidden; }
.anim-gabarit i:nth-child(2) { width: 88%; }
.anim-gabarit i:nth-child(3) { width: 74%; }
.anim-gabarit i:nth-child(4) { width: 58%; }
.anim-gabarit i::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ink, #0b0b0b) 9%, transparent), transparent); animation: anim-brille 1.3s ease-in-out infinite; }
@keyframes anim-brille { to { transform: translateX(100%); } }

/* 15 · Livrée racing de l'accueil : bandes fixes sur le fond habituel (au-dessus des taches de couleur, sous tout le reste) */
.anim-livree { --livree-1: var(--accent, #2a78d6); --livree-2: #eb6834; --livree-filet: rgba(255,255,255,0.95); --trainee: rgba(255,255,255,0.9);
  position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .anim-livree { --livree-2: #d95926; --livree-filet: rgba(255,255,255,0.8); --trainee: rgba(255,255,255,0.7); } }
:root[data-theme="dark"] .anim-livree { --livree-2: #d95926; --livree-filet: rgba(255,255,255,0.8); --trainee: rgba(255,255,255,0.7); }
.anim-livree svg { width: 100%; height: 100%; display: block; opacity: .9; }
.anim-b1 { fill: var(--livree-1); }
.anim-b2 { fill: var(--livree-2); }
.anim-filet { fill: var(--livree-filet); }
.anim-bandes { transform-box: view-box; }
.anim-livree.anim-attente .anim-bandes { opacity: 0; }
.anim-livree.anim-entre .anim-bandes { animation: anim-entre 1s cubic-bezier(.22,1.12,.36,1) backwards; }
@keyframes anim-entre { from { transform: translateX(-125%) skewX(-12deg); } }
.anim-trainees { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: -1; pointer-events: none; }

/* 16 · Bienvenue en grand : la photo arrive, reste un instant, puis part dans le fond en tournant */
.anim-bienvenue { --bv: min(300px, 64vw, 40vh); position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; perspective: 1000px; cursor: pointer; }
.anim-bv-voile { position: absolute; inset: 0; background: color-mix(in srgb, var(--page, #eef1f6) 60%, transparent); animation: anim-bv-voile 2.4s ease both; }
.anim-bv-bloc { position: relative; display: grid; justify-items: center; gap: 14px;
  animation: anim-bv-arrive .55s cubic-bezier(.2,1.35,.4,1) both, anim-bv-part 1.1s cubic-bezier(.55,0,.8,.25) 1.25s forwards; }
.anim-bv-photo { position: relative; width: var(--bv); height: calc(var(--bv) * 1.2); }
.anim-bv-photo::before { content: ""; position: absolute; left: 0; bottom: 0; width: var(--bv); height: var(--bv); border-radius: 50%;
  background: linear-gradient(145deg, var(--accent, #2a78d6), #eb6834); box-shadow: 0 18px 50px rgba(15,20,40,0.35), 0 0 0 6px var(--surface, #fbfcfe); }
/* La tête sort du rond : la photo n'est coupée que par le bas du cercle */
.anim-bv-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 0;
  -webkit-mask: linear-gradient(#000 0 0) top / 100% 58.34% no-repeat, radial-gradient(circle closest-side at 50% 58.33%, #000 99%, transparent 100%);
  mask: linear-gradient(#000 0 0) top / 100% 58.34% no-repeat, radial-gradient(circle closest-side at 50% 58.33%, #000 99%, transparent 100%); }
.anim-bv-nom { font-size: 24px; font-weight: 750; letter-spacing: -0.02em; padding: 7px 18px; border-radius: 999px; color: var(--ink, #0b0b0b);
  background: var(--glass-strong, rgba(255,255,255,0.85)); box-shadow: 0 8px 24px rgba(15,20,40,0.15); animation: anim-bv-nom 1.3s ease both; }
@keyframes anim-bv-voile { 0% { opacity: 0; } 12%, 55% { opacity: 1; } 100% { opacity: 0; } }
@keyframes anim-bv-arrive { from { opacity: 0; transform: scale(.2) rotate(-14deg); } to { opacity: 1; transform: none; } }
@keyframes anim-bv-part { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateZ(-2400px) rotate(900deg) scale(.4); } }
@keyframes anim-bv-nom { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }

/* Animations coupées : réglage d'Argos (data-motion) ou réglage du système. Les états finaux restent affichés. */
:root[data-motion="reduce"] :is(.anim-mois, .anim-trace, .anim-point, .anim-cascade, .anim-arrive, .hb .fill, .hb .stack, .obj-barre .fait, .pie-wrap svg, .anim-rond, .anim-coche) { animation: none !important; }
:root[data-motion="reduce"] :is(.tip.anim-glisse, .anim-toast, .pie-wrap .part, .anim-mois) { transition: none !important; }
:root[data-motion="reduce"] :is(.anim-btn[data-anim-etat="fait"], .anim-toast.vu) .anim-coche { stroke-dashoffset: 0; }
:root[data-motion="reduce"] .pie-wrap svg .part:hover { transform: none; }
:root[data-motion="reduce"] .anim-gabarit i::after { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  :is(.anim-mois, .anim-trace, .anim-point, .anim-cascade, .anim-arrive, .hb .fill, .hb .stack, .obj-barre .fait, .pie-wrap svg, .anim-rond, .anim-coche) { animation: none !important; }
  :is(.tip.anim-glisse, .anim-toast, .pie-wrap .part, .anim-mois) { transition: none !important; }
  :is(.anim-btn[data-anim-etat="fait"], .anim-toast.vu) .anim-coche { stroke-dashoffset: 0; }
  .pie-wrap svg .part:hover { transform: none; }
  .anim-gabarit i::after { animation: none !important; }
}
