/* ULTRABENCH — leaderboard: filter rail, wide board (winner-highlight columns, pinning).
   Scoped entirely under .lb-* so it cannot leak into the shared table primitives. */

/* ---------- filter rail ---------- */

.lb-rail {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px; margin-bottom: 12px;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
}
.lb-rail-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lb-rail-spacer { flex: 1 1 auto; }
.lb-rail-label {
  color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  margin-right: 2px;
}

.lb-search { flex: 0 1 280px; display: flex; }
.lb-search input {
  width: 100%; font: inherit; font-size: 13px;
  background: var(--bg-inset); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  padding: 6px 9px;
}
.lb-search input::placeholder { color: var(--text-faint); }

.lb-chip {
  font: inherit; font-size: 12px; line-height: 1;
  padding: 6px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--bg-inset); color: var(--text-dim);
  white-space: nowrap;
}
.lb-chip:hover { color: var(--text); border-color: var(--text-faint); }
.lb-chip[aria-pressed="true"] {
  color: var(--accent); border-color: var(--accent); background: var(--accent-dim);
}
.lb-chip-quiet { border-style: dashed; }
.lb-chip-set { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.lb-vendors { gap: 6px; }
.lb-vendor {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text-dim);
  border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 3px 7px; cursor: pointer;
}
.lb-vendor:hover { border-color: var(--line-strong); color: var(--text); }
.lb-vendor.is-on { color: var(--text); border-color: var(--accent-dim); background: var(--accent-dim); }
.lb-vendor input { accent-color: var(--accent); margin: 0; }
.lb-vendor-n { color: var(--text-faint); font-family: var(--mono); font-size: 11px; }

/* ---------- board ---------- */

/* The window owns vertical scroll — the wrap only ever scrolls horizontally, so the
   page grows to the board's full height (livebench-style). No max-height anywhere. */
.lb-wrap {
  overflow-x: auto;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-raised);
  -webkit-overflow-scrolling: touch;
}
table.lb {
  border-collapse: separate; border-spacing: 0; width: 100%;
  font-size: 13px;
}
table.lb th, table.lb td {
  padding: 7px 11px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
table.lb td.num, table.lb th.num {
  text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums;
}

/* header: group row over column row. NOT vertically sticky — a horizontal-only scroller
   cannot host viewport-sticky headers (accepted with D4; only the left columns pin). */
table.lb thead th { background: var(--bg-inset); }
.lb-grp-row th {
  height: 24px; padding: 4px 11px;
  font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-faint); border-bottom: 1px solid var(--line);
  background: var(--bg-inset);
}
.lb-grp-benchmarks, .lb-grp-cost, .lb-grp-specs {
  border-left: 1px solid var(--line-strong); color: var(--text-dim);
}
.lb-head-row th {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-dim); vertical-align: bottom;
}
table.lb th.sortable { cursor: pointer; user-select: none; }
table.lb th.sortable:hover { color: var(--text); }
/* the header is also the drag handle for the reader's column order; the indicator marks
   the left edge the dragged column will land at */
table.lb th.sortable[draggable="true"] { cursor: grab; }
.lb-drop-target { box-shadow: inset 3px 0 0 var(--accent); }
table.lb th .sort-arrow { color: var(--accent); margin-left: 4px; font-size: 9px; }
.lb-th-label { display: inline-block; max-width: 132px; overflow: hidden; text-overflow: ellipsis;
               vertical-align: bottom; }

/* sticky rank + model columns — width fits the 32px pin-star slot + 3-digit rank; the
   model column's `left` must always equal the rank column's width */
table.lb th.lb-rank, table.lb td.lb-rank {
  position: sticky; left: 0; width: 78px; min-width: 78px;
  text-align: right; color: var(--text-faint);
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  background: var(--bg-raised); padding-right: 8px;
}
table.lb thead th.lb-rank { background: var(--bg-inset); z-index: 5; }
/* Column 2 pins only on the head row and body rows. The group row is excluded on
   purpose: ITS second cell is the empty colspan core th, and pinning that slides a
   full-core-width blank over the BENCHMARKS / COST labels once scrolled right. */
table.lb .lb-head-row th:nth-child(2), table.lb td:nth-child(2) {
  position: sticky; left: 78px; min-width: 190px; background: var(--bg-raised);
  border-right: 1px solid var(--line);
}
table.lb .lb-head-row th:nth-child(2) { background: var(--bg-inset); z-index: 5; }
table.lb tbody td:nth-child(1), table.lb tbody td:nth-child(2) { z-index: 1; }

