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

/* ---------- "N more models are unranked" hint ----------
   Deliberately NOT `.notice`: that block carries a warn rule and is reserved for the board
   the filters emptied. This states a count and offers the toggle, so it reads in the muted
   register the rail already uses and can sit on the default board without shouting. */

.lb-hint {
  margin: -4px 0 12px; padding: 0 2px;
  color: var(--text-dim); font-size: 12px; line-height: 1.5;
}
.lb-hint-action {
  background: none; border: 0; padding: 0; margin-left: 2px;
  font: inherit; color: var(--accent); cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.lb-hint-action:hover { color: var(--text); }

/* ---------- 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;
}

/* release-date floor: label + native date input, chip-toned */
.lb-since {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim); white-space: nowrap;
}
.lb-since input {
  font: inherit; font-size: 12px;
  background: var(--bg-inset); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  padding: 4px 7px;
  color-scheme: dark; /* the native picker + calendar glyph follow the app's dark scheme */
}
.lb-since.is-on input { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
/* hardware fit (UB-291): label + native select, toned like the date floor */
.lb-fits {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim); white-space: nowrap;
}
.lb-fits select {
  font: inherit; font-size: 12px; max-width: 220px;
  background: var(--bg-inset); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  padding: 4px 7px; cursor: pointer;
  color-scheme: dark;
}
.lb-fits.is-on select { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
.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; }
/* "Reset filters" is a link styled as a chip (UB-511); the global link underline stays off. */
a.lb-chip { display: inline-block; text-decoration: none; }
a.lb-chip:hover { text-decoration: none; }
.empty-state .lb-empty-action { margin-top: 10px; }
.lb-chip-set { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
/* Better than (spec 10): the chip and its × wrap as one unit; a long reference name ellipsizes. */
.bt-set { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.bt-chip { max-width: min(340px, 100%); overflow: hidden; text-overflow: ellipsis;
  line-height: 1.2; padding-top: 5px; padding-bottom: 5px; }  /* no descender clip; same height as .lb-chip */
/* The panel is loading (a slow link, or a touch screen with no hover to warm it). */
.bt-chip[aria-busy="true"] { cursor: progress; }
.bt-chip.is-missing { border-style: dashed; }
/* The reference row's star focuses the ×; the scroll that brings it into view clears the
   sticky header. */
.bt-clear { scroll-margin-top: 72px; }
.bt-empty p { margin: 0; }
.bt-empty p + p { margin-top: 6px; }
/* The ≤520px rail chip keeps 5px padding at 11px text; at line-height 1.2 the chip would stand
   2px taller than its neighbours (0,2,0 so it outranks that later .lb-chip rule). */
@media (max-width: 520px) {
  .lb-chip.bt-chip { padding-top: 4px; padding-bottom: 4px; }
}
/* The × is one glyph wide: on touch it gets the 36 px box every other × has. */
@media (pointer: coarse) {
  .bt-clear { min-width: 36px; }
}

/* ---------- vendor picker (UB-528) ----------
   The rail's second row, left of the column chips: the label and a type-ahead box with
   nothing picked. Picked vendors become accent pills closed with ×; the list drops over
   the board and scrolls on its own. */

/* It grows into the row's free space: sized to its content alone, a multi-line flex box
   under-counts the box's 220px basis and drops the box under its label. */
.lb-vendors {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  flex: 1 1 auto; position: relative; min-width: 0;
}
.lb-vendor-pills { display: contents; }
.lb-chip.is-on { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
.lb-vendor-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 3px 2px 10px; cursor: default;
}
.lb-vendor-pill:hover { color: var(--accent); border-color: var(--accent); }
.lb-vendor-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; padding: 0; border: 0; border-radius: 999px;
  background: transparent; color: inherit; font: inherit; font-size: 14px; line-height: 1;
  cursor: pointer;
}
/* background-color, not the shorthand: the shorthand would reset the touch disc's clip below. */
.lb-vendor-x:hover, .lb-vendor-x:focus-visible { background-color: var(--bg-inset); color: var(--text); }
/* A fingertip needs more than the glyph: the × takes a 36px hit box that overhangs the
   pill's edge (UB-415); its hover disc stays 30px and the pill keeps its footprint. */
@media (pointer: coarse) {
  .lb-vendor-x {
    width: 36px; height: 36px; margin: -8px -6px -8px -5px;
    padding: 3px; background-clip: content-box;
  }
}
.lb-vendor-combo { position: relative; display: flex; flex: 0 1 220px; min-width: 160px; }
.lb-vendor-combo input {
  width: 100%; font: inherit; font-size: 12px;
  background: var(--bg-inset); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  padding: 5px 9px;
}
.lb-vendor-combo input::placeholder { color: var(--text-faint); }
.lb-vendor-list, .lb-vendor-none {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 40;
  min-width: 100%; margin: 0;
  background: var(--bg-raised); border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .45);
}
.lb-vendor-list {
  /* Capped to the viewport too (VF-211). On a touch screen the picker overrides max-height
     with the space actually visible below the box, keyboard included (fit.js, VF-R1-22). */
  width: max-content; max-width: min(320px, 92vw); max-height: min(288px, 40vh); overflow-y: auto;
  padding: 4px; list-style: none; overscroll-behavior: contain;
}
.lb-vendor-list[hidden], .lb-vendor-none[hidden], .lb-vendor-option[hidden] { display: none; }
.lb-vendor-none { padding: 8px 10px; font-size: 12px; color: var(--text-faint); white-space: nowrap; }
.lb-vendor-option {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 6px 8px; border-radius: var(--radius-s);
  font-size: 12px; color: var(--text-dim); cursor: pointer;
}
.lb-vendor-option:hover, .lb-vendor-option.is-active { background: var(--accent-dim); color: var(--text); }
.lb-vendor-n { color: var(--text-faint); font-family: var(--mono); font-size: 11px; }
/* On the accent wash no faint grey reaches 4.5:1; the dim one does (4.7:1, UB-246). */
.lb-vendor-pill .lb-vendor-n,
.lb-vendor-option:hover .lb-vendor-n,
.lb-vendor-option.is-active .lb-vendor-n { color: var(--text-dim); }
/* A vendor the other filters leave empty (UB-402): muted, still pickable. A picked one keeps
   its accent and trades the solid edge for a dashed one. The muted name and the dashed edge
   carry the signal; the count keeps its full colour, since a still-pickable option's text
   must hold AA (VF-208: a faded count measured 3.1:1). */
