/* ===================================================================
   OpenFront Scanner — "tactical command console"
   Dark-first radar/strategy aesthetic with a light fallback.
   Display: Chakra Petch · Body: IBM Plex Sans · Numerals: IBM Plex Mono
   =================================================================== */

:root {
  color-scheme: dark light;

  --green: #1d9d5a;        /* radar / brand accent (brightened for dark) */
  --amber: #d97706;        /* armed / alert */
  --blue: #2563eb;         /* primary action */

  --bg: #0a0f17;
  --bg-grid: rgba(29, 157, 90, 0.045);
  --panel: #111927;
  --panel-2: #0d1420;
  --line: #20304a;
  --line-soft: #18243a;
  --ink: #e7eef7;
  --ink-dim: #9fb0c6;
  --ink-faint: #64748b;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  --font-display: "Chakra Petch", ui-sans-serif, system-ui, sans-serif;
  --font-body: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --green: #167c45;
    --bg: #eef2f1;
    --bg-grid: rgba(29, 111, 66, 0.05);
    --panel: #ffffff;
    --panel-2: #f5f7f6;
    --line: #d6dde4;
    --line-soft: #e4e9ee;
    --ink: #16202c;
    --ink-dim: #4a5a6b;
    --ink-faint: #8595a5;
    --shadow: 0 14px 40px rgba(15, 30, 25, 0.12);
  }
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--bg);
  /* layered atmosphere: a faint tactical grid + a radial radar glow */
  background-image:
    radial-gradient(120% 80% at 78% -10%, rgba(29, 157, 90, 0.1), transparent 55%),
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 100% 100%, 38px 38px, 38px 38px;
  background-attachment: fixed;
  line-height: 1.55;
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, summary, .panel-title {
  font-family: var(--font-display);
  letter-spacing: 0.01em;
}

/* ── Masthead ─────────────────────────────────────────────────────── */
.masthead {
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(29, 157, 90, 0.06), transparent);
}
.masthead-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.4rem 1.25rem 1.1rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand { display: flex; gap: 0.85rem; align-items: center; }
.brand-logo {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 11px;
  box-shadow: 0 0 0 1px var(--line), 0 4px 16px rgba(0, 0, 0, 0.28);
}
h1 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tagline { margin: 0.25rem 0 0; color: var(--ink-dim); max-width: 46ch; font-size: 0.95rem; }
.chips { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
/* Settings gear (⚙) — a right-edge tab pinned just below the intro ▶ play button. */
.settings-wrap { position: fixed; right: 0; top: calc(45% + 3.4rem); z-index: 65; }
.gear-btn {
  width: 44px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-right: none;
  color: var(--ink-dim);
  border-radius: 10px 0 0 10px;
  font-size: 1.15rem;
  cursor: pointer;
  box-shadow: -2px 2px 10px rgba(0, 0, 0, 0.18);
  transition: color 0.15s var(--ease), transform 0.3s var(--ease);
}
.gear-btn:hover { color: var(--green); transform: rotate(45deg); }
.gear-btn[aria-expanded="true"] { color: var(--green); }
.settings-pop {
  position: absolute;
  right: calc(100% + 0.5rem);
  top: 0;
  z-index: 80;
  width: 250px;
  padding: 0.9rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.settings-title {
  font-family: var(--font-display);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
  margin-bottom: 0.7rem;
}

/* ── Status chips ─────────────────────────────────────────────────── */
.status {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink-dim);
  white-space: nowrap;
}
.status[data-state="connected"] { border-color: rgba(29, 157, 90, 0.5); color: var(--green); }
.status[data-state="connecting"],
.status[data-state="error"] { border-color: rgba(217, 119, 6, 0.55); color: var(--amber); }
.status:empty { display: none; }

/* ── Two-column layout ────────────────────────────────────────────── */
.layout {
  max-width: 1200px;
  margin: 1.5rem auto;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: minmax(330px, 400px) 1fr;
  gap: 1.5rem;
  align-items: start;
}
.col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

/* ── Cards / panels ───────────────────────────────────────────────── */
.action-card,
.panel,
.maps-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Action card (auto-join + ETA + notifications) — gated until a map is picked */
.action-card { position: relative; padding: 1.1rem; overflow: hidden; }
.gate-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-align: center;
  padding: 1rem;
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  backdrop-filter: blur(3px);
  border-radius: var(--radius);
}
.action-card.gated .gate-overlay { display: flex; }
.action-card.gated > :not(.gate-overlay) { opacity: 0.35; }
.gate-overlay .gate-icon { font-size: 1.9rem; }
.gate-overlay p { margin: 0; color: var(--ink-dim); }
.gate-overlay strong { color: var(--green); font-family: var(--font-display); }

/* ── Auto-join button ─────────────────────────────────────────────── */
.autojoin {
  display: block;
  width: 100%;
  padding: 0.95rem 1rem;
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  transition: filter 0.15s var(--ease), background 0.2s var(--ease), transform 0.1s var(--ease);
}
.autojoin:hover:not(:disabled) { filter: brightness(1.1); }
.autojoin:active:not(:disabled) { transform: translateY(1px); }
.autojoin:disabled { cursor: not-allowed; }
.autojoin.armed { background: var(--amber); animation: ofs-pulse 1.6s ease-in-out infinite; }
@keyframes ofs-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 134, 6, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(217, 134, 6, 0); }
}

