/* Live view of the 3GPP chain. Tokens and components copied from the groundloc page
   (site/css/style.css) so the two look alike; the rules after "live view" are new. */
:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-2: #f3f4f2;
  --ink: #15171a;
  --ink-2: #4a4f57;
  --muted: #7b818a;
  --line: #e4e5e2;
  --accent: #1f5fd6;
  --scene: #0b0f17;
  --scene-2: #121826;
  --scene-ink: #dfe6f1;
  --scene-muted: #8a96aa;
  --scene-line: #232c3b;
  --road: #1a2232;
  --road-edge: #273249;
  --gps: #e8edf5;
  --pf: #34d399;
  --dr: #f5a524;
  --dr-raw: #f2545b;
  --shape: #6ea0ff;
  --ask: #fbbf24;
  --c-pf: #0f9f6e;
  --c-dr: #d48806;
  --c-raw: #d9363e;
  --c-gps: #15171a;
  --radius: 14px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --surface: #161a21; --surface-2: #1d222b; --ink: #eceef2; --ink-2: #b4bac4;
    --muted: #8a919c; --line: #2a303a; --accent: #6ea0ff;
    --c-pf: #34d399; --c-dr: #f5a524; --c-raw: #f2545b; --c-gps: #eceef2;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116; --surface: #161a21; --surface-2: #1d222b; --ink: #eceef2; --ink-2: #b4bac4;
  --muted: #8a919c; --line: #2a303a; --accent: #6ea0ff;
  --c-pf: #34d399; --c-dr: #f5a524; --c-raw: #f2545b; --c-gps: #eceef2;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.5;
       -webkit-font-smoothing: antialiased; }
a { color: inherit; }
img, video { max-width: 100%; display: block; }

/* header */
.site-header {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  justify-content: space-between; gap: 16px; padding: 14px clamp(16px, 4vw, 48px);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand a { text-decoration: none; }
.brand-mark { font-weight: 700; letter-spacing: -0.02em; font-size: 18px; }
.brand-by:hover { color: var(--ink); text-decoration: underline; }
.brand-mark span { color: var(--accent); }
.brand-by { color: var(--muted); font-size: 13px; }
.nav { display: flex; align-items: center; gap: 22px; font-size: 14px; }
.nav a { text-decoration: none; color: var(--ink-2); }
.nav a:hover { color: var(--ink); }
.theme-btn { border: 1px solid var(--line); background: transparent; color: var(--ink-2);
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 15px; }
@media (max-width: 720px) { .nav a { display: none; } .brand-by { font-size: 12px; } }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 48px); }

/* hero */
.hero { padding: clamp(36px, 6vw, 80px) 0 20px; max-width: 860px; }
.kicker { font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 14px; }
.hero h1 { font-size: clamp(32px, 4.6vw, 56px); line-height: 1.05; letter-spacing: -0.035em;
  margin: 0 0 18px; font-weight: 700; }
.lead { font-size: clamp(16px, 1.4vw, 19px); color: var(--ink-2); margin: 0 0 28px; max-width: 40em; }

/* replay */
.replay { border-radius: var(--radius); overflow: hidden; background: var(--scene);
  box-shadow: 0 30px 60px -30px rgba(10, 20, 40, 0.5); color: var(--scene-ink); }
.stage { position: relative; aspect-ratio: 16 / 9; min-height: 340px; max-height: 78vh; width: 100%; }
@media (max-width: 700px) { .stage { aspect-ratio: 4 / 5; } }
.stage canvas.map { position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  cursor: grab; touch-action: pan-y; }
.stage canvas.map.drag { cursor: grabbing; }
.ov { position: absolute; pointer-events: none; }
.ov-tl { top: 14px; left: 14px; display: flex; gap: 6px; flex-wrap: wrap; max-width: 60%; pointer-events: auto; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; background: rgba(11, 15, 23, 0.6); color: var(--scene-ink);
  border: 1px solid rgba(255, 255, 255, 0.12); backdrop-filter: blur(6px); cursor: pointer;
  user-select: none; font-family: inherit; }
.chip i { width: 14px; height: 3px; border-radius: 2px; background: var(--c); display: inline-block; }
.chip i.dots { height: 8px; width: 8px; border-radius: 50%; }
.chip.off { opacity: 0.45; }
.chip.off i { background: transparent; outline: 1px solid var(--c); }
.ov-hud { left: 14px; bottom: 14px; right: 14px; display: flex; justify-content: flex-end;
  align-items: flex-end; gap: 14px; }
