/* ═══════════════════════════════════════════════════════════════════════════
   Animation d'attente « over the top » — base commune (voir chargement.js)
   Modèle unique : ~/Developer/outils/communs/chargement.css.
   Couleurs : jetons --ch-* ci-dessous, à redéfinir au besoin dans la feuille
   du site (ex. .ch { --ch-rgb: 29, 78, 216; } pour le bleu de carte-au).
   La scène (.ch-scene) est dessinée par la feuille du site.
   =========================================================================== */

.ch {
  --ch-rgb: 29, 184, 96;                 /* accent (vert commun) */
  --ch-accent: rgb(var(--ch-rgb));
  --ch-clair: #7cf7b4;                    /* version lumineuse de l'accent */
  --ch-texte: #0f1a14;
  --ch-doux: #5d6b63;
  --ch-fond: rgba(255, 255, 255, .9);
  --ch-voile: rgba(238, 243, 240, .72);
  --ch-taille: 150px;                     /* côté de la scène */
  --ch-p: 0;                              /* progression 0 → 1 (Chargement.progres) */
  font-family: inherit;
  font-feature-settings: normal;          /* « tnum » d'Inter élargit le trait d'union */
}
.ch-voile {
  position: fixed; inset: 0; z-index: 3000;
  display: grid; place-items: center; padding: 16px;
  background: var(--ch-voile);
  -webkit-backdrop-filter: blur(6px) saturate(140%); backdrop-filter: blur(6px) saturate(140%);
  animation: ch-fondu .25s ease both;
}
.ch-flottant {
  position: fixed; left: 50%; top: 50%; z-index: 1400;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 32px));
  pointer-events: none;
}
.ch-dans { position: relative; }

.ch-carte {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 26px;
  width: min(520px, 100%); box-sizing: border-box;
  padding: 24px 28px;
  border-radius: 24px;
  background: var(--ch-fond);
  -webkit-backdrop-filter: blur(14px) saturate(160%); backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid rgba(var(--ch-rgb), .28);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .5) inset, 0 24px 60px -18px rgba(var(--ch-rgb), .45), 0 8px 24px -12px rgba(0, 0, 0, .25);
  animation: ch-entree .45s cubic-bezier(.2, .9, .3, 1.3) both;
}
.ch-dans .ch-carte { width: 100%; }
/* Reflet qui traverse la carte */
.ch-carte::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(var(--ch-rgb), .12) 50%, transparent 65%);
  background-size: 250% 100%;
  animation: ch-reflet 1.6s linear infinite;
}

/* Scène : la métaphore du site (sa feuille la dessine) */
.ch-scene {
  position: relative; flex: none; overflow: hidden;
  width: var(--ch-taille); height: var(--ch-taille);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--ch-rgb), .16), rgba(var(--ch-rgb), .03) 70%);
  box-shadow: 0 0 0 1px rgba(var(--ch-rgb), .35), 0 0 40px -6px rgba(var(--ch-rgb), .55), inset 0 0 30px rgba(var(--ch-rgb), .18);
  animation: ch-respire 2.4s ease-in-out infinite;
}
.ch-scene > * { position: absolute; }

.ch-texte { flex: 1; min-width: 0; position: relative; z-index: 1; }
.ch-titre {
  margin: 0; font-size: 19px; font-weight: 750; line-height: 1.25;
  background: linear-gradient(90deg, var(--ch-texte) 0%, var(--ch-accent) 25%, var(--ch-clair) 50%, var(--ch-accent) 75%, var(--ch-texte) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: ch-brille 1.8s linear infinite;
}
.ch-detail {
  margin: 6px 0 0; font-size: 14.5px; color: var(--ch-doux); overflow-wrap: anywhere;
}
.ch-curseur::after { content: "▍"; margin-left: 2px; color: var(--ch-accent); animation: ch-curseur .8s steps(1) infinite; }
.ch-barre {
  display: block; position: relative; overflow: hidden;
  height: 6px; margin-top: 14px; border-radius: 999px;
  background: rgba(var(--ch-rgb), .14);
}
.ch-barre i {
  position: absolute; inset: 0; width: 40%; border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--ch-accent), var(--ch-clair), var(--ch-accent), transparent);
  box-shadow: 0 0 12px rgba(var(--ch-rgb), .8);
  animation: ch-barre 1.1s cubic-bezier(.6, 0, .4, 1) infinite;
}
/* Vraie progression : la barre se remplit, une étincelle court dessus */
.ch-barre-progres i {
  width: calc(var(--ch-p) * 100%); min-width: 6px;
  background: linear-gradient(90deg, var(--ch-accent), var(--ch-clair));
  transition: width .35s cubic-bezier(.2, .9, .3, 1.1);
  animation: none;
}
.ch-barre-progres i::after {
  content: ""; position: absolute; right: 0; top: -3px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 10px 3px rgba(var(--ch-rgb), .9);
  animation: ch-etincelle .9s ease-in-out infinite;
}
.ch-pourcent { display: block; margin-top: 6px; font-size: 12.5px; font-weight: 700; color: var(--ch-accent); font-variant-numeric: tabular-nums; }

