/* users.css — the /users/ (around the world) hub: the shared numbers row, a
   draggable orthographic globe with a persistent reading panel, a ranked list
   whose rows double as the globe's control surface, a per-continent breakdown
   and an honest methodology line. The numbers are live counts spliced at build;
   nothing here fabricates proof. Depth is tone, never a resting shadow; every
   corner is a squircle via the token radii. Targets & state: DESIGN.md →
   Do's and Don'ts. */

/* The shared strip is also used on the home page. Reset doc-stack list spacing
   and give it the same breathing room as the former stat row. */
.doc-content .numbers-strip {
  margin-block: calc(var(--space-2xl) * 2);
}

.doc-content .numbers-row {
  margin: 0;
  padding: 0;
}

.doc-content .numbers-row > li {
  margin-bottom: 0;
}

/* --------------------------------------------------------- globe + data */

.users-explorer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  gap: var(--space-4xl);
  margin: 0 0 var(--space-2xl);
}

.users-globe {
  position: sticky;
  top: calc(var(--chrome-offset) + var(--space-lg));
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.users-globe-stage {
  position: relative;
  width: min(520px, 100%);
  aspect-ratio: 1 / 1;
  margin-inline: auto;
}

.users-globe-canvas {
  display: block;
  width: 100%;
  height: 100%;
  /* The globe's palette lives here as custom props so world-globe.js reads it
     from getComputedStyle and the sphere re-themes with dark mode for free. */
  --users-ocean: var(--color-bg-muted);
  --users-land: var(--color-border-strong);
  --users-land-with-players: var(--kind-guide);
  --users-land-without-players: color-mix(
    in srgb,
    var(--kind-guide) 40%,
    var(--color-bg-muted)
  );
  --users-rim: var(--color-border);
  --users-marker: var(--color-accent);
  --users-marker-halo: color-mix(in srgb, var(--color-accent) 22%, transparent);
  /* The canvas is decorative; the readout and the list are the real surfaces.
     It still tracks the pointer so it is draggable, but it is not a target. */
  touch-action: none;
  cursor: grab;
}

.users-globe-canvas:active {
  cursor: grabbing;
}

/* The persistent reading panel: a filled squircle below the globe, separated
   by tone alone (no border, no shadow). */
.users-readout {
  position: static;
  width: max-content;
  max-width: 92%;
  margin-inline: auto;
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-card);
  border-radius: var(--radius-lg);
  text-align: center;
  pointer-events: none;
}

.users-readout-title {
  margin: 0;
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  color: var(--color-heading);
  text-wrap: balance;
}

/* Three comparable totals take the hero-number scale. */
.users-readout-sub {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-md);
  margin: 2px 0 0;
  padding-block-start: calc(var(--space-sm) / 2);
  padding-block-end: calc(var(--space-sm) * 2);
  font-variant-numeric: tabular-nums;
}

.users-readout-sub > span {
  display: grid;
  gap: var(--space-2xs);
}

.users-readout-sub [data-readout-players],
.users-readout-sub [data-readout-teams],
.users-readout-sub [data-readout-matches] {
  font-size: var(--fs-stat);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: var(--track-tight);
  color: var(--color-heading);
}

/* The caption role owns the type; the rules below own the box and the muted ink. */
.users-readout-sub [data-readout-players-label],
.users-readout-sub [data-readout-teams-label],
.users-readout-sub [data-readout-matches-label] {
  color: var(--color-muted);
}

/* Static instructions, kept last and quiet: they never change with the
   selection, so they read as a footnote to the reading panel. */
.users-readout-hint {
  margin: var(--space-md) auto 0;
  max-width: 34ch;
  font-size: var(--fs-micro);
  color: var(--color-muted);
  text-wrap: balance;
}

/* ------------------------------------------------------------ ranked list */

.users-list-section {
  /* The doc stack's section component owns the beat: no margin here. */
  margin: 0;
}

.users-list-section > h2,
.users-continent-section > h2,
.users-card > h2 {
  font-size: var(--fs-h4);
  font-weight: var(--fw-bold);
  letter-spacing: var(--track-tight);
  text-wrap: balance;
  margin: 0 0 var(--space-md);
  color: var(--color-heading);
}

.users-empty {
  margin: 0;
  color: var(--color-muted);
  font-style: italic;
  text-wrap: pretty;
}

.doc-content .users-list {
  list-style: none;
  display: grid;
  gap: var(--space-2xs);
  margin: 0;
  padding: 0;
  max-width: 70ch;
}

.users-continent-section {
  /* The doc stack's section component owns the beat: no margin here. */
}

.users-row {
  /* One control: selects the country on the globe and pins the readout.
     >=44px hit area, tone shift on hover, ring on focus — no lift. */
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) minmax(0, 1.5fr);
  align-items: center;
  gap: var(--space-sm) var(--space-md);
  width: 100%;
  min-height: 2.75rem;
  padding: var(--space-sm) 0;
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  font: inherit;
  color: var(--color-body);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.users-row:hover {
  background: var(--color-bg-muted);
}

