/* tank.tektology.com - the full leaderboard at /leaderboard/.

   Layered on app.css, which owns the bar, the notched panel, the input and the
   gold champion colour. What is local: the record-holder cards, and the
   table - which scrolls both ways inside its own frame, with the heading row
   and the rank and name columns held in place so a long list and a wide one
   both stay readable.

   GOLD is reserved for a champion, so the only gold here is the outright
   leader's row and the crown on a record card's figure. */

.lb { max-width: 1240px; }

.lb-hero { margin-bottom: 18px; }
.lb-hero .eyebrow { display: block; margin-bottom: 5px; }
.lb-hero h1 { font-size: clamp(30px, 6vw, 40px); }
.lb-lede { margin: 10px 0 0; font-size: 16px; color: var(--fg-2); max-width: 52ch; }

/* ---------------------------------------------------------------- records */

.lb-records {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.lb-rec {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 11px 13px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.lb-rec-t {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-3);
}

.lb-rec-v {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  color: var(--accent-hi);
}

.lb-rec-n {
  font-size: 13px;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-rec-n.is-me { color: var(--accent-hi); }
.lb-rec.is-empty .lb-rec-v { color: var(--fg-3); }
.lb-rec.is-empty .lb-rec-n { color: var(--fg-3); white-space: normal; }

/* ------------------------------------------------------------------ table */

.lb-tools { display: flex; margin: 0 0 12px; }
.lb-find { display: flex; flex-direction: column; gap: 5px; width: min(320px, 100%); }
.lb-find-l {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-3);
}

/* The frame that scrolls. A fixed maximum height, so the list scrolls inside
   the card and the page does not grow with the number of drivers. */
.lb-scroll {
  max-height: min(70vh, 640px);
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--bg-2);
  -webkit-overflow-scrolling: touch;
}

.lb-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.lb-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.lb-table th,
.lb-table td {
  padding: 9px 12px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
}

.lb-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 0;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-hard);
  font-weight: 400;
}

.lb-table .lb-num { text-align: right; }
.lb-table td.lb-num { font-family: var(--mono); color: var(--fg-2); }
.lb-table td.lb-num.is-zero { color: var(--fg-3); }
.lb-table td.lb-num.is-sorted { color: var(--fg); background: rgba(255, 154, 42, 0.05); }

/* Rank and name stay put while the stats scroll sideways. The header cells
   that are also sticky sideways need the higher z-index, and every sticky
   cell needs a solid background or the numbers slide under it visibly. */
.lb-table .lb-rank,
.lb-table .lb-name {
  position: sticky;
  z-index: 2;
  background: var(--bg-2);
}

.lb-table thead .lb-rank,
.lb-table thead .lb-name { z-index: 4; background: var(--surface-2); padding: 9px 12px; }

.lb-table .lb-rank { left: 0; width: 44px; min-width: 44px; text-align: right; color: var(--fg-3); font-family: var(--mono); }
.lb-table .lb-name { left: 44px; min-width: 130px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; color: var(--fg); }
.lb-table thead .lb-name { text-align: left; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-3); }
.lb-table thead .lb-rank { font-family: var(--mono); font-size: 11px; color: var(--fg-3); }

/* A shadow edge under the name column once the table is scrolled sideways
   would need script; the hairline is enough. */
.lb-table .lb-name { border-right: 1px solid var(--line-soft); }

.lb-sort {
  display: block;
  width: 100%;
  padding: 9px 12px;
  font: inherit;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: right;
  color: var(--fg-3);
  background: none;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--fast), background-color var(--fast);
}

.lb-sort:hover { color: var(--fg); background: var(--surface-3); }
.lb-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.lb-table th.is-sorted .lb-sort { color: var(--accent-hi); }
.lb-arrow { font-size: 10px; }

.lb-table tbody tr:hover td { background: rgba(214, 218, 222, 0.04); }
.lb-table tbody tr:hover td.lb-rank,
.lb-table tbody tr:hover td.lb-name { background: var(--surface); }

/* You. Accent, not gold. */
.lb-table tr.is-me td { color: var(--accent-hi); }
.lb-table tr.is-me td.lb-rank,
.lb-table tr.is-me td.lb-name { background: #1a1408; font-weight: 600; }

/* The outright leader of whatever the table is sorted by. */
.lb-table tr.champion td.lb-rank,
.lb-table tr.champion td.lb-name { color: var(--gold); font-weight: 600; }

.lb-foot {
  margin: 12px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--fg-3);
  max-width: 78ch;
}

@media (max-width: 640px) {
  .lb-records { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lb-table th, .lb-table td { padding: 8px 10px; }
  .lb-table .lb-name { min-width: 104px; }
}
