/*
  A&N Road Incident Tracker — civic data instrument
  Design read: public-sector map-first dashboard (GOV.UK / USWDS semantics)
  Dials: VARIANCE 4 · MOTION 5 · DENSITY 7
  Motion: purposeful only (load cascade, chips, filter fade, flyTo, modal, row flash)
  WCAG 2.2 AA · ISO 3864 severity · system fonts · no glass / no shadow chrome
*/

:root {
  --ink: #0b0c0c;
  --text: #0b0c0c;
  --muted: #505a5f;
  --border: #b1b4b6;
  --border-light: #f3f2f1;
  --paper: #f3f2f1;
  --white: #ffffff;
  --surface: #ffffff;
  --row-hover: #f8f8f8;
  --row-active: #e8f1f8;

  --action: #1d70b8;
  --action-hover: #003078;
  --action-soft: #d2e2f1;

  --header: #0b0c0c;
  --header-text: #ffffff;
  --disclaimer-bg: #1d70b8;
  --disclaimer-text: #ffffff;

  --fatal: #d4351c;
  --fatal-bg: #fcebea;
  --major: #f47738;
  --major-bg: #fff2e8;
  --minor: #505a5f;
  --minor-bg: #f3f2f1;
  --unknown: #6f777b;

  --focus-fill: #ffdd00;
  --focus-ink: #0b0c0c;

  --radius: 4px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shell: 1200px;
  --bar-h: 72px;
  --disc-h: 44px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans", "Liberation Sans", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas,
    "DejaVu Sans Mono", monospace;

  --text-xs: 0.8125rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.25rem;
  --text-2xl: 1.75rem;
  --leading: 1.5;
  --leading-tight: 1.25;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  font-size: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: var(--leading);
  font-weight: 400;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

a {
  color: var(--action);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--action-hover);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus-fill);
  outline-offset: 0;
  box-shadow: 0 0 0 4px var(--focus-ink);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10001;
  padding: 0.5rem 1rem;
  background: var(--focus-fill);
  color: var(--focus-ink);
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
  outline: 3px solid var(--focus-ink);
}

/* —— App bar —— */
.app-bar {
  background: var(--header);
  color: var(--header-text);
  min-height: var(--bar-h);
  position: sticky;
  top: 0;
  z-index: 500;
  border-bottom: 4px solid var(--action);
}

.app-bar__inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0.7rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Whole brand block is the home link */
.app-bar__brand {
  display: block;
  min-width: 0;
  flex: 1 1 auto;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius);
  padding: 0.15rem 0.35rem 0.15rem 0;
  margin: -0.15rem 0;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.app-bar__brand:hover {
  text-decoration: none;
  background: rgba(255, 255, 255, 0.06);
}

.app-bar__brand:hover .app-bar__title {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.app-bar__brand:focus-visible {
  outline: 3px solid var(--focus-fill);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus-ink);
}

.app-bar__service {
  display: block;
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #b1b4b6;
}

