:root {
  --ink: #142226;
  --ink-soft: #3a4a4f;
  --paper: #f4f7f8;
  --teal: #0f4c5c;
  --teal-deep: #0a3440;
  --amber: #c97816;
  --line: rgba(15, 76, 92, 0.14);
  --good: #1f6b4a;
  --mid: #8a6a12;
  --thin: #8a3b2a;
  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Outfit", "Segoe UI", sans-serif;
  --radius: 4px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.92em;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 480px at 8% -10%, rgba(15, 76, 92, 0.14), transparent 60%),
    radial-gradient(700px 420px at 92% 8%, rgba(201, 120, 22, 0.1), transparent 55%),
    linear-gradient(165deg, #eef4f5 0%, #f7f5f1 48%, #e8f0f2 100%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}

.topbar,
main,
.footer {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 1.25rem clamp(1.25rem, 4vw, 3rem);
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--teal-deep);
}

.brand-sub {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.hero {
  min-height: calc(100vh - 4.5rem);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 1.5rem;
  padding: 0.5rem clamp(1.25rem, 4vw, 3rem) 2.5rem;
}

.hero__copy {
  max-width: 40rem;
}

.brand-hero {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: clamp(3.4rem, 9vw, 6.2rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--teal-deep);
}

.hero__line {
  margin: 0;
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  color: var(--ink-soft);
  max-width: 34rem;
}

.hero__stat {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.65rem 1rem;
  margin: 1.4rem 0 0;
}

.hero__stat-num {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 650;
  color: var(--teal);
}

.hero__stat-label {
  color: var(--ink-soft);
  font-size: 0.98rem;
}

.hero__chart {
  align-self: end;
  padding: 0.25rem 0 0;
}

.chart-shell {
  width: 100%;
}

.totals-chart {
  width: 100%;
  height: auto;
  display: block;
}

.grid-line {
  stroke: rgba(15, 76, 92, 0.1);
  stroke-width: 1;
}

.axis-label {
  fill: var(--ink-soft);
  font-size: 11px;
  font-family: var(--font-ui);
}

.gap-year {
  fill: rgba(58, 74, 79, 0.45);
}

.chart-area {
  fill: rgba(15, 76, 92, 0.12);
  animation: rise 1s ease-out both;
}

.chart-line {
  fill: none;
  stroke: var(--teal);
  stroke-width: 2.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1400;
  stroke-dashoffset: 1400;
  animation: draw 1.35s ease-out forwards 0.15s;
}

.chart-dot {
  fill: #fff;
  stroke: var(--teal);
  stroke-width: 2.25;
  cursor: pointer;
  transition: fill 160ms ease;
}

.chart-dot.is-active,
.chart-dot:hover {
  fill: var(--amber);
  stroke: var(--teal-deep);
}

.chart-value {
  fill: var(--teal-deep);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 650;
}

.gap-mark {
  stroke: rgba(58, 74, 79, 0.28);
  stroke-width: 1.5;
  stroke-dasharray: 3 5;
}

.chart-caption {
  margin: 0.15rem 0.25rem 0.85rem;
  font-size: 0.86rem;
  color: var(--ink-soft);
}

.year-panel {
  padding: 1rem clamp(1.25rem, 4vw, 3rem) 3rem;
}

.year-panel__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.25rem 2rem;
  margin-bottom: 1.5rem;
}

.year-panel h2,
.honesty h2 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3vw, 2.2rem);
  font-weight: 650;
  color: var(--teal-deep);
}

.section-lead {
  margin: 0;
  color: var(--ink-soft);
  max-width: 34rem;
}

.year-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-content: flex-start;
}

.year-switch button {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.year-switch button:hover {
  border-color: rgba(15, 76, 92, 0.35);
}

.year-switch button.is-active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.year-panel__body {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(280px, 1.3fr);
  gap: 1.5rem 2.5rem;
  align-items: start;
}

.year-summary {
  padding: 1.25rem 0;
}

.eyebrow {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--amber);
  font-weight: 600;
}

.year-total {
  margin: 0 0 1rem;
}

.year-total__num {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  font-weight: 650;
  line-height: 1;
  color: var(--teal-deep);
}

