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

/* === Theme variables === */
:root {
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  --font-display: var(--font-sans);

  --bg: #f1efe8;
  --bg-alt: #ebe8df;
  --fg: #2a2a2e;
  --fg-muted: #6b6b6b;
  --rule: #d9d5c8;
  --link: #0055a4;
  --link-hover: #003d75;
  --nav-bg: #1a1a2e;
  --nav-fg: #ffffff;
  --nav-fg-muted: #888;
  --table-header-bg: #ebe8df;
  --table-header-fg: #6b6b6b;
  --table-row-hover: rgba(103, 49, 189, 0.18);
  --table-stripe: #ebe8df;
  --stub-fg: #999;
  --accent: #6731bd;

  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--fg);
  background-color: var(--bg);
}

[data-theme="dark"] {
  --bg: #1a1e33;
  --bg-alt: #212542;
  --fg: #e0e0e0;
  --fg-muted: #8b93b3;
  --rule: #282d50;
  --link: #6db3f2;
  --link-hover: #8fc7f7;
  --nav-bg: #0d0d1a;
  --nav-fg: #e0e0e0;
  --nav-fg-muted: #666;
  --table-header-bg: #212542;
  --table-header-fg: #8b93b3;
  --table-row-hover: rgba(103, 49, 189, 0.25);
  --table-stripe: #212542;
  --stub-fg: #555;
  --accent: #9d6cff;
}

/* No-JS fallback for system dark preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #1a1e33;
    --bg-alt: #212542;
    --fg: #e0e0e0;
    --fg-muted: #8b93b3;
    --rule: #282d50;
    --link: #6db3f2;
    --link-hover: #8fc7f7;
    --nav-bg: #0d0d1a;
    --nav-fg: #e0e0e0;
    --nav-fg-muted: #666;
    --table-header-bg: #212542;
    --table-header-fg: #8b93b3;
    --table-row-hover: rgba(103, 49, 189, 0.25);
    --table-stripe: #212542;
    --stub-fg: #555;
    --accent: #9d6cff;
  }
}

/* === Links === */
a {
  color: var(--link);
  text-decoration: none;
}

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

/* === Global nav === */
.global-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: var(--nav-bg);
  color: var(--nav-fg);
  font-size: 14px;
}

.nav-wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--nav-fg);
  text-decoration: none;
}

.wordmark-bracket {
  color: var(--accent);
}

.nav-wordmark:hover {
  color: var(--nav-fg);
  text-decoration: none;
  opacity: 0.85;
}

.nav-leagues {
  display: flex;
  gap: 0.75rem;
}

.nav-leagues a {
  color: var(--nav-fg);
  font-weight: 600;
  text-decoration: none;
}

.nav-leagues a:hover {
  opacity: 0.85;
  text-decoration: underline;
}

.nav-leagues a[aria-current="true"] {
  border-bottom: 2px solid var(--nav-fg);
}

.nav-search {
  margin-left: auto;
}

.nav-search input {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--nav-fg-muted);
  border-radius: 3px;
  background: transparent;
  color: var(--nav-fg);
  font-size: 13px;
}

.nav-search input::placeholder {
  color: var(--nav-fg-muted);
}

.theme-toggle {
  background: none;
  border: none;
  color: var(--nav-fg);
  cursor: pointer;
  font-size: 18px;
  padding: 0.25rem;
  line-height: 1;
}

.theme-toggle:hover {
  opacity: 0.85;
}

/* Show moon in light mode, sun in dark mode */
.theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: inline; }

/* === League subnav === */
.league-subnav {
  display: flex;
  gap: 1.25rem;
  padding: 0.4rem 1rem;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
}

.league-subnav a {
  color: var(--fg);
  text-decoration: none;
}

.league-subnav a:hover {
  text-decoration: underline;
}

.nav-stub {
  color: var(--stub-fg) !important;
  cursor: help;
}

.nav-stub:hover {
  text-decoration: none !important;
}

/* === Breadcrumbs === */
.breadcrumbs {
  padding: 0.5rem 1rem;
  font-size: 13px;
  color: var(--fg-muted);
}

.breadcrumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
}

.breadcrumbs li::after {
  content: "\203A";
  margin: 0 0.35rem;
  color: var(--fg-muted);
}

.breadcrumbs li:last-child::after {
  content: "";
}

.breadcrumbs a {
  color: var(--link);
}

