/* =========================================
   MLB Leaders — Netherite Theme
   ========================================= */

:root {
  --bg: #000000;
  --card: rgba(20, 14, 35, 0.9);
  --row: rgba(25, 18, 42, 0.9);
  --row-hover: rgba(32, 22, 55, 0.92);
  --row-alt: rgba(22, 16, 38, 0.9);
  --border: rgba(140, 100, 220, 0.12);
  --fg: #e2e8f0;
  --muted: #8a8a9a;
  --dim: #5a5a6a;
  --gold: #ffd54f;
  --silver: #bdbdbd;
  --bronze: #ffab40;
  --accent: #a78bfa;
}

/* =========================================
   Light Mode Overrides
   ========================================= */
[data-theme="light"] {
  --bg: #f5f5f7;
  --card: rgba(255, 255, 255, 0.9);
  --row: rgba(245, 242, 255, 0.9);
  --row-hover: rgba(235, 230, 250, 0.95);
  --row-alt: rgba(248, 245, 255, 0.9);
  --border: rgba(140, 100, 220, 0.18);
  --fg: #1a1a2e;
  --muted: #5a5a6e;
  --dim: #8a8a9a;
  --gold: #b8860b;
  --silver: #6b6b6b;
  --bronze: #cd6600;
  --accent: #7c3aed;
}

[data-theme="light"] body::before {
  background:
    repeating-conic-gradient(#e8e8ec 0% 25%, #ededf0 0% 50%) 0 0 / 4px 4px,
    linear-gradient(145deg, #f0f0f4 0%, #e8e8ec 30%, #f2f0f0 50%, #eaeaee 70%, #f0eeec 100%);
}

[data-theme="light"] body::after {
  background: linear-gradient(
    -45deg,
    transparent 0%, transparent 40%,
    rgba(120, 80, 200, 0.04) 45%,
    rgba(100, 60, 180, 0.07) 48%,
    rgba(140, 100, 220, 0.05) 50%,
    rgba(100, 60, 180, 0.07) 52%,
    rgba(120, 80, 200, 0.04) 55%,
    transparent 60%, transparent 100%
  );
  background-size: 400% 400%;
}

[data-theme="light"] .page-title {
  background: linear-gradient(135deg, #1a1a2e 0%, #7c3aed 60%, #b8860b 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

[data-theme="light"] ::selection { background: rgba(124, 58, 237, 0.2); color: #7c3aed; }

[data-theme="light"] .stats-table tbody tr {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .fg select {
  background: rgba(255, 255, 255, 0.9);
}

/* =========================================
   Theme Toggle Button
   ========================================= */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, border-color 0.2s ease;
  align-self: center;
}

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

.icon-sun  { display: none; }
.icon-moon { display: block; }

[data-theme="light"] .icon-sun  { display: block; }
[data-theme="light"] .icon-moon { display: none; }

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', -apple-system, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Netherite texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    repeating-conic-gradient(#0a0a0a 0% 25%, #070707 0% 50%) 0 0 / 4px 4px,
    linear-gradient(145deg, #0c0c0c 0%, #050505 30%, #0a0808 50%, #060606 70%, #080706 100%);
}

body > * { position: relative; z-index: 1; }

::selection { background: rgba(167, 139, 250, 0.25); color: #a78bfa; }
a { color: var(--muted); text-decoration: none; }
a:hover { color: var(--fg); }

/* =========================================
   Layout
   ========================================= */
.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
}

.page-title {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  padding: 1.25rem 0 0;
  background: linear-gradient(135deg, #e2e8f0 0%, #a78bfa 60%, #ffd54f 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* =========================================
   Position Tabs
   ========================================= */
.pos-tabs {
  display: flex;
  gap: 0;
  justify-content: center;
  padding: 1rem 0 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.pos-tab {
  padding: 0.45rem 0.9rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.pos-tab:hover { color: var(--fg); }

.pos-tab.active {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

/* =========================================
   Filter Bar
   ========================================= */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.fg {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.fg label {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
}

.fg select {
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  outline: none;
  cursor: pointer;
  min-width: 110px;
}

.fg select:focus { border-color: var(--accent); }

.back-link {
  font-size: 0.8rem;
  font-weight: 500;
  margin-left: auto;
  align-self: center;
}

/* =========================================
   Rankings Card
   ========================================= */
.rankings-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  overflow-x: auto;
}

.state {
  padding: 3rem;
  text-align: center;
  color: var(--dim);
  font-size: 0.88rem;
}

/* =========================================
   Stats Table
   ========================================= */
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 700px;
}

.stats-table thead th {
  padding: 0.5rem 0.5rem;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.12s;
  user-select: none;
}

.stats-table thead th:hover { color: var(--muted); }
.stats-table thead th.active { color: var(--accent); }

.stats-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background 0.1s;
}

.stats-table tbody tr:hover { background: var(--row-hover); }
.stats-table tbody tr:nth-child(even) { background: var(--row-alt); }
.stats-table tbody tr:nth-child(even):hover { background: var(--row-hover); }

.stats-table td {
  padding: 0.45rem 0.5rem;
  white-space: nowrap;
}

/* Column types */
.col-rank {
  width: 36px;
  text-align: center;
  font-weight: 700;
  color: var(--dim);
}

.col-rank.gold { color: var(--gold); }
.col-rank.silver { color: var(--silver); }
.col-rank.bronze { color: var(--bronze); }

.col-name {
  font-weight: 500;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-team {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.col-pos {
  color: var(--dim);
  font-size: 0.72rem;
  font-weight: 600;
}

.col-stat {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.col-stat.active {
  color: var(--accent);
  font-weight: 700;
}

/* =========================================
   Footer
   ========================================= */
.foot {
  text-align: center;
  padding: 2rem 0 1rem;
  font-size: 0.72rem;
  color: var(--dim);
}

.foot a { color: var(--muted); }

/* =========================================
   Responsive
   ========================================= */
@media (max-width: 700px) {
  .wrap { padding: 0.5rem 0.5rem 1rem; }
  .rankings-card { padding: 0.5rem; }
  .filter-bar { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .fg select { width: 100%; }
  .back-link { margin-left: 0; }
  .pos-tabs { justify-content: flex-start; padding: 0.75rem 0; }
}