/* Packet Dash · network-operations theme */
:root {
  --bg: #060c18;
  --bg-2: #0b1424;
  --panel: #0e1a2e;
  --line: #1f3150;
  --text: #d7e3f4;
  --muted: #8ea2c0;
  --cyan: #2fd3ff;
  --ok: #3ddc84;
  --bad: #ff6b7a;
  --warn: #ffb020;
  --copper: #d08a4a;
  --focus: #ffd166;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(ellipse at top, #0c1a33 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}
a { color: var(--cyan); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--focus); color: #000; padding: 6px 10px; z-index: 10; }
.skip:focus { left: 8px; }
.mono { font-family: var(--mono); }
.small { font-size: 0.85rem; color: var(--muted); }
.ok { color: var(--ok); }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: rgba(6, 12, 24, 0.8);
}
.brand { display: flex; align-items: baseline; gap: 10px; font-family: var(--mono); }
.brand-mark { width: 22px; height: 16px; border-radius: 4px; background: var(--cyan); box-shadow: inset 0 4px 0 #0a4f66; align-self: center; }
.brand-name { font-weight: 700; font-size: 1.2rem; letter-spacing: 0.02em; }
.brand-name span { color: var(--cyan); animation: blink 1.1s steps(1) infinite; }
.brand-sub { color: var(--muted); font-size: 0.8rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }

button {
  font: 600 0.9rem var(--mono); color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--cyan); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button[aria-pressed="true"] { background: #13324a; border-color: var(--cyan); color: var(--cyan); }
button.primary { background: var(--cyan); color: #04121c; border-color: var(--cyan); }
button.primary:disabled { background: var(--panel); color: var(--muted); border-color: var(--line); }
kbd { font: 0.75rem var(--mono); border: 1px solid currentColor; border-radius: 3px; padding: 0 4px; opacity: 0.8; }

/* ---------- packet header bar ---------- */
.pcap {
  display: flex; align-items: stretch; gap: 0; border-bottom: 1px solid var(--line);
  background: #081222; font-family: var(--mono); font-size: 0.85rem; overflow-x: auto;
}
.pcap-tag { background: var(--cyan); color: #04121c; font-weight: 700; padding: 8px 10px; display: flex; align-items: center; }
.pcap-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 6px 14px; flex: 1; }
.pf { display: inline-flex; gap: 6px; white-space: nowrap; }
.pk { color: var(--muted); }
.pv { color: var(--text); font-weight: 600; }
.pf.hot .pv { color: var(--warn); }
.pf.ok .pv { color: var(--ok); }
.arrow { color: var(--cyan); }
.pf-right { margin-left: auto; display: inline-flex; flex-wrap: wrap; gap: 4px 14px; }

/* ---------- screens ---------- */
#screen { padding: 20px 16px 24px; max-width: 1240px; width: 100%; margin: 0 auto; outline: none; }
.screen h1 { font-family: var(--mono); font-size: clamp(1.4rem, 3vw, 2rem); margin: 0 0 8px; }
.screen h1:focus { outline: none; }
.screen h2 { font-family: var(--mono); font-size: 1.05rem; margin: 0 0 8px; color: var(--cyan); }
.eyebrow { font-family: var(--mono); color: var(--warn); margin: 0 0 4px; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; }
.lede { font-size: 1.05rem; max-width: 70ch; }
.pitch { max-width: 75ch; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 12px 0; max-width: 80ch; }
.card p { margin: 0; }
.card-term { border-left: 4px solid var(--cyan); }
.card-term p { white-space: pre-wrap; }
.boundary { color: var(--muted); max-width: 80ch; }
.controls-tip { font-family: var(--mono); font-size: 0.9rem; color: var(--warn); }
.actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }
.actions button { font-size: 1rem; padding: 10px 18px; }
details { margin: 10px 0; max-width: 80ch; }
summary { cursor: pointer; color: var(--muted); font-family: var(--mono); }
.sources { font-size: 0.85rem; color: var(--muted); padding-left: 18px; }

/* ---------- topology map ---------- */
.map { margin: 14px 0; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.map-svg { width: 100%; height: auto; display: block; max-height: 200px; }
.map-compact .map-svg { max-height: 130px; }
.node rect { fill: #0e1a2e; stroke: var(--cyan); stroke-width: 2; }
.node-name { fill: var(--text); font: 700 13px var(--mono); }
.node-addr { fill: var(--muted); font: 11px var(--mono); }
.link line { stroke-width: 4; }
.link-up line { stroke: var(--ok); }
.link-current line { stroke: var(--warn); stroke-dasharray: 10 6; animation: dash 1s linear infinite; }
.link-down line { stroke: #34445f; stroke-dasharray: 3 6; }
.link-title { fill: var(--text); font: 600 12px var(--mono); }
.link-state { font: 11px var(--mono); fill: var(--muted); }
.link-up .link-state { fill: var(--ok); }
.link-current .link-state { fill: var(--warn); }
.pulse { fill: #c9ffe0; animation: travel 1.6s linear infinite; }

/* ---------- play ---------- */
.play-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.is-console .play-grid { grid-template-columns: minmax(0, 1fr); }
.is-console .side { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.stage { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); }
#game { display: block; width: 100%; height: auto; aspect-ratio: 960 / 400; }
#game:focus { outline: none; }
.stage:focus-within { box-shadow: 0 0 0 3px var(--focus); }
.focus-hint {
  position: absolute; inset: auto 0 0 0; margin: 0; padding: 6px; text-align: center; font: 600 0.85rem var(--mono);
  background: rgba(255, 176, 32, 0.9); color: #1a1200; pointer-events: none;
}
.stage:focus-within .focus-hint { display: none; }
.side { display: flex; flex-direction: column; gap: 14px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.play-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-top: 12px; }
.goal { margin: 0; font-family: var(--mono); font-size: 0.9rem; }
.play-actions button { font-size: 1rem; padding: 10px 18px; }

.stats { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin: 6px 0; }
.stats caption { text-align: left; color: var(--muted); font-family: var(--mono); padding-bottom: 4px; }
.stats th, .stats td { border-bottom: 1px solid var(--line); padding: 5px 6px; text-align: left; }
.stats thead th { color: var(--muted); font-weight: 600; font-family: var(--mono); }
.stats td { white-space: nowrap; }
.screen-done .stats, .screen-summary .stats { max-width: 640px; }

/* link test checklist */
.tut-steps { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.tut-steps li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-family: var(--mono); }
.tut-keys { display: inline-flex; gap: 4px; min-width: 70px; }
.tut-keys kbd { background: #eef4ff; color: #0b1424; border: 0; box-shadow: 0 3px 0 #7d8aa3; padding: 2px 7px; font-weight: 700; opacity: 1; }
.tut-done { color: var(--ok); border-color: var(--ok) !important; }
.tut-done::after { content: '✔'; margin-left: auto; }
.tut-now { color: var(--warn); border-color: var(--warn) !important; animation: throb-warn 1.4s ease-in-out infinite; }
.tut-todo { color: var(--muted); }
@keyframes throb-warn { 50% { background: rgba(255, 176, 32, 0.12); } }

/* receiver board */
.slots { list-style: none; padding: 0; margin: 8px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slot { border: 2px solid var(--line); border-radius: 8px; padding: 6px; display: grid; gap: 2px; font-family: var(--mono); text-align: center; }
.slot-n { font-weight: 700; }
.slot-c { font-size: 1.05rem; }
.slot-s, .slot-r { font-size: 0.7rem; }
.slot.have { border-color: var(--ok); background: #0f2318; }
.slot.have .slot-s { color: var(--ok); }
.slot.gap { border-style: dashed; border-color: var(--bad); background: #24101a; animation: throb 1.4s ease-in-out infinite; }
.slot.gap .slot-s { color: var(--bad); }
.slot.sel { box-shadow: 0 0 0 3px var(--warn); }
.slot-r { color: var(--warn); }

/* race replay */
.race-lanes { display: grid; gap: 8px; margin: 4px 0 10px; }
.race-lane { display: grid; grid-template-columns: 105px 1fr 70px; gap: 8px; align-items: center; font-size: 0.8rem; }
.race-name { font-family: var(--mono); }
.race-track { height: 14px; background: #0a1322; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.race-fill { display: block; height: 100%; width: 0; }
.race-fill.copper { background: var(--copper); }
.race-fill.fibre { background: var(--cyan); }
.race-ms { text-align: right; }

/* console mode */
.console { border-color: var(--cyan); }
.choices { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.choices button.choice { width: 100%; text-align: left; font-weight: 500; }
.choices button.closed { border-style: dashed; }
.choices label { margin-left: 8px; font-family: var(--mono); font-size: 0.9rem; }
.choices input { width: 18px; height: 18px; vertical-align: middle; accent-color: var(--warn); }

/* news card */
.news { background: linear-gradient(180deg, #14213a, #0e1a2e); border: 1px solid #2c4470; border-left: 4px solid var(--warn); border-radius: 10px; padding: 14px 18px; margin: 16px 0; max-width: 80ch; }
.news h2 { color: var(--text); font-size: 1.15rem; }
.news h3 { font: 600 0.85rem var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 12px 0 4px; }
.news ul { margin: 0; padding-left: 20px; }
.news-tag { font: 700 0.8rem var(--mono); color: var(--warn); margin: 0 0 4px; }
.disclaimer { font-size: 0.8rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; margin-bottom: 0; }

/* ---------- network log ---------- */
.log { border-top: 1px solid var(--line); background: #040912; }
.log-title { margin: 0; padding: 6px 16px; font: 600 0.8rem var(--mono); color: var(--muted); border-bottom: 1px solid var(--line); }
.log-scroll { max-height: 170px; overflow-y: auto; padding: 6px 16px 10px; }
#log-lines { list-style: none; margin: 0; padding: 0; font: 0.85rem/1.55 var(--mono); }
#log-lines li { padding: 2px 0; border-bottom: 1px dotted #111c2e; }
.log-stamp { color: #5b6f8e; }
.log-ok { color: var(--ok); }
.log-bad { color: var(--bad); }
.log-warn { color: var(--warn); }
.log-hint { color: #b9a6ff; }
.log-info { color: var(--muted); }

/* ---------- motion ---------- */
@keyframes blink { 50% { opacity: 0; } }
@keyframes dash { to { stroke-dashoffset: -16; } }
@keyframes travel { from { transform: translateX(0); } to { transform: translateX(172px); } }
@keyframes throb { 50% { background: #3a1422; } }
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- narrow ---------- */
@media (max-width: 900px) {
  .play-grid { grid-template-columns: minmax(0, 1fr); }
  .brand-sub { display: none; }
  .pf-right { margin-left: 0; }
}
@media (max-width: 520px) {
  .toolbar button { padding: 6px 8px; font-size: 0.8rem; }
  kbd { display: none; }
  .slots { grid-template-columns: repeat(2, 1fr); }
}