/* === Main content === */
main {
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* === Tables === */
main h2 {
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
  font-size: 18px;
  font-weight: 600;
}

main h2:first-of-type {
  margin-top: 1rem;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.25rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums lining-nums slashed-zero;
  font-size: 14px;
}

thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

thead th {
  background: var(--table-header-bg);
  color: var(--table-header-fg);
  border-bottom: 1px solid var(--rule);
  padding: 0.4rem 0.5rem;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

tbody tr {
  height: 36px;
}

tbody td {
  padding: 0.4rem 0.5rem;
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

tbody tr:nth-child(even) td:first-child,
tbody tr:nth-child(even) th:first-child {
  background: var(--table-stripe);
}

tbody tr:hover {
  background: var(--table-row-hover);
}

tbody tr:hover td:first-child,
tbody tr:hover th:first-child {
  background-image: linear-gradient(var(--table-row-hover), var(--table-row-hover));
}

/* Sticky first column */
th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--bg);
}

thead th:first-child {
  z-index: 3;
  background: var(--table-header-bg);
}

/* Table footer row (totals, etc.) */
tfoot td {
  border-top: 1px solid var(--rule);
  font-weight: 600;
}

/* === Mobile column classes === */
.col-essential {
  /* Full weight at all viewports — no special styling needed */
}

@media (max-width: 768px) {
  .col-detail {
    opacity: 0.5;
    font-size: 12px;
  }
}

/* === Data notes footer === */
.data-notes {
  padding: 1.5rem 1rem;
  font-size: 12px;
  color: var(--fg-muted);
  text-align: center;
  border-top: 1px solid var(--rule);
  margin-top: 2rem;
}

/* === Game header === */
.game-header {
  margin-bottom: 1.5rem;
}

.game-matchup {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 20px;
  font-family: var(--font-display);
  font-weight: 600;
}

.game-at {
  color: var(--fg-muted);
  font-size: 14px;
}

.game-team {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.team-score {
  font-size: 28px;
  font-family: var(--font-mono);
}

.game-meta {
  display: flex;
  gap: 1rem;
  font-size: 13px;
  color: var(--fg-muted);
  margin-top: 0.25rem;
}

/* DNP rows */
.dnp {
  opacity: 0.45;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* === Player avatar === */
.player-avatar {
  flex: none;
  width: 104px;
  height: 104px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 6px;
  overflow: hidden;
  text-align: center;
  user-select: none;
}

.avatar-number {
  font-size: 34px;
  font-weight: 500;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.avatar-name {
  font-weight: 700;
  letter-spacing: 1.5px;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

/* === Player header (layout for avatar + name stack) === */
.player-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.player-header-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.player-header-text h1 {
  margin: 0;
  font-size: 24px;
}

/* === Teams grid === */
.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.team-card {
  display: block;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-alt);
  text-decoration: none;
  color: var(--fg);
  transition: box-shadow 0.15s ease;
}

.team-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  text-decoration: none;
  color: var(--fg);
}

.team-card-stripe {
  height: 80px;
}

.team-card-body {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.team-card-name {
  font-weight: 600;
  font-size: 15px;
}

.team-card-city {
  font-size: 13px;
  color: var(--fg-muted);
}

@media (max-width: 480px) {
  .teams-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* === Home page === */
.home-leagues {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  margin-top: 1rem;
}

.home-leagues a {
  font-weight: 600;
  font-size: 18px;
}

/* === Search === */
.search-landing {
  text-align: center;
  margin-top: 3rem;
}

.search-form input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
  font-size: 16px;
  width: 100%;
  max-width: 400px;
  margin-top: 1rem;
}

.search-tip {
  margin-top: 0.75rem;
  color: var(--fg-muted);
  font-size: 14px;
}

.search-results {
  margin-top: 0.5rem;
}

.search-result-list {
  list-style: none;
  margin: 0.5rem 0 1rem;
}

.search-result-list li {
  padding: 0.4rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--rule);
}

.search-no-results {
  margin-top: 1rem;
  color: var(--fg-muted);
}

.search-overflow {
  margin-top: 0.25rem;
  font-size: 13px;
  color: var(--fg-muted);
  font-style: italic;
}

.league-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.4;
  vertical-align: middle;
}

.league-badge-wnba {
  background-color: #c4540a;
}

.league-badge-nwsl {
  background-color: #1a4d8f;
}

.color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  vertical-align: middle;
  flex-shrink: 0;
}
