/* Les animations VIVANTES des pages (`app/vivant.py`, `static/vivant.js`).
 * Elles tournent en continu et montrent quelque chose de vrai. Memes regles
 * que les halos (mesurees sous Safari le 14/11/2026, gardees par
 * `test_vivant.py`) : aucun `animation-direction`, aucun dessin SVG anime,
 * des images cles en `transform` et `opacity` seulement. */

/* ── Bandeau du marche (tableau de bord) ─────────────────────────────── */
.viv-bandeau { overflow: hidden; border-block: 1px solid var(--border); margin: 0 0 10px; padding: 6px 0; }
.viv-piste { display: flex; width: max-content; animation: vivDefile 40s linear infinite; }
.viv-bandeau:hover .viv-piste, .viv-bandeau:focus-within .viv-piste { animation-play-state: paused; }
.viv-lot { display: flex; }
.viv-item { padding: 0 14px; white-space: nowrap; font-size: .8rem; font-variant-numeric: tabular-nums; }
.viv-item em { font-style: normal; font-weight: 600; }
.viv-item em.up { color: var(--success, #16a34a); }
.viv-item em.down { color: var(--danger); }
.viv-item small { color: var(--text-muted); }
@keyframes vivDefile { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ── Le signal qui s'allume (change depuis la veille) ───────────────── */
td[data-signal-change] .signal-badge { position: relative; overflow: hidden; }
td[data-signal-change] .signal-badge::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, #fff 55%, transparent) 50%, transparent 70%);
  transform: translateX(-120%); animation: vivEclat 4.5s ease-in-out infinite;
}
@keyframes vivEclat { 0% { transform: translateX(-120%); } 25% { transform: translateX(120%); } 100% { transform: translateX(120%); } }

/* ── Le pouls de « Ce qui a bouge » ──────────────────────────────────── */
.viv-pouls { margin-top: 10px; color: var(--brand); }
.viv-ecg-cadre { height: 48px; overflow: hidden; transform: scaleY(calc(.35 + var(--amp, .5))); transform-origin: 50% 50%; }
.viv-ecg { width: 200%; height: 48px; animation: vivDefile 3.4s linear infinite; }
.viv-ecg svg { width: 100%; height: 100%; display: block; }
.viv-pouls-txt { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--text-muted); }
.viv-pouls-txt i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); animation: vivBat 1s ease-in-out infinite; }
@keyframes vivBat { 0%, 100% { transform: scale(.8); opacity: .6; } 50% { transform: scale(1.25); opacity: 1; } }

/* ── L'orbite du portefeuille (posee par vivant.js) ─────────────────── */
/* Une orbite par secteur : toutes a la MEME vitesse (`--tour`, pose par le
   script), dans le meme sens ; le satellite tourne a l'inverse pour que son
   etiquette reste droite. Le survol arrete tout, le temps de lire. */
.viv-orbite { display: flex; justify-content: center; margin: 0 0 12px; overflow: hidden; }
.viv-orbite-c { position: relative; flex: 0 0 auto; transform-origin: top center; }
.viv-anneau-o { position: absolute; border: 1px dashed var(--border); border-radius: 50%; }
.viv-rot { position: absolute; inset: 0; animation: vivTourne var(--tour, 70s) linear infinite; }
.viv-planete { position: absolute; transform: translate(-50%, -50%); }
.viv-planete b { display: grid; place-items: center; width: var(--d); height: var(--d); border-radius: 50%; font-size: .55rem; font-weight: 700; color: var(--bg); background: var(--brand); overflow: hidden; cursor: default;
  animation: vivTourneInv var(--tour, 70s) linear infinite; }
.viv-rot-nc .viv-planete b { background: var(--text-muted); }
.viv-orbite-c:hover .viv-rot, .viv-orbite-c:hover .viv-planete b { animation-play-state: paused; }
.viv-orbite-lib { position: absolute; transform: translate(-50%, -50%); font-size: .62rem; line-height: 1.2; padding: 0 5px; border-radius: 4px; white-space: nowrap; color: var(--text-muted); background: var(--card-bg); pointer-events: none; }
@keyframes vivTourne { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes vivTourneInv { from { transform: rotate(360deg); } to { transform: rotate(0deg); } }

/* ── Les sources du score (fenetre du score, posees par vivant.js) ──── */
.viv-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -4px 0 12px; }
.viv-src { font-size: .72rem; padding: 2px 8px; border-radius: 6px; background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--text); }
.viv-voie { position: relative; flex: 1 1 60px; min-width: 40px; height: 8px; border-top: 1px dashed var(--border); margin-top: 6px; }
.viv-voie i { position: absolute; left: 0; top: -4px; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); opacity: 0; }

/* ── Le flux des scores (« Ce qui a bouge », dessine par vivant.js) ─── */
.viv-flux { margin: 0; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--card-bg); }
.viv-flux-tete { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: .82rem; font-weight: 600; margin-bottom: 6px; }
.viv-flux-cpt { font-weight: 400; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.viv-flux-cpt b.up { color: var(--brand); }
.viv-flux-cpt b.down { color: var(--danger); }
.viv-flux canvas { display: block; width: 100%; height: 220px; }
.viv-flux-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; font-size: .78rem; }
.viv-flux-ctl .viv-flux-curseur { flex: 1 1 160px; accent-color: var(--brand); }
.viv-flux-ctl .viv-flux-quand { min-width: 7em; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.viv-flux-ctl input[type="search"], .viv-flux-ctl select { width: auto; flex: 0 1 160px; }
.viv-flux-info { min-height: 1.3em; margin-top: 4px; font-size: .78rem; color: var(--text); font-variant-numeric: tabular-nums; }

/* ── La repartition de « Ce qui a bouge » pousse depuis zero ─────────── */
.auj-jauge span { transform-origin: 0 50%; animation: vivPousse .9s cubic-bezier(.2, .8, .2, 1) both; }
.auj-jauge span:nth-child(2) { animation-delay: .3s; }
.auj-jauge span:nth-child(3) { animation-delay: .6s; }
@keyframes vivPousse { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ── L'onde derriere les titres de page (posee par vivant.js) ───────── */
.titre-page.viv-avec-onde { position: relative; isolation: isolate; }
.viv-onde { position: absolute; left: 0; right: 0; top: 50%; height: 0; z-index: -1; display: flex; justify-content: space-between; pointer-events: none; }
.viv-onde i { width: 3px; height: 3px; border-radius: 50%; background: var(--brand); opacity: .3; animation: vivOnde 3.2s ease-in-out infinite; animation-delay: var(--dl); }
@keyframes vivOnde { 0%, 100% { transform: translateY(-11px); opacity: .12; } 50% { transform: translateY(11px); opacity: .42; } }

/* ── Le temoin du direct (pose par direct.js) ────────────────────────── */
.viv-direct { position: fixed; z-index: 1040; left: calc(12px + env(safe-area-inset-left, 0px)); bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px; font-size: .74rem;
  background: var(--card-bg); border: 1px solid var(--border); color: var(--text-muted); pointer-events: none; }
.viv-direct i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); animation: vivBat 1.2s ease-in-out infinite; }
.viv-direct .viv-paquet { position: absolute; left: 10px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 2px; background: var(--brand); opacity: 0; }
@media (max-width: 900px) { .viv-direct { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); } }

@media (prefers-reduced-motion: reduce) {
  .viv-piste, .viv-ecg, .viv-onde i, .viv-pouls-txt i, .viv-direct i, .auj-jauge span,
  .viv-rot, .viv-rot .viv-planete b,
  td[data-signal-change] .signal-badge::after { animation: none !important; }
}
