/* public/styles.css — World Cup 2026 Sweepstakes */

/* ---------- Theme palettes ---------- */
:root {
  /* shared */
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 10px 26px rgba(16,24,40,.08);

  /* LIGHT (default) */
  --bg: #f4f6fb;
  --page-glow: #e3ebfb;
  --bg-1: #ffffff;
  --bg-2: #f3f6fc;
  --bg-3: #e7edf8;
  --border: #d6deef;
  --border-soft: #e6ecf7;
  --text: #141a28;
  --muted: #5a6678;
  --muted-2: #8b95a8;

  --accent: #2f7fe0;
  --in: #12a06a;       --in-bg: rgba(18,160,106,.12);
  --edge: #c98700;     --edge-bg: rgba(201,135,0,.13);
  --risk: #d2691e;     --risk-bg: rgba(210,105,30,.12);
  --out: #d64545;      --out-bg: rgba(214,69,69,.11);
  --gold: #a87a00;     --gold-bg: rgba(214,170,40,.16);
  --gold-chip: #6b4e00; --gold-chip-bg: #f4cf57;
}

/* DARK — applied when the OS prefers dark (and no manual override) … */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.18);
    --bg: #0b0e17;
    --page-glow: #16203a;
    --bg-1: #131826;
    --bg-2: #1a2032;
    --bg-3: #222a40;
    --border: #283150;
    --border-soft: #1e2538;
    --text: #eef1f7;
    --muted: #93a0bd;
    --muted-2: #6b7798;

    --accent: #4ea1ff;
    --in: #34d399;       --in-bg: rgba(52,211,153,.12);
    --edge: #fbbf24;     --edge-bg: rgba(251,191,36,.12);
    --risk: #fb923c;     --risk-bg: rgba(251,146,60,.12);
    --out: #f87171;      --out-bg: rgba(248,113,113,.12);
    --gold: #ffd24a;     --gold-bg: rgba(255,210,74,.14);
    --gold-chip: #1a1400; --gold-chip-bg: #ffd24a;
  }
}
/* … or when the user explicitly picks Dark. */
:root[data-theme="dark"] {
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.18);
  --bg: #0b0e17;
  --page-glow: #16203a;
  --bg-1: #131826;
  --bg-2: #1a2032;
  --bg-3: #222a40;
  --border: #283150;
  --border-soft: #1e2538;
  --text: #eef1f7;
  --muted: #93a0bd;
  --muted-2: #6b7798;

  --accent: #4ea1ff;
  --in: #34d399;       --in-bg: rgba(52,211,153,.12);
  --edge: #fbbf24;     --edge-bg: rgba(251,191,36,.12);
  --risk: #fb923c;     --risk-bg: rgba(251,146,60,.12);
  --out: #f87171;      --out-bg: rgba(248,113,113,.12);
  --gold: #ffd24a;     --gold-bg: rgba(255,210,74,.14);
  --gold-chip: #1a1400; --gold-chip-bg: #ffd24a;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }   /* never let a layout `display` re-show hidden elements */

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -200px, var(--page-glow) 0%, var(--bg) 60%);
  background-attachment: fixed;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 18px clamp(12px,3vw,24px) 64px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}
.header-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 12px clamp(12px,3vw,24px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.title-wrap { min-width: 0; }
.site-header h1 { font-size: clamp(1rem,2.6vw,1.3rem); letter-spacing: .2px; }
.subtitle {
  margin: 2px 0 0; font-size: .82rem; color: var(--muted);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.stage-chip {
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 1px 9px; font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.stage-chip:empty { display: none; }
.meta { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.updated { font-size: .78rem; color: var(--muted); white-space: nowrap; }

.icon-btn {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; width: 36px; height: 36px; font-size: 1.05rem; cursor: pointer;
  display: grid; place-items: center; flex: 0 0 auto; line-height: 1;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.spinning { animation: spin .6s ease; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Settings menu */
.settings { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  background: var(--bg-1); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; min-width: 156px;
}
.menu-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted-2); font-weight: 700; padding: 6px 8px 4px;
}
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: transparent; border: 0; border-radius: 8px;
  padding: 8px 9px; font: inherit; color: var(--text); cursor: pointer; text-align: left;
}
.menu-item:hover { background: var(--bg-2); }
.menu-item[aria-checked="true"] { background: var(--bg-3); font-weight: 600; }
.menu-item[aria-checked="true"]::after { content: "✓"; margin-left: auto; color: var(--accent); }

.banner { max-width: 1280px; margin: 0 auto; padding: 8px clamp(12px,3vw,24px); font-size: .84rem; }
.banner-error { color: var(--out); background: var(--out-bg); }
.banner-warn { color: var(--edge); background: var(--edge-bg); }

/* ---------- Champion banner ---------- */
.champion-banner {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(100deg, var(--gold-bg), transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 55%, transparent);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px;
}
.champion-banner .trophy { font-size: 2rem; }
.champion-line { font-size: 1.05rem; }
.champion-sub { color: var(--muted); font-size: .86rem; }

/* ---------- Sections ---------- */
.section-title {
  font-size: .82rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 700; margin: 4px 2px 10px;
}
.section-title .hint { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--muted-2); }

/* ---------- Leaderboard ---------- */
.standings { margin-bottom: 22px; }
.leaderboard { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 8px; }
.lb-item {
  text-align: left; cursor: pointer;
  background: var(--bg-1); border: 1px solid var(--border-soft); border-radius: 12px;
  padding: 9px 11px; display: grid; grid-template-columns: 1fr auto; align-items: center;
  gap: 2px 8px; color: var(--text); font: inherit;
  transition: border-color .15s, transform .05s;
}
.lb-item:hover { border-color: var(--accent); }
.lb-item:active { transform: scale(.985); }
.lb-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-count { font-weight: 700; font-size: 1rem; color: var(--in); }
.lb-of { color: var(--muted-2); font-size: .72rem; font-weight: 500; }
.lb-bar { grid-column: 1 / -1; height: 5px; border-radius: 999px; background: var(--bg-3); overflow: hidden; margin-top: 3px; }
.lb-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--in), color-mix(in srgb, var(--in) 70%, #000)); border-radius: 999px; }
.lb-leading { border-color: color-mix(in srgb, var(--in) 45%, transparent); }
.lb-champion { border-color: color-mix(in srgb, var(--gold) 55%, transparent); background: var(--gold-bg); }
.lb-champion .lb-count { color: var(--gold); }

/* ---------- Board ---------- */
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px,1fr)); gap: 16px; align-items: start; }
.loading { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 56px 0; }

