/* ============================================================
   EVERFIELD — design system
   Aesthetic: floodlit night broadcast. Near-black green-cast
   surfaces, chalk ink, volt accent used sharply, gold for glory.
   ============================================================ */

:root {
  /* surfaces */
  --bg: #070b08;
  --surface: #0d130e;
  --surface-2: #121a12;
  --surface-3: #182218;
  --line: #223122;
  --line-soft: rgba(120, 150, 110, 0.12);

  /* ink */
  --ink: #edf2e4;
  --ink-2: #a3b198;
  --ink-3: #63735c;

  /* signals */
  --volt: #d7f95c;
  --volt-ink: #0b0f06;
  --volt-glow: rgba(215, 249, 92, 0.35);
  --gold: #f2c94c;
  --danger: #ff5d45;
  --sky: #6ecff6;
  --win: #7fe08a;
  --loss: #ff7a68;
  --draw: #8b9a84;

  /* charts — fixed categorical order, validated for dark surface */
  --chart-1: #d7f95c;
  --chart-2: #6ecff6;
  --chart-3: #ff8a5c;
  --chart-4: #c9a1f5;
  --chart-5: #5ce8b2;
  --chart-6: #f76ea1;

  /* type */
  --font-display: 'Bricolage Grotesque', sans-serif;
  --font-body: 'Schibsted Grotesk', sans-serif;
  --font-mono: 'Spline Sans Mono', monospace;
  --font-serif: 'Instrument Serif', serif;

  --rad: 10px;
  --rad-sm: 6px;
  --topbar-h: 58px;
  --ticker-h: 40px;
  --nav-w: 132px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
  /* faint floodlight wash + grain-ish vignette */
  background-image:
    radial-gradient(1200px 600px at 18% -10%, rgba(150, 200, 120, 0.07), transparent 60%),
    radial-gradient(1400px 700px at 85% 110%, rgba(110, 207, 246, 0.045), transparent 60%);
}

::selection { background: var(--volt); color: var(--volt-ink); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- boot splash ---------- */
#boot-splash {
  position: fixed; inset: 0; z-index: 99;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; background: var(--bg);
}
.boot-mark {
  font-family: var(--font-display); font-weight: 800; font-size: 44px; letter-spacing: 0.04em;
}
.boot-mark span { color: var(--volt); }
.boot-sub {
  font-family: var(--font-serif); font-style: italic; color: var(--ink-2); font-size: 16px;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- app frame ---------- */
#app { height: 100vh; display: flex; flex-direction: column; }

#topbar {
  height: var(--topbar-h); flex: 0 0 auto;
  display: flex; align-items: center; gap: 18px; padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(215, 249, 92, 0.035), transparent 70%), var(--surface);
}
.brand { display: flex; flex-direction: column; line-height: 1.05; }
.wordmark {
  font-family: var(--font-display); font-weight: 800; font-size: 21px; letter-spacing: 0.05em;
}
.wordmark span { color: var(--volt); }
.brand-sub { font-family: var(--font-serif); font-style: italic; font-size: 11.5px; color: var(--ink-3); }

.topbar-mid { display: flex; gap: 8px; align-items: center; flex: 1; justify-content: center; }

.chip {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--ink-2);
  background: var(--surface-2); white-space: nowrap;
}
.chip-season { color: var(--volt); border-color: rgba(215, 249, 92, 0.35); }

.controls { display: flex; gap: 6px; align-items: center; }
.ctl-btn {
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--rad-sm);
  padding: 6px 10px; cursor: pointer; transition: all 0.15s ease;
}
.ctl-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.speed-group { display: flex; }
.speed-group .ctl-btn { border-radius: 0; margin-left: -1px; }
.speed-group .ctl-btn:first-child { border-radius: var(--rad-sm) 0 0 var(--rad-sm); margin-left: 0; }
.speed-group .ctl-btn:last-child { border-radius: 0 var(--rad-sm) var(--rad-sm) 0; }
.ctl-btn.active, .ctl-btn.active:hover {
  background: var(--volt); color: var(--volt-ink); border-color: var(--volt); font-weight: 700;
}
.ctl-universe { color: var(--gold); }