/* Erreur : tout s'arrête, le message reste */
.ch-erreur .ch-scene, .ch-erreur .ch-scene *, .ch-erreur .ch-carte::after, .ch-erreur .ch-barre i { animation: none !important; }
.ch-erreur .ch-titre { background: none; color: #b42318; animation: none; }
.ch-erreur .ch-barre, .ch-erreur .ch-pourcent { display: none; }

/* Sortie */
.ch-sortie .ch-carte { animation: ch-sortie .26s ease-in both; }
.ch-voile.ch-sortie { animation: ch-fondu-sortie .26s ease-in both; }

/* Arrivée du résultat (Chargement.arrivee) */
.ch-arrivee { animation: ch-resultat .5s cubic-bezier(.2, .9, .3, 1.2) both; }
.ch-bloc { animation: ch-bloc .45s cubic-bezier(.2, .9, .3, 1.2) both; }
.ch-bloc-2 { animation-delay: .06s; } .ch-bloc-3 { animation-delay: .12s; } .ch-bloc-4 { animation-delay: .18s; }
.ch-bloc-5 { animation-delay: .24s; } .ch-bloc-6 { animation-delay: .3s; } .ch-bloc-7 { animation-delay: .36s; }
.ch-bloc-8 { animation-delay: .42s; } .ch-bloc-9 { animation-delay: .48s; } .ch-bloc-10 { animation-delay: .54s; }
.ch-bloc-11 { animation-delay: .6s; } .ch-bloc-12 { animation-delay: .66s; }

@keyframes ch-fondu { from { opacity: 0; } }
@keyframes ch-fondu-sortie { to { opacity: 0; } }
@keyframes ch-entree { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes ch-sortie { to { opacity: 0; transform: translateY(-8px) scale(.97); filter: blur(4px); } }
@keyframes ch-reflet { from { background-position: 150% 0; } to { background-position: -100% 0; } }
@keyframes ch-respire { 50% { box-shadow: 0 0 0 1px rgba(var(--ch-rgb), .5), 0 0 60px -4px rgba(var(--ch-rgb), .8), inset 0 0 30px rgba(var(--ch-rgb), .25); } }
@keyframes ch-brille { to { background-position: -200% center; } }
@keyframes ch-curseur { 50% { opacity: 0; } }
@keyframes ch-barre { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes ch-etincelle { 50% { transform: scale(.6); opacity: .6; } }
@keyframes ch-resultat { from { opacity: 0; transform: translateY(16px) scale(.98); filter: blur(6px); } }
@keyframes ch-bloc { from { opacity: 0; transform: translateY(10px); } }

/* Mode sombre */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ch {
    --ch-texte: #eef4f0; --ch-doux: #a3b3aa;
    --ch-fond: rgba(18, 26, 22, .88); --ch-voile: rgba(8, 12, 10, .66);
  }
  :root:not([data-theme="light"]) .ch-scene { background: radial-gradient(circle, rgba(var(--ch-rgb), .22), rgba(11, 19, 16, .6) 75%); }
  :root:not([data-theme="light"]) .ch-carte { box-shadow: 0 0 0 1px rgba(255, 255, 255, .06) inset, 0 24px 60px -18px rgba(var(--ch-rgb), .5), 0 8px 24px -12px rgba(0, 0, 0, .6); }
}
:root[data-theme="dark"] .ch {
  --ch-texte: #eef4f0; --ch-doux: #a3b3aa;
  --ch-fond: rgba(18, 26, 22, .88); --ch-voile: rgba(8, 12, 10, .66);
}
:root[data-theme="dark"] .ch-scene { background: radial-gradient(circle, rgba(var(--ch-rgb), .22), rgba(11, 19, 16, .6) 75%); }
/* Impression : jamais d'animation d'attente sur papier */
@media print { .ch { display: none !important; } }

/* Mouvement réduit : tout est figé (la scène montre son état final), le texte reste */
@media (prefers-reduced-motion: reduce) {
  .ch, .ch *, .ch *::before, .ch *::after, .ch-carte::after, .ch-arrivee, .ch-bloc { animation: none !important; transition: none !important; }
  .ch-titre { background: none; color: var(--ch-texte); }
  .ch-barre:not(.ch-barre-progres) i { left: 30%; }
}

@media (max-width: 560px) {
  .ch { --ch-taille: 120px; }
  .ch-carte { flex-direction: column; text-align: center; gap: 16px; padding: 22px 20px; }
  .ch-titre { font-size: 17px; }
}