.year-total__num--muted {
  color: rgba(20, 34, 38, 0.35);
}

.year-total__label {
  display: block;
  margin-top: 0.45rem;
  color: var(--ink-soft);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.9rem;
}

.badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.28rem 0.55rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
}

.badge--a {
  background: rgba(31, 107, 74, 0.12);
  color: var(--good);
  border-color: rgba(31, 107, 74, 0.22);
}

.badge--b {
  background: rgba(138, 106, 18, 0.12);
  color: var(--mid);
  border-color: rgba(138, 106, 18, 0.22);
}

.badge--c {
  background: rgba(138, 59, 42, 0.1);
  color: var(--thin);
  border-color: rgba(138, 59, 42, 0.2);
}

.badge--soft {
  background: rgba(15, 76, 92, 0.08);
  color: var(--teal-deep);
  border-color: var(--line);
}

.user-note {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  max-width: 28rem;
}

.category-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}

.cat-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.3rem;
  font-size: 0.95rem;
}

.cat-name {
  color: var(--ink);
}

.cat-val {
  font-weight: 600;
  color: var(--teal-deep);
  font-variant-numeric: tabular-nums;
}

.cat-bar {
  height: 6px;
  background: rgba(15, 76, 92, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.cat-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), #1f7a6e);
  border-radius: inherit;
  transform-origin: left center;
  animation: grow 0.7s ease-out both;
}

.empty-detail {
  margin: 0;
  padding: 1.25rem 0;
  color: var(--ink-soft);
}

.crime-panel {
  padding: 1rem clamp(1.25rem, 4vw, 3rem) 2.5rem;
}

.crime-panel__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.25rem 2rem;
  margin-bottom: 1.25rem;
}

.crime-panel h2 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3vw, 2.2rem);
  font-weight: 650;
  color: var(--teal-deep);
}

.subhead {
  margin: 0 0 0.65rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 650;
  color: var(--teal-deep);
}

.section-lead--tight {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.pulse-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 2rem;
}

.pulse-card {
  padding: 1rem 1.1rem 1.15rem;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.pulse-card--lead {
  background: linear-gradient(160deg, rgba(15, 76, 92, 0.1), rgba(255, 255, 255, 0.7));
  border-color: rgba(15, 76, 92, 0.22);
}

.pulse-label {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--amber);
}

.pulse-num {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 3.5vw, 2.6rem);
  font-weight: 650;
  line-height: 1.05;
  color: var(--teal-deep);
}

.pulse-num--sm {
  font-size: clamp(1.25rem, 2.4vw, 1.7rem);
}

.pulse-desc {
  margin: 0.45rem 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.pulse-meta {
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
  color: var(--teal);
}

.pulse-muted {
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.delta--up {
  color: var(--thin);
  font-weight: 600;
}

.delta--down {
  color: var(--good);
  font-weight: 600;
}

.delta--flat {
  color: var(--ink-soft);
  font-weight: 600;
}

.crime-split {
  display: grid;
  grid-template-columns: minmax(240px, 0.95fr) minmax(280px, 1.35fr);
  gap: 1.75rem 2.5rem;
  align-items: start;
}

.compose-note {
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.compose-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}

.swatch {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  margin-right: 0.45rem;
  border-radius: 2px;
  vertical-align: middle;
}

.cat-val em {
  font-style: normal;
  font-weight: 500;
  color: var(--ink-soft);
  margin-left: 0.35rem;
}

.matrix-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
}

.matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.matrix th,
.matrix td {
  padding: 0.45rem 0.4rem;
  text-align: center;
  border-bottom: 1px solid rgba(15, 76, 92, 0.08);
}

.matrix th[scope="row"] {
  text-align: left;
  padding-left: 0.7rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: #f4f7f8;
  z-index: 1;
}

.matrix thead th,
.matrix tr:first-child th {
  font-weight: 600;
  color: var(--ink-soft);
  background: rgba(15, 76, 92, 0.04);
}

.matrix .is-selected {
  outline: 2px solid rgba(201, 120, 22, 0.55);
  outline-offset: -2px;
}

.matrix-empty {
  color: rgba(20, 34, 38, 0.28);
}

.map-section {
  padding: 0.5rem clamp(1.25rem, 4vw, 3rem) 3rem;
}

.map-stage {
  position: relative;
}

.map-crime-card {
  position: absolute;
  z-index: 500;
  top: 0.85rem;
  right: 0.85rem;
  width: min(260px, calc(100% - 1.7rem));
  padding: 0.9rem 1rem;
  background: rgba(244, 247, 248, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(10, 52, 64, 0.12);
  pointer-events: none;
}

.map-legend {
  position: absolute;
  z-index: 500;
  left: 0.85rem;
  bottom: 1.6rem;
  width: min(220px, calc(100% - 1.7rem));
  padding: 0.7rem 0.85rem;
  background: rgba(244, 247, 248, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.78rem;
  color: var(--ink-soft);
  pointer-events: none;
}

.map-legend strong {
  display: block;
  color: var(--teal-deep);
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
}

.map-legend-scale {
  display: flex;
  height: 10px;
  border-radius: 2px;
  overflow: hidden;
  margin: 0.45rem 0 0.3rem;
  background: linear-gradient(90deg, rgba(138, 59, 42, 0.15), rgba(138, 59, 42, 0.85));
}

.map-legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
}

.city-bubble-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #f4f7f8;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1.05rem;
  text-shadow: 0 1px 4px rgba(10, 52, 64, 0.65);
  text-align: center;
}

.city-bubble-label::before {
  display: none !important;
}

.map-card-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--amber);
}

