/* ==========================================================================
   NRSniffer project page
   Light + dark themes. Dark surface matches the logo background (#1c1c1c).
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #fbfbfa;
  --bg-alt: #f2f3f1;
  --surface: #ffffff;
  --surface-2: #f6f7f5;
  --border: #e3e4e0;
  --border-strong: #cfd1cb;
  --text: #121212;
  --text-2: #4a4a47;
  --text-3: #6e6d69;
  --accent: #0b7fa6;          /* deep cyan (readable on light) */
  --accent-strong: #075f7d;
  --accent-soft: #e3f4fa;
  --accent-ink: #ffffff;
  --logo-cyan: #8eddf4;
  --terminal: #1c1c1c;
  --warn: #b5560f;
  --warn-soft: #fbeee3;
  --ok: #157a3c;
  --ok-soft: #e4f4ea;
  --bad: #b3261e;
  /* chart */
  --series-1: #2a78d6;
  --series-base: #8a8883;
  --grid: #e7e7e3;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #1c1c1c;
    --bg-alt: #202020;
    --surface: #242424;
    --surface-2: #2a2a2a;
    --border: #333333;
    --border-strong: #444444;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #9a9990;
    --accent: #8eddf4;
    --accent-strong: #b5ebfa;
    --accent-soft: rgba(142,221,244,.10);
    --accent-ink: #0f1a1d;
    --warn: #f0a35e;
    --warn-soft: rgba(240,163,94,.10);
    --ok: #6fd39a;
    --ok-soft: rgba(111,211,154,.10);
    --bad: #f28b82;
    --series-1: #3987e5;
    --series-base: #7a7975;
    --grid: #333333;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c1c1c;
  --bg-alt: #202020;
  --surface: #242424;
  --surface-2: #2a2a2a;
  --border: #333333;
  --border-strong: #444444;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --text-3: #9a9990;
  --accent: #8eddf4;
  --accent-strong: #b5ebfa;
  --accent-soft: rgba(142,221,244,.10);
  --accent-ink: #0f1a1d;
  --warn: #f0a35e;
  --warn-soft: rgba(240,163,94,.10);
  --ok: #6fd39a;
  --ok-soft: rgba(111,211,154,.10);
  --bad: #f28b82;
  --series-1: #3987e5;
  --series-base: #7a7975;
  --grid: #333333;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
