/* app.css — bw-nostr V2 "steel" theme. SINGLE owner of all CSS.
   Watch-first: browse/settings are width-capped; the replay/watch page is full-bleed so the
   canvas can be large. Every class the 3 views + theater use is defined here. */

/* ===================================================================== */
/* design tokens                                                          */
/* ===================================================================== */
:root {
  --bg:        #0e141b;
  --panel:     #161e28;
  --panel-2:   #1c2630;
  --border:    #2a323e;
  --text:      #e6e9ef;
  --muted:     #8b97a8;
  --accent:    #5b8ff0; /* steel blue */
  --accent-2:  #7aa6ff;
  --danger:    #e06b6b;
  --ok:        #5fcf8f;

  /* race colors */
  --race-zerg:    #b48be4;
  --race-terran:  #5b8ff0;
  --race-protoss: #e6c34a;

  --radius:   10px;
  --radius-sm: 6px;
  --gap:      16px;
  --maxw:     1200px;
  --nav-h:    56px;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ===================================================================== */
/* reset + base                                                           */
/* ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
img { max-width: 100%; display: block; }
canvas { display: block; }

/* ===================================================================== */
/* nav (sticky header)                                                    */
/* ===================================================================== */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 0 20px;
  background: rgba(14, 20, 27, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav .brand {
  font-weight: 700;
  letter-spacing: .2px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav .brand:hover { text-decoration: none; }
.nav .brand .accent { color: var(--accent); }
.nav a.nav-link {
  color: var(--muted);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}
.nav a.nav-link:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.nav a.nav-link.active { color: var(--text); background: var(--panel-2); }
.nav .spacer { flex: 1; }

/* global spoiler toggle */
.spoiler-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--muted);
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
}
.spoiler-toggle:hover { color: var(--text); border-color: var(--accent); }
.spoiler-toggle .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--ok);
}
.spoiler-toggle[data-hidden="true"] .dot { background: var(--accent); }

/* ===================================================================== */
/* content host                                                           */
/* ===================================================================== */
.content {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 20px 64px;
}
/* full-bleed modifier for the replay/watch page */
.content.full {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 12px;
}

/* ===================================================================== */
/* utility                                                                */
/* ===================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--panel); border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0b1018; font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.small, .small { font-size: 12px; padding: 4px 9px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; padding: 2px 9px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
}
.row { display: flex; align-items: center; gap: var(--gap); }
.col { display: flex; flex-direction: column; gap: var(--gap); }
.spacer { flex: 1; }
.mono { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--muted); }

/* notices / fallbacks */
.notice, .bw-fallback {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--muted);
}
.bw-fallback { border-left-color: var(--danger); }
.notice strong { color: var(--text); }

/* toast */
.toast-host {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 16px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}

/* empty state (also used for 404) */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--muted);
}
.empty-state h2 { color: var(--text); }
.empty-state .big { font-size: 40px; margin-bottom: 8px; opacity: .6; }

/* ===================================================================== */
/* browse                                                                 */
/* ===================================================================== */
.filter-bar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
}
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.filter-row + .filter-row { margin-top: 10px; }
.filter-row input[type="text"],
.filter-row select {
  font: inherit; font-size: 14px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 10px;
}
.filter-row input[type="text"] { min-width: 220px; }

.replay-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--gap);
}
.replay-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .12s, transform .12s;
}
.replay-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.replay-card .card-body { padding: 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.card-players { display: flex; flex-direction: column; gap: 6px; }
.player-chip {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px;
}
.race-dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex: none; background: var(--muted);
}
.race-dot.zerg    { background: var(--race-zerg); }
.race-dot.terran  { background: var(--race-terran); }
.race-dot.protoss { background: var(--race-protoss); }

.winner-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px;
  background: rgba(95, 207, 143, .14); color: var(--ok);
  border: 1px solid rgba(95, 207, 143, .35);
}
.winner-pill.hidden {
  color: transparent; background: var(--panel-2); border-color: var(--border);
  filter: blur(5px); user-select: none;
}

/* pagination */
.pagination {
  display: flex; justify-content: center; align-items: center; gap: 12px;
  margin-top: 28px;
}
.pagination .page-info { color: var(--muted); font-size: 13px; }

/* ===================================================================== */
/* replay page (full-bleed)                                               */
/* ===================================================================== */
/* Watch-first: a compact info panel stacked above a full-width theater. (The view nests everything
   under .replay-info and appends .replay-stage as a sibling, so this MUST be a single column —
   a 2-col grid would trap the theater in a ~340px column and collapse the canvas to 0 width.) */
