/* SDR Scanner — dark-first design. Colors here mirror web/systems.py;
   change both together. */

:root {
  --bg: #111;
  --bg-raised: #191b1e;
  --fg: #ddd;
  --fg-dim: #888;
  --border: #2a2d31;

  /* System identity colors — used everywhere a system appears.
     Police/sheriff = greens & blues, EMS = reds/yellows/oranges.
     WSP and Jefferson Sheriff are lighter tints of PA's blue and
     Sequim's green — same family, not an unrelated hue. */
  --sys-sequim-pd-ccso: #22c55e;
  --sys-port-angeles-pd: #3b82f6;
  --sys-jefferson-sheriff: #4ade80;
  --sys-clallam-ems: #ef4444;
  --sys-east-jefferson-ems: #eab308;
  --sys-wsp-area: #60a5fa;
  --sys-unknown: #8a8f98;

  /* Ops-dashboard status/categorical colors — dataviz skill's fixed
     reference palette (status colors are constant across brands; the
     first three categorical slots cover the 3-way device breakdown). */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-critical: #d03b3b;
  --status-info: #3987e5;
  --cat-1: #3987e5;
  --cat-2: #199e70;
  --cat-3: #c98500;
}

body {
  font-family: system-ui, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .6rem 1.5rem;
}

.header-logo-link {
  flex: none;
  line-height: 0;
}

.header-logo {
  height: 96px;
  width: auto;
  display: block;
  border-radius: 6px;
}

.header-titles {
  flex: 1 1 auto;
  min-width: 0;
}

.header-titles h1 {
  margin: 0 0 .2rem;
  font-size: 1.2rem;
}

.header-ai {
  margin: 0;
  color: var(--fg-dim);
  font-size: .78rem;
  max-width: 640px;
}

.header-ai a {
  color: var(--fg-dim);
  text-decoration: underline;
}

.header-ai a:hover {
  color: var(--fg);
}

/* Same color treatment as the active Clallam EMS chip: red fill,
   near-black text (owner request 2026-07-08). */
.header-donate {
  flex: none;
  background: var(--sys-clallam-ems);
  border: 1px solid var(--sys-clallam-ems);
  color: #0b0c0e;
  font-weight: 600;
  padding: .4rem .9rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: .82rem;
  white-space: nowrap;
}

.header-donate:hover {
  opacity: .85;
}

/* Accuracy notice — deliberately separate from the branding/donate
   row so it doesn't read as marketing copy. Stays visible at every
   screen size, unlike .header-ai which drops out on mobile. */
.header-disclaimer {
  padding: .3rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--sys-east-jefferson-ems);
  font-size: .75rem;
  text-align: center;
}

.search-form {
  margin: 0 0 1rem;
}

.search-form input[type="search"] {
  width: 100%;
  max-width: 420px;
  padding: .5rem .75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--fg);
  font-size: .9rem;
}

.search-form input[type="search"]:focus {
  outline: none;
  border-color: var(--fg-dim);
}

mark {
  background: var(--sys-east-jefferson-ems);
  color: #0b0c0e;
  padding: 0 .1em;
  border-radius: 2px;
}

.search-note {
  color: var(--fg-dim);
  font-size: .78rem;
  margin: -.5rem 0 1rem;
}

main {
  padding: 1rem 1.5rem;
  max-width: 900px;
}

main.pods-main {
  max-width: none;
}

table {
  width: 100%;
  border-collapse: collapse;
}

td {
  padding: .4rem .6rem;
  border-bottom: 1px solid #222;
  vertical-align: top;
}

.sys {
  white-space: nowrap;
  font-size: .85rem;
}

.time {
  color: var(--fg-dim);
  white-space: nowrap;
  font-size: .85rem;
}

.time a {
  color: inherit;
  text-decoration: none;
}

.time a:hover {
  text-decoration: underline;
}

.stats {
  color: var(--fg-dim);
  font-size: .85rem;
  margin: .5rem 0 1rem;
}

.lowconf {
  opacity: .55;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 0 0 1rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: .3rem .75rem;
  border-radius: 999px;
  border: 1.5px solid var(--chip-color, var(--sys-unknown));
  color: var(--chip-color, var(--sys-unknown));
  background: transparent;
  text-decoration: none;
  font-size: .8rem;
  white-space: nowrap;
}

.chip:hover {
  opacity: .8;
}

.chip.active {
  background: var(--chip-color, var(--sys-unknown));
  color: #0b0c0e;
  font-weight: 600;
}

.viewnav {
  display: flex;
  gap: .5rem;
  margin: 0 0 1rem;
}

