/* TSFM-RouterBench leaderboard — hand-written, no framework.
   One light design language: warm paper ground, white cards, ink text, deep
   teal accent. Every colour is stated explicitly; nothing is inherited from
   the host, and there is no dark variant. */

:root {
  /* paper and ink */
  --paper: #FAFAF7;
  --card: #FFFFFF;
  --ink: #1C2733;
  --ink-soft: #5B6B7A;
  --ink-faint: #8794A1;
  --rule: #E7E5DE;
  --rule-strong: #D8D5CC;

  /* accent */
  --accent: #0F6B62;
  --accent-soft: #E4F1EF;

  /* source badges */
  --reproduced: #0F6B62;
  --reproduced-bg: #E4F1EF;
  --community: #8A5A0B;
  --community-bg: #F7EDDA;
  /* Demo rows are illustration, never measurement: they get their own colour so
     the distinction survives a screenshot with the notice cropped out. */
  --demo: #8B2F5F;
  --demo-bg: #F8E8F0;

  /* table */
  --row-zebra: #FBFBF9;
  --row-hover: #F4F6F4;

  /* notice */
  --notice-bg: #F7EDDA;
  --notice-rule: #E4CFA3;

  --serif: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* `hidden` must win over the table display roles the UA sheet assigns. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

a { color: var(--accent); }

.mono {
  font-family: var(--mono);
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
}

/* ---------- header: paper ground, one hairline, no colour block ---------- */

.site-head {
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  padding: 44px 0 26px;
}

.site-head h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.005em;
  text-wrap: balance;
}

.tagline {
  margin: 8px 0 14px;
  max-width: 75ch;
  color: var(--ink-soft);
  font-size: 15.5px;
}

.build-line {
  margin: 0;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ---------- panels ---------- */

main { padding-bottom: 8px; }

.notice {
  margin: 24px 0 0;
  padding: 12px 16px;
  max-width: 75ch;
  background: var(--notice-bg);
  border: 1px solid var(--notice-rule);
  border-radius: 6px;
  font-size: 13.5px;
}

.panel {
  margin: 24px 0;
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.panel-note {
  margin: 0 0 18px;
  max-width: 75ch;
  color: var(--ink-soft);
  font-size: 13.5px;
}

.panel-note strong { color: var(--ink); font-weight: 600; }

.panel-note em { font-style: normal; font-weight: 500; color: var(--ink); }

/* ---------- filter rows ---------- */

.filter-rows { display: flex; flex-direction: column; gap: 12px; }

.filter-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.filter-label {
  width: 108px;
  flex: 0 0 108px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.chips { display: flex; flex-wrap: wrap; gap: 7px; }

.chip {
  padding: 5px 13px;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}

.chip:hover { color: var(--accent); border-color: var(--accent); }

.chip[aria-pressed="true"],
.chip[aria-checked="true"] {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 500;
}

.chip:focus-visible,
.reset:focus-visible,
th.sortable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Single-choice rows read as one connected control. */
.chips-single {
  gap: 0;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
}

.chips-single .chip {
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--rule-strong);
}

.chips-single .chip:first-child { border-radius: 999px 0 0 999px; }

.chips-single .chip:last-child { border-right: 0; border-radius: 0 999px 999px 0; }

.pool-line {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  max-width: 75ch;
  color: var(--ink-faint);
  font-size: 12.5px;
}

.pool-line .mono { color: var(--ink-soft); }

.filter-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}

.reset {
  padding: 6px 14px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  cursor: pointer;
}

.reset:hover { color: var(--accent); border-color: var(--accent); }

.count {
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

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

.table-panel { padding-bottom: 18px; }

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  white-space: nowrap;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 16px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: var(--card);
  border-bottom: 1px solid var(--rule-strong);
}

th.num, td.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

th.sortable { cursor: pointer; user-select: none; }

th.sortable:hover { color: var(--accent); }

th.sortable::after {
  content: "";
  display: inline-block;
  width: 0.85em;
  color: var(--ink-faint);
}

th.sortable[data-dir="asc"]::after { content: " \2191"; color: var(--accent); }
th.sortable[data-dir="desc"]::after { content: " \2193"; color: var(--accent); }

tbody td {
  height: 44px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}

/* Rows come in pairs (data row + its detail row), so the stripe steps by
   four to land on every other data row. */
tbody tr:nth-child(4n+3) td { background: var(--row-zebra); }

tbody tr:last-child td { border-bottom: 0; }

tbody tr:hover td { background: var(--row-hover); }

.method-name { font-weight: 600; }

a.method-name { color: var(--accent); text-decoration: none; }

a.method-name:hover { text-decoration: underline; }

.method-links { margin-left: 8px; font-size: 11px; font-weight: 400; }

.method-links a { color: var(--ink-faint); text-decoration: none; }

.method-links a:hover { color: var(--accent); text-decoration: underline; }

.method-org {
  display: block;
  margin-top: 1px;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink-faint);
  white-space: normal;
}

.dash { color: var(--ink-faint); }

/* mechanism is multi-label: one small tag per "+"-separated value */
.tags { display: inline-flex; flex-wrap: wrap; gap: 4px; }

.tag {
  padding: 1px 8px;
  font-size: 11.5px;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: 999px;
}

.badge-reproduced { color: var(--reproduced); background: var(--reproduced-bg); }
.badge-community { color: var(--community); background: var(--community-bg); }
.badge-demo { color: var(--demo); background: var(--demo-bg); }

