/* Map page shell */
body:has(.map-shell) {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.map-shell {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  max-width: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.map-shell #map,
.map-shell #map-fullscreen {
  position: absolute;
  inset: 0;
  background: var(--surface);
  text-align: left;
}

/* MapLibre built-in controls */
.maplibregl-ctrl-group {
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--border), 0 2px 8px var(--shadow);
}

.maplibregl-ctrl-group button + button {
  border-top: 1px solid var(--border);
}

.maplibregl-ctrl button:not(:disabled):hover {
  background-color: var(--hover);
}

.maplibregl-ctrl-attrib {
  background-color: var(--surface);
  color: var(--muted);
}

.maplibregl-ctrl-attrib a {
  color: var(--muted);
}

.maplibregl-ctrl-attrib.maplibregl-compact {
  background-color: var(--surface);
}

@media (prefers-color-scheme: dark) {
  .maplibregl-ctrl-icon,
  .maplibregl-ctrl-attrib-button {
    filter: invert(1);
  }

  .maplibregl-ctrl-logo {
    filter: brightness(0) invert(1);
  }
}

/* MapLibre popup shell */
.maplibregl-popup-content {
  max-width: 340px;
  padding: 0.75rem 0.9rem;
  background: var(--surface);
  color: var(--text-primary);
  border-radius: 8px;
  box-shadow: 0 2px 10px var(--shadow);
}

.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
  border-bottom-color: var(--surface);
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
  border-top-color: var(--surface);
}

.maplibregl-popup-anchor-left .maplibregl-popup-tip {
  border-right-color: var(--surface);
}

.maplibregl-popup-anchor-right .maplibregl-popup-tip {
  border-left-color: var(--surface);
}

.maplibregl-popup-close-button {
  display: flex;
  align-items: center;
  justify-content: center;
  top: 0;
  right: 0;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  border-radius: 0 8px 0 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.maplibregl-popup-close-button:hover {
  background: var(--hover);
  color: var(--text-primary);
}

.maplibregl-popup-close-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.map-popup {
  max-height: 320px;
  overflow-y: auto;
  color: var(--text-primary);
  font-size: 0.85rem;
  line-height: 1.4;
}

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

.map-popup-title {
  margin: 0 0 4px;
  padding-right: 3rem;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
}

.map-popup-status {
  display: inline-block;
  margin-bottom: 4px;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--muted);
  color: var(--accent-contrast);
  font-size: 0.72rem;
  font-weight: 600;
}

.map-popup-description {
  margin: 0.55rem 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.map-popup-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.5rem;
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
}

.map-popup-meta dt {
  color: var(--muted);
  white-space: nowrap;
}

.map-popup-meta dd {
  margin: 0;
}

.map-popup-action {
  display: block;
  width: fit-content;
  margin: 10px auto 0;
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-contrast);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.map-popup-action:hover {
  opacity: 0.9;
  text-decoration: none;
}

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