/* ==========================================================================
   SmartAGM v2 — Stats counter
   Markup: templates/home/v2/partials/stats.html, inside the "Partner" section
   (components/partners.css), right under the orbit's horizon; its sentence is
   the section's lead (.partners__lead). One row of four figures on the section's navy, split by hairlines, each with a
   short accent bar before its label. The figures size themselves to their
   column (container query units), so the row stays on one line at every
   width; below 560px figures from 10,000 up show their short form.
   Roll animation: stats.js splits each digit into a reel (.stats__reel) and
   sets [data-stats-pre] on the section until the row scrolls into view.
   Logical properties mirror in RTL; the digits themselves stay LTR.
   ========================================================================== */

.stats {
  padding-top: clamp(28px, 4vw, 48px);
}

.stats__band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  /* Every item keeps the same inner padding (equal columns give equal figure sizes),
     so the band's own side padding is that much smaller. */
  padding: 0 clamp(4px, 2vw, 20px);
  color: var(--color-on-dark);
  list-style: none;
}

/* ---- Item --------------------------------------------------------------- */

.stats__item {
  --grow: 1;
  position: relative;
  display: grid;
  align-content: start;
  gap: clamp(6px, 1vw, 12px);
  min-width: 0;
  padding-inline: clamp(8px, 2vw, 28px);
  container-type: inline-size;
}

/* Hairline between figures; grows down from the top as the row rolls in. */
.stats__item + .stats__item::before {
  content: "";
  position: absolute;
  inset-block: 6%;
  inset-inline-start: 0;
  width: 1px;
  background: var(--color-on-dark-divider);
  transform: scaleY(var(--grow));
  transform-origin: top;
  transition: transform 900ms var(--ease-settle);
}

/* ---- Figure ------------------------------------------------------------- */

.stats__value {
  display: flex;
  /* Fallback, then sized to the column: "412,800" is about 4em wide. */
  font-size: clamp(20px, 4vw, 56px);
  font-size: min(56px, 23cqi);
  font-weight: var(--weight-semibold);
  line-height: 1;
  letter-spacing: var(--tracking-tight);
  white-space: nowrap;
}

/* Digits use the Latin face in both languages and always read left to right. */
.stats__digits {
  display: inline-flex;
  direction: ltr;
  font-family: var(--font-latin);
  font-variant-numeric: tabular-nums;
}

.stats__short {
  display: none;
  align-items: baseline;
  gap: 0.08em;
}

.stats__unit {
  color: var(--color-accent);
  font-size: 0.6em;
  font-weight: var(--weight-semibold);
  letter-spacing: 0;
  transition: opacity 400ms ease var(--d, 0ms);
}

:lang(ar) .stats__unit {
  font-size: 0.45em;
  margin-inline-start: 0.2em;
}

/* ---- Label -------------------------------------------------------------- */

.stats__label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-on-dark-muted);
  font-size: clamp(var(--text-xs), 1.25vw, var(--text-base));
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
}

.stats__label::before {
  content: "";
  flex: none;
  width: clamp(14px, 2vw, 24px);
  height: 3px;
  border-radius: 2px;
  background: var(--color-accent);
  transform: scaleX(var(--grow));
  transform-origin: left;
  transition: transform 700ms var(--ease-settle) var(--bar-delay, 0ms);
}

[dir="rtl"] .stats__label::before {
  transform-origin: right;
}

/* ---- Roll animation (stats.js) ------------------------------------------ */

/* One digit: a 1em window onto a reel of 0–9 three times over, which slides to --to. */
.stats__col {
  display: inline-block;
  height: 1em;
  overflow: hidden;
}

.stats__reel {
  display: flex;
  flex-direction: column;
  transform: translateY(calc(var(--to) * -1em));
  transition: transform calc(1500ms + var(--i) * 60ms) var(--ease-settle) calc(var(--i) * 70ms);
}

.stats__reel > span {
  display: block;
  height: 1em;
  text-align: center;
}

.stats__static {
  transition: opacity 400ms ease var(--d, 0ms);
}

.stats[data-stats-pre] .stats__item {
  --grow: 0;
}

.stats[data-stats-pre] .stats__reel {
  transform: translateY(0);
  transition: none;
}

.stats[data-stats-pre] .stats__static,
.stats[data-stats-pre] .stats__unit {
  opacity: 0;
}

/* ---- Smaller screens ---------------------------------------------------- */

@media (max-width: 560px) {
  .stats__band {
    padding-inline: 6px;
  }

  .stats__item {
    padding-inline: 6px;
  }

  .stats__value {
    font-size: min(40px, 27cqi);
  }

  .stats__full:not(:last-child) {
    display: none;
  }

  .stats__short {
    display: inline-flex;
  }

  .stats__label::before {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stats__item + .stats__item::before,
  .stats__label::before,
  .stats__reel,
  .stats__static,
  .stats__unit {
    transition: none;
  }
}
