:root {
  --bg: #edf5f0;
  --paper: rgba(250, 252, 252, 0.9);
  --ink: #142330;
  --muted: #5d6d78;
  --line: rgba(20, 35, 48, 0.1);
  --accent: #17a36d;
  --accent-strong: #0d8f61;
  --accent-deep: #0e6b63;
  --sand: #f1e9d8;
  --shadow: 0 24px 60px rgba(18, 38, 48, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Work Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(23, 163, 109, 0.16), transparent 26%),
    radial-gradient(circle at right 20%, rgba(14, 107, 99, 0.12), transparent 24%),
    linear-gradient(135deg, #e9f5ef 0%, var(--bg) 48%, #f3f8f2 100%);
}

.skip-link {
  position: absolute;
  left: 14px;
  top: -48px;
  z-index: 50;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--accent-deep);
  color: white;
  text-decoration: none;
  font-weight: 700;
}

.skip-link:focus {
  top: 14px;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  align-items: start;
  gap: 20px;
  padding: 20px;
}

.sidebar,
.map-frame {
  background: var(--paper);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-top {
  grid-column: 1;
  grid-row: 1;
  gap: 14px;
}

.sidebar-bottom {
  grid-column: 1;
  grid-row: 2;
}

.hero {
  position: relative;
  padding: 4px 0 0;
}

.eyebrow,
.map-kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--accent-deep);
}

h1,
h2 {
  font-family: "Fraunces", serif;
  line-height: 1.02;
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
}

h2 {
  font-size: 1.25rem;
}

.lede,
.source-note p,
.list-header p,
.stat-card p,
.location-meta,
.popup-meta {
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(243, 249, 247, 0.78));
  border: 1px solid var(--line);
}

.stat-card strong {
  display: block;
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.controls,
.filters-panel,
.stats-panel,
.source-note,
.list-panel {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.search span {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.search input {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 13px 15px;
  font: inherit;
  background: rgba(255, 255, 255, 0.95);
}

.helper-text {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.search-block {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.search-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.search-button {
  border: 0;
  border-radius: 16px;
  padding: 13px 18px;
  min-height: 48px;
  font: inherit;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--accent-deep), var(--accent));
  cursor: pointer;
}

.secondary-button {
  border: 1px solid rgba(14, 107, 99, 0.18);
  border-radius: 16px;
  padding: 13px 16px;
  min-height: 48px;
  font: inherit;
  font-weight: 700;
  color: var(--accent-deep);
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
}

.search-status {
  min-height: 1.2rem;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.toggles {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  font-size: 0.95rem;
}

.toggles label {
  display: flex;
  gap: 10px;
  align-items: center;
}

.section-head {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

.map-panel {
  min-width: 0;
  grid-column: 2;
  grid-row: 1 / span 2;
}

.map-frame {
  height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow: hidden;
}

.map-title {
  padding: 4px 6px 16px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.map-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.map-toggle-button {
  display: none;
  border: 1px solid rgba(14, 107, 99, 0.18);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-deep);
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
#map:focus-visible {
  outline: 3px solid #0e7f94;
  outline-offset: 3px;
}

.map-title a {
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 600;
}

#map {
  flex: 1;
  min-height: 420px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.custom-marker {
  background: transparent;
  border: 0;
}

.custom-marker span {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 2px solid rgba(10, 38, 36, 0.86);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.88),
    0 10px 18px rgba(18, 42, 31, 0.18);
}

.custom-marker.is-nearest span {
  width: 24px;
  height: 24px;
  border-width: 3px;
  box-shadow:
    0 0 0 4px rgba(47, 125, 246, 0.2),
    0 0 0 7px rgba(255, 255, 255, 0.92),
    0 12px 20px rgba(18, 42, 31, 0.24);
}

.cluster-badge {
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: white;
  font-weight: 700;
  border: 3px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 26px rgba(19, 41, 52, 0.18);
}

.cluster-badge.small {
  background: radial-gradient(circle at 30% 30%, #2cc981, #14905f);
}

.cluster-badge.medium {
  background: radial-gradient(circle at 30% 30%, #15b39a, #0d7d71);
}

.cluster-badge.large {
  background: radial-gradient(circle at 30% 30%, #0e7f94, #0d5667);
}

.popup-title {
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.2;
  margin-bottom: 10px;
}

.popup-kicker {
  margin: 0 0 6px;
  color: var(--accent-deep);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.68rem;
  font-weight: 700;
}

.popup-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.popup-links {
  display: grid;
  gap: 2px;
  margin-bottom: 10px;
}

.popup-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-deep), var(--accent));
  color: white;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 10px 18px rgba(14, 107, 99, 0.18);
}

.popup-button:link,
.popup-button:visited,
.popup-button:hover,
.popup-button:active {
  color: white;
}

.popup-button:hover {
  filter: brightness(1.03);
}

.popup-link-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
  padding-left: 2px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(23, 163, 109, 0.11);
  color: var(--accent-deep);
  font-size: 0.83rem;
  font-weight: 600;
}

.leaflet-popup-content-wrapper {
  border-radius: 18px;
}

.leaflet-popup-content {
  margin: 14px 16px;
  min-width: 200px;
  max-width: 250px;
}

.leaflet-control-zoom a {
  color: var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 960px) {
  .shell {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px;
  }

  .sidebar-top,
  .sidebar-bottom,
  .map-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .sidebar {
    padding: 18px;
    border-radius: 24px;
  }

  .map-frame {
    height: 62vh;
    padding: 12px;
    border-radius: 24px;
  }

  .map-title {
    padding: 4px 4px 12px;
    flex-direction: column;
    align-items: flex-start;
  }

  .map-actions {
    width: 100%;
    justify-content: space-between;
  }

  .map-toggle-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  body.map-fullscreen {
    overflow: hidden;
  }

  body.map-fullscreen .sidebar-top,
  body.map-fullscreen .sidebar-bottom {
    display: none;
  }

  body.map-fullscreen .shell {
    display: block;
    padding: 0;
  }

  body.map-fullscreen .map-panel {
    position: fixed;
    inset: 0;
    z-index: 30;
  }

  body.map-fullscreen .map-frame {
    height: 100vh;
    border-radius: 0;
    padding: 10px;
  }

  #map {
    min-height: 0;
  }

  .search-block {
    grid-template-columns: 1fr;
  }

  .filter-search {
    margin-top: 0;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1 {
    font-size: clamp(2.3rem, 11vw, 4.4rem);
  }
}

@media (min-width: 961px) {
  .search span {
    white-space: nowrap;
  }
}
