@import url("https://fonts.googleapis.com/css2?family=Courier+Prime:wght@400;700&family=Inter:wght@400;600;700&display=swap");

body {
  margin: 0;
  background: #f5f5f2;
  color: #1c1d1f;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Sticky nav sits over anchored sections; leave room for it */
.anchor {
  scroll-margin-top: 76px;
}

.nav-btn {
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.nav-btn:hover {
  background: #1f5f8b !important;
  border-color: #1f5f8b !important;
  color: #ffffff !important;
}

/* Tables: highlight the row under the pointer */
.hot-table tbody tr:hover td {
  background: #f1f5f9;
}

/* Callout stat cards */
.stat-card {
  transition: transform 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
}

/* Dash dropdown inherits the page font */
.Select-control,
.Select-menu-outer {
  font-family: "Inter", system-ui, sans-serif;
}

@media (max-width: 640px) {
  h1 {
    font-size: 1.7rem !important;
  }
}

/* Radio buttons and checkboxes in the page blue */
input[type="radio"],
input[type="checkbox"] {
  accent-color: #1f5f8b;
}

/* Map attribution (required by OSM/CARTO) as a small label inside the map's
   bottom-right corner. Without these rules the control renders unstyled and
   drops below the map onto the caption. Covers MapLibre (plotly >= 5.24) and
   Mapbox (older plotly). */
.maplibregl-map,
.mapboxgl-map {
  position: relative;
  overflow: hidden;
}

.maplibregl-ctrl-bottom-left,
.maplibregl-ctrl-bottom-right,
.mapboxgl-ctrl-bottom-left,
.mapboxgl-ctrl-bottom-right {
  position: absolute !important;
  bottom: 0 !important;
  z-index: 2;
  pointer-events: none;
}

.maplibregl-ctrl-bottom-left,
.mapboxgl-ctrl-bottom-left {
  left: auto !important;
  right: 0 !important;
}

.maplibregl-ctrl-bottom-right,
.mapboxgl-ctrl-bottom-right {
  right: 0 !important;
}

.maplibregl-ctrl-attrib,
.mapboxgl-ctrl-attrib {
  pointer-events: auto;
  margin: 0 !important;
  padding: 1px 6px !important;
  background: rgba(255, 255, 255, 0.8) !important;
  font-size: 10px !important;
  line-height: 16px;
  color: #55585d;
}

.maplibregl-ctrl-attrib a,
.mapboxgl-ctrl-attrib a {
  color: #55585d !important;
  text-decoration: none;
}

.maplibregl-ctrl-attrib-button,
.mapboxgl-ctrl-attrib-button {
  display: none !important;
}

.maplibregl-ctrl-attrib-inner,
.mapboxgl-ctrl-attrib-inner {
  display: block !important;
}

/* Concentration section: Lorenz chart and stat cards side by side, both
   columns the same height. Stacks on narrow screens. */
.conc-row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr);
  gap: 24px;
  align-items: stretch;
}

.conc-cards,
.conc-stack {
  height: 100%;
}