.lb-vendor-option.is-empty:not(.is-active) { color: var(--text-faint); }
.lb-vendor-pill.is-empty { border-style: dashed; }

/* ---------- 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;
  /* Every muted value in the board inherits the pre-UB-246 tone, so the table is unchanged. */
  --text-faint: var(--text-faint-board);
}
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);
}
/* An unlabeled core segment that FOLLOWS a labeled group needs the same seam, or the
   Specs/Benchmarks labels visually annex the trailing core columns. :nth-child(2) is the
   identity segment right after the rank th — no seam belongs there. */
.lb-grp-row .lb-grp-core:not(:nth-child(2)) { border-left: 1px solid var(--line-strong); }
.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); }

/* header tooltips: the column's calculation in ≤15 words (data-tip). Pure CSS, and the
   popup is pointer-transparent, so it can never steal a hover or a drag from the header
   underneath; while a column drag is in flight (.lb-dragging) they stay hidden outright.
   The sticky rank/model headers carry no data-tip, so this never fights position:sticky. */
table.lb th[data-tip] { position: relative; }
table.lb th[data-tip]::after {
  content: attr(data-tip);
  position: absolute; left: 0; top: calc(100% + 4px); z-index: 30;
  width: max-content; max-width: 230px;
  padding: 6px 9px; border-radius: var(--radius-s);
  background: var(--bg-inset); border: 1px solid var(--line-strong);
  color: var(--text); font-family: var(--sans); font-size: 11px; font-weight: 400;
  line-height: 1.45; letter-spacing: 0; text-transform: none;
  white-space: normal; text-align: left;
  pointer-events: none; opacity: 0; visibility: hidden;
  transition: opacity .12s ease .25s, visibility 0s linear .25s;
}
table.lb th[data-tip]:hover::after,
table.lb th[data-tip]:focus-visible::after { opacity: 1; visibility: visible; }
/* near the pane's right edge the popup hangs left instead, so the scroller cannot clip it */
table.lb th[data-tip]:nth-last-child(-n+3)::after { left: auto; right: 0; }
/* transition: none, or the .25s show/hide delay would let a tooltip linger into the drag */
table.lb.lb-dragging th[data-tip]::after {
  opacity: 0 !important; visibility: hidden !important; transition: none !important;
}
/* 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);
  /* Lets the phone breakpoint cap the sticky column: as a flex item the name may
     ellipsize instead of forcing the cell wide. Unconstrained on desktop. */
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.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; }
  /* The rail wraps here, so the spacer would only right-align whichever group wraps after
     it (VF-224): the Columns set starts its own line under the full-width picker. */
  .lb-rail-spacer { display: none; }
  .lb-chip { padding: 5px 8px; font-size: 11px; }
  /* The picker takes the whole row (the column chips wrap under it), its box the rest of
     that row, and its list spans the row. */
  .lb-vendors { flex: 1 1 100%; }
  .lb-vendor-combo { position: static; flex: 1 1 160px; }
  .lb-vendor-list, .lb-vendor-none { right: 0; width: auto; max-width: none; }
  /* The native date box is the rail's one fiddly tap target — give it real height. */
  .lb-since input { min-height: 40px; }
  .lb-fits select { min-height: 40px; max-width: 200px; }
  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; }
  /* The sticky pair (rank 64px + model) must NOT blanket the pane: uncapped, a long
     model name left ~70px of scroll reveal on a 390px phone. Capping the cell — and the
     flex content inside it, since table cells honor max-width unreliably — keeps ~140px
     of the board visible while the name ellipsizes. */
  table.lb .lb-head-row th:nth-child(2), table.lb td:nth-child(2) {
    left: 64px; min-width: 148px; max-width: 160px;
  }
  table.lb td:nth-child(2) .lb-mdl { max-width: 144px; }
  /* 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; }
}

/* Touch pointers (UB-415): rail chips, vendor pills, the picker's box and its options get
   a finger-sized box; a mouse keeps the desktop density, even in a narrow window. The
   inline "Show unranked" action keeps its sentence line-height and grows only its hit
   area — nothing tappable sits within 9px of it. */
@media (pointer: coarse) {
  .lb-chip { min-height: 36px; }
  a.lb-chip { display: inline-flex; align-items: center; }
  .lb-vendor-combo input { min-height: 36px; }
  /* iOS zooms the page when a text box or select under 16px takes focus; the email gate's
     field already holds 16px on phones (VF-210, VF-R1-21). */
  .lb-vendor-combo input, .lb-search input { font-size: 16px; }
  .lb-since input, .lb-fits select { font-size: 16px; }
  .lb-vendor-option { min-height: 36px; align-items: center; }
  .lb-hint-action { position: relative; }
  .lb-hint-action::after { content: ""; position: absolute; inset: -9px -6px; }
}

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