#shell { flex: 1; display: flex; min-height: 0; }

/* ---------- side nav ---------- */
#sidenav {
  width: var(--nav-w); flex: 0 0 auto; padding: 14px 10px; display: flex; flex-direction: column; gap: 4px;
  border-right: 1px solid var(--line); background: var(--surface);
}
.nav-btn {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: none; border: none; border-radius: var(--rad-sm); cursor: pointer;
  color: var(--ink-2); font-family: var(--font-body); font-size: 13.5px; font-weight: 500;
  text-align: left; transition: all 0.15s ease;
}
.nav-btn:hover { color: var(--ink); background: var(--surface-2); }
.nav-btn.active { color: var(--volt); background: rgba(215, 249, 92, 0.08); }
.nav-ico { width: 18px; text-align: center; font-size: 13px; opacity: 0.9; }

/* ---------- stage & views ---------- */
#stage { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; position: relative; }
.view { display: none; padding: 20px 24px 40px; }
.view.active { display: block; animation: view-enter 0.28s ease; }
#view-live.view { padding: 16px; height: 100%; }
@keyframes view-enter { from { opacity: 0; transform: translateY(6px); } }

/* section headings shared by views */
.sec-title {
  font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: 0.01em;
  margin: 4px 0 14px;
}
.sec-sub { font-family: var(--font-serif); font-style: italic; color: var(--ink-2); margin: -10px 0 16px; }

/* ---------- live view ---------- */
.live-grid { display: grid; grid-template-columns: 1fr 300px; gap: 14px; height: 100%; }
.pitch-wrap {
  position: relative; border-radius: var(--rad); overflow: hidden;
  border: 1px solid var(--line); background: #0a150c; min-height: 0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 0 120px rgba(0, 0, 0, 0.4);
}
#pitch { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

#match-hud { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; align-items: center; }
#scoreboard {
  margin-top: 10px; pointer-events: auto;
  background: rgba(7, 11, 8, 0.82); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--rad);
  padding: 7px 16px 9px; min-width: 320px; text-align: center;
}
.sb-comp {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 3px;
}
.sb-main { display: flex; align-items: center; justify-content: center; gap: 14px; }
.sb-team { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; font-size: 16px; min-width: 110px; justify-content: flex-end; }
.sb-team.sb-away { justify-content: flex-start; }
.sb-team .crest { width: 22px; height: 22px; }
.sb-mid { display: flex; flex-direction: column; align-items: center; }
.sb-score { font-family: var(--font-mono); font-weight: 700; font-size: 24px; letter-spacing: 0.02em; line-height: 1; }
.sb-clock { font-family: var(--font-mono); font-size: 11px; color: var(--volt); margin-top: 2px; }
.sb-comm {
  margin-top: auto; margin-bottom: 12px; max-width: 72%; text-align: center; pointer-events: none;
  font-family: var(--font-serif); font-style: italic; font-size: 15px; color: rgba(237, 242, 228, 0.92);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9); min-height: 22px;
  transition: opacity 0.3s ease;
}

#live-side { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }

/* ---------- ticker ---------- */
#ticker {
  height: var(--ticker-h); flex: 0 0 auto; overflow: hidden; position: relative;
  border-top: 1px solid var(--line); background: var(--surface);
  display: flex; align-items: center;
}
#ticker::before {
  content: 'LIVE'; position: absolute; left: 0; top: 0; bottom: 0; z-index: 2;
  display: flex; align-items: center; padding: 0 14px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.18em;
  color: var(--volt-ink); background: var(--volt);
}
#ticker-track {
  display: inline-flex; gap: 44px; white-space: nowrap; padding-left: 80px;
  will-change: transform; animation: ticker-scroll var(--ticker-dur, 60s) linear infinite;
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-2);
}
#ticker-track:hover { animation-play-state: paused; }
@keyframes ticker-scroll { to { transform: translateX(-50%); } }
.tick-item b { color: var(--ink); font-weight: 600; }
.tick-item .tick-flag { color: var(--volt); margin-right: 6px; }
.tick-item .tick-goal { color: var(--gold); }

