/* Les douze halos de chargement (`app/halos.py`, `templates/_halos.html`).
 *
 * DEUX REGLES, mesurees sous Safari le 14/11/2026 avec un blocage de trois
 * secondes de la page (ce que Safari fait pendant un changement de page) :
 *   1. aucun `animation-direction` : une rotation inverse a ses propres images
 *      cles (`hlTourneInv`) ; `reverse` se figeait ;
 *   2. seuls des blocs HTML s'animent, jamais un dessin SVG : un arc SVG qui
 *      tournait se figeait, le chiffre HTML a cote continuait.
 * Gardes : `test_halos.py`. Les couleurs viennent du theme : un halo suit la
 * palette choisie. */

.hl { position: relative; width: 150px; height: 150px; display: grid; place-items: center; }

@keyframes hlTourne { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes hlTourneInv { from { transform: rotate(360deg); } to { transform: rotate(0deg); } }
@keyframes hlPouls { 0%, 100% { transform: scale(.7); opacity: .45; } 50% { transform: scale(1.15); opacity: .95; } }

/* Orbites a plat */
.hl-orbites .plan { position: absolute; inset: 0; }
.hl-orbites .plan svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.hl-orbites .tour { position: absolute; inset: 0; animation: hlTourne var(--dur) linear infinite; }
.hl-orbites .tour.inv { animation-name: hlTourneInv; }
.hl-orbites .bille { position: absolute; top: calc(50% - 7px); right: 3px; width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff 0%, var(--c) 55%, transparent 100%); box-shadow: 0 0 10px 3px var(--c); }
.hl-orbites .coeur { position: absolute; inset: 42%; border-radius: 50%; background: var(--brand); filter: blur(6px); animation: hlPouls 2.4s ease-in-out infinite; }

/* Anneau de score */
.hl-anneau .couche { position: absolute; inset: 15px; }
.hl-anneau .couche svg { width: 100%; height: 100%; display: block; }
.hl-anneau .c1 { animation: hlTourne 1.4s linear infinite; }
.hl-anneau .c2 { animation: hlTourneInv 2.3s linear infinite; }
.hl-anneau .chiffre { position: absolute; inset: 0; display: grid; place-items: center; font: 500 1.3rem ui-monospace, Menlo, monospace; color: var(--text); }
.hl-anneau .chiffre span { animation: hlPouls 2.4s ease-in-out infinite; }

/* Chandeliers */
.hl-bougies { display: flex; align-items: flex-end; justify-content: center; gap: 10px; height: 110px; }
.hl-bougies .bougie { width: 14px; height: 100%; position: relative; }
.hl-bougies .meche { position: absolute; left: 6px; width: 2px; top: 6%; bottom: 6%; background: color-mix(in srgb, var(--text) 30%, transparent); border-radius: 2px; }
.hl-bougies .corps { position: absolute; left: 0; width: 14px; bottom: 15%; height: 60%; border-radius: 3px; transform-origin: 50% 100%; animation: hlMonte 1.6s ease-in-out infinite; animation-delay: var(--d); background: var(--brand); }
.hl-bougies .b .corps { background: var(--danger); }
@keyframes hlMonte { 0%, 100% { transform: scaleY(.25); } 50% { transform: scaleY(1); } }

/* Courbe qui defile */
.hl-courbe { width: 220px; height: 90px; overflow: hidden; border-bottom: 1px solid var(--border); }
.hl-courbe .bande { position: absolute; left: 0; top: 0; width: 440px; height: 90px; animation: hlDefile 2.8s linear infinite; }
.hl-courbe .bande svg { width: 440px; height: 90px; display: block; }
.hl-courbe .point { position: absolute; left: calc(50% - 5px); top: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--brand-ink); box-shadow: 0 0 10px 3px var(--brand); animation: hlBouge 2.8s ease-in-out infinite; }
@keyframes hlDefile { from { transform: translateX(0); } to { transform: translateX(-220px); } }
@keyframes hlBouge { 0%, 100% { transform: translateY(40px); } 25% { transform: translateY(18px); } 55% { transform: translateY(52px); } 80% { transform: translateY(26px); } }