.readout { display: grid; grid-template-columns: repeat(6, auto); gap: 4px 18px; text-align: right;
  background: rgba(11, 15, 23, 0.66); border: 1px solid rgba(255,255,255,.1); border-radius: 12px;
  padding: 10px 14px; backdrop-filter: blur(6px); }
.readout div { font-family: var(--mono); font-size: 15px; font-variant-numeric: tabular-nums; }
.readout label { display: block; font-family: var(--font); font-size: 11px; color: var(--scene-muted); }
@media (max-width: 700px) { .readout { grid-template-columns: repeat(2, auto); } }

/* map controls (js/mapnav.js): + / - / fit, and the two-finger hint on touch */
.map-nav { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); display: flex;
  flex-direction: column; gap: 6px; align-items: flex-end; z-index: 2; }
.map-nav button { min-width: 34px; height: 34px; padding: 0 10px; border-radius: 10px; font: inherit; font-size: 18px;
  line-height: 1; background: rgba(11, 15, 23, 0.66); color: var(--scene-ink); border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px); cursor: pointer; }
.map-nav button.fit { font-size: 12px; }
.map-hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 3;
  padding: 10px 16px; border-radius: 12px; background: rgba(11, 15, 23, 0.82); color: var(--scene-ink);
  font-size: 14px; pointer-events: none; opacity: 0; transition: opacity .25s; white-space: nowrap; }
.map-hint.show { opacity: 1; }

.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--scene-muted);
  font-size: 14px; }
.site-footer { padding: 8px 0 40px; color: var(--muted); font-size: 13px; }
.site-footer .row { max-width: 1200px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 48px);
  display: flex; flex-direction: column; gap: 4px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card h3 { margin: 0 0 2px; font-size: 16px; letter-spacing: -0.01em; }
.card .sub { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
table.nums { width: 100%; border-collapse: collapse; font-size: 14px; }
table.nums td, table.nums th { padding: 9px 4px; border-bottom: 1px solid var(--line); text-align: right;
  font-variant-numeric: tabular-nums; }
table.nums td:first-child, table.nums th:first-child { text-align: left; color: var(--ink-2); }
table.nums th { font-size: 12px; color: var(--muted); font-weight: 600; }
table.nums tr:last-child td { border-bottom: 0; }

/* live view */
.hero { padding-bottom: 8px; }
.readout span { display: block; }
.simulated { display: inline-block; font-size: 13.5px; color: var(--ink-2); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 0 0 20px; }
.conn { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.conn.on i { background: var(--c-pf); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-pf) 25%, transparent); }
.conn.off i { background: var(--c-raw); }
.conn b { font-weight: 500; }

.chain { list-style: none; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px;
  padding: 0; margin: 0 0 18px; counter-reset: c; }
