/* ── Explorer Page ─────────────────────────────────────── */
/* Inherits reset, variables, fonts, and nav from shared.css */

:root {
  --teal:    #0d9488;
  --green:   #059669;
  --red:     #dc2626;
  --orange:  #ea580c;

  --dm-trauma:     #b91c1c;
  --dm-ems:        #1d4ed8;
  --dm-ed:         #6d28d9;
  --dm-fire:       #c2410c;
  --dm-911:        #0e7490;
  --dm-air:        #4338ca;
  --dm-disaster:   #a16207;
  --dm-injury:     #15803d;
  --dm-workforce:  #be185d;
  --dm-overdose:   #0f766e;
}

body { background: var(--wash); }

/* Coverage area context bar */
.explore-context {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: .85rem 0;
}
.explore-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--brand-navy);
  letter-spacing: -.02em;
  line-height: 1.25;
}
.explore-sub {
  font-size: .72rem;
  font-weight: 400;
  color: var(--ink-3);
  line-height: 1.3;
}

/* ── Layout ───────────────────────────────────────────── */
main { max-width: 1400px; margin: 0 auto; padding: 1.5rem 2rem 4rem; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.card h2 {
  font-size: .75rem;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 1rem;
}
.card h3 {
  font-size: .7rem;
  font-weight: 600;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 1rem 0 .5rem;
}

/* ── Top row: Map + Stats ─────────────────────────────── */
.top-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }

/* Map */
.us-map-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 4px;
  max-width: 540px;
}
.state-tile {
  aspect-ratio: 1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .62rem;
  font-weight: 600;
  color: #fff;
  background: #d1d5db;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, background .15s;
  user-select: none;
  border: 2px solid transparent;
  position: relative;
  letter-spacing: .02em;
}
.state-tile:hover {
  transform: scale(1.2);
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.state-tile.has-data { background: #9ca3af; }
.state-tile.active {
  background: var(--brand-navy) !important;
  border-color: #0f2640;
  box-shadow: 0 0 0 2px var(--accent-l);
}

/* US tile separate */
.map-row { display: flex; align-items: flex-end; gap: 1.5rem; }
.us-tile-wrap { display: flex; flex-direction: column; align-items: center; gap: .25rem; flex-shrink: 0; }
#us-tile {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  color: #fff;
  background: #9ca3af;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, background .15s;
  user-select: none;
  border: 2px solid transparent;
}
#us-tile:hover { transform: scale(1.15); box-shadow: 0 4px 12px rgba(0,0,0,.2); }
#us-tile.active { background: var(--brand-navy) !important; border-color: #0f2640; box-shadow: 0 0 0 2px var(--accent-l); }
.us-tile-label { font-size: .6rem; color: var(--ink-4); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }

.map-actions { display: flex; gap: .5rem; margin-top: .75rem; }
.btn-small {
  font-size: .7rem; padding: .3rem .65rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-3);
  cursor: pointer; transition: all .15s; font-weight: 500;
}
.btn-small:hover { background: var(--wash); color: var(--ink-2); }
.selected-label { font-size: .75rem; color: var(--ink-4); margin-top: .4rem; min-height: 1.2em; }

/* Stats */
.stat-hero {
  text-align: center;
  padding: .5rem 0;
  margin-bottom: .75rem;
  border-bottom: 1px solid var(--line-l);
}
.stat-hero-number {
  font-size: 2.75rem;
  font-weight: 800;
  color: var(--brand-navy);
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.stat-hero-context { font-size: .8rem; color: var(--ink-3); margin-top: .35rem; }

/* Stacked status bar */
.breakdown-section { margin-bottom: .75rem; }
.stacked-bar {
  display: flex;
  height: 20px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--line-l);
}
.stacked-bar-seg {
  height: 100%;
  min-width: 2px;
  transition: width .3s ease;
  cursor: default;
  position: relative;
}
.stacked-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .2rem .65rem;
  margin-top: .4rem;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: .25rem;
  font-size: .68rem;
  color: var(--ink-3);
}
.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  flex-shrink: 0;
}
.legend-count { font-weight: 700; color: var(--ink); }

/* Funding callout */
.funding-callout {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  padding: .5rem .75rem;
  background: #f0fdf4;
  border-radius: 6px;
  border-left: 3px solid var(--teal);
}
.funding-number { font-size: 1.05rem; font-weight: 800; color: var(--teal); font-variant-numeric: tabular-nums; }
.funding-label { font-size: .75rem; color: var(--ink-3); }

