/* GitHub Pages adaptation and fidelity fixes */
:root { --focus-ring: 0 0 0 3px rgba(20, 91, 120, .22); }
html, body { max-width: 100%; }
body.search-open { overflow: hidden; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 3px;
}
.app-loading, .app-error {
  width: min(760px, calc(100% - 32px)); margin: 80px auto; padding: 28px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
}
.app-error { color: #7b2d2d; }
.site-header-actions .current { color: var(--blue); }
.search-overlay[hidden] { display: none !important; }
.search-dialog-head, .search-field { flex: none; }
.search-results { flex: 1 1 auto; }
.search-group a { cursor: pointer; }
.search-close-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.metric-switch.compact-list { max-height: none; overflow: visible; padding-right: 0; }
.bar-row { text-decoration: none; }
.bar-fill { min-width: 2px; }
.bar-row:focus-visible .bar-hover-label { opacity: 1; transform: translate(-50%, -7px); }
.topic-bars-empty { color: var(--muted); padding: 45px 10px; text-align: center; }
.topic-dashboard > *, .topic-controls, #compare-bars { min-width: 0; }
.topic-dashboard .indicator-definition dd a { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }
.aggregate-value { display: block; letter-spacing: -.04em; margin: 10px 0 4px; font-size: 30px; }
.chart-shell { width: 100%; overflow-x: auto; overflow-y: hidden; }
.trend-chart { min-width: 560px; }
.trend-chart svg { width: 100%; height: auto; overflow: visible; }
.chart-area { fill: color-mix(in srgb, var(--theme-color, var(--blue)) 10%, transparent); }
.chart-label { fill: var(--muted); font-size: 10px; font-family: var(--font-geist-mono), monospace; }
.chart-tooltip[hidden] { display: none; }
.chart-a11y-table {
  clip: rect(0 0 0 0) !important; clip-path: inset(50%) !important; white-space: nowrap !important;
  width: 1px !important; height: 1px !important; margin: -1px !important; padding: 0 !important;
  border: 0 !important; position: absolute !important; overflow: hidden !important;
}
.town-data-actions { justify-content: flex-end; margin-top: 18px; }
.town-topic > .metric-switch { margin-top: 34px; }
.metric-meta-row { color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; font-size: 10px; }
.metric-meta-row span { display: inline-flex; gap: 5px; }
.metric-meta-row b { color: var(--ink); }
.topic-deep-dive { margin-top: 55px; }
.feedback-form button[disabled] { opacity: .55; cursor: wait; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 1000; padding: 8px 12px; transform: translateY(-150%); background: var(--ink); color: white; border-radius: 8px; }
.skip-link:focus { transform: translateY(0); }
.no-results { color: var(--muted); padding: 22px 0; }
.print-only { display: none; }
.theme-nav { scroll-padding-inline: 20px; }
.theme-nav button svg { flex: 0 0 auto; }
.town-profile .crime-context { width: 100%; }
.town-benchmark.benchmark-unavailable { background: transparent; }

/* Critical correction for the mobile global search */
@media (max-width: 700px) {
  .search-overlay { align-items: stretch; padding: 0; }
  .search-dialog { width: 100%; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
  .search-dialog-head { position: sticky; top: 0; z-index: 3; padding-top: max(18px, env(safe-area-inset-top)); background: var(--surface); }
  .search-field { position: sticky; top: calc(77px + env(safe-area-inset-top)); z-index: 2; background: #fff; }
  .search-results { min-height: 0; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .search-footer { display: none; }
  .topic-controls .metric-switch { display: flex; flex-wrap: nowrap; align-items: stretch; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
  .topic-controls .metric-switch button { flex: 0 0 auto; text-align: center; border-radius: 999px; scroll-snap-align: center; }
  .town-topic > .metric-switch { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
  .town-topic > .metric-switch button { flex: 0 0 auto; scroll-snap-align: center; }
  .town-data-actions { justify-content: flex-start; }
  .panel-title { flex-direction: column; align-items: flex-start; gap: 10px; }
  .source-pill { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .trend-chart { min-width: 500px; }
}
@media print {
  .site-header, .site-footer, .data-actions, .global-search-trigger, .theme-nav { display: none !important; }
  body { background: white; }
  .page-width { width: 100%; }
  .topic-bars, .explorer-panel, .town-metric-primary, .history-panel { box-shadow: none !important; }
  .print-only { display: block; }
}
