/* Bench Labs Leaderboard — v2.
   Dark-dimmed default with automatic light mode. Design language: compact
   density, pill chips, soft shadows, gamma-ramped score colors (set by JS
   through --score-* tokens below). */

:root {
  --bg: #0d1117;
  --bg-warm: #161b22;
  --card: #161b22;
  --card-hover: #1c2129;
  --border: #30363d;
  --border-light: #21262d;
  --text: #c9d1d9;
  --text-2: #8b949e;
  --text-3: #6e7681;
  --accent: #58a6ff;
  --green: #3fb950;
  --gold: #e3b341;
  --silver: #b1bac4;
  --bronze: #d18b47;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --t: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --score-base: 201, 209, 217;   /* worst score text color (rgb) */
  --score-best: 63, 185, 80;     /* best score text color (rgb) */
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fa;
    --bg-warm: #eaeef2;
    --card: #ffffff;
    --card-hover: #f6f8fa;
    --border: #d0d7de;
    --border-light: #e4e9ee;
    --text: #1f2328;
    --text-2: #57606a;
    --text-3: #8c959f;
    --accent: #0969da;
    --green: #1a7f37;
    --gold: #9a6700;
    --silver: #57606a;
    --bronze: #a04100;
    --shadow-sm: 0 1px 3px rgba(31, 35, 40, 0.08);
    --shadow-md: 0 4px 12px rgba(31, 35, 40, 0.12);
    --score-base: 87, 96, 106;
    --score-best: 26, 127, 55;
    color-scheme: light;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

code, pre { font-family: "SF Mono", "Cascadia Code", "Fira Code", Consolas, monospace; }

.shell { max-width: 1080px; margin: 0 auto; padding: 2rem 1.75rem 3rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* entry animation */
.anim { opacity: 0; animation: fadeUp 0.45s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.d1 { animation-delay: 0.02s; } .d2 { animation-delay: 0.06s; }
.d3 { animation-delay: 0.10s; } .d4 { animation-delay: 0.14s; }
.d5 { animation-delay: 0.18s; } .d6 { animation-delay: 0.22s; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .anim { animation: none; opacity: 1; } }

/* ---- hero ---------------------------------------------------------------- */

.hero { margin-bottom: 1.4rem; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.78rem; color: var(--text-2); margin-bottom: 0.4rem;
}
.eyebrow-sep { color: var(--text-3); }
.hero h1 { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.02em; }
.subtitle { color: var(--text-2); max-width: 60ch; margin-top: 0.35rem; font-size: 0.92rem; }

/* ---- stat pills ----------------------------------------------------------- */

.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px; margin-bottom: 1.2rem;
}
.stat-pill {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.7rem 0.9rem;
  transition: var(--t);
}
.stat-pill:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.stat-pill .label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-2);
}
.stat-pill .value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-pill .value.good { color: var(--green); }
.stat-pill .sub { font-size: 0.72rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- controls ------------------------------------------------------------- */

.controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-bottom: 0.9rem;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.chip {
  border: 1px solid var(--border); background: var(--card); color: var(--text-2);
  border-radius: 100px; padding: 4px 14px; font-size: 0.78rem; cursor: pointer;
  transition: var(--t); user-select: none;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .chip-note { opacity: 0.75; font-size: 0.7rem; margin-left: 4px; }

.controls-right { display: flex; gap: 8px; align-items: center; }
.search-pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); border: 1px solid var(--border); border-radius: 100px;
  padding: 5px 13px; color: var(--text-3); transition: var(--t);
}
.search-pill:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.25); }
.search-pill input {
  border: 0; background: transparent; outline: 0; color: var(--text);
  font-size: 0.82rem; width: 170px;
}
.sort-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--border); border-radius: 100px;
  padding: 5px 8px 5px 13px; transition: var(--t);
}
.sort-pill:focus-within { border-color: var(--accent); }
.sort-label { font-size: 0.74rem; color: var(--text-3); }
.sort-pill select {
  border: 0; background: transparent; color: var(--text); font-size: 0.82rem;
  outline: 0; cursor: pointer;
}
.sort-pill select option { background: var(--card); color: var(--text); }

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

.table-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.table-scroll { overflow: auto; max-height: 78vh; -webkit-overflow-scrolling: touch; }
.table-scroll::-webkit-scrollbar { height: 6px; width: 6px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 100px; }