.app-bar__title {
  display: block;
  margin: 0.1rem 0 0;
  font-size: clamp(1.15rem, 2.4vw, 1.4rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: var(--leading-tight);
  color: var(--header-text);
}

.app-bar__subtitle {
  display: block;
  margin: 0.15rem 0 0;
  font-size: var(--text-xs);
  font-weight: 400;
  line-height: 1.35;
  color: #b1b4b6;
}

/* —— Buttons —— */
.btn {
  appearance: none;
  border: 2px solid transparent;
  border-radius: 0;
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: inherit;
  transition: background-color 0.15s ease, color 0.15s ease,
    border-color 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn--ghost {
  border-color: #ffffff;
  color: var(--header-text);
  background: transparent;
  flex-shrink: 0;
}

.btn--ghost:hover {
  background: #ffffff;
  color: var(--header);
}

.btn--secondary {
  width: 100%;
  margin-top: 0.35rem;
  border-color: var(--ink);
  background: var(--white);
  color: var(--ink);
}

.btn--secondary:hover {
  background: var(--border-light);
}

.btn--icon {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: var(--radius);
  font-size: 1.4rem;
  line-height: 1;
  color: var(--ink);
  border: 2px solid var(--border);
  background: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn--icon:hover {
  border-color: var(--ink);
}

.link-btn {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: inherit;
  font-weight: 700;
  color: #ffffff;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  white-space: nowrap;
}

.link-btn:hover {
  text-decoration-thickness: 2px;
}

/* —— Disclaimer —— */
.disclaimer {
  position: sticky;
  top: var(--bar-h);
  z-index: 490;
  background: var(--disclaimer-bg);
  color: var(--disclaimer-text);
  padding: 0.55rem 1.25rem;
  font-size: var(--text-sm);
  line-height: 1.4;
  min-height: var(--disc-h);
}

.disclaimer__inner {
  max-width: var(--shell);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.disclaimer__inner p {
  margin: 0;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex: 1 1 16rem;
}

.disclaimer__icon {
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  border: 1.5px solid #fff;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  font-style: italic;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.1rem;
}

/* —— Layout —— */
.main {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.section-label {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ink);
  line-height: var(--leading-tight);
}

.section-hint {
  margin: 0.2rem 0 0;
  font-size: var(--text-xs);
  color: var(--muted);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.panel-meta {
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: 600;
}

.flat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* —— Map —— */
.map-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 0.9rem 0.9rem 0.65rem;
}

.map-card__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
}

.map-hud {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--muted);
  text-align: right;
}

.map-container {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #e5e7eb;
  transition: opacity 0.15s ease;
}

.map-container.is-filtering {
  opacity: 0.72;
}

.map-host {
  width: 100%;
  min-height: 48dvh;
  height: 48dvh;
  z-index: 1;
}

@media (min-width: 768px) {
  .map-host {
    min-height: 56vh;
    height: 56vh;
  }
}

.map-empty {
  position: absolute;
  inset: 0;
  z-index: 450;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(243, 242, 241, 0.86);
  color: var(--ink);
  font-size: var(--text-base);
  font-weight: 700;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.2s var(--ease-out);
}

.map-empty[hidden] {
  display: none;
  opacity: 0;
}

/* Leaflet markers: brief pop-in on (re)draw */
.leaflet-interactive.pin-enter {
  animation: pin-pop 0.35s var(--ease-out) both;
}

@keyframes pin-pop {
  from {
    opacity: 0;
    transform: scale(0.55);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.map-legend {
  position: absolute;
  z-index: 440;
  left: 0.65rem;
  bottom: 1.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  align-items: center;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink);
  max-width: calc(100% - 1.3rem);
  pointer-events: none;
}

.map-legend__title {
  color: var(--muted);
  margin-right: 0.15rem;
}

.map-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.swatch {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  background: currentColor;
  opacity: 0.9;
}

.swatch--fatal {
  color: var(--fatal);
}
.swatch--major {
  color: var(--major);
}
.swatch--minor {
  color: var(--minor);
}
.swatch--unknown {
  color: var(--unknown);
}

/* Leaflet chrome */
.leaflet-container {
  font-family: var(--font);
}

.leaflet-control-attribution {
  font-size: 10px !important;
  max-width: 70%;
  background: rgba(255, 255, 255, 0.92) !important;
}

.leaflet-popup-content-wrapper {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: none;
  font-family: var(--font);
}

.leaflet-popup-content {
  margin: 0.7rem 0.9rem;
  font-size: var(--text-sm);
  line-height: 1.45;
  color: var(--text);
  min-width: 12rem;
}

.leaflet-popup-tip {
  box-shadow: none;
}

.popup-card__date {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--muted);
  margin: 0 0 0.25rem;
}

.popup-card__place {
  font-weight: 700;
  margin: 0 0 0.2rem;
  color: var(--ink);
}

.popup-card__title {
  margin: 0.25rem 0;
  font-weight: 400;
}

.popup-card__meta {
  margin: 0.4rem 0 0;
  font-size: var(--text-xs);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.popup-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.12rem 0.4rem;
  border: 1px solid var(--border);
  background: var(--minor-bg);
}

.popup-badge--fatal {
  background: var(--fatal);
  border-color: var(--fatal);
  color: #fff;
}

.popup-badge--major {
  background: var(--major);
  border-color: var(--major);
  color: var(--ink);
}

.popup-badge--minor {
  background: var(--minor-bg);
  border-color: var(--border);
  color: var(--ink);
}

.popup-badge--unknown {
  background: var(--minor-bg);
  border-color: var(--unknown);
  color: var(--unknown);
}

/* —— Below map —— */
.below-map {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.15rem;
  align-items: start;
}

@media (min-width: 768px) {
  .below-map {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .filters-panel {
    position: sticky;
    top: calc(var(--bar-h) + var(--disc-h) + 0.75rem);
  }
}

@media (min-width: 1100px) {
  .below-map {
    grid-template-columns: 300px minmax(0, 1fr);
  }
}

.filters-panel {
  padding: 1rem 1.05rem 1.1rem;
}

.filter-group {
  border: 0;
  margin: 0 0 0.95rem;
  padding: 0;
  min-width: 0;
}

.filter-dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.filter-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.35rem;
}

.chip-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
}

@media (min-width: 360px) {
  .chip-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.chip {
  appearance: none;
  min-width: 0;
  width: 100%;
  border: 2px solid var(--border);
  background: var(--white);
  color: var(--ink);
  border-radius: 0;
  padding: 0.4rem 0.35rem;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease,
    border-color 0.2s ease, transform 0.15s var(--ease-out);
  border-left-width: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .chip {
    padding: 0.4rem 0.45rem;
    font-size: 0.8125rem;
  }
}

.chip:active {
  transform: scale(0.97);
}

.chip--fatal {
  border-left-color: var(--fatal);
}
.chip--major {
  border-left-color: var(--major);
}
.chip--minor {
  border-left-color: var(--minor);
}
.chip--unknown {
  border-left-color: var(--unknown);
}

.chip:hover {
  border-color: var(--ink);
}

.chip[aria-pressed="true"] {
  background: var(--action);
  border-color: var(--action);
  color: var(--white);
}

.chip[aria-pressed="true"].chip--fatal {
  background: var(--fatal);
  border-color: var(--fatal);
}

.chip[aria-pressed="true"].chip--major {
  background: var(--major);
  border-color: var(--major);
  color: var(--ink);
}

.chip[aria-pressed="true"].chip--minor {
  background: var(--minor);
  border-color: var(--minor);
  color: var(--white);
}

.chip[aria-pressed="true"].chip--unknown {
  background: var(--unknown);
  border-color: var(--unknown);
  color: var(--white);
}

.input {
  width: 100%;
  border: 2px solid var(--ink);
  border-radius: 0;
  padding: 0.45rem 0.55rem;
  font: inherit;
  font-size: var(--text-sm);
  color: var(--ink);
  background: var(--white);
  min-height: 2.4rem;
}

.input:hover {
  border-color: var(--action);
}

.input[aria-invalid="true"] {
  border-color: var(--fatal);
}

.field-error {
  margin: -0.5rem 0 0.85rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--fatal);
}

.field-error[hidden] {
  display: none;
}

/* —— Stats —— */
.right-col {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  min-width: 0;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

@media (min-width: 900px) {
  .stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  padding: 0.85rem 0.95rem 0.9rem;
  border-top: 4px solid var(--action);
  min-height: 5.5rem;
}

.stat-card[data-stat="fatal"] {
  border-top-color: var(--fatal);
}

.stat-card[data-stat="geocoded"] {
  border-top-color: var(--action);
}

.stat-card[data-stat="sources"] {
  border-top-color: var(--minor);
}

.stat-card__label {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink);
}

.stat-card__value {
  margin: 0.15rem 0 0;
  font-size: clamp(1.5rem, 3vw, var(--text-2xl));
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
}

.stat-card[data-stat="fatal"] .stat-card__value {
  color: var(--fatal);
}

.stat-card__hint {
  margin: 0.25rem 0 0;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 500;
}

/* —— List —— */
.list-panel {
  padding: 1rem 1.05rem 0.25rem;
  min-height: 12rem;
  display: flex;
  flex-direction: column;
}

.list-panel .panel-head {
  margin-bottom: 0.5rem;
}

.incident-list {
  list-style: none;
  margin: 0 -0.25rem;
  padding: 0;
  max-height: min(52vh, 480px);
  overflow-y: auto;
  border-top: 1px solid var(--border);
  scrollbar-gutter: stable;
}

.incident-row {
  display: grid;
  /* Badge col sizes to content so "UNKNOWN" (uppercase + letter-spacing) never clips */
  grid-template-columns: 5.5rem max-content minmax(0, 1fr);
  gap: 0.35rem 0.55rem;
  align-items: start;
  padding: 0.75rem 0.45rem;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

@media (max-width: 520px) {
  .incident-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "date badge"
      "body body";
  }
  .incident-row__date {
    grid-area: date;
  }
  .incident-row__badge {
    grid-area: badge;
    justify-self: end;
  }
  .incident-row__body {
    grid-area: body;
  }
}

.incident-row:hover {
  background: var(--row-hover);
}

.incident-row:focus-visible {
  outline: 3px solid var(--focus-fill);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 3px var(--focus-ink);
}

.incident-row.is-highlight {
  background: var(--row-active);
  border-left-color: var(--action);
  animation: row-flash 0.55s ease-out;
}

.incident-row.is-selected {
  background: var(--row-active);
  border-left-color: var(--action);
}

.list-empty__title {
  margin: 0 0 0.35rem;
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--ink);
}

