/* 08-top-lists.css
   top lists

   Page-scoped, like every sheet in this directory. The numeric prefix decides
   load order (styles.css first, then styles/*.css alphabetically); nothing
   here depends on a sibling, so the number only has to be unique.
   ======================================================================== */

.toplist-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 20px;
}

/* Three side by side is the whole point — the same name appearing in two of
   them is the finding. Below this they stack, at which point the comparison is
   a scroll rather than a glance, but a squeezed three-column rank list is
   unreadable either way. */
@media (max-width: 1180px) {
  .toplist-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ===========================================================================
   The podium
   ======================================================================== */

.podium-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 6px 8px 2px;
}

/* First, second and third side by side is the comparison — the winner's
   thirteen ranks mean little until they sit against the two it beat. Below
   this they stack, which keeps each card legible at the cost of the glance. */
@media (max-width: 1000px) {
  .podium-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.podium {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 14px 15px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

/* Only first place is dressed. Ranking the borders as well as the contents
   would say the same thing twice, and a bronze-tinted panel edge reads as a
   warning rather than as third. */
.podium.is-place-1 {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.podium__head {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

.podium__medal {
  flex: none;
  width: 26px;
  height: 26px;
  margin-top: 2px;
}

.podium__medal svg {
  width: 100%;
  height: 100%;
}

/* Gold, silver and bronze as their own values rather than palette tokens: the
   categorical series are for data, and a medal is not a series. All three hold
   contrast on both grounds — they are mid-tone by nature, which is the one
   useful thing about metal colours. */
.podium.is-place-1 .podium__medal { color: #c9992c; }
.podium.is-place-2 .podium__medal { color: #98a2ac; }
.podium.is-place-3 .podium__medal { color: #b0703c; }

.podium__title {
  min-width: 0;
}

.podium__place {
  display: block;
  color: var(--ink-faint);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.podium.is-place-1 .podium__place {
  color: var(--accent);
}

.podium__name {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.podium__score {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 5px;
}

.podium__score b {
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
  color: var(--accent);
}

.podium__score span {
  font-size: 11px;
  color: var(--ink-faint);
}

/* --- the metric rows ---------------------------------------------------- */

.podium__metrics {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin: 11px 0 0;
  padding: 0;
  list-style: none;
}

/* Rank, name and value on one line with the bar under it. The rank leads
   because it is the column a reader scans down — the values are in four
   different units and cannot be compared to each other, where "1st, 1st, 4th,
   9th" is a shape you can read in one pass. */
.podium-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  grid-template-areas:
    "rank label value"
    "rank track track";
  gap: 2px 8px;
  align-items: center;
}

.podium-row__rank {
  grid-area: rank;
  align-self: start;
  padding-top: 1px;
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.podium-row__rank.is-first {
  color: var(--accent);
}

.podium-row__label {
  grid-area: label;
  min-width: 0;
  color: var(--ink);
  font-size: 11px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The weight this component carries in the score. Every row on the card has
   one — the card shows the five the score is made of and nothing else — and
   the three sizes are what stop the five bars reading as five equal votes. */
.podium-row__label em {
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
}

.podium-row__value {
  grid-area: value;
  color: var(--ink-soft);
  font-size: 11px;
  white-space: nowrap;
}

.podium-row.is-unknown .podium-row__value {
  color: var(--ink-faint);
  font-style: italic;
}

.podium-row__track {
  grid-area: track;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-sunk);
  overflow: hidden;
}

.podium-row__track i {
  display: block;
  width: var(--w, 0%);
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
}

/* ===========================================================================
   Records
   ======================================================================== */

.records {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  padding: 6px 8px;
}

/* Separate bordered cards rather than one bordered strip with hairline gaps.
   The strip is tidier at the width that fits all five, and wrong at every
   other one: five cards wrapping 4 + 1 leaves the sixth cell showing the
   strip's own background as a grey block with nothing in it. */
.record {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.record__title {
  color: var(--ink-faint);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.record__value {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--ink);
}

.record__subject {
  font-size: 13px;
  color: var(--ink);
}

.record__detail {
  font-size: 11px;
  color: var(--ink-soft);
}

.record__next {
  margin-top: 4px;
  font-size: 11px;
  color: var(--ink-faint);
}

/* ===========================================================================
   Leaders at a glance
   ======================================================================== */

.leaders {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.leaders th,
.leaders td {
  padding: 7px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: baseline;
}

.leaders thead th {
  color: var(--ink-faint);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.leaders tbody th {
  color: var(--ink-soft);
  font-weight: 600;
  white-space: nowrap;
}

.leaders tbody tr:last-child th,
.leaders tbody tr:last-child td {
  border-bottom: 0;
}

/* Name above value rather than beside it: the names are long enough that a
   two-column cell would wrap the value onto its own line anyway, at which
   point the column widths stop lining up down the table. */
.leaders td b {
  display: block;
  color: var(--ink);
  font-weight: 600;
}

.leaders__name {
  display: block;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.leaders td.is-empty {
  color: var(--ink-faint);
}

/* ===========================================================================
   The metric picker
   ======================================================================== */

/* `.panel__head` is space-between and this is the only thing on the right, so
   it lands top right of the panel — the same corner `.segments` occupies on
   every other chart whose data can be switched. It is a select rather than a
   segmented control only because thirteen metrics do not fit in a strip; see
   `metricPicker`. */
.toplist-control {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  font-size: 12px;
  color: var(--ink-soft);
}

.toplist-control__label {
  white-space: nowrap;
}

.toplist-control__select {
  appearance: auto;
  max-width: 100%;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
}

/* Below the three-column breakpoint the panels are full width and the label
   has room; above it, in a third of the screen, "Rank by" and a 150px select
   together push the title into two lines. The select alone is legible enough —
   every option names a metric. */
@media (min-width: 1181px) and (max-width: 1500px) {
  .toplist-control__label {
    display: none;
  }
}
