/* Crime Map — design system. Per-service brand colours are injected as CSS variables at runtime
   (see applyTheme in common.js): --primary, --accent, plus derived AA-safe tokens (--accent-aa,
   --on-brand). Everything else derives from those + a neutral palette. */
:root {
  --primary: #0A2A66;
  --accent: #C8102E;
  --ink: #16202c;
  --muted: #5b6b7b;
  --line: #e4e8ee;
  --bg: #f5f7fa;
  --card: #ffffff;
  --shadow: 0 1px 2px rgba(16,32,53,.06), 0 6px 20px rgba(16,32,53,.06);
  --radius: 12px;
  --radius-sm: 8px;
  --bar-h: 60px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

/* The map page root is a fixed-height flex column: the app bar never scrolls and the view area below
   owns its own scrolling, so the map fills the viewport instead of being stretched by the sidebar.
   overflow:hidden enforces that — every scrollable region below (.v2-panel, .v2-trends-scroll, modal
   body, popovers) already clips itself; without this, any descendant that's ever a hair taller than
   its box (e.g. the map canvas's device-pixel-ratio-scaled backing store) leaks past #app and makes
   the real page scroll into blank, unstyled space below the app. */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
#view { flex: 1 1 auto; min-height: 0; position: relative; display: flex; flex-direction: column; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
button { font: inherit; cursor: pointer; }

/* ---- Top app bar ---- */
.appbar {
  height: var(--bar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
  position: relative; z-index: 1100;
  flex: 0 0 auto;
}
/* Logos are real service artwork (often wide wordmarks): constrain height, let width follow. */
.appbar .logo { height: 36px; width: auto; max-width: 220px; flex: 0 0 auto; }
.appbar .logo-compact { display: none; } /* shown instead of the wordmark on small screens (v2.css) */
.appbar .titles { display: flex; flex-direction: column; line-height: 1.15; }
.appbar .titles .t { font-weight: 700; font-size: 1.05rem; letter-spacing: .2px; }
.appbar .titles .s { font-size: .8rem; opacity: .85; }
.appbar .spacer { flex: 1; }
.appbar .badge {
  font-size: .72rem; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25);
}
/* Filled accent controls use --accent-aa (the registry accent darkened only as much as needed to
   guarantee >= 4.5:1 against white — see applyTheme in common.js), so white text stays AA for any
   service's accent (e.g. Guelph's gold fails at 3.32:1 raw). Hover darkens rather than brightens
   so a minimally-passing fill can't dip below AA on hover. */
.appbar .tip-btn {
  flex: 0 0 auto; padding: 6px 14px; border-radius: 999px;
  background: var(--accent-aa, var(--accent, #C8102E)); color: #fff; font-weight: 600; font-size: .85rem;
  text-decoration: none; white-space: nowrap;
}
.appbar .tip-btn:hover { filter: brightness(.9); }
.appbar .tip-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.muted { color: var(--muted); font-size: .85rem; }

.field { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); font-size: .9rem; }
.search { margin-bottom: 8px; }

.checklist { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding-right: 4px; }
.checkitem { display: flex; align-items: center; gap: 9px; padding: 5px 6px; border-radius: 6px; cursor: pointer; font-size: .88rem; }
.checkitem:hover { background: var(--bg); }
.checkitem input { accent-color: var(--accent); width: 15px; height: 15px; }
.checkitem .swatch { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.checkitem .label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.checkitem .num { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }

/* ---- Buttons ---- */
.btn { padding: 9px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: .88rem; }
.btn.primary { background: var(--accent-aa, var(--accent)); border-color: var(--accent-aa, var(--accent)); color: #fff; }

/* ---- Modal (terms) ---- */
.modal-bg { position: fixed; inset: 0; background: rgba(10,20,35,.55); display: flex; align-items: center;
  justify-content: center; z-index: 2000; padding: 20px; }
.modal { background: #fff; border-radius: var(--radius); max-width: 620px; width: 100%; max-height: 86vh;
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden; }
.modal .head { background: var(--primary); color: #fff; padding: 18px 22px; font-weight: 700; font-size: 1.1rem; }
.modal .body { padding: 20px 22px; overflow-y: auto; color: var(--ink); line-height: 1.6; font-size: .92rem; }
.modal .foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Landing ---- */
.landing { max-width: 980px; margin: 0 auto; padding: 48px 20px; }
.landing .hero h1 { font-size: 2rem; margin: 0 0 8px; color: var(--ink); }
.landing .hero p { color: var(--muted); font-size: 1.05rem; max-width: 640px; }
.services { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; margin-top: 30px; }
.service-card { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); transition: transform .12s ease, box-shadow .12s ease; }
.service-card:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(16,32,53,.12); }
.service-card .top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
/* Service logo on the card: colour crests sit directly on the white card; knockout wordmarks get a
   primary-coloured chip behind them (.tinted, background set per service from the registry). */
.service-card .logo-chip { display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; border-radius: 10px; }
.service-card .logo-chip.tinted { padding: 6px 10px; }
.service-card .logo-chip img { display: block; height: 40px; width: auto; max-width: 140px; }
.service-card .swatch-bar { height: 6px; border-radius: 3px; margin: 12px 0;
  background: linear-gradient(90deg, var(--swatch-from, #0A2A66), var(--swatch-to, #C8102E)); }
.service-card h2 { font-size: 1.1rem; margin: 0; }
.service-card .ds { display: inline-block; font-size: .78rem; color: var(--muted); background: var(--bg);
  border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px; margin: 4px 6px 0 0; }

/* ---- Loading / misc ---- */
.spinner { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); color: var(--muted); z-index: 500; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