table { border-collapse: collapse; width: 100%; }
thead { position: sticky; top: 0; z-index: 2; }
th {
  background: var(--bg-warm); text-align: left; font-size: 0.68rem;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2);
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td {
  padding: 7px 10px; font-size: 0.82rem; border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
tbody tr.model-row { cursor: pointer; transition: background var(--t); }
tbody tr.model-row:hover { background: var(--bg-warm); }
tr:last-child td { border-bottom: 0; }

.rank { color: var(--text-3); font-variant-numeric: tabular-nums; }
.rank-1 { color: var(--gold); font-weight: 700; }
.rank-2 { color: var(--silver); font-weight: 700; }
.rank-3 { color: var(--bronze); font-weight: 700; }

.model-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.model-cell a { color: var(--text); font-weight: 600; }
.model-cell a:hover { color: var(--accent); text-decoration: none; }

.org-tag {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 100px; padding: 1px 9px; font-size: 0.72rem;
}
.org-tag .dot { width: 7px; height: 7px; border-radius: 50%; }

td.score { font-variant-numeric: tabular-nums; }
td.score.best { font-weight: 700; }
td.score .na { color: var(--text-3); font-style: italic; font-size: 0.76rem; }

.expand-hint { color: var(--text-3); font-size: 0.7rem; transition: transform var(--t); display: inline-block; }
tr.open .expand-hint { transform: rotate(90deg); }

/* expanded detail row */
tr.detail-row td { background: var(--bg-warm); padding: 12px 16px; white-space: normal; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.detail-block h4 {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-2); margin-bottom: 6px;
}
.mode-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mode-chip {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 3px 9px; font-size: 0.74rem; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.mode-chip b { color: var(--text); }
.cat-table { width: 100%; font-size: 0.76rem; border-collapse: collapse; }
.cat-table td { padding: 2.5px 6px; border: 0; }
.cat-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.cat-bar { height: 4px; border-radius: 100px; background: var(--border-light); overflow: hidden; }
.cat-bar i { display: block; height: 100%; background: var(--green); border-radius: 100px; }

/* ---- mobile cards --------------------------------------------------------- */

#model-cards { display: none; }
.m-card { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border-light); }
.m-card:last-child { border-bottom: 0; }
.m-card-top { display: flex; align-items: baseline; gap: 8px; }
.m-card-top .rank { font-size: 0.8rem; }
.m-card-top a { color: var(--text); font-weight: 600; font-size: 0.92rem; }
.m-card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 5px 0 7px; align-items: center; }
.m-card-meta .params { color: var(--text-3); font-size: 0.74rem; }
.m-scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 6px; }
.m-score { background: var(--bg-warm); border-radius: var(--radius-sm); padding: 5px 8px; }
.m-score .k { font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); }
.m-score .v { font-size: 0.9rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- empty / howto / footer ---------------------------------------------- */

#empty-state { padding: 3rem 1.5rem; text-align: center; }
.empty-title { font-weight: 600; }
.empty-sub { color: var(--text-2); font-size: 0.85rem; margin-top: 0.4rem; }
.linklike {
  border: 0; background: transparent; color: var(--accent); cursor: pointer;
  font: inherit; padding: 0;
}
.linklike:hover { text-decoration: underline; }

.howto { margin-top: 1.1rem; }
.howto details {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.7rem 1rem;
}
.howto summary { cursor: pointer; font-size: 0.85rem; color: var(--text-2); }
.howto p { font-size: 0.82rem; color: var(--text-2); margin: 0.6rem 0 0.4rem; }
.howto pre {
  background: var(--bg); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; overflow-x: auto;
  font-size: 0.75rem; line-height: 1.55;
}

.foot {
  margin-top: 1.6rem; padding-top: 1rem; border-top: 1px solid var(--border-light);
  text-align: center; color: var(--text-3); font-size: 0.78rem;
}

/* ---- breakpoints ----------------------------------------------------------- */

@media (max-width: 768px) {
  .shell { padding: 1.2rem 1rem 2rem; }
  .hero h1 { font-size: 1.4rem; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .search-pill input { width: 120px; }
}

@media (max-width: 640px) {
  .table-scroll { display: none; }
  #model-cards { display: block; }
}

@media (max-width: 480px) {
  .stat-row { grid-template-columns: 1fr; }
  .controls-right { width: 100%; }
  .search-pill { flex: 1; }
  .search-pill input { width: 100%; }
}
