/* =============================================================================
   World statistics — Doc/WORLD_STATISTICS.md

   A reading page, not a dashboard. DESIGN_SYSTEM §2 rules out data-heavy
   chrome, and these figures are context for what people are asking rather than
   the product's subject — so: generous spacing, one figure per card, and the
   citation always visible rather than hidden behind a tooltip nobody opens.
   ========================================================================== */

.pw-stats {
  display: flex;
  flex-direction: column;
  gap: var(--pw-6);
}

.pw-stats__header {
  display: flex;
  flex-direction: column;
  gap: var(--pw-2);
}

.pw-stats__lede {
  color: var(--pw-text-secondary);
  max-inline-size: 60ch;
}

.pw-stats__freshness {
  color: var(--pw-text-secondary);
  font-size: var(--pw-text-sm);
}

.pw-stats__freshness--stale {
  color: var(--pw-text-primary);
  font-weight: 600;
}

/* The provenance notice. It is a border-left rather than a coloured box: it
   must read as a statement the page is making, not as a dismissible banner. */
.pw-stats__notice {
  border-inline-start: 3px solid var(--pw-accent);
  padding-inline-start: var(--pw-3);
  color: var(--pw-text-secondary);
  font-size: var(--pw-text-sm);
  max-inline-size: 70ch;
}

.pw-stats__group {
  display: flex;
  flex-direction: column;
  gap: var(--pw-3);
}

.pw-stats__groupTitle {
  font-size: var(--pw-text-lg);
  margin: 0;
}

.pw-stats__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--pw-3);
}

/* --- one figure ---------------------------------------------------------- */

.pw-stat {
  display: flex;
  flex-direction: column;
  gap: var(--pw-1);
  padding: var(--pw-4);
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-lg);
  background: var(--pw-surface);
}

.pw-stat__head {
  display: flex;
  align-items: center;
  gap: var(--pw-2);
}

.pw-stat__icon {
  color: var(--pw-primary);
  flex: none;
}

.pw-stat__name {
  font-size: var(--pw-text-sm);
  font-weight: 600;
  color: var(--pw-text-secondary);
  margin: 0;
}

/* The number is the thing a reader takes away, so it gets the size. Tabular
   figures stop the digits shifting between cards of the same shape. */
.pw-stat__value {
  font-size: var(--pw-text-2xl);
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  margin: 0;
}

.pw-stat__desc {
  color: var(--pw-text-secondary);
  font-size: var(--pw-text-sm);
  margin: 0;
}

.pw-stat__context {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-block-start: var(--pw-1);
}

.pw-stat__world,
.pw-stat__change {
  font-size: var(--pw-text-sm);
  color: var(--pw-text-secondary);
  margin: 0;
}

/* Direction is shown by the word in the copy; colour only reinforces it, and
   only where the product actually holds a view. A `neutral` indicator gets
   neither modifier, so population growth is never painted good or bad. */
.pw-stat__change--better {
  color: var(--pw-success-text, var(--pw-text-primary));
}

.pw-stat__change--worse {
  color: var(--pw-danger-text, var(--pw-text-primary));
}

/* The citation. Always visible. It is small, but it is never hidden — a figure
   about the real world whose source takes an interaction to reveal is a figure
   most readers will take on trust. */
.pw-stat__source {
  font-size: var(--pw-text-xs);
  color: var(--pw-text-secondary);
  margin: 0;
  margin-block-start: auto;
  padding-block-start: var(--pw-2);
}

.pw-stat__source--illustrative {
  font-style: italic;
}

.pw-stat__sourceLink {
  color: inherit;
}

.pw-stats__footer {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pw-2);
  padding-block-start: var(--pw-4);
  border-block-start: 1px solid var(--pw-border);
}

@media (max-width: 560px) {
  .pw-stats__grid {
    grid-template-columns: 1fr;
  }
}
