/* ══════════════════════════════════════════════════════════
   CHIFFRES CLÉS — frise chronologique animée
   Même langage que le fil de « Notre histoire » :
   - un seul fil continu, du 1er au dernier point (posé par JS),
     dont les couleurs restent fixes et sont dévoilées de gauche
     à droite, avec un halo diffus et une tête lumineuse ;
   - pastilles : à venir (anneau vide) · en cours (anneau qui
     pulse) · atteinte (pleine) ; le chiffre compte à ce moment.
   Sur téléphone, la frise devient verticale.
   ══════════════════════════════════════════════════════════ */

.hero-showcase .hero-stats {
  --stats-gap: 2rem;
  --step: 450ms; /* doit correspondre à STATS_STEP dans enhance.js */
  --dot: 16px;
  --thread-start: 0px; /* posés par enhance.js */
  --thread-length: 0px;
  --thread-cross: 8px; /* centre des pastilles sur l'axe perpendiculaire */
  position: relative;
  /* annule les décalages left/right/bottom de l'ancien style inline */
  inset: auto;
  column-gap: var(--stats-gap);
}

.hero-showcase .stat-item {
  --stat-color: var(--turquoise);
  position: relative;
  z-index: 1;
  padding-top: calc(var(--dot) + 1.1rem);
}
.hero-showcase .stat-item:nth-child(3),
.hero-showcase .stat-item:nth-child(4) {
  --stat-color: var(--jaune);
}
.hero-showcase .stat-item:nth-child(5) {
  --stat-color: var(--vert);
}

/* ── Fil continu (injecté par enhance.js) ─────── */
.stats-thread {
  position: absolute;
  z-index: 0;
  top: calc(var(--thread-cross) - 2px);
  left: var(--thread-start);
  width: var(--thread-length);
  height: 4px;
  border-radius: 4px;
  background: var(--bordure);
  pointer-events: none;
}
.stats-thread-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  /* une couleur par chiffre : 12 et 6 turquoise, 10 et 3 jaune, 1 an vert */
  background: linear-gradient(
    90deg,
    var(--turquoise) 0%,
    var(--turquoise) 25%,
    var(--jaune) 50%,
    var(--jaune) 75%,
    var(--vert) 100%
  );
  clip-path: inset(0 100% 0 0 round 4px);
}
.stats-thread-fill::after {
  content: "";
  position: absolute;
  inset: -4px 0;
  background: inherit;
  filter: blur(8px);
  opacity: 0.35;
}
.stats-thread-head {
  position: absolute;
  top: 50%;
  left: 0;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: #fff;
  box-shadow:
    0 0 0 3px var(--head-color, var(--turquoise)),
    0 0 18px 4px color-mix(in srgb, var(--head-color, var(--turquoise)) 55%, transparent);
  opacity: 0;
}

/* Animation : fill + tête parcourent le fil en 4 étapes */
.hero-stats.is-running .stats-thread-fill {
  clip-path: inset(0 0 0 0 round 4px);
  transition: clip-path calc(var(--step) * 4) linear;
}
.hero-stats.is-running .stats-thread-head {
  left: 100%;
  opacity: 1;
  transition:
    left calc(var(--step) * 4) linear,
    opacity 0.3s;
}
.hero-stats.is-done .stats-thread-head {
  opacity: 0;
}

/* ── Pastilles ─────────────────────────────── */
.hero-showcase .stat-item::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: var(--dot);
  height: var(--dot);
  margin-left: calc(var(--dot) / -2);
  box-sizing: border-box;
  border-radius: 50%;
  border: 2.5px solid var(--stat-color);
  background: var(--stat-color);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--stat-color) 16%, transparent);
  transition:
    background 0.35s,
    border-color 0.35s,
    box-shadow 0.4s,
    transform 0.45s var(--ease-spring, ease);
}
/* À venir (JS actif, pas encore atteinte) */
.js .hero-showcase .stat-item:not(.is-read)::after {
  background: var(--bg);
  border-color: var(--bordure);
  box-shadow: 0 0 0 0 transparent;
}
/* En cours : anneau épais qui pulse */
.hero-showcase .stat-item.is-current::after {
  background: var(--bg);
  border-width: 4px;
  transform: scale(1.2);
  animation: stats-dot-pulse 1.6s ease-in-out infinite;
}
@keyframes stats-dot-pulse {
  50% {
    box-shadow: 0 0 0 11px color-mix(in srgb, var(--stat-color) 6%, transparent);
  }
}

/* Chiffre et libellé s'allument avec leur pastille */
.hero-showcase .stat-num,
.hero-showcase .stat-label {
  transition:
    opacity 0.4s,
    transform 0.5s var(--ease-out, ease);
}
.js .hero-showcase .stat-item:not(.is-read) .stat-num,
.js .hero-showcase .stat-item:not(.is-read) .stat-label {
  opacity: 0.25;
  transform: translateY(6px);
}

/* ── Tablette : frise horizontale sur 5 colonnes ── */
@media (max-width: 900px) {
  .hero-showcase .hero-stats {
    --stats-gap: 1rem;
    grid-template-columns: repeat(5, 1fr);
  }
}

/* ── Téléphone : frise verticale ─────────── */
@media (max-width: 600px) {
  .hero-showcase .hero-stats {
    --stats-gap: 1.4rem;
    --dot: 14px;
    grid-template-columns: 1fr;
    row-gap: var(--stats-gap);
    width: 100%;
    max-width: 20rem;
    margin: 1rem auto 0;
    text-align: left;
  }
  /* Le libellé peut passer à la ligne au lieu d'être coupé */
  .hero-showcase .stat-label {
    flex: 1;
    min-width: 0;
  }
  .hero-showcase .stat-item {
    flex-direction: row;
    align-items: baseline;
    gap: 0.75rem;
    padding-top: 0;
    padding-left: calc(var(--dot) + 1.1rem);
  }
  .hero-showcase .stat-num {
    min-width: 3.2ch;
  }
  .hero-showcase .stat-item::after {
    top: 0.35em;
    left: 0;
    margin-left: 0;
  }
  .stats-thread {
    top: var(--thread-start);
    left: calc(var(--thread-cross) - 2px);
    width: 4px;
    height: var(--thread-length);
  }
  .stats-thread-fill {
    background: linear-gradient(
      180deg,
      var(--turquoise) 0%,
      var(--turquoise) 25%,
      var(--jaune) 50%,
      var(--jaune) 75%,
      var(--vert) 100%
    );
    clip-path: inset(0 0 100% 0 round 4px);
  }
  .stats-thread-fill::after {
    inset: 0 -4px;
  }
  .stats-thread-head {
    top: 0;
    left: 50%;
  }
  .hero-stats.is-running .stats-thread-head {
    top: 100%;
    left: 50%;
    transition:
      top calc(var(--step) * 4) linear,
      opacity 0.3s;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-stats .stats-thread-fill,
  .hero-stats .stats-thread-head,
  .hero-showcase .stat-item::after,
  .hero-showcase .stat-num,
  .hero-showcase .stat-label {
    transition: none !important;
    animation: none !important;
  }
}