.list-empty__hint {
  margin: 0 0 0.85rem;
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--muted);
}

.list-empty__btn {
  max-width: 14rem;
  margin: 0 auto;
}

.incident-row.is-unmapped {
  opacity: 0.92;
}

.incident-row__date {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--muted);
  white-space: nowrap;
  padding-top: 0.2rem;
}

.incident-row__badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.18rem 0.4rem;
  border: 1px solid var(--border);
  color: var(--minor);
  background: var(--minor-bg);
  white-space: nowrap;
  text-align: center;
  margin-top: 0.05rem;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.incident-row__badge--fatal {
  color: #ffffff;
  background: var(--fatal);
  border-color: var(--fatal);
}

.incident-row__badge--major {
  color: var(--ink);
  background: var(--major);
  border-color: var(--major);
}

.incident-row__badge--minor {
  color: var(--ink);
  background: var(--minor-bg);
  border-color: var(--border);
}

.incident-row__badge--unknown {
  color: var(--unknown);
  background: var(--minor-bg);
  border-color: var(--unknown);
}

.incident-row__body {
  min-width: 0;
}

.incident-row__place {
  margin: 0;
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.pin-tag {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.05rem 0.3rem;
  background: var(--paper);
}

.incident-row__title {
  margin: 0.15rem 0 0;
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.incident-row__source {
  margin: 0.2rem 0 0;
  font-size: var(--text-xs);
  color: var(--muted);
}

.incident-row__source a {
  color: var(--action);
  text-decoration: underline;
  font-weight: 600;
}

.list-empty {
  padding: 2rem 0.75rem;
  text-align: center;
  color: var(--muted);
  font-size: var(--text-base);
  font-weight: 600;
}

.list-skeleton {
  display: grid;
  grid-template-columns: 5.5rem max-content 1fr;
  gap: 0.5rem;
  padding: 0.9rem 0.45rem;
  border-bottom: 1px solid var(--border);
}

.sk {
  display: block;
  height: 0.85rem;
  background: linear-gradient(90deg, #e5e5e5 25%, #f0f0f0 50%, #e5e5e5 75%);
  background-size: 200% 100%;
  animation: shimmer 1.1s ease-in-out infinite;
}

.sk--wide {
  height: 2rem;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

/* —— Footer —— */
.footer {
  margin-top: 0.5rem;
  border-top: 1px solid var(--border);
  background: var(--white);
}

.footer__inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2rem;
  font-size: var(--text-xs);
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.footer p {
  margin: 0;
}

.footer__freshness {
  color: var(--ink);
  font-weight: 600;
}

.footer__freshness[hidden] {
  display: none;
}

.footer strong {
  color: var(--ink);
  font-weight: 700;
  margin-right: 0.35rem;
}

.footer a {
  color: var(--action);
}

/* —— Modal —— */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(11, 12, 12, 0.55);
  opacity: 0;
  transition: opacity 0.2s var(--ease-out);
}

.modal-overlay.is-open {
  display: flex;
  opacity: 1;
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal-panel {
  width: min(560px, 100%);
  max-height: min(85dvh, 720px);
  overflow: auto;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transform: scale(0.98);
  transition: transform 0.2s var(--ease-out);
  border-top: 4px solid var(--action);
}

.modal-overlay.is-open .modal-panel {
  transform: scale(1);
}

.modal-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 1;
}

.modal-panel__head h2 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--ink);
}

.modal-panel__body {
  padding: 1rem 1.15rem 1.35rem;
  font-size: var(--text-base);
  color: var(--text);
  line-height: var(--leading);
}

.modal-panel__body h3 {
  margin: 1.15rem 0 0.35rem;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink);
}

