/* ===========================================================================
   CoDeC (Contamination Detection via Context) Leaderboard — NVIDIA-inspired light theme
   =========================================================================== */

:root {
  --nv-green: #76b900;
  --nv-green-dim: #5a8f00;
  --nv-green-bg: rgba(118, 185, 0, 0.08);
  --bg-base: #f5f5f5;
  --bg-white: #fff;
  --bg-surface: #fafafa;
  --border: #e0e0e0;
  --border-light: #eee;
  --text-primary: #1a1a1a;
  --text-secondary: #555;
  --text-muted: #999;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 8px;
  --radius-sm: 4px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== Top bar ===== */
#topbar {
  background: #1a1a1a;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 32px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nv-logo { flex-shrink: 0; }
.topbar-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  letter-spacing: 0.5px;
}
.topbar-sep {
  color: #666;
  font-weight: 300;
}
.topbar-subtitle {
  font-size: 0.85rem;
  color: #aaa;
  font-weight: 400;
}
#last-updated {
  margin-left: auto;
  font-size: 0.75rem;
  color: #888;
  white-space: nowrap;
}

/* ===== Hero ===== */
#hero {
  background: linear-gradient(135deg, #fff 0%, #f8f8f8 50%, #f0f0f0 100%);
  border-bottom: 1px solid var(--border);
  padding: 44px 32px 36px;
  text-align: center;
}
#hero h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
#hero p {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 400;
}
.paper-link {
  color: var(--nv-green-dim);
  text-decoration: none;
  font-weight: 500;
  margin-left: 4px;
}
.paper-link:hover {
  text-decoration: underline;
}

/* ===== Controls ===== */
#controls {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}
.controls-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}
.select-group {
  flex: 1;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.select-group .checkbox-panel {
  flex: 1;
}
.select-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.select-group label {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.select-buttons {
  display: flex;
  gap: 6px;
}
.select-buttons button {
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 3px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}
.select-buttons button:hover {
  border-color: var(--nv-green);
  color: var(--nv-green);
  background: var(--nv-green-bg);
}
/* Checkbox panels */
.checkbox-panel {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-white);
  padding: 2px 0;
}
.family-group:not(:last-child) {
  border-bottom: 1px solid var(--border-light);
}
.family-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  cursor: pointer;
  background: var(--bg-surface);
  user-select: none;
  transition: background 0.12s;
}
.family-header:hover {
  background: var(--nv-green-bg);
}
.family-label {
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex: 1;
}
.family-chevron {
  font-size: 0.55rem;
  color: var(--text-muted);
  transition: transform 0.15s;
  line-height: 1;
}
.family-header.collapsed .family-chevron {
  transform: rotate(-90deg);
}
.family-body.collapsed {
  display: none;
}
.filter-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 28px;
  font-size: 0.8rem;
  font-family: var(--font);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}
#benchmark-select .filter-item {
  padding-left: 10px;
}
.filter-item:hover {
  background: var(--nv-green-bg);
}
.filter-item input[type="checkbox"],
.family-header input[type="checkbox"] {
  accent-color: var(--nv-green);
  cursor: pointer;
  flex-shrink: 0;
}

/* ===== Table ===== */
#table-section {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 32px;
}
#table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-white);
  box-shadow: var(--shadow-md);
}
#table-container table {
  border-collapse: collapse;
  font-size: 0.78rem;
  white-space: nowrap;
  width: 100%;
}
#table-container th,
#table-container td {
  border: 1px solid var(--border-light);
  text-align: center;
  width: 72px;
  min-width: 72px;
  max-width: 72px;
}
#table-container thead {
  background: var(--bg-surface);
}

/* First column — model name */
#table-container th.model-header,
#table-container td.model-cell {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg-white);
  text-align: left;
  width: auto;
  min-width: 200px;
  max-width: 320px;
  padding: 6px 12px;
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background 0.12s;
}
#table-container th.model-header {
  background: var(--bg-surface);
  z-index: 3;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.6px;
}
#table-container td.model-cell {
  font-weight: 500;
  color: var(--text-primary);
  border-right: 1px solid var(--border-light);
  white-space: nowrap;
}
.model-name {
  overflow: hidden;
  text-overflow: ellipsis;
}
#table-container td.model-cell:hover {
  background: #eef6e0;
  color: var(--nv-green-dim);
}