.viewlink {
  padding: .3rem .75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--fg-dim);
  text-decoration: none;
  font-size: .85rem;
}

.viewlink.active {
  color: var(--fg);
  border-color: var(--fg-dim);
  background: var(--bg-raised);
}

.pod-toolbar {
  margin: 0 0 .75rem;
}

.pod-reset {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--fg-dim);
  border-radius: 6px;
  padding: .3rem .75rem;
  font-size: .8rem;
  cursor: pointer;
}

.pod-reset:hover {
  color: var(--fg);
  border-color: var(--fg-dim);
}

.pod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

/* Freeform (drag/resize) mode swaps grid flow for absolute
   positioning — pods.js sets each pod's left/top/width/height. */
.pod-grid.freeform {
  position: relative;
  display: block;
}

.pod-grid.freeform .pod {
  position: absolute;
  box-sizing: border-box;
}

.pod {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--chip-color, var(--border));
  border-radius: 8px;
  background: var(--bg-raised);
  overflow: hidden;
}

.pod-grid:not(.freeform) .pod {
  max-height: 480px;
}

.pod-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: .5rem .75rem;
  background: var(--chip-color, var(--sys-unknown));
  color: #0b0c0e;
  font-weight: 600;
  font-size: .85rem;
  flex: none;
}

.pod-grid.freeform .pod-header {
  cursor: move;
  user-select: none;
}

.pod-freq {
  font-weight: 400;
  opacity: .8;
}

.pod-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 .25rem;
}

.pod-body table {
  font-size: .85rem;
}

.pod-body td {
  padding: .3rem .5rem;
}

/* Purely visual resize-corner cue; interactjs listens on the pod's
   own edges, this element has no pointer handling of its own. */
.pod-grid.freeform .pod::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 12px;
  height: 12px;
  pointer-events: none;
  opacity: .6;
  background:
    linear-gradient(135deg,
      transparent 0 40%, var(--fg-dim) 40% 46%,
      transparent 46% 60%, var(--fg-dim) 60% 66%,
      transparent 66% 100%);
}

h2 {
  font-size: 1.05rem;
  margin: 0 0 .75rem;
}

.donate-button {
  display: inline-block;
  background: #ffc439;
  color: #111;
  font-weight: 600;
  padding: .6rem 1.25rem;
  border-radius: 6px;
  text-decoration: none;
}

.donate-button:hover {
  opacity: .9;
}

.call-meta {
  color: var(--fg-dim);
  font-size: .85rem;
  margin: .25rem 0 1rem;
}

.call-transcript {
  font-size: 1rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

audio {
  width: 100%;
  max-width: 480px;
  display: block;
  margin: 0 0 1rem;
}

/* Mobile: pods degrade to stacked full-width feeds (matches the
   768px + fine-pointer gate in pods.js — below that, no drag wiring
   runs at all, so the toolbar and nested pod scrollbars would just
   be dead weight). Everything else here is general narrow-screen
   breathing room. */
@media (max-width: 767px) {
  .pod-toolbar {
    display: none;
  }

  .pod-grid:not(.freeform) {
    display: block;
  }

  .pod-grid:not(.freeform) .pod {
    margin-bottom: 1rem;
    max-height: none;
  }

  .pod-grid:not(.freeform) .pod-body {
    overflow-y: visible;
  }

  /* The sticky header eats screen height on every scroll position, not
     just at the top — the AI banner paragraph is the one thing safe to
     drop here since the logo/title/donate link carry the same content
     more compactly. */
  .header-row {
    padding: .5rem 1rem;
    gap: .6rem;
  }

  .header-logo {
    height: 48px;
  }

  .header-ai {
    display: none;
  }

  .header-titles h1 {
    font-size: 1rem;
    margin: 0;
  }

  .header-donate {
    padding: .3rem .6rem;
    font-size: .75rem;
  }

  .header-disclaimer {
    padding: .3rem 1rem;
    font-size: .7rem;
  }
}

@media (max-width: 480px) {
  main {
    padding: .75rem 1rem;
  }

  td {
    padding: .35rem .4rem;
    font-size: .82rem;
  }

  .chip {
    padding: .25rem .6rem;
    font-size: .75rem;
  }
}

/* First-visit help overlay (templates/_help.html). Auto-opens unless
   the visitor has clicked "Don't show this again" (localStorage);
   the Help button in the nav reopens it anytime. */
.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, .65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.help-overlay[hidden] {
  display: none;
}

body.help-open {
  overflow: hidden;
}

.help-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}

.help-card h2 {
  margin: 0 0 .75rem;
}

.help-section {
  margin: 0 0 1.1rem;
}

.help-section h3 {
  margin: 0 0 .3rem;
  font-size: .9rem;
}

