/* ══════════════════════════════════════════════════
   SITE STATS BAR — Section 2
   Split layout: left = stat card (Typography in Motion
   morph-stage component), right = one morphing SVG/canvas
   panel that becomes a different visual per stat (a
   document-stamping conveyor, a scrolling year ruler, a
   dot-matrix crowd, and a highlighted world map).
   Depends on: tokens.css, hero.css (@keyframes bgs)
   ══════════════════════════════════════════════════ */

/* ── SECTION ─────────────────────────────────────── */

.site-stats {
  position: relative;
  min-height: 80vh;
  padding-block: var(--space-12);
  background: var(--c0);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@keyframes sv-pulse {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 0.80; }
}

.site-stats__inner {
  width: min(calc(100% - 2 * var(--content-inset)), var(--container-max));
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ── LABEL + HEADING ─────────────────────────────── */
/* Pinned to the top of the section — flex-shrink: 0 keeps it from being
   pushed around when the visual panel's content (SVG/canvas/map) changes
   height as it cycles between stats; only .stats-split below it centers
   within the remaining space. */

.site-stats__head {
  max-width: 64rem;
  margin-bottom: var(--space-6);
  flex-shrink: 0;
}

.site-stats__label {
  display: block;
  font-family: var(--fm);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--t3);
  margin: 0 0 var(--space-3);
}

.site-stats__heading {
  font-family: var(--fd);
  font-size: clamp(3.6rem, 5vw, 6.4rem);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
  padding-bottom: 0.08em;
  background: var(--gr);
  background-size: 200% 200%;
  animation: bgs 6s ease infinite;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ── SPLIT LAYOUT ────────────────────────────────── */

.stats-split {
  width: 100%;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(26rem, 34rem) 1fr;
  gap: var(--space-8);
  align-items: center;
}

/* ── CARD (.morph-stage) ────────────────────────── */

.morph-stage {
  width: 100%;
  background: var(--c1);
  border: 1px solid var(--bd);
  border-radius: var(--radius-lg);
  padding: 3.6rem;
  user-select: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ── NUMBER SLOT (.morph-num-wrap) ──────────────── */

.morph-num-wrap {
  position: relative;
  height: clamp(5.6rem, 5.5vw, 8rem);
  overflow: hidden;
  width: 100%;
}

/* ── SLIDING NUMBER SPANS (.morph-cur / .morph-nxt) */

.morph-cur,
.morph-nxt {
  font-family: var(--fd);
  font-size: clamp(5.6rem, 5.5vw, 8rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  display: block;
  position: absolute;
  left: 0;
  white-space: nowrap;
  background: var(--gr);
  background-size: 200% 200%;
  animation: bgs 6s ease infinite;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.morph-cur { top: 0; }
.morph-nxt { top: 100%; opacity: 0; }

/* ── STAT TITLE (.morph-label-text) ────────────── */

.morph-label-text {
  font-family: var(--fd);
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--txt);
  margin: 0;
}

/* ── DESCRIPTION (.tim-hint) ───────────────────── */

.tim-hint {
  font-family: var(--fm);
  font-size: 1.3rem;
  color: var(--t3);
  letter-spacing: .05em;
  line-height: 1.65;
  margin: 0;
}

/* ── PROGRESS BAR (.morph-bar-track / .morph-bar-fill) */

.morph-bar-track {
  width: 100%;
  height: 1px;
  background: var(--bd);
  border-radius: var(--radius-sm);
}

.morph-bar-fill {
  height: 1px;
  width: 0%;
  background: linear-gradient(90deg, var(--v), var(--a));
  border-radius: var(--radius-sm);
  transition: width 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── RIGHT PANEL ─────────────────────────────────── */

.sv-right {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sv-canvas {
  width: 100%;
  max-width: 52rem;
  height: auto;
  overflow: visible;
  transition: opacity 0.35s ease;
}

.sv-ambient {
  animation: sv-pulse 4s ease-in-out infinite;
}

/* ── NODES (Countries formation only) ────────────── */
/* Each node is a <g> with a fixed icon drawn centred at its own local
   origin; JS positions/sizes it purely via transform: translate() scale().
   (Not a shared <symbol>/<use> — that silently stopped painting after the
   world-map's large innerHTML injection elsewhere in the DOM, a Chromium
   staleness bug with <use>+<symbol> across big unrelated DOM mutations.) */

.sv-canvas[data-ready] .sv-node {
  transition: transform 0.85s cubic-bezier(0.16,1,0.3,1),
              opacity   0.45s ease;
}

#svLines {
  transition: opacity 0.22s ease;
}

/* ── COUNTRIES MAP ───────────────────────────────── */

.sv-map-wrap {
  display: none;          /* toggled by JS; no absolute positioning */
  width: 100%;
  opacity: 0;
  transition: opacity 0.45s ease;
}

.sv-map-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

/* ── ATTENDEES CROWD ─────────────────────────────── */

.sv-crowd-wrap {
  display: none;          /* toggled by JS; no absolute positioning */
  width: 100%;
  max-width: 62rem;
  margin-inline: auto;
  opacity: 0;
  transition: opacity 0.4s ease;
}

#attCanvas {
  display: block;
  width: 100%;
  height: auto;
}

/* ── YEARS TIMELINE ──────────────────────────────── */

#svTimeline {
  transition: opacity 0.3s ease;
}

#tlTrack {
  transition: transform 0.05s linear;
}

#tlPointer {
  filter: drop-shadow(0 0 11px rgba(85,68,187,0.9));
}

#tlNumReel {
  transition: transform 0.05s linear;
}

.sv-tl-num {
  font-family: var(--fd);
  font-weight: 700;
  transition: opacity 0.18s ease, fill 0.18s ease, font-size 0.18s ease;
}

/* ── EVENTS STAMP CONVEYOR ───────────────────────── */
/* Documents AND the stamp's thump are both driven from the same per-frame
   rAF loop with no CSS transition on transform for either — a CSS
   transition eases over its own independent clock, decoupled from the
   actual document position, which reads as visibly out of sync. Only
   opacity (the seal fade-in / text-line fade-out) still uses a CSS
   transition since those aren't per-frame-computed values. */

#svStamp {
  transition: opacity 0.3s ease;
}

.doc-seal,
.doc-lines {
  transition: opacity 0.07s ease;
}

/* ── RESPONSIVE ──────────────────────────────────── */

@media (max-width: 1024px) {
  .stats-split {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .morph-stage {
    width: min(60rem, 100%);
  }

  .sv-right {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .site-stats {
    padding-block: var(--space-8);
  }

  .morph-label-text {
    font-size: clamp(1.8rem, 4vw, 2.2rem);
  }
}

/* ── REDUCED MOTION ──────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .morph-cur,
  .morph-nxt          { animation: none; }
  .morph-bar-fill     { transition: none; }
  .sv-ambient         { animation: none; }
  .site-stats__heading { animation: none; }
}