.users-row:focus-visible {
  outline: var(--focus-w) solid var(--focus-color);
  outline-offset: calc(var(--focus-offset) * -1);
}

.users-row[aria-pressed="true"] {
  background: var(--color-bg-muted);
}

.users-row-rank {
  font-variant-numeric: tabular-nums;
  color: var(--color-muted);
  min-width: 2ch;
  text-align: right;
}

.users-row-flag {
  font-size: 1.375rem;
  line-height: var(--lh-tight);
}

.users-row-name {
  font-weight: var(--fw-regular);
  color: var(--color-heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.users-row-metrics {
  display: grid;
  grid-column: 4;
  grid-row: 1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-sm);
  min-width: 0;
  color: var(--color-muted);
  font-size: var(--fs-micro);
  line-height: var(--lh-ui);
  font-variant-numeric: tabular-nums;
}

.users-row-metric {
  display: grid;
  min-width: 0;
  text-align: center;
}

.users-row-metric-value {
  color: var(--color-heading);
  font-weight: var(--fw-bold);
}

.users-row-metric-label {
  color: var(--color-muted);
  text-wrap: balance;
}

/* The log-scaled bar rides under the row, spanning the name column. The fill
   width is set inline from barWidthPct (min nub so a lone count reads). */
.users-row-bar {
  grid-column: 3 / -1;
  grid-row: 2;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--color-bg-muted);
  overflow: hidden;
}

.users-bar-fill {
  display: block;
  height: 100%;
  min-width: 4px;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
}

/* ------------------------------------------------------- continent strip */

.users-cont-bar {
  display: flex;
  gap: 2px;
  height: 12px;
  margin: 0 0 var(--space-md);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.users-cont-seg {
  /* flex-grow carries the proportion; solid tints keep the forest scale
     distinct without relying on opacity over the track. */
  background: color-mix(
    in srgb,
    var(--kind-guide) var(--tone),
    var(--color-bg)
  );
  min-width: 4px;
}

.users-cont-list {
  list-style: none;
  display: grid;
  gap: var(--space-2xs);
  margin: 0;
  padding: 0;
  max-width: 70ch;
}

.users-cont-list > li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-2xs) 0;
}

.users-cont-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-circle);
  background: color-mix(
    in srgb,
    var(--kind-guide) var(--tone),
    var(--color-bg)
  );
}

.users-cont-name {
  color: var(--color-body);
}

.users-cont-count {
  font-variant-numeric: tabular-nums;
  color: var(--color-muted);
}

/* Share of the country-listed people · how many countries the continent
   holds — the reference hub's "77% · 10 países". Full --color-muted (no
   opacity, which would drop the text below the AA 4.5:1 floor); the count
   stays the primary read by sitting left of it. */
.users-cont-meta {
  font-variant-numeric: tabular-nums;
  color: var(--color-muted);
  min-width: 8ch;
  text-align: right;
}

/* ------------------------------------------------------------ methodology */

/* Methodology + privacy continue the right-hand reading column. Filled
   squircles lift them off the page with tone alone (DESIGN.md → Shapes). */
.users-methods {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
  margin: var(--space-2xl) 0 0;
}

.users-card {
  /* The sanctioned filled panel: --surface-soft + the --r squircle marker,
     the same treatment as .gd-summary (support.css) — tone, never a border. */
  --r: var(--radius-lg);
  background: var(--surface-soft);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-xl);
}

/* A heading inside a filled panel is a label, not a section (DESIGN.md →
   Layout · Section rhythm). The `.doc-content` prefix is load-bearing: the bare
   `.users-card > h2` above ties with `.doc-content h2` (0,1,1) and loses to the
   later sheet, which would drop the section beat inside the card. */
.doc-content .users-card > h2 {
  margin: 0 0 var(--space-sm);
}

.users-card p {
  margin: 0 0 var(--space-sm);
  color: var(--color-body);
  text-wrap: pretty;
}

.users-card > h2 + p {
  margin-top: 0;
}

.users-card p:last-child {
  margin-bottom: 0;
}

.users-methods .users-dateline {
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 899px) {
  .users-explorer {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .users-globe {
    position: static;
    margin-bottom: var(--space-2xl);
  }

  .users-globe-stage {
    width: min(420px, 100%);
  }
}

@media (max-width: 640px) {
  .users-row {
    grid-template-columns: auto auto minmax(0, 1fr) minmax(0, 2.5fr);
    column-gap: var(--space-xs);
  }

  .users-row-metrics {
    gap: var(--space-2xs);
  }
}

/* The hub's quotable sentence: the same totals the strip shows, in one line
   (built from the study calculation, page-users.hbs). */
.users-summary {
  max-width: 60ch;
  font-size: var(--fs-lead);
  line-height: var(--lh-body);
  color: var(--color-heading);
  text-wrap: pretty;
}
