/* Scanner. One small stylesheet. Colours and type live in the variables. */

:root {
  color-scheme: light dark;
  --bg: #f6f3ed;
  --sheet: #fffdf9;
  --ink: #1b1a17;
  --muted: #6c675d;
  --faint: #a29c90;
  --line: #e4dfd3;
  --hover: #efebe2;
  --live: #c2412d;
  --fire: #c2412d;
  --ambulance: #2f7a5c;
  --rescue: #a96a08;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --tabs: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311;
    --sheet: #1d1c19;
    --ink: #efece5;
    --muted: #a09b90;
    --faint: #6f6a60;
    --line: #2b2925;
    --hover: #1b1a17;
    --live: #ec6a53;
    --fire: #ec6a53;
    --ambulance: #5fb996;
    --rescue: #e3a94e;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabs) + 24px + env(safe-area-inset-bottom));
}
body.hasplayer { padding-bottom: calc(var(--tabs) + 96px + env(safe-area-inset-bottom)); }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }

.wrap { max-width: 640px; margin: 0 auto; }

/* Top bar */

.sticky {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 4px 20px;
}

.brand {
  margin: 0;
  flex: 1;
  font: 600 1.5rem/1 var(--serif);
  letter-spacing: -0.01em;
}

.conn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--muted);
}
.conn i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}
.conn[data-state="live"] i { background: var(--live); animation: pulse 2.4s ease-out infinite; }
.conn[data-state="sample"] i { background: transparent; box-shadow: inset 0 0 0 1.5px var(--live); }
.conn[data-state="retry"] i { background: var(--rescue); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 45%, transparent); }
  70%, 100% { box-shadow: 0 0 0 8px transparent; }
}

.icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
}
.icon:hover { background: var(--hover); }
.icon[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.icon.ghost { visibility: hidden; }

.searchrow { padding: 4px 20px 8px; }
.searchrow input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--sheet);
  font-size: 1rem; /* 16px stops iPhones from zooming in. */
}
.searchrow input:focus { outline: none; border-color: var(--ink); }

/* Filters */

.chips {
  display: flex;
  gap: 8px;
  padding: 8px 20px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips[data-tab="listen"] { display: none; }

.chip {
  flex: none;
  height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: transparent;
  font-size: 0.9375rem;
  white-space: nowrap;
}
.chip .n { margin-left: 2px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip[aria-pressed="true"] .n { color: inherit; opacity: 0.7; }

/* Summary */

.notice {
  margin: 16px 20px 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--sheet);
  color: var(--muted);
  font-size: 0.875rem;
}

.summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 10px;
}
.summary p { margin: 0; color: var(--muted); }
.summary strong {
  margin-right: 6px;
  color: var(--ink);
  font: 600 2.25rem/1 var(--serif);
  font-variant-numeric: tabular-nums;
}

.toggle {
  flex: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 0.875rem;
  color: var(--muted);
  cursor: pointer;
}
.toggle input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }

/* Incident list */

.list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.list li { border-bottom: 1px solid var(--line); }

.rowbtn {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 16px 20px;
  border: 0;
  background: none;
  text-align: left;
}
.rowbtn:hover { background: var(--hover); }
.rowbtn:active { background: var(--hover); }

.main, .side { display: flex; flex-direction: column; min-width: 0; }
.main { gap: 2px; }
.side { align-items: flex-end; gap: 2px; flex: none; text-align: right; }

.svc {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.svc i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.svc.fire i { background: var(--fire); }
.svc.ambulance i { background: var(--ambulance); }
.svc.rescue i { background: var(--rescue); }

.title { font-size: 1.0625rem; font-weight: 600; line-height: 1.3; }
.where { font-size: 0.9375rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side time { font-size: 0.9375rem; font-variant-numeric: tabular-nums; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; color: var(--muted); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.status.active { color: var(--ink); }
.status.active::before { background: var(--live); }
.status.controlled::before { box-shadow: inset 0 0 0 1.5px var(--rescue); }
.status.finished { color: var(--faint); }
.status.finished::before { background: var(--faint); }

.list li.enter { animation: enter 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
.list li.enter .rowbtn { animation: flash 4s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(-8px); } }
@keyframes flash { from { background: color-mix(in srgb, var(--live) 12%, transparent); } }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.fine { margin: 28px 20px 0; font-size: 0.8125rem; color: var(--muted); text-align: center; }

/* Listen */

.intro { padding: 24px 20px 16px; }
.intro h2 { margin: 0 0 4px; font: 600 2rem/1.1 var(--serif); letter-spacing: -0.01em; }
.intro p { margin: 0; color: var(--muted); }

.group { margin: 0; padding: 20px 20px 8px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

.feed {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.feed:first-of-type { border-top: 1px solid var(--line); }
.feed .text { flex: 1; min-width: 0; }
.feed h3 { margin: 0; font-size: 1.0625rem; }
.feed p { margin: 2px 0 0; font-size: 0.9375rem; color: var(--muted); }
.feed .soon { flex: none; font-size: 0.8125rem; color: var(--muted); border: 1px solid var(--line); border-radius: 14px; padding: 4px 10px; }
.feed.on h3::after { content: "Playing"; margin-left: 10px; font-size: 0.75rem; font-weight: 600; color: var(--live); }

.playbtn {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
}
.playbtn svg { display: block; }

/* Player bar */

.player {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(var(--tabs) + 8px + env(safe-area-inset-bottom));
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 624px;
  margin: 0 auto;
  padding: 8px 4px 8px 8px;
  border-radius: 16px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
}
.player .playbtn { background: var(--bg); color: var(--ink); }
.player .ptext { flex: 1; min-width: 0; }
.player p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pname { font-weight: 600; }
.pstate { font-size: 0.8125rem; opacity: 0.7; }
.pclose:hover { background: rgb(255 255 255 / 0.12); }

/* Tab bar */

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 7;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabsin { display: flex; height: var(--tabs); }
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.tab[aria-current="page"] { color: var(--ink); }

/* Detail sheet */

dialog {
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--sheet);
  color: var(--ink);
  overflow: auto;
}
dialog::backdrop { background: rgb(20 18 15 / 0.5); }
dialog[open] { animation: rise 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }
dialog[open]::backdrop { animation: fade 0.3s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

@media (min-width: 700px) {
  dialog { margin: auto; border-radius: 20px; }
}

.sheetin { position: relative; padding: 24px 24px calc(24px + env(safe-area-inset-bottom)); }
.sheetin .close { position: absolute; top: 8px; right: 8px; }
.sheetin h2 { margin: 6px 0 8px; padding-right: 40px; font: 600 1.875rem/1.15 var(--serif); letter-spacing: -0.01em; }
.sheetin .note { margin: 16px 0 0; color: var(--muted); }

.facts { margin: 20px 0 0; border-top: 1px solid var(--line); }
.facts div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; }

.actions { display: flex; gap: 10px; margin-top: 20px; }
.btn {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  text-decoration: none;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }

/* Message */

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--tabs) + 16px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: 420px;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.9375rem;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
