/* NFL Excitement Index — cyberpunk HUD. Neon-minimal: effects stay subtle,
   viewability first. Both themes share one variable palette. */

:root {
  color-scheme: light;
  --bg: #e9eef5;
  --grid: rgba(20, 60, 100, 0.05);
  --scanline: rgba(15, 40, 70, 0.025);
  --card: #f7f9fc;
  --ink: #14202e;
  --muted: #4e6076;
  --faint: #74869c;
  --line: #c6d2e0;
  --thead: #eff3f8;
  --row-hover: rgba(0, 147, 168, 0.08);
  --code-bg: #dde6f0;
  --chip-bg: #ffffff;
  --chip-hover: #dce7f2;
  --neon: #0093a8;
  --neon-soft: rgba(0, 147, 168, 0.35);
  --accent: #d81b60;
  --shadow: 0 1px 3px rgba(15, 40, 70, 0.14);
    --pill-ink: #0b0e14;
  --pill-glow: transparent;
  --caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234e6076' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  /* thermal excitement ramp: 1 cold steel → 2 cyan → 3 amber → 4 orange → 5 magenta */
  --r1-bg: #8d99ab; --r1-ink: #10151d;
  --r2-bg: #1b7f96; --r2-ink: #eaf6fa;
  --r3-bg: #bd8a00; --r3-ink: #10151d;
  --r4-bg: #cf5f0a; --r4-ink: #fff3e8;
  --r5-bg: #d81b60; --r5-ink: #ffffff;
  --font-display: "Orbitron", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Share Tech Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0e17;
  --grid: rgba(0, 240, 255, 0.04);
  --scanline: rgba(210, 240, 255, 0.028);
  --card: #101623;
  --ink: #d9e6f2;
  --muted: #7d8ca3;
  --faint: #55647c;
  --line: #1e2a3d;
  --thead: #0d1320;
  --row-hover: rgba(0, 240, 255, 0.05);
  --code-bg: #182236;
  --chip-bg: #131b2b;
  --chip-hover: #223350;
  --neon: #00f0ff;
  --neon-soft: rgba(0, 240, 255, 0.4);
  --accent: #ff2a6d;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  --pill-glow: rgba(255, 255, 255, 0.4);
  --caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398a1b0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  --r1-bg: #46536b; --r1-ink: #d9e6f2;
  --r2-bg: #2a9db8; --r2-ink: #06121a;
  --r3-bg: #ffb800; --r3-ink: #1a1205;
  --r4-bg: #ff7a1a; --r4-ink: #1a0d02;
  --r5-bg: #ff2a6d; --r5-ink: #1a040c;
}

* { box-sizing: border-box; }

html { scrollbar-color: var(--chip-hover) var(--bg); }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 44px 44px;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* faint CRT scanlines over everything */
.fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  background: repeating-linear-gradient(
    0deg, var(--scanline) 0 1px, transparent 1px 3px);
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 20px 64px;
}

/* ---- header ---- */

header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--neon);
  text-shadow: 0 0 14px var(--neon-soft);
}

header h1:hover { animation: glitch 0.25s steps(2, end) 2; }

@keyframes glitch {
  0%   { text-shadow: 2px 0 var(--accent), -2px 0 var(--neon-soft); }
  50%  { text-shadow: -2px 0 var(--accent), 2px 0 var(--neon-soft); }
  100% { text-shadow: 0 0 14px var(--neon-soft); }
}

.meta {
  margin: 10px 0 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- week nav ---- */

.weeks-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 24px 0 6px;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}

.week-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  border: none;
  background: var(--chip-bg);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  flex: 0 0 auto;
  scroll-snap-align: start;
  -webkit-tap-highlight-color: transparent;
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px),
                     calc(100% - 9px) 100%, 0 100%, 0 9px);
}

.week-chip:hover { background: var(--chip-hover); }

.week-chip.active {
  background: var(--neon);
  color: var(--pill-ink);
}

