/* Map tab — kept separate so other site pages are not affected. */

body.map-page {
  height: 100vh;
  overflow: hidden;
}

body.map-page main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.map-shell {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #d9dde3;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.map-panel {
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  z-index: 5;
  width: min(22.5rem, calc(100% - 1.7rem));
  max-height: calc(100% - 1.7rem);
  overflow: auto;
  background: rgba(244, 242, 238, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(12, 27, 42, 0.16);
  color: var(--ink);
}

.map-panel-header {
  padding: 1rem 1.05rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.map-panel-header .eyebrow {
  margin-bottom: 0.4rem;
}

.map-panel-header h1 {
  color: var(--navy);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
  max-width: none;
}

.map-panel-header h1::before {
  display: block;
  width: 2rem;
  height: 2px;
  margin: 0 0 0.55rem;
  background: var(--accent);
  content: "";
}

.map-panel-header .lead {
  margin-top: 0.55rem;
  font-size: 0.88rem;
  line-height: 1.45;
}

.map-layers {
  padding: 0.55rem 0.45rem 0.85rem;
}

.map-group {
  margin: 0.35rem 0.4rem 0.7rem;
}

.map-group h2 {
  margin: 0 0 0.35rem 0.2rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.map-layer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.45rem 0.55rem;
  align-items: start;
  padding: 0.4rem 0.45rem;
  border-radius: 2px;
}

.map-layer:hover {
  background: rgba(12, 27, 42, 0.04);
}

.map-layer input[type="checkbox"] {
  margin: 0.2rem 0 0;
  accent-color: var(--navy);
}

.map-layer-copy strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--navy);
}

.map-layer-copy .src,
.map-layer-copy .status {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.map-layer-copy .status.is-error {
  color: #8a2f2f;
}

.map-layer-copy .coverage {
  display: block;
  margin-top: 0.2rem;
  color: var(--navy);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.35;
}

.map-swatch {
  width: 0.85rem;
  height: 0.85rem;
  margin-top: 0.18rem;
  border: 1px solid rgba(12, 27, 42, 0.25);
  flex: none;
}

.map-swatch.line {
  height: 3px;
  margin-top: 0.45rem;
  border: 0;
}

.map-swatch.fill-states { background: rgba(12, 27, 42, 0.08); border-color: #0c1b2a; }
.map-swatch.fill-counties { background: transparent; border-color: #7a8490; }
.map-swatch.fill-cities { background: #9a7b4f; border-radius: 50%; }
.map-swatch.fill-tolls { background: #9a7b4f; }
.map-swatch.fill-water { background: #2b6e8a; border-radius: 50%; }
.map-swatch.fill-universities { background: #3d4d8f; border-radius: 50%; }
.map-swatch.fill-electric { background: rgba(154, 123, 79, 0.35); border-color: #9a7b4f; }
.map-swatch.fill-airports { background: #1f7a62; border-radius: 50%; }
.map-swatch.fill-hospitals { background: #9a3b3b; border-radius: 50%; }
.map-swatch.fill-fires { background: #d3531a; border-color: #8c2f0f; }
.map-swatch.fill-weather { background: linear-gradient(90deg, #7eb6d9, #e7c56a, #d3531a); }

.weather-options {
  grid-column: 1 / -1;
  margin: 0.15rem 0 0 1.4rem;
  display: none;
}

.map-layer.is-on .weather-options {
  display: block;
}

.weather-options label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0.15rem 0.7rem 0 0;
  font-size: 0.75rem;
  color: var(--ink);
}

.map-footnote {
  padding: 0.15rem 1.05rem 1rem;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.4;
}

.map-footnote a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

body.map-page .leaflet-container {
  background: #d9dde3;
  font-family: "IBM Plex Sans", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

body.map-page .leaflet-control-zoom a {
  color: var(--navy);
  border-bottom-color: var(--line);
}

body.map-page .leaflet-popup-content-wrapper,
body.map-page .leaflet-popup-tip {
  background: var(--white);
  color: var(--ink);
  border-radius: 2px;
  box-shadow: 0 8px 22px rgba(12, 27, 42, 0.18);
}

body.map-page .leaflet-popup-content {
  margin: 0.85rem 0.95rem;
  font-size: 0.85rem;
  line-height: 1.4;
}

body.map-page .leaflet-popup-content strong {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--navy);
  font-size: 0.95rem;
  font-weight: 600;
}

body.map-page .leaflet-popup-content .meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: rgba(12, 27, 42, 0.18);
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: var(--navy);
  color: #fff;
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: 600;
}

@media (max-width: 720px) {
  .map-panel {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 42%;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }

  body.map-page .leaflet-control-zoom {
    margin-bottom: calc(42% + 0.5rem);
  }
}

/* Map search — lives in the layer panel so other pages are unaffected. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.map-search {
  padding: 0.7rem 1.05rem 0.55rem;
  border-bottom: 1px solid var(--line);
}

.map-search-row {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}

.map-search-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 2.35rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--white, #fff);
  color: var(--ink);
  font-family: inherit;
  font-size: 16px; /* keep iOS from zooming on focus */
  line-height: 1.3;
}

.map-search-input:focus {
  outline: 2px solid var(--navy);
  outline-offset: 1px;
}

.map-search-clear {
  flex: none;
  padding: 0 0.7rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--navy);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.map-search-clear:hover,
.map-search-clear:focus {
  background: rgba(12, 27, 42, 0.06);
}

.map-search-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-top: 0.45rem;
}

.map-search-filter {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.map-search-filter select {
  width: 100%;
  height: 2rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--white, #fff);
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.map-search-status {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
  min-height: 1em;
}

.map-search-results {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  max-height: 14rem;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--white, #fff);
  -webkit-overflow-scrolling: touch;
}

.map-search-results[hidden] {
  display: none;
}

.map-search-results li {
  margin: 0;
}

.map-search-option {
  display: block;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}

.map-search-option:last-child,
.map-search-results li:last-child .map-search-option {
  border-bottom: 0;
}

.map-search-option:hover,
.map-search-option.is-active {
  background: rgba(12, 27, 42, 0.06);
}

.map-search-option:focus {
  outline: 2px solid var(--navy);
  outline-offset: -2px;
}

.map-search-option .name {
  display: block;
  color: var(--navy);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
}

.map-search-option .meta {
  display: block;
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

@media (max-width: 720px) {
  .map-search-results {
    max-height: 9.5rem;
  }
}