.person {
  background: var(--bg-1); border: 1px solid var(--border-soft);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  scroll-margin-top: 84px;
}
.person-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; background: var(--bg-2); border-bottom: 1px solid var(--border-soft);
}
.person-id { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.person-id h3 { font-size: 1.05rem; }
.person-stage { font-size: .72rem; color: var(--muted); }
.person-tally { display: flex; gap: 6px; flex: 0 0 auto; }
.tally { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.tally-in { color: var(--in); background: var(--in-bg); }
.tally-out { color: var(--out); background: var(--out-bg); }
.tally-na { color: var(--muted); background: color-mix(in srgb, var(--muted) 14%, transparent); }

.team-list { list-style: none; margin: 0; padding: 6px; }
.team {
  position: relative; display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: 10px; padding: 9px 10px 9px 14px; border-radius: 11px;
}
.team + .team { margin-top: 2px; }
.team-clickable { cursor: pointer; }
.team-clickable:hover { background: var(--bg-2); }
.team:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.status-rail { position: absolute; left: 4px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; }
.status-rail-in { background: var(--in); }
.status-rail-edge { background: var(--edge); }
.status-rail-risk { background: var(--risk); }
.status-rail-out { background: var(--out); }
.status-rail-champion { background: var(--gold); }
.status-rail-na { background: var(--muted-2); }
.status-rail-pending { background: var(--muted-2); opacity: .5; }

.crest { width: 26px; height: 26px; object-fit: contain; flex: 0 0 26px; }
.crest-lg { width: 40px; height: 40px; object-fit: contain; }
.crest-empty {
  width: 26px; height: 26px; display: grid; place-items: center;
  font-size: .6rem; font-weight: 800; color: var(--muted);
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 6px;
}

.team-body { min-width: 0; }
.team-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.team-name { font-weight: 600; font-size: .95rem; }
.team-sub { font-size: .72rem; color: var(--muted); }
.team-stats { display: flex; gap: 7px; margin-top: 2px; font-size: .74rem; color: var(--muted); flex-wrap: wrap; }
.team-stats .stat-pts { color: var(--text); font-weight: 700; }
.team-stats .stat-muted { font-style: italic; }
.team-fixtures { margin-top: 3px; display: flex; flex-direction: column; gap: 1px; font-size: .74rem; color: var(--muted); }
.fixture-next { color: var(--accent); }
.fixture-live { color: var(--edge); font-weight: 700; }
.fixture-muted { font-style: italic; color: var(--muted-2); }
.res-W { color: var(--in); } .res-L { color: var(--out); } .res-D { color: var(--muted); }

.chip {
  flex: 0 0 auto; align-self: center; font-size: .66rem; font-weight: 800; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 7px; white-space: nowrap; border: 1px solid transparent;
}
.chip-in { color: var(--in); background: var(--in-bg); }
.chip-advanced { color: var(--in); background: var(--in-bg); border-color: color-mix(in srgb, var(--in) 35%, transparent); }
.chip-edge { color: var(--edge); background: var(--edge-bg); }
.chip-risk { color: var(--risk); background: var(--risk-bg); }
.chip-out { color: var(--out); background: var(--out-bg); }
.chip-champion { color: var(--gold-chip); background: var(--gold-chip-bg); }
.chip-na { color: var(--muted); background: color-mix(in srgb, var(--muted) 14%, transparent); }
.chip-pending { color: var(--muted-2); background: color-mix(in srgb, var(--muted) 10%, transparent); }

.team-eliminated, .team-na { opacity: .58; }
.team-eliminated .team-name { text-decoration: line-through; text-decoration-color: var(--out); }
.team-eliminated:hover, .team-na:hover { opacity: .9; }
.team-champion { background: var(--gold-bg); }
.team-champion .team-name { font-weight: 800; }

/* ---------- Tooltip ---------- */
.tip {
  position: absolute; z-index: 60; max-width: min(280px,86vw);
  background: var(--bg-1); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; font-size: .78rem; line-height: 1.35;
  box-shadow: var(--shadow); pointer-events: none;
}

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; }
.modal-overlay { position: absolute; inset: 0; background: rgba(8,11,20,.55); backdrop-filter: blur(2px); }
.modal-card {
  position: relative; z-index: 1; width: min(560px, 100%); max-height: 86vh; overflow: auto;
  background: var(--bg-1); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4); padding: 18px;
}
.modal-close {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 1.2rem; cursor: pointer; line-height: 1;
}
.modal-close:hover { border-color: var(--accent); }
.m-head { display: flex; align-items: center; gap: 12px; padding-right: 36px; }
.m-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.m-title h2 { font-size: 1.2rem; }
.m-title .m-sub { font-size: .8rem; color: var(--muted); }
.m-reason { margin: 12px 0 4px; font-size: .86rem; color: var(--muted); }
.m-standing {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; padding: 10px 12px;
  background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: 10px; font-size: .82rem;
}
.m-standing b { color: var(--text); }
.m-muted { color: var(--muted-2); }
/* Group table (in modal) */
.grp-toggle {
  margin-top: 14px; width: 100%; text-align: left;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font: inherit; font-weight: 600; cursor: pointer;
}
.grp-toggle:hover { border-color: var(--accent); }
.grp-wrap { margin-top: 8px; }
.grp-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.grp-table th {
  text-align: right; font-weight: 600; color: var(--muted-2);
  padding: 6px 6px; border-bottom: 1px solid var(--border-soft); font-size: .72rem;
}
.grp-table th:nth-child(2) { text-align: left; }
.grp-table td { text-align: right; padding: 7px 6px; border-bottom: 1px solid var(--border-soft); font-variant-numeric: tabular-nums; }
.grp-table .grp-pos { color: var(--muted-2); width: 1.4rem; }
.grp-table .grp-team { text-align: left; display: flex; align-items: center; gap: 7px; }
.grp-table .grp-team img { width: 18px; height: 18px; object-fit: contain; }
.grp-table .grp-pts { font-weight: 800; color: var(--text); }
.grp-table .grp-me { background: var(--bg-2); }
.grp-table .grp-me td { font-weight: 700; }
.grp-table .grp-me .grp-team span { color: var(--accent); }
.grp-note { margin: 8px 2px 0; font-size: .72rem; color: var(--muted-2); }