.wk-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.wk-dates {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
}

.week-chip:hover .wk-dates { color: var(--ink); }
.week-chip.active .wk-dates { color: inherit; opacity: 0.75; }

/* ---- toolbar ---- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 20px 0 12px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.toolbar select,
.theme-toggle {
  font-family: var(--font-mono);
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background-color: var(--card);
  color: var(--ink);
  min-height: 40px;
}

/* Custom caret: native select chrome draws its own arrow close to the edge
   on some platforms (macOS Chrome), so strip appearance and draw ours. */
.toolbar select {
  appearance: none;
  -webkit-appearance: none;
  font-size: 0.85rem;
  width: 150px;
  padding-right: 32px;
  background-image: var(--caret);
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 11px;
}

.toolbar #season { width: 96px; text-align: center; }

.toolbar select:focus-visible,
.theme-toggle:focus-visible {
  outline: 1px solid var(--neon);
  outline-offset: 1px;
}

.theme-toggle {
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 7px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  display: block;
  stroke: var(--neon);
  filter: drop-shadow(0 0 5px var(--neon-soft));
}

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

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

.table-wrap {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

/* HUD corner brackets */
.table-wrap::before,
.table-wrap::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  pointer-events: none;
  z-index: 2;
}

.table-wrap::before {
  top: 0;
  left: 0;
  border-top: 2px solid var(--neon);
  border-left: 2px solid var(--neon);
}

.table-wrap::after {
  bottom: 0;
  right: 0;
  border-bottom: 2px solid var(--neon);
  border-right: 2px solid var(--neon);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  min-width: 460px;
}

thead th {
  text-align: left;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  background: var(--thead);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--row-hover); }

.teams { display: block; font-weight: 600; }
.teams .at { color: var(--faint); font-weight: 400; }

.date-cell {
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--muted);
}

.kick { color: var(--faint); font-variant-numeric: tabular-nums; }

/* ---- rating badges: chamfered neon ---- */

.pill {
  display: inline-block;
  min-width: 3.4rem;
  text-align: center;
  padding: 5px 12px;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 400;
  color: var(--pill-ink);
  white-space: nowrap;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px),
                     calc(100% - 8px) 100%, 0 100%, 0 8px);
}

.pill.r5 { background: var(--r5-bg); color: var(--r5-ink); text-shadow: 0 0 6px var(--pill-glow); }
.pill.r4 { background: var(--r4-bg); color: var(--r4-ink); text-shadow: 0 0 6px var(--pill-glow); }
.pill.r3 { background: var(--r3-bg); color: var(--r3-ink); }
.pill.r2 { background: var(--r2-bg); color: var(--r2-ink); }
.pill.r1 { background: var(--r1-bg); color: var(--r1-ink); }

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

.empty {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 2px;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}

.empty code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  border-radius: 2px;
  padding: 2px 6px;
  font-size: 0.85em;
}

/* ---- theme transitions ---- */

body,
.table-wrap,
thead th,
tbody tr,
.week-chip,
.toolbar select,
.theme-toggle,
.pill {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* ---- mobile: table becomes stacked cards ---- */

@media (max-width: 560px) {
  .container { padding: 24px 12px 48px; }
  header h1 { font-size: 1.15rem; }

  .table-wrap { overflow-x: visible; }
  table { display: block; min-width: 0; }
  thead { display: none; }
  tbody { display: block; }
  tbody tr {
    display: block;
    position: relative;
    border-bottom: 1px solid var(--line);
    padding: 12px 96px 12px 14px;
  }
  tbody tr:last-child { border-bottom: none; }
  tbody td { display: block; border-bottom: none; padding: 2px 0; }
  td.matchup { padding-right: 0; }
  td.date-cell { font-size: 0.8rem; }
  td:last-child {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
  }

  .toolbar { justify-content: flex-start; flex-wrap: wrap; }
  .weeks-nav { scroll-snap-type: x mandatory; }
}

/* ---- reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}