/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Light theme (default) */
  --bg: #faf9f6;
  --bg-card: #ffffff;
  --bg-hover: #f5f3ef;
  --border: #e5e2db;
  --border-strong: #ccc7bd;
  --text: #1a1a1a;
  --text-dim: #4a4a4a;
  --text-muted: #888888;
  --accent: #1e3a5f;
  --accent-hover: #2a5080;
  --green: #15803d;
  --red: #b91c1c;
  --yellow: #a16207;
  --puzzle-bg: #ffffff;
  --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --max-width: 1100px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114;
    --bg-card: #1a1a1f;
    --bg-hover: #222228;
    --border: #2a2a32;
    --border-strong: #3a3a44;
    --text: #e4e4e7;
    --text-dim: #a1a1aa;
    --text-muted: #71717a;
    --accent: #7c9cc5;
    --accent-hover: #9bb5d6;
    --green: #4ade80;
    --red: #f87171;
    --yellow: #facc15;
    --puzzle-bg: #ffffff;
  }
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Layout ──────────────────────────────────────────────── */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }

/* ── Navigation ──────────────────────────────────────────── */
nav {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  background: var(--bg);
}
nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.nav-brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 28px; align-items: center; }
.nav-links a {
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 500;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); text-decoration: none; }
.nav-sep {
  width: 1px;
  height: 14px;
  background: var(--border-strong);
}
.nav-icon {
  display: inline-flex;
  align-items: center;
}
.nav-icon svg { display: block; }

/* ── Hero ────────────────────────────────────────────────── */
.hero {
  padding: 56px 0 40px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}
.hero h1 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
  line-height: 1.25;
}
.hero .hero-tagline {
  font-size: 1.1rem;
  color: var(--text-dim);
  margin-bottom: 20px;
  letter-spacing: 0.01em;
}
.hero .subtitle {
  font-size: 1.05rem;
  color: var(--text-dim);
  max-width: 640px;
  margin: 0 auto 28px;
  line-height: 1.7;
}
.hero-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.hero-stat { text-align: center; }
.hero-stat .number {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
  letter-spacing: -0.02em;
}
.hero-stat .label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

/* ── Hero Grid (3x3 puzzle preview) ─────────────────────── */
.hero-grid {
  max-width: 360px;
  margin: 0 auto 36px;
}
.hero-grid img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.hero-grid a { display: block; }
.hero-grid a:hover img { border-color: var(--accent); }

/* ── CTA Buttons ─────────────────────────────────────────── */
.cta-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.88rem;
  transition: all 0.15s;
  border: none;
  cursor: pointer;
}
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); color: white; text-decoration: none; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ── Section Headers ─────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.section-header h2 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
}

/* ── Leaderboard Table ───────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: 48px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
thead th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  border-bottom: 2px solid var(--border-strong);
}
thead th:hover { color: var(--text); }
thead th.sorted { color: var(--accent); border-bottom-color: var(--accent); }
thead th .sort-arrow { margin-left: 4px; font-size: 0.7rem; }
tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }

.rank-cell {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  width: 36px;
}
.model-cell {
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  white-space: normal;
}
.model-name {
  white-space: nowrap;
}
a.model-name { text-decoration: none; }
a.model-name:hover { text-decoration: underline; }
.provider-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 600;
  font-family: var(--font-sans);
  margin-left: 8px;
  vertical-align: middle;
}
.rate-cell {
  font-family: var(--font-mono);
  font-weight: 600;
}
.rate-cell.high { color: var(--green); }
.rate-cell.medium { color: var(--yellow); }
.rate-cell.low { color: var(--text-muted); }
.cost-cell {
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-size: 0.82rem;
}

/* ── Filters ─────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.filter-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.filter-btn {
  padding: 5px 12px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--text); }
.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ── Footer ──────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  margin-top: 56px;
  color: var(--text-muted);
  font-size: 0.82rem;
}
footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
footer a { color: var(--text-dim); }
footer a:hover { color: var(--accent); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .hero h1 { font-size: 1.6rem; }
  .hero-stats { gap: 20px; }
  .hero-stat .number { font-size: 1.3rem; }
  .cta-row { flex-direction: column; align-items: center; }
  nav .container { flex-direction: column; gap: 8px; }
  .nav-links { flex-wrap: nowrap; justify-content: center; gap: 16px; }
  .nav-links a { font-size: 0.82rem; }
  .nav-sep { display: none; }
  .nav-links a[target="_blank"]:not(.nav-icon) { display: none; }
  .section-header { flex-direction: column; gap: 8px; }
  table { font-size: 0.75rem; }
  thead th { padding: 6px 6px; font-size: 0.65rem; letter-spacing: 0.03em; }
  tbody td { padding: 5px 6px; }
  .provider-badge { display: none; }
  .model-name {
    display: inline-block;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
  }
  .model-cell { font-size: 0.72rem; }
  .rank-cell { width: 24px; padding-left: 4px; padding-right: 4px; }
  .cost-cell { font-size: 0.72rem; }
}