.replay-page {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: 100%;
}
.replay-info {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.replay-body { display: flex; flex-direction: column; gap: 14px; }
.replay-stage, .watch-host { width: 100%; }
.replay-header { display: flex; flex-direction: column; gap: 8px; }
.row.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.winner-row { display: flex; align-items: center; gap: 8px; }
.player-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.player-chip { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel-2); }
.player-chip.is-winner { border-color: var(--accent); }
.notice.warn { border: 1px solid var(--warn, #b9863b); background: rgba(185,134,59,.12); border-radius: var(--radius); padding: 12px; }
.replay-info h1 { font-size: 18px; }

.participants { display: flex; flex-direction: column; gap: 10px; }
.participants .vs { text-align: center; color: var(--muted); font-size: 12px; }

.map-block { display: flex; flex-direction: column; gap: 8px; }
/* the clickable summary panel (a <button> with a minimap thumb + info) */
.map-panel {
  display: flex; gap: 12px; align-items: center; text-align: left; width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: inherit;
  padding: 10px;
  cursor: pointer;
  transition: border-color .12s;
}
.map-panel:hover, .map-panel.open { border-color: var(--accent); }
.map-panel .minimap { width: 96px; height: 96px; object-fit: cover; border-radius: var(--radius-sm); background: #0a0e14; flex: none; }
.map-panel-info { display: flex; flex-direction: column; gap: 2px; }
.map-name { font-weight: 600; }
/* inline expansion (NOT a modal) */
.map-expanded-inner {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel-2); padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.map-expanded-inner .row { display: flex; gap: 14px; flex-wrap: wrap; }
.map-expanded .minimap.large { width: 200px; height: 200px; object-fit: cover; border-radius: var(--radius-sm); background: #0a0e14; }
.map-facts { display: flex; flex-direction: column; gap: 6px; }
.fact-grid { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; align-content: start; }
.map-desc { color: var(--muted); font-size: 13px; }

/* ===================================================================== */
/* theater                                                                */
/* ===================================================================== */
.theater {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
  min-height: 600px;
}
.theater:fullscreen {
  height: 100vh;
  border-radius: 0;
  border: none;
  padding: 0;
  background: #000;
}
.theater:fullscreen .theater-stage { flex: 1; min-height: 0; }

.theater-main {
  display: flex;
  gap: var(--gap);
  flex: 1;
  min-height: 0;
}
.theater-stage {
  flex: 1;
  min-height: 480px;
  position: relative;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.theater-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}
.theater-stage .stage-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 24px; color: var(--muted);
}

.theater-sidebar {
  width: 300px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

/* transport bar */
.theater-transport {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.theater-transport .scrubber {
  flex: 1;
  min-width: 120px;
  accent-color: var(--accent);
}
.theater-transport .time { font-family: var(--mono); font-size: 13px; color: var(--muted); white-space: nowrap; }
.theater-transport .speeds { display: flex; gap: 4px; }

/* live data */
.stat-strip { display: flex; flex-direction: column; gap: 8px; }
.stat {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px;
}
.stat .label { color: var(--muted); }
.stat .value { font-family: var(--mono); }

.player-row {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.player-row .player-head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.player-row .player-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px;
  font-size: 12px;
}

/* sparkline / time-series */
.spark { display: flex; flex-direction: column; gap: 4px; }
.spark .spark-label { font-size: 11px; color: var(--muted); }
.spark-graph {
  width: 100%; height: 40px; display: block;
  background: var(--bg); border-radius: 4px;
}
.spark-graph path { fill: none; stroke: var(--accent); stroke-width: 1.5; }

/* ===================================================================== */
/* V3 rich data deck (army / production / tech / build order)            */
/* ===================================================================== */
.pdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.value.blocked { color: var(--danger); font-weight: 600; }
.muted.small, .small { font-size: 11px; }
.theater-sidebar .muted.small { color: var(--muted); }

/* tab bar */
.data-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.data-tab {
  font: inherit; font-size: 11px; cursor: pointer;
  padding: 4px 8px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--border);
}
.data-tab:hover { color: var(--text); }
.data-tab.active { background: var(--accent); border-color: var(--accent); color: #0b1018; font-weight: 600; }

.data-panel { display: flex; flex-direction: column; gap: 10px; }

/* per-player section */
.data-sect {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.sect-head { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; }
.sect-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* label · bar · value rows (army composition + production) */
.comp-row, .prod-row, .tech-row {
  display: grid; grid-template-columns: 1fr 46px auto; align-items: center;
  gap: 6px; font-size: 12px;
}
.comp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comp-val { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: right; min-width: 26px; }
.bar { height: 7px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; min-width: 2px; transition: width .25s linear; }

/* tech tab */
.tech-label { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: 4px; }
.tech-row { grid-template-columns: 1fr auto auto; }
.tech-lvl { font-family: var(--mono); font-size: 11px; color: var(--accent-2); }
.tech-done { color: var(--ok); font-size: 12px; }
.tech-prog { font-family: var(--mono); font-size: 11px; color: var(--accent); }

/* build order */
.bo-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; color: var(--muted); }
.bo-leg { display: flex; align-items: center; gap: 5px; }
.bo-list { display: flex; flex-direction: column; gap: 2px; max-height: 360px; overflow-y: auto; }
.bo-row { display: grid; grid-template-columns: 40px 10px 1fr auto; align-items: center; gap: 6px; font-size: 12px; }
.bo-time { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.bo-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { font-size: 9px; text-transform: uppercase; letter-spacing: .03em; padding: 1px 5px; border-radius: 4px; color: var(--muted); background: var(--bg); border: 1px solid var(--border); }
.chip-building { color: var(--accent-2); }
.chip-tech { color: var(--ok); }
.chip-unit { color: var(--muted); }

/* ===================================================================== */
/* responsive                                                             */
/* ===================================================================== */
@media (max-width: 1000px) {
  .replay-page { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .theater-main { flex-direction: column; }
  .theater-sidebar { width: 100%; max-height: 320px; }
}