code, .mono { font-family: var(--mono); font-size: .88em; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: .05em .35em; }
strong { font-weight: 650; }
img, video { max-width: 100%; display: block; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.wrap-narrow { max-width: 820px; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav .wrap { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-weight: 700; letter-spacing: .04em; color: var(--text); text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.nav-links { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a { color: var(--text-2); text-decoration: none; font-size: 14px; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--surface-2); }
.theme-toggle {
  flex: none; display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--border-strong); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (max-width: 860px) { .nav-links { display: none; } .theme-toggle { margin-left: auto; } }

/* ---------- hero ---------- */
.hero { padding: 64px 0 40px; text-align: center; }
.terminal {
  background: var(--terminal);
  border-radius: 16px;
  border: 1px solid #2e2e2e;
  box-shadow: var(--shadow);
  overflow: hidden;
  max-width: 820px; margin: 0 auto;
}
.terminal-bar { display: flex; align-items: center; gap: 7px; padding: 11px 14px; border-bottom: 1px solid #2c2c2c; }
.terminal-bar i { width: 11px; height: 11px; border-radius: 50%; background: #3a3a3a; }
.terminal-bar i:nth-child(1) { background: #ff5f57; }
.terminal-bar i:nth-child(2) { background: #febc2e; }
.terminal-bar i:nth-child(3) { background: #28c840; }
.terminal-bar span { margin-left: 10px; font-family: var(--mono); font-size: 12px; color: #8b8b8b; }
.terminal-body { padding: 26px 28px 30px; }
.terminal-body img { margin: 0 auto; width: 100%; max-width: 752px; height: auto; image-rendering: auto; }
.terminal-line { margin-top: 18px; font-family: var(--mono); font-size: 13px; color: #a8a8a8; text-align: left; max-width: 752px; margin-left: auto; margin-right: auto; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.terminal-line .p { color: var(--logo-cyan); }
.terminal-line .ok { color: #6fd39a; }
.cursor { display: inline-block; width: 8px; height: 1em; vertical-align: -2px; background: var(--logo-cyan); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cursor { animation: none; } }

.hero h1 { font-size: clamp(28px, 4.2vw, 46px); line-height: 1.15; letter-spacing: -.02em; margin: 40px auto 14px; max-width: 900px; font-weight: 750; }
.hero .lede { font-size: clamp(17px, 2vw, 20px); color: var(--text-2); max-width: 760px; margin: 0 auto; }
 color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); }

.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 28px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; font-size: 15px; font-weight: 600;
  text-decoration: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { border-color: var(--border-strong); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
.btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

/* ---------- sections ---------- */
section { padding: 72px 0; }
section.alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.eyebrow { font-family: var(--mono); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin: 0 0 8px; }
h2 { font-size: clamp(26px, 3.2vw, 36px); line-height: 1.2; letter-spacing: -.015em; margin: 0 0 14px; font-weight: 720; }
h3 { font-size: 20px; line-height: 1.3; margin: 0 0 8px; font-weight: 680; }
h4 { font-size: 15px; margin: 0 0 6px; font-weight: 680; }
.section-intro { color: var(--text-2); font-size: 18px; max-width: 780px; margin: 0 0 36px; }
p { margin: 0 0 14px; }
.muted { color: var(--text-3); }
.small { font-size: 14px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- layman section ---------- */
.explain { display: grid; grid-template-columns: 1.05fr 1fr; gap: 40px; align-items: center; }
@media (max-width: 900px) { .explain { grid-template-columns: 1fr; } }
.explain-text p { font-size: 18px; }
.scene-card { margin: 0; padding: 18px; }
.scene { width: 100%; height: auto; display: block; }
.scene .s-stroke { stroke: var(--text-2); }
.scene .s-fill { fill: var(--surface); }
.scene .s-text { fill: var(--text-2); font-family: var(--sans); font-size: 13px; }
.scene .s-text-strong { fill: var(--text); font-family: var(--sans); font-size: 15px; font-weight: 700; }
.scene .s-accent { stroke: var(--accent); }
.scene .s-accent-fill { fill: var(--accent); }
.scene .s-ok-fill { fill: var(--ok); }
.scene .s-dl { stroke: var(--series-1); }
.scene .s-ul { stroke: var(--warn); }
.scene .pkt-dl { fill: var(--series-1); }
.scene .pkt-ul { fill: var(--warn); }
/* dashes travel along the path's own direction (DL: tower→phone, UL: phone→tower) */
.scene .wave { stroke-dasharray: 4 7; opacity: .55; animation: flow 1.1s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -22; } }
.scene .pulse, .scene .listen { animation: pulse 2.4s ease-out infinite; opacity: 0; }
.scene .p2 { animation-delay: .4s; }
.scene .p3 { animation-delay: .8s; }
/* receive: outer arc first, then inward toward the antennas */
.scene .l3 { animation-delay: 0s; }
.scene .l2 { animation-delay: .4s; }
.scene .l1 { animation-delay: .8s; }
@keyframes pulse { 0% { opacity: 0; } 30% { opacity: .9; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .scene .wave { animation: none; }
  .scene .pulse, .scene .listen { animation: none; opacity: .6; }
  .scene .pkt { display: none; }
}

.sees { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 36px; }
@media (max-width: 620px) { .sees { grid-template-columns: 1fr; } }
.sees ul { margin: 0; padding-left: 0; list-style: none; }
.sees li { padding: 6px 0 6px 28px; position: relative; color: var(--text-2); font-size: 15.5px; }
.sees li::before { position: absolute; left: 0; top: 6px; width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.sees .yes li::before { content: "✓"; background: var(--ok-soft); color: var(--ok); }
.sees .no li::before { content: "✕"; background: var(--warn-soft); color: var(--warn); }

/* ---------- target ---------- */
.phases { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: stretch; margin-top: 28px; }
.phases .arrow { display: grid; place-items: center; color: var(--text-3); font-size: 24px; }
@media (max-width: 720px) { .phases { grid-template-columns: 1fr; } .phases .arrow { transform: rotate(90deg); } }
.phase-tag { display: inline-block; font-family: var(--mono); font-size: 12px; padding: 2px 8px; border-radius: 6px; margin-bottom: 8px; }
.phase-tag.active { background: var(--warn-soft); color: var(--warn); }
.phase-tag.passive { background: var(--ok-soft); color: var(--ok); }
.phases p { color: var(--text-2); font-size: 15.5px; margin: 0; }

/* ---------- challenges ---------- */
.ca-row { display: grid; grid-template-columns: 1fr 56px 1fr; align-items: stretch; margin-bottom: 22px; }
.ca-row .link { display: grid; place-items: center; color: var(--accent); }
.ca-row .link svg { width: 28px; height: 28px; }
@media (max-width: 820px) { .ca-row { grid-template-columns: 1fr; } .ca-row .link { height: 44px; transform: rotate(90deg); } }
.ca { position: relative; }
.ca .tag { font-family: var(--mono); font-size: 13px; font-weight: 700; padding: 3px 9px; border-radius: 7px; display: inline-block; margin-bottom: 10px; }
.ca.challenge .tag { background: var(--warn-soft); color: var(--warn); }
.ca.approach .tag { background: var(--accent-soft); color: var(--accent); }
.ca .plain { font-size: 16.5px; color: var(--text); margin-bottom: 10px; }
.ca .tech { font-size: 14.5px; color: var(--text-2); margin: 0; }
.ca ul { margin: 8px 0 0; padding-left: 18px; font-size: 14.5px; color: var(--text-2); }
.ca ul li { margin: 3px 0; }

.dci-compare { margin-top: 14px; font-family: var(--mono); font-size: 12px; }
.dci-compare .lbl { color: var(--text-3); margin: 8px 0 4px; display: flex; justify-content: space-between; }
.bits { display: flex; gap: 1px; }
.bits span { flex: 1; height: 14px; background: var(--border-strong); border-radius: 1px; }
.bits span.chg { background: var(--warn); }
.bits span.gap { background: transparent; }

.pipeline { margin-top: 40px; }
.diagram-scroll { overflow-x: auto; margin-top: 12px; -webkit-overflow-scrolling: touch; }
.diagram { width: 100%; min-width: 820px; height: auto; display: block; }
.diagram text { font-family: var(--sans); }
.d-phase { font-family: var(--mono) !important; font-size: 11.5px; letter-spacing: .08em; font-weight: 700; }
.d-phase-1 { fill: var(--warn); }
.d-phase-2 { fill: var(--ok); }
.d-region { stroke-width: 1.4; stroke-dasharray: 6 5; }
.d-region-1 { fill: color-mix(in srgb, var(--warn) 5%, var(--surface-2)); stroke: color-mix(in srgb, var(--warn) 55%, transparent); }
.d-region-2 { fill: color-mix(in srgb, var(--ok) 4%, transparent); stroke: color-mix(in srgb, var(--ok) 50%, transparent); }
.d-panel { fill: var(--surface-2); stroke: var(--border); stroke-width: 1.2; }
.d-box { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.2; }
.d-box-a { stroke: var(--accent); }
.d-gpu { fill: var(--accent-soft); stroke: color-mix(in srgb, var(--accent) 55%, transparent); stroke-width: 1.4; }
.d-a2 { fill: var(--surface); stroke: color-mix(in srgb, var(--accent) 50%, transparent); stroke-width: 1.2; stroke-dasharray: 4 4; }
.d-title { fill: var(--accent); font-size: 14px; font-weight: 700; }
.d-title-sm { font-size: 13px; }
.d-lbl { fill: var(--text); font-size: 13px; }
.d-sm { fill: var(--text-3); font-size: 11.5px; }
.d-icon { color: var(--text-2); }
.d-icon-a { color: var(--accent); }
.d-arrow { fill: none; stroke: var(--text-3); stroke-width: 1.8; }
.d-arrow-a { stroke: var(--accent); }
.d-bits { font-family: var(--mono) !important; font-size: 18px; font-weight: 600; fill: var(--text); }
.d-bits .hot { fill: var(--warn); }
.d-chip-txt { font-family: var(--mono) !important; font-size: 10px; font-weight: 700; fill: var(--accent); }
.d-badge { fill: var(--accent); }
.d-badge-txt { font-family: var(--mono) !important; font-size: 11px; font-weight: 700; fill: var(--accent-ink); }

/* ---------- shared controls ---------- */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button {
  font: inherit; font-size: 13.5px; padding: 6px 12px; border-radius: 8px; border: 0;
  background: transparent; color: var(--text-2); cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
.tip {
  position: fixed; z-index: 100; pointer-events: none;
  background: var(--text); color: var(--bg);
  font-size: 12.5px; line-height: 1.4; padding: 7px 10px; border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2); opacity: 0; transform: translateY(4px);
  transition: opacity .12s, transform .12s; max-width: 260px;
}
.tip.show { opacity: 1; transform: none; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
thead th {
  position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 650;
  font-size: 13px; color: var(--text-2); padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--text); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
td.mono, td code { font-family: var(--mono); font-size: 13px; }
td code { word-break: break-word; }
td.id { font-family: var(--mono); font-weight: 700; color: var(--accent); white-space: nowrap; }
td.num { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
td.center, th.center { text-align: center; }
.chip { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.chip.k { border-color: color-mix(in srgb, var(--series-1) 45%, transparent); color: var(--series-1); background: color-mix(in srgb, var(--series-1) 10%, transparent); }
.chip.u { border-color: color-mix(in srgb, var(--warn) 45%, transparent); color: var(--warn); background: var(--warn-soft); }
.chip.cots { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); }
.chip.var { color: var(--text-2); }
.yes-mark { color: var(--ok); font-weight: 700; }
.no-mark { color: var(--text-3); }
.r-mark { color: var(--warn); font-weight: 600; }
tr.group-row td { background: var(--surface-2); font-size: 12.5px; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; padding: 8px 14px; }
tr.hl td { background: color-mix(in srgb, var(--accent) 8%, transparent); }

.table-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.search {
  font: inherit; font-size: 14px; padding: 8px 12px; border-radius: 10px; min-width: 240px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.search:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 1px; }
.count { font-size: 13px; color: var(--text-3); }
.table-foot { font-size: 13px; color: var(--text-3); margin-top: 12px; line-height: 1.55; }
.ref-card { margin-bottom: 16px; padding: 16px 20px; font-size: 14.5px; color: var(--text-2); }
.ref-card b { color: var(--text); }

details.nochange { margin-top: 16px; }
details.nochange summary { cursor: pointer; font-weight: 600; font-size: 15px; padding: 10px 0; color: var(--text-2); }
details.nochange summary:hover { color: var(--text); }

.subnav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 26px; }
.subnav a { font-size: 14px; text-decoration: none; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); color: var(--text-2); background: var(--surface); }
.subnav a:hover { color: var(--text); border-color: var(--border-strong); }
.data-block { margin-bottom: 64px; }
.data-block:last-child { margin-bottom: 0; }
.data-block h3 { font-size: 22px; }

/* ---------- video ---------- */
.video-frame { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow); background: #000; aspect-ratio: 16 / 9; }
.video-frame video { width: 100%; height: 100%; }
.video-notes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 22px; }
@media (max-width: 720px) { .video-notes { grid-template-columns: 1fr; } }
.video-notes div { font-size: 14.5px; color: var(--text-2); }
.video-notes b { display: block; color: var(--text); font-size: 15px; margin-bottom: 2px; }

/* ---------- ethics / footer ---------- */
.ethics li { margin: 6px 0; color: var(--text-2); }
footer { padding: 40px 0 56px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 14px; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }

.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