/* Average column — sticky next to model */
#table-container th.avg-header,
#table-container td.avg-cell {
  position: sticky;
  z-index: 2;
  white-space: nowrap;
  border-right: 2px solid var(--border);
}
#table-container th.avg-header {
  z-index: 3;
  background: var(--bg-surface);
  font-weight: 600;
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 6px 8px;
}
#table-container th.avg-header:hover .header-sort,
#table-container th.avg-header .header-sort:has(.active) {
  opacity: 1;
}
#table-container td.avg-cell {
  font-weight: 600;
}

/* Rotated benchmark headers */
#table-container thead th.bench-header {
  height: 130px;
  padding: 0;
  vertical-align: bottom;
  cursor: pointer;
  transition: background 0.12s;
}
#table-container thead th.bench-header > div {
  transform: rotate(-50deg);
  transform-origin: bottom left;
  width: 30px;
  margin-left: 24px;
  margin-bottom: 10px;
  text-align: left;
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
#table-container thead th.bench-header:hover {
  background: var(--nv-green-bg);
}
#table-container thead th.bench-header:hover > div {
  color: var(--nv-green-dim);
}

/* Sort arrows in model header */
.header-sort {
  display: inline-flex !important;
  flex-direction: row !important;
  margin-left: 6px;
  vertical-align: middle;
}
#table-container th.model-header:hover .header-sort,
.header-sort:has(.active) {
  opacity: 1;
}
.header-sort {
  opacity: 0;
  transition: opacity 0.15s;
}

/* Row sort arrows (on model cells) */
.row-sort-arrows {
  display: inline-flex;
  flex-direction: column;
  margin-left: 6px;
  opacity: 0;
  transition: opacity 0.15s;
  vertical-align: middle;
  line-height: 1;
  gap: 0;
}
#table-container td.model-cell:hover .row-sort-arrows,
.row-sort-arrows:has(.active) {
  opacity: 1;
}
.sort-arrow {
  font-size: 0.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  border-radius: 2px;
  transition: color 0.12s, background 0.12s;
  user-select: none;
}
.sort-arrow:hover {
  color: var(--nv-green);
  background: var(--nv-green-bg);
}
.sort-arrow.active {
  color: var(--nv-green);
}

/* Column sort arrows (on benchmark headers) */
.col-sort-arrows {
  display: flex;
  justify-content: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
}
#table-container thead th.bench-header {
  position: relative;
}
#table-container thead th.bench-header:hover .col-sort-arrows,
.col-sort-arrows:has(.active) {
  opacity: 1;
}

/* Score cells */
#table-container td.score-cell {
  padding: 4px 5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
#table-container td.score-cell a {
  color: inherit;
  text-decoration: none;
  display: block;
}
#table-container td.score-cell a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}
#table-container td.missing {
  color: var(--text-muted);
  background: var(--bg-surface);
}

/* Active model row */
#table-container tr.active-row td {
  box-shadow: inset 0 0 0 1.5px var(--nv-green);
}
#table-container tr.active-row td.model-cell {
  color: var(--nv-green-dim);
  background: #eef6e0;
  font-weight: 600;
}

/* ===== Charts section ===== */
#charts-section {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 32px 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}
.chart-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 960px;
  box-shadow: var(--shadow-sm);
}
.chart-card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

/* ===== Model detail panel ===== */
#model-detail {
  background: linear-gradient(180deg, var(--nv-green-bg) 0%, var(--bg-base) 100%);
  border-top: 2px solid var(--nv-green);
}
.detail-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 32px;
}
#model-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
#model-detail-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}
#model-detail-close {
  font-family: var(--font);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 16px;
  border: 1px solid var(--nv-green);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  color: var(--nv-green-dim);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.15s;
}
#model-detail-close:hover {
  background: var(--nv-green);
  color: #fff;
}
#model-detail-close span {
  font-size: 1.1rem;
  line-height: 1;
}
#model-detail-charts {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
#model-detail-charts .chart-card {
  max-width: 440px;
  flex: 1 1 380px;
}

/* ===== Footer ===== */
footer {
  border-top: 1px solid var(--border);
  padding: 20px 32px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-white);
}

/* ===== Scrollbar (webkit) ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }
