.county-map-page {
  --county-complete: var(--q2-accent, #2f6f4e);
  --county-incomplete: color-mix(in srgb, var(--q2-text-muted, #6b7280) 18%, var(--q2-bg-elev, #fff));
  --county-border: color-mix(in srgb, var(--q2-text-strong, #1f2937) 38%, transparent);
  --county-state-border: var(--q2-text-strong, #1f2937);
}

.county-map-page__intro {
  max-width: 62rem;
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
}

.county-map-status,
.county-map-error {
  padding: 1rem 1.1rem;
  border: 1px solid var(--q2-border, currentColor);
  border-radius: var(--q2-radius-md, 0.5rem);
  background: var(--q2-bg-muted, transparent);
}

.county-map-error {
  border-color: #b42318;
}

.county-map-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(8rem, 1fr));
  gap: 0.75rem;
  margin: 0 0 1.25rem;
}

.county-map-summary > div {
  padding: 0.9rem 1rem;
  border: 1px solid var(--q2-border, currentColor);
  border-radius: var(--q2-radius-md, 0.5rem);
  background: var(--q2-bg-elev, transparent);
}

.county-map-summary dt {
  color: var(--q2-text-muted, inherit);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.county-map-summary dd {
  margin: 0.2rem 0 0;
  font-size: clamp(1.2rem, 3vw, 1.75rem);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.county-map-controls {
  display: grid;
  grid-template-columns: minmax(11rem, 0.7fr) minmax(15rem, 1.4fr) auto;
  align-items: end;
  gap: 0.85rem;
  margin-bottom: 0.75rem;
}

.county-map-controls label span {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 700;
}

.county-map-controls select,
.county-map-controls input,
.county-map-controls button {
  width: 100%;
  min-height: 2.75rem;
  margin: 0;
}

.county-state-summary {
  min-height: 1.5rem;
  margin: 0.5rem 0 1rem;
  color: var(--q2-text-muted, inherit);
}

.county-map-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(17rem, 1fr);
  align-items: start;
  gap: 1.25rem;
}

.county-map-figure,
.county-detail {
  border: 1px solid var(--q2-border, currentColor);
  border-radius: var(--q2-radius-md, 0.5rem);
  background: var(--q2-bg-elev, transparent);
}

.county-map-figure {
  min-width: 0;
  padding: 0.75rem;
}

#county-progress-map {
  display: block;
  width: 100%;
  height: auto;
  overflow: hidden;
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
}

#county-progress-map.is-panning {
  cursor: grabbing;
}

.county-map-viewport {
  position: relative;
  overflow: hidden;
  border-radius: calc(var(--q2-radius-md, 0.5rem) * 0.65);
}

.county-map-viewport.is-zoomed {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--county-complete) 70%, transparent);
}

.county-map-viewport.is-zoomed #county-progress-map {
  touch-action: none;
}

.county-map-zoom-controls {
  position: absolute;
  z-index: 2;
  top: 0.5rem;
  left: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  max-width: calc(100% - 1rem);
  padding: 0.35rem;
  border: 1px solid var(--q2-border, currentColor);
  border-radius: var(--q2-radius-md, 0.5rem);
  background: color-mix(in srgb, var(--q2-bg-elev, #fff) 92%, transparent);
  box-shadow: 0 0.15rem 0.5rem rgb(0 0 0 / 14%);
}

.county-map-zoom-controls button {
  width: auto;
  min-width: 2.75rem;
  min-height: 2.75rem;
  margin: 0;
  padding: 0.35rem 0.65rem;
  line-height: 1.1;
}

.county-map-zoom-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.county-map-zoom-level {
  align-self: center;
  min-width: 3.25rem;
  padding: 0 0.3rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.county-map-zoom-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.county-shape {
  fill: var(--county-incomplete);
  stroke: var(--county-border);
  stroke-width: 0.35;
  vector-effect: non-scaling-stroke;
  transition: fill 120ms ease, opacity 120ms ease;
  cursor: pointer;
}

.county-shape.is-complete {
  fill: var(--county-complete);
}

.county-shape:hover,
.county-shape.is-selected {
  fill: color-mix(in srgb, var(--county-complete) 68%, #f4c95d);
  stroke: var(--county-state-border);
  stroke-width: 1.6;
}

.county-shape.is-dimmed {
  opacity: 0.14;
}

.county-state-outline {
  fill: none;
  stroke: var(--county-state-border);
  stroke-width: 1.05;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.county-state-outline.is-dimmed {
  opacity: 0.2;
}

.county-map-hover {
  min-height: 1.5rem;
  margin: 0.5rem 0 0;
  font-weight: 650;
}

.county-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.4rem;
  color: var(--q2-text-muted, inherit);
  font-size: 0.9rem;
}

.county-map-key {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  margin-right: 0.3rem;
  border: 1px solid var(--county-border);
  vertical-align: -0.15rem;
}

.county-map-key--complete { background: var(--county-complete); }
.county-map-key--incomplete { background: var(--county-incomplete); }

.county-detail {
  position: sticky;
  top: 1rem;
  padding: 1rem 1.1rem;
}

.county-detail h2 {
  margin-top: 0;
  font-size: 1.25rem;
}

.county-detail dl {
  margin: 0;
}

.county-detail dl > div {
  display: grid;
  grid-template-columns: minmax(7rem, 0.8fr) 1.2fr;
  gap: 0.6rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--q2-divider, var(--q2-border, currentColor));
}

.county-detail dt {
  color: var(--q2-text-muted, inherit);
}

.county-detail dd {
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 58rem) {
  .county-map-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .county-map-layout { grid-template-columns: 1fr; }
  .county-detail { position: static; }
}

@media (max-width: 42rem) {
  .county-map-controls { grid-template-columns: 1fr; }
  .county-map-controls button { width: 100%; }
  .county-map-figure {
    margin-inline: -0.75rem;
    padding: 0.4rem;
  }
  .county-shape { stroke-width: 0.25; }
  .county-map-viewport {
    display: flex;
    flex-direction: column;
    overflow: visible;
  }
  .county-map-zoom-controls {
    position: static;
    order: 2;
    max-width: none;
    margin-top: 0.4rem;
    padding: 0.25rem;
    gap: 0.25rem;
    box-shadow: none;
  }
  .county-map-zoom-controls button {
    min-width: 2.5rem;
    min-height: 2.5rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.86rem;
  }
  .county-map-zoom-controls [data-map-zoom="selected"] { flex: 1 1 9rem; }
  .county-map-zoom-level {
    min-width: 2.8rem;
    font-size: 0.86rem;
  }
  .county-map-viewport.is-zoomed {
    box-shadow: none;
  }
  .county-map-viewport.is-zoomed #county-progress-map {
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--county-complete) 70%, transparent);
  }
}

@media (max-width: 26rem) {
  .county-map-summary { grid-template-columns: 1fr; }
  .county-detail dl > div { grid-template-columns: 1fr; gap: 0.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .county-shape { transition: none; }
}