/* Taquin ALPHAVIU (pose par static/halos.js) */
.hl-taquin { --t: 50px; --g: 6px; width: calc(3 * var(--t) + 2 * var(--g)); height: calc(3 * var(--t) + 2 * var(--g)); display: block; }
.hl-taquin .tuile { position: absolute; left: 0; top: 0; width: var(--t); height: var(--t); border-radius: 9px; display: grid; place-items: center; font: 400 calc(var(--t) * .55) Georgia, "Times New Roman", serif; color: var(--bg); background: var(--brand); box-shadow: inset 0 -3px 0 color-mix(in srgb, #000 22%, transparent); }
.hl-taquin .tuile.place { background: var(--brand-ink); }
.hl-taquin .tuile.mobile { background: var(--warning); }
.hl-taquin.resolu .tuile { background: var(--brand-ink); }

/* Courbe de Lissajous (rapport 3:2) */
.hl-lissajous .lx { position: absolute; left: 50%; top: 50%; animation: hlLx 3s ease-in-out infinite; animation-delay: var(--dl); }
.hl-lissajous .ly { animation: hlLy 2s ease-in-out infinite; animation-delay: var(--dl); }
.hl-lissajous b { display: block; width: var(--s); height: var(--s); margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2); border-radius: 50%; background: var(--brand); opacity: var(--o); box-shadow: 0 0 8px var(--brand); }
@keyframes hlLx { 0% { transform: translateX(-60px); } 50% { transform: translateX(60px); } 100% { transform: translateX(-60px); } }
@keyframes hlLy { 0% { transform: translateY(-60px); } 50% { transform: translateY(60px); } 100% { transform: translateY(-60px); } }

/* Epicycles */
.hl-epicycles .n { position: absolute; width: 0; height: 0; animation-timing-function: linear; animation-iteration-count: infinite; animation-delay: var(--dl); }
.hl-epicycles .n1 { left: 50%; top: 50%; animation-name: hlTourne; animation-duration: 9s; }
.hl-epicycles .n2 { left: 42px; top: 0; animation-name: hlTourneInv; animation-duration: 2.7s; }
.hl-epicycles .n3 { left: 22px; top: 0; animation-name: hlTourne; animation-duration: 1.2s; }
.hl-epicycles .bras { position: absolute; left: 0; top: -1px; height: 2px; border-radius: 2px; background: color-mix(in srgb, var(--brand-ink) 55%, transparent); }
.hl-epicycles .n1 > .bras { width: 42px; }
.hl-epicycles .n2 > .bras { width: 22px; }
.hl-epicycles .n3 > .bras { width: 12px; }
.hl-epicycles .pt { position: absolute; left: 12px; top: 0; width: var(--s); height: var(--s); margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2); border-radius: 50%; background: var(--warning); opacity: var(--o); box-shadow: 0 0 8px var(--warning); }
.hl-epicycles .fantome .bras { display: none; }

/* Engrenages */
.hl-engrenages { width: 160px; height: 160px; display: block; }
.hl-engrenages .roue { position: absolute; }
.hl-engrenages .roue svg { width: 100%; height: 100%; display: block; }

/* Carres du nombre d'or : chaque carre tourne dans le precedent */
.hl-nombre_or { display: block; }
.hl-nombre_or .carre { position: absolute; inset: 11%; border: 1.5px solid var(--c); border-radius: 3px; animation: hlTourne 14s linear infinite; }
.hl-nombre_or > .carre { inset: 4%; }

/* Echanges d'informations (paquets poses par static/halos.js) */
.hl-echanges { width: 230px; height: 160px; display: block; }
.hl-echanges svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hl-echanges .noeud { position: absolute; transform: translate(-50%, -50%); font: .62rem ui-monospace, Menlo, monospace; padding: 3px 7px; border-radius: 6px; background: var(--card-bg); border: 1px solid var(--border); color: var(--text); white-space: nowrap; }
.hl-echanges .centre { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: var(--brand); color: var(--bg); display: grid; place-items: center; font: 600 1rem ui-monospace, Menlo, monospace; animation: hlCoeur 1.6s ease-in-out infinite; }
@keyframes hlCoeur { 0%, 100% { transform: scale(.92); } 50% { transform: scale(1.06); } }
.hl-echanges .paquet { position: absolute; left: 0; top: 0; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: var(--brand-ink); box-shadow: 0 0 6px var(--brand); opacity: 0; }

/* Double helice */
.hl-helice { display: flex; gap: 7px; align-items: center; justify-content: center; height: 120px; width: auto; }
.hl-helice .col { position: relative; width: 8px; height: 100%; }
.hl-helice .br { position: absolute; left: 0; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; animation: hlHelice 2.4s linear infinite; animation-delay: var(--dl); background: var(--brand); }
.hl-helice .br.b { background: var(--brand-strong); }
@keyframes hlHelice {
  0% { transform: translateY(-38px) scale(.7); opacity: .55; }
  25% { transform: translateY(0) scale(1.25); opacity: 1; }
  50% { transform: translateY(38px) scale(.7); opacity: .55; }
  75% { transform: translateY(0) scale(.4); opacity: .25; }
  100% { transform: translateY(-38px) scale(.7); opacity: .55; }
}

/* Tournesol : graines a l'angle d'or */
.hl-tournesol { display: block; animation: hlTourne 24s linear infinite; }
.hl-tournesol i { position: absolute; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--c); animation: hlGraine 2.2s ease-in-out infinite; animation-delay: var(--dl); }
.hl-tournesol i.t0 { --c: var(--brand-ink); }
.hl-tournesol i.t1 { --c: var(--brand); }
.hl-tournesol i.t2 { --c: var(--brand-strong); }
@keyframes hlGraine { 0%, 100% { transform: scale(.5); opacity: .45; } 50% { transform: scale(1.35); opacity: 1; } }

/* Mouvement reduit : le halo reste, immobile ; il dit encore « ca charge ». */
@media (prefers-reduced-motion: reduce) {
  .hl, .hl * { animation: none !important; }
}