.modal-panel__body p,
.modal-panel__body ul {
  margin: 0.4rem 0;
}

.modal-panel__body ul {
  padding-left: 1.25rem;
}

.modal-panel__body code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--border-light);
  padding: 0.1em 0.35em;
  border-radius: 2px;
  border: 1px solid var(--border);
}

/* —— Motion 5: purposeful only (no scroll hijack, no parallax, no GSAP) —— */
.reveal {
  opacity: 0;
  transform: translateY(10px);
}

body.is-ready .reveal {
  opacity: 1;
  transform: none;
  transition: opacity 0.4s var(--ease-out), transform 0.4s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 55ms);
}

.incident-row.reveal {
  opacity: 0;
  transform: translateY(8px);
}

body.is-ready .incident-row.reveal {
  opacity: 1;
  transform: none;
  transition: opacity 0.35s var(--ease-out), transform 0.35s var(--ease-out),
    background-color 0.15s, border-color 0.15s;
  transition-delay: calc(var(--i, 0) * 45ms);
}

.stat-card__value {
  transition: color 0.2s ease, transform 0.25s var(--ease-out);
}

.stat-card__value.is-tick {
  transform: translateY(-2px);
}

@keyframes row-flash {
  from {
    background: var(--row-active);
  }
  to {
    background: transparent;
  }
}

.incident-list.is-updating {
  opacity: 0.5;
  transition: opacity 0.15s ease;
}

/* Soft pulse on map HUD when filter results change */
.map-hud.is-pulse {
  animation: hud-pulse 0.45s var(--ease-out);
}

@keyframes hud-pulse {
  0% {
    opacity: 0.35;
    transform: translateY(2px);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .reveal,
  body.is-ready .reveal,
  body.is-ready .incident-row.reveal,
  .sk,
  .leaflet-interactive.pin-enter {
    opacity: 1;
    transform: none;
    transition: none;
    animation: none;
  }

  .map-container.is-filtering,
  .incident-list.is-updating {
    opacity: 1;
  }

  .modal-overlay,
  .modal-panel {
    transition: none;
  }

  .modal-panel {
    transform: none;
  }

  .chip:active,
  .btn:active {
    transform: none;
  }
}