/* rows */
.lb-row { cursor: pointer; }
/* hover must not erase the winner highlight, so it overlays instead of replacing it */
.lb-row:hover td { box-shadow: inset 0 0 0 9999px rgba(255, 255, 255, .035); }
table.lb tbody tr:last-child td { border-bottom: none; }

/* pin star — ghost until the row is hovered or the pin is pressed. Inline it drifted
   with the rank's digit count and rendered at table type size; absolute inside the
   sticky rank cell (sticky = positioned containing block) gives it a fixed, centered
   32px slot at the cell's left and a glyph ~3× the table type, without growing the row. */
.lb-pin {
  position: absolute; left: 4px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  font: inherit; font-size: 26px; line-height: 1;
  background: transparent; border: 0; padding: 0;
  color: var(--text-faint); opacity: .3; cursor: pointer;
}
tr:hover .lb-pin, .lb-pin:focus-visible, .lb-pin[aria-pressed="true"] { opacity: 1; }
.lb-pin[aria-pressed="true"] { color: var(--accent); }

/* pinned block: faint accent wash, then a strong divider on the first unpinned row.
   The sticky cells need the wash layered OVER an opaque base or scrolled columns
   bleed through them. */
.lb-row-pinned td { background: rgba(84, 214, 176, .05); }
table.lb .lb-row-pinned td.lb-rank,
table.lb .lb-row-pinned td:nth-child(2) {
  background: linear-gradient(rgba(84, 214, 176, .05), rgba(84, 214, 176, .05)), var(--bg-raised);
}
.lb-row-first td { border-top: 2px solid var(--line-strong); }

/* winner-only highlight: in each shaded column the best value (ties included) pops in
   accent; every other value mutes to the same tone as the null-value dash */
table.lb td.lb-best { background: var(--accent-dim); }
td.lb-best, .lb-best .lb-score, .lb-best .lb-free { color: var(--accent); }
td.lb-val, .lb-val .lb-score, .lb-val .lb-free { color: var(--text-faint); }

.lb-mdl { display: flex; align-items: baseline; gap: 6px; }
.lb-name { font-weight: 600; color: var(--text); }
.lb-name:hover { color: var(--accent); }
.lb-vendor-line { color: var(--text-faint); font-size: 11px; line-height: 1.3; }
.lb-tag {
  font-family: var(--mono); font-size: 9px; line-height: 1; letter-spacing: .04em;
  padding: 2px 4px; border-radius: 3px;
  color: var(--warn); border: 1px solid #3a3116;
}
.lb-sup {
  font-size: 10px; color: var(--text-faint); border-bottom: 1px dotted var(--line-strong);
  cursor: help;
}

/* "free" reads as a value in the price/value columns, not as a missing number */
.lb-free { color: var(--info); font-family: var(--mono); font-size: 11px; letter-spacing: .02em; }

.lb-score { color: var(--text); }
.lb-src {
  font-size: 10px; color: var(--text-faint); opacity: .2; text-decoration: none;
  padding-left: 1px;
}
.lb-td:hover .lb-src { opacity: 1; color: var(--accent); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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

@media (max-width: 860px) {
  .lb-search { flex: 1 1 100%; }
}

@media (max-width: 520px) {
  .lb-rail { padding: 8px 10px; }
  .lb-chip { padding: 5px 8px; font-size: 11px; }
  .lb-vendor { font-size: 11px; padding: 2px 6px; }
  table.lb th, table.lb td { padding: 6px 8px; }
  table.lb th.lb-rank, table.lb td.lb-rank { width: 64px; min-width: 64px; padding-right: 5px; }
  table.lb .lb-head-row th:nth-child(2), table.lb td:nth-child(2) { left: 64px; min-width: 148px; }
  /* the fixed slot stays ≥24×24px, just slightly tighter than desktop */
  .lb-pin { left: 2px; width: 28px; height: 28px; font-size: 22px; }
  .lb-th-label { max-width: 92px; }
  .lb-vendor-line { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .lb-chip, .lb-vendor, .lb-src, .lb-pin { transition: color .12s ease, border-color .12s ease, opacity .12s ease; }
}