/* ── ETA readout ──────────────────────────────────────────────────── */
.eta {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  color: var(--ink-dim);
  margin: 0.7rem 0 0;
  min-height: 1.2em;
  border-left: 2px solid var(--green);
  padding-left: 0.6rem;
}
.eta:empty { display: none; }

/* ── Notifications switch ─────────────────────────────────────────── */
.switch-row {
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line-soft);
}
.switch { display: flex; align-items: center; gap: 0.6rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  flex: none;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  position: relative;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink-dim);
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}
.switch input:checked + .switch-track { background: var(--green); border-color: var(--green); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); background: #fff; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--green); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.5; }
.switch-text { font-family: var(--font-display); font-weight: 600; font-size: 0.95rem; }
.switch-hint { display: block; margin-top: 0.3rem; font-size: 0.78rem; color: var(--ink-faint); }

/* ── Collapsible panels (native details) ──────────────────────────── */
.panel { overflow: hidden; }
.panel summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.05rem;
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.panel summary::-webkit-details-marker { display: none; }
.panel summary:hover { color: var(--green); }
.panel-title::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 0.55rem;
  border-radius: 50%;
  background: var(--green);
  vertical-align: middle;
  box-shadow: 0 0 8px rgba(29, 157, 90, 0.7);
}
.chev { color: var(--ink-faint); transition: transform 0.2s var(--ease); }
.panel[open] .chev { transform: rotate(180deg); }
.panel-body { padding: 0 1.05rem 1.05rem; }

/* ── Select grids (modes + excludes) ──────────────────────────────── */
.grid-select { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.3rem 0.75rem; }
.grid-select label,
.maps label {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  font-size: 0.92rem;
  padding: 0.2rem 0;
  cursor: pointer;
}
.grid-select input,
.maps input { accent-color: var(--green); }

.subfilter { margin-top: 0.95rem; padding-top: 0.85rem; border-top: 1px solid var(--line-soft); }
.subfilter-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
  margin-bottom: 0.55rem;
}
.filter-counts { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; }
.filter-inline { display: inline-flex; flex-direction: column; gap: 0.25rem; font-size: 0.82rem; color: var(--ink-dim); }
.filter-inline input { width: 5rem; }

input[type="number"],
.search {
  font-family: var(--font-mono);
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
}
input[type="number"]:focus,
.search:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(29, 157, 90, 0.18); }

/* ── Maps panel (right hero) ──────────────────────────────────────── */
.maps-panel { padding: 1.1rem 1.2rem 1.3rem; }
.maps-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.maps-head h2 {
  margin: 0;
  font-size: 1.2rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.search { width: min(320px, 100%); }

.presets { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1rem; }
.presets button {
  font-family: var(--font-mono);
  padding: 0.32rem 0.75rem;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--ink-dim);
  cursor: pointer;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease);
}
.presets button:hover { border-color: var(--green); color: var(--green); }
.presets .preset-all { border-color: var(--green); color: var(--green); font-weight: 600; }
.presets .preset-style { border-style: dashed; }

.maps { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem 0.8rem; }
/* Map cell = card: thumbnail on top, name (with its checkbox) below it. */
.maps label { flex-direction: column; align-items: stretch; gap: 0.35rem; }
.map-cap { display: flex; gap: 0.4rem; align-items: center; font-size: 0.86rem; line-height: 1.25; }
/* Map thumbnail fills the card and is clearly larger than the Live-now .thumb. */
.map-thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line-soft);
  background: var(--panel-2);
}
.cat {
  grid-column: 1 / -1;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin-top: 0.9rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--line-soft);
}

/* ── Live-now list ────────────────────────────────────────────────── */
.live { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.35rem; }
.live li { font-size: 0.92rem; }
.live li.muted { padding: 0.2rem 0; }
/* The whole Live-now row is a single clickable join link. */
.live-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.live-row:hover { background: var(--panel-2); border-color: var(--line); text-decoration: none; }
.live-row:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.live-text { min-width: 0; }
.live .thumb {
  flex: none;
  width: 56px;
  height: 32px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--line-soft);
  background: var(--panel-2);
}
.join-affordance {
  margin-left: auto;
  flex: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--green);
}
.mods { display: inline-flex; flex-wrap: wrap; gap: 0.25rem; }
.mod {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  line-height: 1.5;
  padding: 0 0.4rem;
  border-radius: 0.5rem;
  background: rgba(29, 157, 90, 0.14);
  color: var(--green);
  white-space: nowrap;
}

