* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #1b2430;
}
#map { position: absolute; inset: 0; }

.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;
}

/* ---- search ---------------------------------------------------------------- */
#search {
  position: absolute; top: 10px; left: 10px; z-index: 5;
  width: min(360px, calc(100vw - 20px));
}

#search-input {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  color: inherit;
  background: rgba(255, 255, 255, .96);
  border: 1px solid #c8cfd8;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
  -webkit-appearance: none;
}
#search-input:focus {
  outline: none;
  border-color: #1a4fa0;
  box-shadow: 0 0 0 3px rgba(26, 79, 160, .18), 0 2px 8px rgba(0, 0, 0, .15);
}

#search-results {
  margin-top: 6px;
  background: #fff;
  border: 1px solid #c8cfd8;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
  max-height: min(50vh, 340px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
#search-results[hidden] { display: none; }

.search-result {
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.35;
  border-bottom: 1px solid #f0f2f5;
  cursor: pointer;
}
.search-result:last-child { border-bottom: 0; }
.search-result:hover, .search-result.active { background: #eef3fb; }
.r-name { font-weight: 600; }
.r-sub { color: #6b7482; }

.search-message { padding: 10px 12px; font-size: 13px; color: #6b7482; }

#clear-selection {
  display: block;
  margin-top: 6px;
  padding: 7px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #b3261e;
  background: rgba(255, 255, 255, .96);
  border: 1px solid #e3b3af;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
  cursor: pointer;
}
#clear-selection[hidden] { display: none; }
#clear-selection:hover { background: #fdeceb; }

/* ---- basemap switcher ------------------------------------------------------ */
#basemaps {
  position: absolute; top: 10px; right: 10px; z-index: 5;
  display: flex; gap: 4px;
  padding: 4px;
  background: rgba(255, 255, 255, .94);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}
#basemaps button {
  border: 0; border-radius: 6px;
  background: #eef1f5;
  padding: 7px 12px;
  font: inherit; font-size: 12px; font-weight: 600;
  color: #1a2f52;
  cursor: pointer;
}
#basemaps button:hover { background: #e2e7ee; }
#basemaps button.active { background: #1a2f52; color: #fff; }

/* ---- overzoom notice ------------------------------------------------------- */
#zoom-notice {
  position: absolute; bottom: 46px; left: 50%; transform: translateX(-50%);
  z-index: 5; margin: 0;
  max-width: calc(100vw - 24px);
  padding: 7px 12px;
  font-size: 12px;
  color: #fff;
  background: rgba(0, 0, 0, .72);
  border-radius: 6px;
  text-align: center;
  pointer-events: none;
}
#zoom-notice[hidden] { display: none; }

/* ---- about link ------------------------------------------------------------ */
#about-link {
  position: absolute; bottom: 10px; left: 10px; z-index: 5;
  padding: 5px 10px;
  font-size: 12px; font-weight: 600;
  color: #1a4fa0; text-decoration: none;
  background: rgba(255, 255, 255, .92);
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}
#about-link:hover { text-decoration: underline; }

/* the scale control sits in the same corner — lift it above the About chip */
.maplibregl-ctrl-bottom-left .maplibregl-ctrl-scale { margin-bottom: 38px; }

/* ---- popups ---------------------------------------------------------------- */
.maplibregl-popup-content {
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}
.vpop { font-size: 13px; line-height: 1.4; }
.vpop-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.vpop p { margin: 2px 0; color: #3c4756; }
.vpop b { font-weight: 600; color: #6b7482; }

.hover-popup .maplibregl-popup-content { padding: 7px 10px; }
.hover-popup { pointer-events: none; }
.hover-popup .vpop { font-size: 12px; }
.hover-popup .vpop-name { font-size: 12.5px; }

.maplibregl-popup-close-button {
  width: 26px; height: 26px;
  font-size: 18px; line-height: 1;
  color: #6b7482;
}
.maplibregl-popup-close-button:hover { background: none; color: #1b2430; }

/* ---- phones ---------------------------------------------------------------- */
@media (max-width: 520px) {
  #search { width: calc(100vw - 20px); max-width: none; }
  /* leave room for the basemap switcher on the same row */
  #search-input { padding-right: 168px; }
  #search-results { max-height: 45vh; }
  #basemaps button { padding: 7px 10px; }
  .maplibregl-popup { max-width: calc(100vw - 24px) !important; }
  /* the attribution goes full width down here — sit above it, not on it */
  #about-link { bottom: 32px; }
  .maplibregl-ctrl-bottom-left .maplibregl-ctrl-scale { margin-bottom: 60px; }
  #zoom-notice { bottom: 68px; }
}