.help-section p {
  margin: 0 0 .6rem;
  color: var(--fg-dim);
  font-size: .82rem;
  line-height: 1.45;
}

.help-footnote {
  color: var(--fg-dim);
  font-size: .78rem;
  margin: 0;
}

.help-actions {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.help-actions button {
  border-radius: 6px;
  padding: .45rem .9rem;
  font-size: .82rem;
  font-family: inherit;
  cursor: pointer;
}

.help-got-it {
  background: var(--fg);
  color: #111;
  border: 1px solid var(--fg);
  font-weight: 600;
}

.help-got-it:hover {
  opacity: .85;
}

.help-never {
  background: transparent;
  color: var(--fg-dim);
  border: 1px solid var(--border);
}

.help-never:hover {
  color: var(--fg);
  border-color: var(--fg-dim);
}

/* The nav Help control is a <button>, unlike its <a> siblings —
   flatten the UA button chrome so .viewlink styles it identically. */
button.viewlink {
  background: transparent;
  font-family: inherit;
  cursor: pointer;
}

button.viewlink:hover {
  color: var(--fg);
}

/* --- Animated demos inside the help card. Pure CSS loops standing in
   for a screen-capture gif — no video/gif assets, consistent with the
   site's no-external-assets rule. Chip/row toggles below must stay in
   phase: each color's chip keyframes and row keyframes share the same
   percentages. --- */
.help-demo {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem;
  max-width: 340px;
}

.demo-chip-row {
  display: flex;
  gap: .4rem;
  margin-bottom: .6rem;
}

.demo-chip {
  padding: .12rem .5rem;
  border-radius: 999px;
  border: 1.5px solid var(--c);
  font-size: .65rem;
  white-space: nowrap;
  background: var(--c);
  color: #0b0c0e;
  font-weight: 600;
}

.demo-chip.dc-blue {
  animation: help-chip-b 9s infinite;
}

.demo-chip.dc-red {
  animation: help-chip-r 9s infinite;
}

.demo-row {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .22rem 0;
}

.demo-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c);
  flex: none;
}

.demo-line {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  flex: 1 1 auto;
}

.demo-row:nth-child(odd) .demo-line {
  flex-basis: 70%;
  flex-grow: 0;
}

.demo-row.dr-blue {
  animation: help-row-b 9s infinite;
}

.demo-row.dr-red {
  animation: help-row-r 9s infinite;
}

@keyframes help-chip-b {
  0%, 20%, 62%, 100% { background: var(--c); color: #0b0c0e; }
  26%, 56% { background: transparent; color: var(--c); }
}

@keyframes help-row-b {
  0%, 20%, 62%, 100% { opacity: 1; }
  26%, 56% { opacity: .07; }
}

@keyframes help-chip-r {
  0%, 40%, 82%, 100% { background: var(--c); color: #0b0c0e; }
  46%, 76% { background: transparent; color: var(--c); }
}

@keyframes help-row-r {
  0%, 40%, 82%, 100% { opacity: 1; }
  46%, 76% { opacity: .07; }
}

/* Pods demo: one mini pod gets "dragged" then "resized" while a
   cursor dot leads the motion; positions in the cursor keyframes are
   hand-matched to the pod's keyframes — change them together. */
.demo-pods {
  position: relative;
  height: 170px;
  overflow: hidden;
}

.demo-pod {
  position: absolute;
  border: 1px solid var(--c);
  border-radius: 6px;
  background: var(--bg-raised);
  overflow: hidden;
}

.demo-pod-header {
  background: var(--c);
  color: #0b0c0e;
  font-size: .6rem;
  font-weight: 600;
  padding: .15rem .4rem;
  white-space: nowrap;
}

.demo-pod-line {
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  margin: .35rem .4rem 0;
}

.demo-pod-a {
  left: 10px;
  top: 10px;
  width: 100px;
  height: 64px;
  animation: help-pod-a 9s infinite;
  z-index: 2;
}

.demo-pod-a::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 10px;
  height: 10px;
  opacity: .6;
  background:
    linear-gradient(135deg,
      transparent 0 40%, var(--fg-dim) 40% 46%,
      transparent 46% 60%, var(--fg-dim) 60% 66%,
      transparent 66% 100%);
}

.demo-pod-b {
  right: 10px;
  top: 10px;
  width: 100px;
  height: 64px;
}

.demo-cursor {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .8);
  border: 1px solid #111;
  z-index: 3;
  pointer-events: none;
  animation: help-cursor 9s infinite;
}