.map-card-num {
  margin: 0.3rem 0 0;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 650;
  line-height: 1;
  color: var(--teal-deep);
}

.map-card-desc {
  margin: 0.4rem 0 0;
  font-size: 0.88rem;
  color: var(--ink);
}

.map-card-foot {
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.popup-note {
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.map-section__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.25rem 2rem;
  margin-bottom: 0.85rem;
}

.map-toolbar {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.65rem;
}

.mode-switch {
  display: flex;
  gap: 0.35rem;
}

.mode-switch button {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius);
  cursor: pointer;
}

.mode-switch button.is-active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.popup-stat {
  margin-top: 0.35rem;
  font-weight: 600;
  color: var(--teal-deep);
}

.map-section h2 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3vw, 2.2rem);
  font-weight: 650;
  color: var(--teal-deep);
}

.layer-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-content: flex-start;
}

.layer-toggles label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  user-select: none;
}

.layer-toggles input {
  accent-color: var(--teal);
}

.map-frame {
  width: 100%;
  height: min(62vh, 560px);
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  z-index: 1;
  background: #dce7ea;
}

.map-frame .leaflet-container {
  font-family: var(--font-ui);
  background: #dce7ea;
}

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

.map-frame .leaflet-popup-content {
  margin: 0.65rem 0.8rem;
  font-size: 0.9rem;
  color: var(--ink);
}

.map-frame .leaflet-control-attribution {
  font-size: 10px;
  background: rgba(244, 247, 248, 0.9);
}

.honesty {
  padding: 0 clamp(1.25rem, 4vw, 3rem) 3rem;
  max-width: 46rem;
}

.honesty p {
  margin: 0;
  color: var(--ink-soft);
}

.footer {
  padding: 1.25rem clamp(1.25rem, 4vw, 3rem) 2rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.footer p {
  margin: 0;
}

.status {
  margin: 2rem 0;
  color: var(--ink-soft);
}

.status--error {
  color: var(--thin);
}

.reveal {
  animation: fade-up 0.7s ease-out both;
}

.reveal--delay {
  animation-delay: 0.12s;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes rise {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes grow {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

@media (max-width: 960px) {
  .pulse-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .crime-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .hero {
    min-height: auto;
  }

  .topbar {
    flex-direction: column;
    gap: 0.2rem;
  }

  .map-crime-card,
  .map-legend {
    position: relative;
    top: auto;
    right: auto;
    left: auto;
    bottom: auto;
    width: 100%;
    margin-bottom: 0.65rem;
    pointer-events: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .chart-line,
  .chart-area,
  .cat-bar span {
    animation: none !important;
  }

  .chart-line {
    stroke-dasharray: none;
    stroke-dashoffset: 0;
  }
}