@media (max-width: 800px) { .chain { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.chain li { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font-size: 14px; transition: border-color .4s, box-shadow .4s; }
.chain li + li::before { content: "→"; position: absolute; left: -10px; top: 50%; transform: translate(-50%, -50%);
  color: var(--muted); font-size: 13px; }
@media (max-width: 800px) { .chain li + li::before { display: none; } }
.chain b { display: block; }
.chain span { font-size: 12px; color: var(--muted); }
.chain li.pulse { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
  transition: none; }

.panels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px; margin: 16px 0 64px; }
@media (max-width: 900px) { .panels { grid-template-columns: 1fr; } }
.panels .wide { grid-column: 1 / -1; }
.card code, .muted { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; background: var(--c); }
pre.raw { margin: 0; max-height: 360px; overflow: auto; font-family: var(--mono); font-size: 12px; line-height: 1.45;
  background: var(--surface-2); border-radius: 10px; padding: 12px; color: var(--ink-2); white-space: pre; }
ol.trace { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; font-family: var(--mono);
  font-size: 12px; }
ol.trace li { display: grid; grid-template-columns: 7em 4.5em 3em minmax(0, 1fr); gap: 10px; padding: 3px 0;
  border-bottom: 1px solid var(--line); }
ol.trace li:last-child { border-bottom: 0; }
ol.trace .t { color: var(--muted); }
ol.trace .n { font-weight: 600; }
ol.trace .d { color: var(--muted); }
ol.trace .m { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ol.trace li.open .m { white-space: normal; }
ol.trace li.has-content { cursor: pointer; }
ol.trace li.has-content:hover { background: var(--surface-2); }
ol.trace li.has-content .m::before { content: "▸ "; color: var(--muted); }
ol.trace li.open .m::before { content: "▾ "; }
ol.trace li.ask { background: color-mix(in srgb, var(--ask) 16%, transparent); }
ol.trace pre.content { grid-column: 1 / -1; margin: 4px 0 6px; max-height: 320px; overflow: auto;
  background: var(--surface-2); border-radius: 8px; padding: 10px; color: var(--ink-2); white-space: pre;
  cursor: text; }

/* own subscription and "ask now" */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0 0 14px; }
.btn { font: inherit; font-size: 14px; font-weight: 600; padding: 8px 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: default; }
.sub-state { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.sub-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sub-state.active i { background: var(--c-pf); }
.sub-state.paused i, .sub-state.full i { background: var(--c-dr); }
.sub-state.error i, .sub-state.off i { background: var(--c-raw); }
.sub-state b { font-weight: 500; }
.ask-result { font-size: 13px; font-family: var(--mono); color: var(--ink-2); }
.ask-result.hit { color: var(--ink); background: color-mix(in srgb, var(--ask) 22%, transparent);
  border-radius: 8px; padding: 2px 8px; }

/* replay or live */
.ov-tr { top: 14px; right: 14px; }
.mode-badge { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; background: rgba(11, 15, 23, 0.7); color: var(--scene-ink);
  border: 1px solid rgba(255, 255, 255, 0.16); backdrop-filter: blur(6px); }
.mode-badge i { width: 9px; height: 9px; border-radius: 50%; background: var(--scene-muted); }
.mode-badge.replay i { background: var(--shape); }
.mode-badge.live { border-color: color-mix(in srgb, var(--dr-raw) 60%, transparent); }
.mode-badge.live i { background: var(--dr-raw); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dr-raw) 30%, transparent);
  animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.35; } }
ol.trace li.note { background: color-mix(in srgb, var(--accent) 12%, transparent); }
ol.trace li.note .m { font-weight: 600; }

/* the readout sits outside the stage: over the map's bottom edge on wide screens */
.replay { position: relative; }
.more-btn { display: none; border: 0; background: none; padding: 0; font: inherit; color: var(--accent);
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
details.fold > summary { list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
@media (min-width: 601px) { details.fold > summary { pointer-events: none; } }

/* phone: map near the top, short intro, readout under the map, panels folded */
@media (max-width: 600px) {
  .wrap { display: flex; flex-direction: column; }
  .controls { order: 2; margin: 12px 0 0; }
  .panels { order: 3; margin: 14px 0 40px; gap: 10px; }
  .hero { padding: 14px 0 0; }
  .kicker { display: none; }
  .hero h1 { font-size: 24px; margin: 0 0 8px; }
  .lead { font-size: 15px; margin: 0 0 10px; }
  .lead .more { display: none; }
  .hero.open .lead .more { display: inline; }
  .more-btn { display: inline; }
  .simulated { font-size: 12.5px; padding: 6px 10px; margin: 0 0 10px; }
  .chain { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin: 0 0 10px; }
  .chain li { padding: 5px 3px; font-size: 11px; text-align: center; border-radius: 8px; }
  .chain li span { display: none; }
  .chain b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .stage { aspect-ratio: auto; height: 60vh; height: 60svh; min-height: 300px; max-height: none; }
  .ov-tl { max-width: calc(100% - 120px); gap: 4px; }
  .ov-tl .chip { font-size: 11px; padding: 2px 8px; }
  .ov-tr { top: auto; right: auto; bottom: 12px; left: 12px; }  /* clear of the layer chips */
  .mode-badge { font-size: 12px; padding: 4px 10px; }
  .replay .ov-hud { position: static; display: block; padding: 6px 4px 8px; pointer-events: auto; }
  .readout { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; text-align: left; background: none;
    border: 0; padding: 4px 10px; backdrop-filter: none; }
  .readout div { font-size: 13px; }
  .readout span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .card { padding: 14px; }
  details.fold > summary { cursor: pointer; display: flex; gap: 6px; align-items: baseline; }
  details.fold > summary::before { content: "▸"; color: var(--muted); }
  details.fold[open] > summary::before { content: "▾"; }
  details.fold:not([open]) > summary h3 { margin: 0; }
  ol.trace li { grid-template-columns: 6.5em 4em 2.6em minmax(0, 1fr); gap: 6px; }
}
