:root {
  --coverage-stroke: #6434a3;
  --coverage-center: #efe3ff;
  --structure-certain: #087954;
  --structure-likely: #a56209;
  --structure-single: #3265a7;
}

@media (prefers-color-scheme: dark) {
  :root {
    --coverage-stroke: #b589ed;
    --coverage-center: #32204c;
    --structure-certain: #4dd3a9;
    --structure-likely: #ffbe60;
    --structure-single: #87b9ff;
  }
}

.home-title,
.home-map-heading,
.home-map-legend,
.home-map-legend li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.home-title h1,
.home-map-heading h2 {
  margin: 0;
}

.home-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.home-stats > div {
  min-width: 0;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.home-stats dt {
  color: var(--muted);
  font-size: 12px;
}

.home-stats dd {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.home-radius {
  position: relative;
}

.home-radius-tooltip {
  visibility: hidden;
  position: absolute;
  z-index: 1;
  inset: calc(100% - 2px) 0 auto;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  font-size: 12px;
  font-weight: normal;
}

.home-radius:hover .home-radius-tooltip,
.home-radius:focus-within .home-radius-tooltip {
  visibility: visible;
}

.home-map-panel {
  overflow: hidden;
}

.home-map-heading {
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.home-coverage-label {
  margin: 0;
}

.home-map-legend {
  flex-wrap: wrap;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.home-map-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--muted);
}

.home-map-dot-active {
  background: var(--accent);
  border-color: var(--accent);
}

.home-map-dot-centroid {
  width: 8px;
  height: 8px;
  margin-inline: 2px;
  background: var(--coverage-center);
  border-color: var(--coverage-stroke);
}

.home-map-dot-coverage {
  border-color: var(--coverage-stroke);
  border-style: dashed;
}

.home-map-frame {
  position: relative;
  isolation: isolate;
}

.home-map {
  height: 420px;
  background: var(--bg);
}

.home-map:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.home-map-marker-active {
  fill: var(--accent);
  stroke: var(--accent);
}

.home-map-marker-inactive {
  stroke: var(--muted);
}

.home-map-centroid {
  fill: var(--coverage-center);
  stroke: var(--coverage-stroke);
}

.home-map-coverage {
  stroke: var(--coverage-stroke);
}

/* A CSS fill beats Leaflet's fill="none" attribute: tint only the shapes
   drawn with fill on, so an outline-only circle stays an outline. */
.home-map-coverage:not([fill="none"]) {
  fill: var(--coverage-stroke);
}

.home-map .leaflet-popup-content-wrapper,
.home-map .leaflet-popup-tip {
  background: var(--surface);
  color: var(--fg);
}

.home-map .leaflet-popup-content {
  overflow-wrap: anywhere;
}

.home-map .leaflet-popup-content a {
  color: var(--accent);
  font-weight: 600;
}

.home-map-empty {
  position: absolute;
  z-index: 1000;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  text-align: center;
}

.home-city-list {
  margin: 0;
  padding-inline-start: 1.5rem;
  overflow-wrap: anywhere;
}

@media (max-width: 560px) {
  .home-map {
    height: 300px;
  }
}


.structure-marker-certain { --structure-marker: var(--structure-certain); }
.structure-marker-likely { --structure-marker: var(--structure-likely); }
.structure-marker-single { --structure-marker: var(--structure-single); }

.structure-marker-certain,
.structure-marker-likely,
.structure-marker-single {
  stroke: var(--structure-marker);
  fill: var(--structure-marker);
  border-color: var(--structure-marker);
}

.home-map-dot[class*="structure-marker-"] {
  background: var(--structure-marker);
}

/* Map square on the left, stats in a column on the right; stacked on
   narrow screens. A square map frames the coverage perimeter without
   showing half the region on either side. */
.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 640px) minmax(220px, 1fr);
  gap: 16px;
  align-items: start;
}
.home-grid .home-map-panel { margin: 0; }
.home-grid .home-map { height: auto; aspect-ratio: 1 / 1; }
.home-grid .home-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
@media (max-width: 860px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); }
  .home-grid .home-map { aspect-ratio: 4 / 3; }
}