/* Mini bar chart */
.bar-chart { display: flex; flex-direction: column; gap: 4px; }
.bar-row { display: flex; align-items: center; gap: .5rem; font-size: .7rem; }
.bar-name { width: 155px; text-align: right; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; font-weight: 500; font-size: .68rem; }
.bar-track { flex: 1; height: 18px; background: var(--line-l); border-radius: 4px; overflow: hidden; display: block; }
.bar-fill { display: block; height: 100%; border-radius: 4px; transition: width .3s ease; min-width: 4px; opacity: .85; }
.bar-count { width: 44px; font-weight: 700; color: var(--ink-2); font-size: .72rem; text-align: right; font-variant-numeric: tabular-nums; }

/* ── Filters ──────────────────────────────────────────── */
.filter-section { padding: 1.25rem 1.5rem; }
.filter-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-start; }
.filter-row-secondary { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line-l); align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: .35rem; }
.filter-group label { font-size: .65rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-4); }
.search-group { flex: 1; min-width: 200px; }
.search-group input { width: 100%; }

.pill-group { display: flex; flex-wrap: wrap; gap: 5px; }
.pill {
  font-size: .68rem; padding: .25rem .6rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-3);
  cursor: pointer; transition: all .15s; white-space: nowrap; user-select: none;
  font-weight: 500;
}
.pill:hover { border-color: var(--brand-navy); color: var(--brand-navy); background: var(--accent-l); }
.pill.active { background: var(--brand-navy); border-color: var(--brand-navy); color: #fff; }
.pill-count {
  display: inline-block; font-size: .55rem; font-weight: 600; margin-left: 4px;
  padding: .05rem .3rem; border-radius: 4px; background: var(--line-l); color: var(--ink-4);
  min-width: 18px; text-align: center; line-height: 1.4; vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.pill.active .pill-count { background: rgba(255,255,255,.2); color: #fff; }

/* Domain pill colors when active */
.pill[data-domain="Trauma Systems"].active       { background: var(--dm-trauma); border-color: var(--dm-trauma); }
.pill[data-domain="Prehospital EMS"].active      { background: var(--dm-ems); border-color: var(--dm-ems); }
.pill[data-domain="Emergency Department"].active  { background: var(--dm-ed); border-color: var(--dm-ed); }
.pill[data-domain="Fire & Rescue"].active        { background: var(--dm-fire); border-color: var(--dm-fire); }
.pill[data-domain="911 Communications"].active   { background: var(--dm-911); border-color: var(--dm-911); }
.pill[data-domain="Air Medical"].active          { background: var(--dm-air); border-color: var(--dm-air); }
.pill[data-domain="Disaster Preparedness"].active { background: var(--dm-disaster); border-color: var(--dm-disaster); }
.pill[data-domain="Injury Prevention"].active    { background: var(--dm-injury); border-color: var(--dm-injury); }
.pill[data-domain="First Responder Workforce"].active { background: var(--dm-workforce); border-color: var(--dm-workforce); }
.pill[data-domain="Overdose Response"].active    { background: var(--dm-overdose); border-color: var(--dm-overdose); }

select, input[type="text"], input[type="number"] {
  font-family: inherit;
  font-size: .8rem; padding: .4rem .55rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus { border-color: var(--brand-navy); box-shadow: 0 0 0 3px rgba(26,58,95,.1); }
input[type="number"] { width: 72px; }
.year-range { display: flex; align-items: center; gap: .3rem; color: var(--ink-4); }

.btn-reset {
  font-family: inherit;
  font-size: .72rem; padding: .4rem .85rem; border-radius: 6px;
  border: 1px solid #fecaca; background: #fef2f2; color: var(--red);
  cursor: pointer; transition: background .15s; align-self: flex-end; font-weight: 500;
}
.btn-reset:hover { background: #fee2e2; }

/* ── Table ────────────────────────────────────────────── */
.table-section { padding: 0; overflow: hidden; }
.table-header, .table-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: .75rem 1.5rem; flex-wrap: wrap; gap: .5rem;
}
.table-header { border-bottom: 1px solid var(--line-l); }
.table-footer { border-top: 1px solid var(--line-l); }
.table-header-left { display: flex; align-items: center; gap: .75rem; }
.table-count { font-size: .8rem; font-weight: 500; color: var(--ink-3); }
.btn-export {
  font-family: inherit;
  font-size: .7rem; padding: .3rem .7rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-3);
  cursor: pointer; transition: all .15s; white-space: nowrap; font-weight: 500;
}
.btn-export:hover { background: var(--brand-navy); color: #fff; border-color: var(--brand-navy); }
.page-controls { display: flex; align-items: center; gap: .5rem; font-size: .78rem; color: var(--ink-3); }
.btn-page {
  font-family: inherit;
  font-size: .72rem; padding: .3rem .6rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-3);
  cursor: pointer; transition: all .15s; font-weight: 500;
}
.btn-page:hover:not(:disabled) { background: var(--wash); }
.btn-page:disabled { opacity: .35; cursor: default; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .8rem; }
thead { position: sticky; top: 0; z-index: 2; }
th {
  text-align: left; padding: .6rem 1rem; font-size: .65rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--ink-4);
  background: var(--wash); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--brand-navy); }
th.sorted-asc::after { content: ' \25B2'; font-size: .55rem; }
th.sorted-desc::after { content: ' \25BC'; font-size: .55rem; }
.col-wide { min-width: 260px; }
.col-med { min-width: 160px; }

td { padding: .6rem 1rem; border-bottom: 1px solid var(--line-l); vertical-align: top; }
td.nowrap { white-space: nowrap; }
tr { cursor: pointer; transition: background .1s; }
tr:hover { background: #f0f4f8; }

.domain-badge {
  display: inline-block; font-size: .62rem; font-weight: 600; padding: .15rem .45rem;
  border-radius: 4px; color: #fff; white-space: nowrap; letter-spacing: .01em;
}
.pf-tag {
  display: inline-block; font-size: .6rem; padding: .12rem .4rem;
  border-radius: 4px; background: var(--wash); color: var(--ink-3); border: 1px solid var(--line-l);
  margin: 1px 2px 1px 0; white-space: nowrap; font-weight: 500;
}
.funding-yes { color: var(--green); font-weight: 600; }
.funding-no { color: var(--ink-4); }
.status-passed { color: var(--green); font-weight: 600; }
.status-failed { color: var(--red); }
.status-vetoed { color: var(--orange); }

/* ── Modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--surface); border-radius: 12px; max-width: 720px; width: 95%;
  max-height: 85vh; overflow-y: auto; padding: 2rem 2.25rem; position: relative;
  box-shadow: 0 24px 48px rgba(0,0,0,.12), 0 8px 16px rgba(0,0,0,.08);
}
.modal-close {
  position: absolute; top: 1rem; right: 1rem; background: var(--wash); border: 1px solid var(--line);
  width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: var(--ink-3); cursor: pointer; line-height: 1; transition: all .15s;
}
.modal-close:hover { background: var(--line-l); color: var(--ink); }
.modal h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: .3rem; color: var(--ink); text-transform: none; letter-spacing: -.015em; line-height: 1.35; }
.modal .meta { font-size: .8rem; color: var(--ink-3); margin-bottom: 1.25rem; }
.modal .meta a { color: var(--brand-navy); text-decoration: none; }
.modal .meta a:hover { text-decoration: underline; }
.modal-field { margin-bottom: .85rem; }
.modal-field dt { font-size: .65rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-4); margin-bottom: .2rem; }
.modal-field dd { font-size: .85rem; color: var(--ink); line-height: 1.6; }
.modal-tags { display: flex; flex-wrap: wrap; gap: 4px; }

/* ── Sponsor list ────────────────────────────────────── */
.sponsor-list { display: flex; flex-direction: column; gap: .4rem; }
.sponsor-item { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.sponsor-name { font-size: .85rem; font-weight: 600; color: var(--ink); }
.sponsor-meta { font-size: .75rem; color: var(--ink-3); }

/* ── State link button ────────────────────────────────── */
.btn-state-link {
  display: inline-flex;
  align-items: center;
  font-size: .82rem;
  font-weight: 600;
  padding: .5rem 1rem;
  border-radius: 6px;
  background: var(--brand-navy);
  color: #fff;
  text-decoration: none;
  margin-bottom: 1.25rem;
  transition: background .15s;
  gap: .35rem;
}
.btn-state-link:hover { background: #244d7a; }

/* ── Timeline ────────────────────────────────────────── */
.timeline { position: relative; padding-left: 1.25rem; border-left: 2px solid var(--line); }
.timeline-item {
  position: relative;
  padding: .35rem 0 .35rem .5rem;
  font-size: .8rem;
  line-height: 1.4;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.56rem;
  top: .55rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-teal);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line);
}
.timeline-item:last-child::before { background: var(--brand-navy); }
.timeline-date {
  display: inline-block;
  font-weight: 600;
  color: var(--ink-3);
  min-width: 82px;
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
}
.timeline-action {
  color: var(--ink);
  font-size: .78rem;
}
.text-muted { color: var(--ink-4); font-size: .8rem; }

/* ── Loading ──────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,.95);
  z-index: 999; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 1rem;
}
.loading-overlay p { font-size: .85rem; color: var(--ink-3); font-weight: 500; }
.loading-logo { height: 40px; width: auto; margin-bottom: .25rem; }
.spinner {
  width: 28px; height: 28px; border: 2.5px solid var(--line); border-top-color: var(--brand-navy);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 900px) {
  .top-row { grid-template-columns: 1fr; }
  main { padding: 1rem; }
  .card { padding: 1.25rem; }
  .table-header, .table-footer { padding: .5rem 1rem; }
  th, td { padding: .5rem .75rem; }
}