/* Per-map hover stats popover — rotates through 3 frames with a fade. */
.map-stats {
  position: fixed;
  z-index: 55;
  pointer-events: none;
  width: 290px;
  padding: 0.7rem 0.85rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  transition: opacity 0.16s var(--ease);
}
.map-stats.fading { opacity: 0; }
.ms-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.ms-thumb { flex: none; width: 48px; height: 28px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line-soft); }
.ms-name { font-family: var(--font-display); font-weight: 600; font-size: 0.92rem; }
.ms-body { min-height: 2.7em; }
.ms-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green);
  margin-bottom: 0.18rem;
}
.ms-text { font-size: 0.84rem; color: var(--ink-dim); line-height: 1.35; }
.ms-dots { display: flex; gap: 0.32rem; justify-content: center; margin-top: 0.55rem; }
.ms-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--line); transition: background 0.16s var(--ease); }
.ms-dots i.on { background: var(--green); }
@media (hover: none) { .map-stats { display: none !important; } }

/* ── Notes ────────────────────────────────────────────────────────── */
.note {
  font-size: 0.85rem;
  background: rgba(217, 119, 6, 0.12);
  color: var(--amber);
  border: 1px solid rgba(217, 119, 6, 0.3);
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
  margin: 0.7rem 0 0;
}
.muted { color: var(--ink-faint); }

footer {
  max-width: 1200px;
  margin: 2.5rem auto 2rem;
  padding: 1.4rem 1.25rem 0;
  border-top: 1px solid var(--line-soft);
  font-size: 0.82rem;
  color: var(--ink-faint);
}
footer p { margin: 0.4rem 0; }

/* ── Sticky top nav (scrolled-away status) ────────────────────────── */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 60;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0.5rem 0.75rem;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  transform: translateY(-110%);
  transition: transform 0.22s var(--ease);
}
.topnav.visible { transform: translateY(0); }
.topnav .status { max-width: 70vw; overflow: hidden; text-overflow: ellipsis; }
.topnav-armed {
  font-family: var(--font-mono);
  background: var(--amber);
  color: #fff;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
}

/* ── Sticky armed bar (auto-join when scrolled away / armed) ───────── */
.armed-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  padding: 0.5rem 0.75rem;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.footer-autojoin {
  display: block;
  width: min(1150px, 100%);
  margin: 0 auto;
  padding: 0.8rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--blue);
  color: #fff;
  transition: filter 0.15s var(--ease), background 0.2s var(--ease);
}
.footer-autojoin:hover:not(:disabled) { filter: brightness(1.1); }
.footer-autojoin:disabled { opacity: 0.5; cursor: not-allowed; }
.footer-autojoin.armed { background: var(--amber); animation: ofs-pulse 1.6s ease-in-out infinite; }
body.footer-on { padding-bottom: 4.5rem; }

/* ── Intro video ──────────────────────────────────────────────────── */
#intro-fab {
  position: fixed; right: 0; top: 45%; transform: translateY(-50%); z-index: 65;
  border: none; cursor: pointer; background: var(--blue); color: #fff;
  font-size: 1.3rem; line-height: 1; padding: 0.6rem 0.7rem;
  border-radius: 10px 0 0 10px; box-shadow: -2px 2px 14px rgba(0, 0, 0, 0.35);
}
#intro-fab:hover { filter: brightness(1.1); }
#intro-nudge {
  position: fixed; right: 3.4rem; top: calc(45% - 1.4rem); z-index: 66;
  max-width: 230px; background: var(--panel); color: var(--ink); cursor: pointer;
  padding: 0.5rem 0.75rem; border-radius: 10px; font-size: 0.9rem; font-weight: 600;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
#intro-card {
  position: fixed; right: 1rem; bottom: 1.25rem; z-index: 70;
  width: 360px; max-width: 92vw; padding: 0.5rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
body.footer-on #intro-card { bottom: 4.9rem; }
#intro-video { display: block; width: 100%; border-radius: 8px; }
.intro-cap { color: var(--ink-dim); font-size: 0.8rem; text-align: center; padding: 0.4rem 0 0.2rem; }
#intro-close {
  position: absolute; top: -10px; right: -10px; width: 28px; height: 28px;
  border-radius: 50%; border: none; cursor: pointer; background: #fff; color: #111;
  font-size: 1.1rem; line-height: 1; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
}

/* ===================================================================
   Stats page — dashboard of stat cards
   =================================================================== */
.stats-wrap { max-width: 1100px; margin: 1.5rem auto; padding: 0 1.25rem; }
.stats-group { margin-top: 1.75rem; }
.stats-group h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  margin: 0 0 0.75rem;
}
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--green);
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.1;
}
.stat-label { display: block; margin-top: 0.3rem; color: var(--ink-dim); font-size: 0.88rem; }
.stat-sub { display: block; margin-top: 0.2rem; color: var(--ink-faint); font-size: 0.78rem; font-family: var(--font-mono); }
.stat-card.alert::before { background: var(--amber); }

/* ── Responsive: single column, reordered by priority ─────────────── */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .col-right { order: -1; }            /* maps first — selecting a map is the entry gesture */
  .maps { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
@media (max-width: 560px) {
  .masthead-inner { padding: 1rem; }
  h1 { font-size: 1.4rem; }
  .maps label, .grid-select label { min-height: 38px; }   /* bigger tap target */
  .maps input, .grid-select input { transform: scale(1.2); }
  .footer-autojoin { font-size: 0.95rem; padding: 0.65rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