/* ---------- overlay (interstitials) ---------- */
/* Starts right of the side nav so navigation stays clickable during phase overlays;
   switchView (app.js) hides/restores the pending overlay when leaving/returning to Live. */
#overlay {
  position: fixed; top: var(--topbar-h); left: var(--nav-w); right: 0; bottom: var(--ticker-h); z-index: 50;
  background: rgba(4, 7, 5, 0.78); backdrop-filter: blur(10px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  animation: view-enter 0.3s ease;
}
#overlay[hidden] { display: none; }
#overlay-content { max-width: 980px; width: 92%; max-height: 82vh; overflow-y: auto; }
#overlay-skip { margin-top: 18px; }

/* ---------- drawer (entity pages) ---------- */
/* Above #overlay (50) so entity links inside phase overlays open a usable drawer;
   below #boot-splash (99). */
#drawer {
  position: fixed; top: var(--topbar-h); right: 0; bottom: var(--ticker-h); z-index: 60;
  width: min(620px, 92vw); background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: -30px 0 80px rgba(0, 0, 0, 0.55);
  animation: drawer-in 0.24s ease; display: flex; flex-direction: column;
}
#drawer[hidden] { display: none; }
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } }
#drawer-close { position: absolute; top: 12px; right: 14px; z-index: 2; }
#drawer-content { overflow-y: auto; padding: 20px 22px 40px; flex: 1; }

/* ---------- shared components ---------- */
.panel {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--rad);
  padding: 14px 16px;
}
.panel-title {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 10px;
}

.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-3); text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line-soft); }
.tbl .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.tbl tr { transition: background 0.12s ease; }
.tbl tbody tr:hover { background: rgba(215, 249, 92, 0.045); }

[data-nav] { cursor: pointer; }
a, .linkish { color: var(--sky); text-decoration: none; cursor: pointer; }
.linkish:hover { text-decoration: underline; }

.crest { display: inline-block; vertical-align: middle; }
.crest svg { display: block; width: 100%; height: 100%; }

/* form dots */
.form-dots { display: inline-flex; gap: 3px; }
.form-dot { width: 7px; height: 7px; border-radius: 50%; }
.form-dot.W { background: var(--win); }
.form-dot.D { background: var(--draw); }
.form-dot.L { background: var(--loss); }

/* rating tints (player overalls & match ratings) */
.rate { font-family: var(--font-mono); font-weight: 700; font-variant-numeric: tabular-nums; }
.rate-elite { color: var(--gold); }
.rate-great { color: var(--volt); }
.rate-good { color: var(--win); }
.rate-mid { color: var(--ink-2); }
.rate-low { color: var(--ink-3); }

/* importance styling for chronicle */
.news-3 { border-left: 3px solid var(--gold); }
.news-2 { border-left: 3px solid var(--volt); }
.news-1 { border-left: 3px solid var(--line); }

/* generic stagger reveal for lists views render */
.stagger > * { animation: view-enter 0.3s ease backwards; }
.stagger > *:nth-child(1) { animation-delay: 0.02s; }
.stagger > *:nth-child(2) { animation-delay: 0.05s; }
.stagger > *:nth-child(3) { animation-delay: 0.08s; }
.stagger > *:nth-child(4) { animation-delay: 0.11s; }
.stagger > *:nth-child(5) { animation-delay: 0.14s; }
.stagger > *:nth-child(6) { animation-delay: 0.17s; }
.stagger > *:nth-child(7) { animation-delay: 0.2s; }
.stagger > *:nth-child(8) { animation-delay: 0.23s; }

/* trophy / award flourish */
.trophy-gold { color: var(--gold); text-shadow: 0 0 24px rgba(242, 201, 76, 0.45); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  :root { --nav-w: 56px; }
  .nav-lbl { display: none; }
  .nav-btn { justify-content: center; }
  .live-grid { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  /* cap the side rail so the pitch row keeps the remaining height (rail scrolls instead) */
  #live-side { flex-direction: row; overflow-x: auto; max-height: clamp(160px, 35vh, 300px); }
  #live-side > * { min-width: 260px; }
  .brand-sub { display: none; }
}