/* Demo toggle and the exit button inside the notice. */
.demo-btn {
  margin-left: 8px;
  color: var(--demo);
  border-color: var(--demo);
}

.notice.demo-on {
  color: var(--demo);
  background: var(--demo-bg);
  border-color: var(--demo);
}

.empty {
  margin: 16px 2px 2px;
  max-width: 75ch;
  color: var(--ink-soft);
  font-size: 13.5px;
}

/* ---------- glossary ---------- */

.glossary { margin: 0; display: grid; grid-template-columns: 120px 1fr; gap: 10px 20px; }

.glossary dt {
  font-family: var(--serif);
  font-size: 14.5px;
  font-weight: 600;
}

.glossary dd {
  margin: 0;
  max-width: 75ch;
  color: var(--ink-soft);
  font-size: 13.5px;
}

/* ---------- footer ---------- */

.site-foot {
  margin-top: 40px;
  padding: 22px 0 44px;
  border-top: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 12.5px;
}

.site-foot p { margin: 0 0 8px; }

.honor { color: var(--ink-faint); max-width: 75ch; }

@media (max-width: 640px) {
  .site-head { padding: 32px 0 22px; }
  .site-head h1 { font-size: 27px; }
  .panel { padding: 18px; }
  .filter-label { width: auto; flex: 0 0 auto; }
  .glossary { grid-template-columns: 1fr; gap: 3px; }
  .glossary dd { margin-bottom: 12px; }
}


/* ---------- tooltips ---------- */

/* Pure CSS: the bubble is a pseudo-element of the trigger, so there is no
   floating layer to position in script. `title` carries the same text for
   assistive tech and for the no-CSS case. */
.has-tip { position: relative; }

.has-tip::after,
.has-tip::before {
  position: absolute;
  left: 50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease 0.25s, transform 0.12s ease 0.25s;
  z-index: 40;
}

.has-tip::after {
  content: attr(data-tip);
  bottom: calc(100% + 9px);
  transform: translate(-50%, 3px);
  width: max-content;
  max-width: 280px;
  padding: 8px 11px;
  background: var(--ink);
  color: #FFFFFF;
  border-radius: 6px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
  text-align: left;
  box-shadow: 0 6px 18px rgba(28, 39, 51, 0.16);
}

.has-tip::before {
  content: "";
  bottom: calc(100% + 3px);
  transform: translate(-50%, 3px);
  border: 6px solid transparent;
  border-top-color: var(--ink);
}

.has-tip:hover::after,
.has-tip:hover::before,
.has-tip:focus-visible::after,
.has-tip:focus-visible::before {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Table headers sit at the top of a scroll box, so their bubble opens down. */
.has-tip-below::after {
  bottom: auto;
  top: calc(100% + 9px);
  transform: translate(-50%, -3px);
}

.has-tip-below::before {
  bottom: auto;
  top: calc(100% + 3px);
  transform: translate(-50%, -3px);
  border-top-color: transparent;
  border-bottom-color: var(--ink);
}

.has-tip-below:hover::after,
.has-tip-below:hover::before,
.has-tip-below:focus-visible::after,
.has-tip-below:focus-visible::before { transform: translate(-50%, 0); }

/* Bubbles on the first and last columns would overhang the table edge. */
#board th:first-child.has-tip::after { left: 0; transform: translate(0, -3px); }
#board th:first-child.has-tip::before { left: 24px; }
#board th:first-child.has-tip:hover::after,
#board th:first-child.has-tip:focus-visible::after { transform: translate(0, 0); }

#board th:last-child.has-tip::after { left: auto; right: 0; transform: translate(0, -3px); }
#board th:last-child.has-tip::before { left: auto; right: 24px; }
#board th:last-child.has-tip:hover::after,
#board th:last-child.has-tip:focus-visible::after { transform: translate(0, 0); }

/* ---------- about ---------- */

.about p {
  margin: 0 0 12px;
  max-width: 75ch;
  color: var(--ink-soft);
  font-size: 14px;
}

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

/* ---------- summary statistics ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 20px;
}

.stat {
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
}

.stat-value {
  display: block;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  line-height: 1.2;
}

.stat-label {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---------- expandable detail row ---------- */

tbody tr[aria-expanded] { cursor: pointer; }

tbody tr.expanded td { background: var(--accent-soft); }

tbody tr.detail-row td,
tbody tr.detail-row:hover td {
  padding: 0;
  height: auto;
  background: var(--row-zebra);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px 24px;
  padding: 16px 16px 18px;
  white-space: normal;
}

.detail-item { display: flex; flex-direction: column; gap: 2px; }

.detail-label {
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.detail-item .mono { font-size: 12.5px; color: var(--ink); word-break: break-word; }

/* Scope/caveat text: full width so an adaptation disclaimer stays readable. */
.detail-item-wide { grid-column: 1 / -1; }
.detail-note { font-size: 12.5px; line-height: 1.5; color: var(--ink); }

.detail-links { display: flex; gap: 10px; font-size: 12.5px; }

/* ---------- protocol tracks ---------- */

.tracks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.track {
  padding: 16px 18px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
}

.track h3 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink);
}

.track p {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 13px;
}

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

/* ---------- empty state ---------- */

.empty p { margin: 0 0 12px; }

@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