@keyframes help-pod-a {
  0%, 12% { transform: translate(0, 0); width: 100px; height: 64px; }
  30%, 52% { transform: translate(36px, 30px); width: 100px; height: 64px; }
  72%, 88% { transform: translate(36px, 30px); width: 150px; height: 96px; }
  100% { transform: translate(0, 0); width: 100px; height: 64px; }
}

@keyframes help-cursor {
  0% { left: 140px; top: 90px; opacity: 0; }
  8%, 12% { left: 55px; top: 20px; opacity: 1; }
  30%, 44% { left: 91px; top: 50px; opacity: 1; }
  52% { left: 141px; top: 100px; opacity: 1; }
  72%, 80% { left: 191px; top: 132px; opacity: 1; }
  88%, 100% { left: 191px; top: 132px; opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .help-demo *, .help-demo::after, .demo-cursor {
    animation: none !important;
  }

  .demo-cursor {
    display: none;
  }
}

@media (max-width: 767px) {
  /* Pod drag/resize doesn't exist on touch — the animation would
     demo a feature the visitor can't use. Text explains instead. */
  .demo-pods {
    display: none;
  }

  .help-card {
    padding: 1rem;
  }
}

/* Ops dashboard (/stats) — owner-only, IP-restricted at the Nginx
   layer, no nav link anywhere in the public site. */
.stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.stats-header h1 {
  margin: 0;
  font-size: 1.1rem;
}

.stats-main {
  padding: 1rem 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.stat-card.wide {
  grid-column: 1 / -1;
}

.stat-card h3 {
  margin: 0 0 .75rem;
  font-size: .9rem;
  color: var(--fg-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: .5rem;
}

.stat-tile {
  flex: 1 1 100px;
}

.stat-tile.small .stat-value {
  font-size: 1.1rem;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  color: var(--fg-dim);
  font-size: .75rem;
}

.meter-col {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  margin-bottom: .75rem;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  color: var(--fg-dim);
  margin-bottom: .25rem;
}

.meter-label span:first-child {
  color: var(--fg);
}

.meter-track {
  height: 8px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .3s ease;
}

.status-good { background: var(--status-good); }
.status-warning { background: var(--status-warning); }
.status-critical { background: var(--status-critical); }
.status-info { background: var(--status-info); }

.service-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.service-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .35rem .7rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
}

.service-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  background: currentColor;
  opacity: .6;
}

/* Solid fill, not just a small colored dot on dim text — status needs
   to be readable at a glance, not squinted at. Text color is chosen
   per background for contrast, matching how .chip.active already
   does it elsewhere on this site. */
.service-pill.status-good {
  background: var(--status-good);
  color: #04210a;
}

.service-pill.status-critical {
  background: var(--status-critical);
  color: #fff;
}

.device-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin: .5rem 0 .4rem;
}

.device-segment {
  height: 100%;
}

.device-desktop { background: var(--cat-1); }
.device-mobile { background: var(--cat-2); }
.device-tablet { background: var(--cat-3); }

.device-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: .75rem;
  font-size: .78rem;
  color: var(--fg-dim);
}

.device-legend-item {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: none;
}

.table-scroll {
  overflow-x: auto;
}

.top-paths, .recent-activity {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
}

.top-paths td, .recent-activity td, .recent-activity th {
  padding: .3rem .5rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.recent-activity th {
  text-align: left;
  color: var(--fg-dim);
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
}

.num {
  font-variant-numeric: tabular-nums;
}

.recent-activity tr.row-err td {
  color: var(--status-critical);
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .5rem;
}

.chart-card-header h3 {
  margin: 0;
}

.range-selector {
  display: flex;
  gap: .35rem;
}

.range-selector a {
  padding: .25rem .6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--fg-dim);
  text-decoration: none;
  font-size: .75rem;
}

.range-selector a.active {
  color: var(--fg);
  border-color: var(--fg-dim);
  background: var(--bg);
}

.chart-title {
  margin: .75rem 0 .25rem;
  font-size: .78rem;
  color: var(--fg-dim);
  font-weight: 600;
}

.chart-svg {
  width: 100%;
  height: 140px;
  display: block;
}

.chart-gridline {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-axis-label {
  fill: var(--fg-dim);
  font-size: 8px;
}

.chart-line {
  fill: none;
  stroke-width: 1.75;
}

.chart-dot {
  opacity: .3;
}

.chart-dot:hover {
  opacity: 1;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: .4rem;
  font-size: .75rem;
  color: var(--fg-dim);
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

@media (max-width: 480px) {
  .stats-header {
    padding: .75rem 1rem;
  }

  .stats-main {
    padding: .75rem 1rem;
  }

  .stat-value {
    font-size: 1.3rem;
  }
}