.m-section-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted-2); font-weight: 700; margin: 16px 0 8px; }
.m-matches { display: flex; flex-direction: column; gap: 6px; }
.m-match {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--border-soft); border-radius: 10px; font-size: .84rem;
}
.m-match-date { color: var(--muted-2); font-size: .74rem; white-space: nowrap; }
.m-match-opp { min-width: 0; }
.m-match-opp .ha { color: var(--muted-2); font-size: .72rem; }
.m-match-stage { font-size: .68rem; color: var(--muted-2); white-space: nowrap; }
.m-match-score { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.m-match-score .sched { color: var(--accent); font-weight: 600; font-size: .76rem; }
.m-res { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 5px; font-size: .68rem; font-weight: 800; }
.m-res-W { color: var(--in); background: var(--in-bg); }
.m-res-L { color: var(--out); background: var(--out-bg); }
.m-res-D { color: var(--muted); background: color-mix(in srgb, var(--muted) 14%, transparent); }

/* ---------- Footer ---------- */
.site-footer {
  max-width: 1280px; margin: 0 auto;
  padding: 8px clamp(12px,3vw,24px) calc(40px + env(safe-area-inset-bottom));
  color: var(--muted-2); font-size: .76rem; text-align: center;
}
.site-footer strong { color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .board { grid-template-columns: 1fr; gap: 12px; }
  .leaderboard { grid-template-columns: repeat(auto-fill, minmax(118px,1fr)); gap: 7px; }
  .header-inner { flex-wrap: wrap; }
  .subtitle { font-size: .78rem; }
  .updated { font-size: .72rem; }
  .person-head { padding: 11px 12px; }
  .team { padding-left: 13px; gap: 9px; }
  .m-match { grid-template-columns: 1fr auto auto; }
  .m-match-date { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; scroll-behavior: auto !important; transition: none !important; }
}