.conc-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.conc-stack>.stat-card {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (max-width: 860px) {

  /* minmax(0, 1fr), not 1fr: a plain 1fr column grows to fit the swipe row
     of cards and pushes the whole panel off the screen */
  .conc-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .conc-cards {
    min-width: 0;
  }
}

/* Count-up numbers keep a steady width while animating */
.count-up {
  font-variant-numeric: tabular-nums;
}

/* "Don't trust this number": an arrow flies in toward the naive 86% after
   its count-up finishes. countup.js adds .counted to .num-row when done; the
   hidden start state applies only when that script is running (.js-countup),
   so without it the callout simply shows. */
.num-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.distrust {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #eb6834;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.distrust-arrow {
  display: inline-flex;
  align-items: center;
}

.distrust-head {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 10px solid #eb6834;
}

.distrust-shaft {
  display: block;
  width: 46px;
  height: 3px;
  border-radius: 2px;
  background: #eb6834;
  transform-origin: right center;
}

.js-countup .num-row:not(.counted) .distrust-arrow {
  opacity: 0;
  transform: translateX(60px);
}

.js-countup .num-row:not(.counted) .distrust-text {
  opacity: 0;
}

.js-countup .num-row.counted .distrust-arrow {
  animation: distrust-fly 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}

.js-countup .num-row.counted .distrust-shaft {
  animation: distrust-shaft 0.55s ease-out both;
}

.js-countup .num-row.counted .distrust-text {
  animation: distrust-text 0.4s ease-out 0.45s both;
}

.js-countup .num-row.counted .distrust-head {
  animation: distrust-nudge 0.5s ease-in-out 0.9s 2;
}

@keyframes distrust-fly {
  from {
    opacity: 0;
    transform: translateX(60px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes distrust-shaft {
  from {
    transform: scaleX(0.2);
  }

  to {
    transform: scaleX(1);
  }
}

@keyframes distrust-text {
  from {
    opacity: 0;
    transform: translateX(8px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes distrust-nudge {

  0%,
  100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(-5px);
  }
}

@media (max-width: 480px) {
  .distrust-shaft {
    width: 22px;
  }

  .distrust {
    font-size: 0.74rem;
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {

  .js-countup .num-row .distrust-arrow,
  .js-countup .num-row .distrust-text,
  .js-countup .num-row .distrust-shaft,
  .js-countup .num-row .distrust-head {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ── Phones ─────────────────────────────────────────────────────────────── */

/* Crash-type and main-cause charts: side by side when there is room,
   stacked on phones. */
.profile-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 8px 24px;
}

@media (max-width: 640px) {

  /* The sticky "Jump to" bar wrapped to five rows and covered a third of
     the screen. On phones it is one row you swipe sideways. */
  .page-nav {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px !important;
    padding: 8px 2px !important;
    /* fade at the right edge hints there is more to swipe */
    -webkit-mask-image: linear-gradient(to right, #000 88%, transparent);
    mask-image: linear-gradient(to right, #000 88%, transparent);
  }

  .page-nav::-webkit-scrollbar {
    display: none;
  }

  .page-nav .nav-btn,
  .page-nav>span {
    flex: none;
  }

  .page-nav .nav-btn {
    padding: 5px 12px !important;
    font-size: 0.85rem !important;
  }

  /* DSD logo: smaller under the header text */
  .dsd-logo {
    width: 180px !important;
    height: 50px !important;
  }

  /* Hotspot table: keep #, location, what stands out, and the ranked-by
     column; the other numbers are in the lookup and the CSV. */
  .hot-table .col-opt {
    display: none;
  }

  .hot-table .c-loc {
    min-width: 110px !important;
  }

  .hot-table .c-so {
    min-width: 120px !important;
  }
}

@media (max-width: 640px) {

  .hot-table th,
  .hot-table td {
    padding-left: 6px !important;
    padding-right: 6px !important;
  }

  .hot-table .mini-bar {
    display: none !important;
  }
}

@media (max-width: 640px) {
  .hot-table th {
    letter-spacing: 0.02em !important;
    font-size: 0.66rem !important;
  }
}

/* ── Map on touch screens ───────────────────────────────────────────────
   A map that grabs every touch traps the page: you cannot scroll past it.
   On touch devices the inline map is a preview under a transparent layer
   (swipes scroll the page); a tap opens the full-screen map. */
.map-wrap {
  position: relative;
}

.map-tap {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .map-tap {
    display: flex;
    position: absolute;
    inset: 0;
    z-index: 5;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 16px;
    cursor: pointer;
    touch-action: pan-y;
    -webkit-tap-highlight-color: transparent;
  }

  .map-tap-pill {
    background: rgba(31, 95, 139, 0.92);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 9px 18px;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  }
}

/* Full-screen map on phones: the whole screen, no settings (they are
   copied from the page), so nothing inside it needs scrolling. */
@media (max-width: 640px) {
  #zoom-modal {
    padding: 0 !important;
  }

  .zoom-box {
    max-height: 100vh !important;
    height: 100vh;
    height: 100dvh;
    border-radius: 0 !important;
    padding: 0 !important;
  }

  .zoom-controls {
    display: none;
  }

  .zoom-caption {
    font-size: 0.82rem !important;
    margin-bottom: 6px !important;
  }

  .zoom-box h2 {
    font-size: 1.15rem !important;
    margin-bottom: 4px !important;
  }

  #zoom-graph {
    height: calc(100dvh - 110px) !important;
  }

  .zoom-box>div {
    padding: 12px 12px 8px !important;
  }

  #zoom-close {
    font-size: 2rem !important;
    top: 6px !important;
    right: 8px !important;
  }
}

/* Stat cards on phones: stacked, but compact. Number on the left, label and
   text beside it, so all cards stay visible without a tall stack. */
@media (max-width: 640px) {
  .card-swipe {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    height: auto !important;
  }

  .card-swipe>.stat-card {
    display: grid !important;
    grid-template-columns: 84px 1fr;
    column-gap: 12px;
    align-items: center;
    padding: 10px 12px !important;
    flex: none !important;
  }

  .card-swipe>.stat-card> :first-child {
    grid-row: 1 / span 2;
  }

  .card-swipe .count-up {
    font-size: 1.6rem !important;
  }

  .card-swipe>.stat-card>p {
    margin: 2px 0 0 !important;
    font-size: 0.8rem !important;
    line-height: 1.45 !important;
  }

  /* the "don't trust" callout sits under the number instead of beside it */
  .card-swipe .num-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .card-swipe .distrust-arrow {
    display: none;
  }

  .card-swipe .distrust {
    white-space: normal;
    font-size: 0.68rem;
    line-height: 1.2;
  }

  .conc-cards {
    height: auto !important;
  }
}