/* P1.7-I — Geospatial workspace
 *
 * Progressive enhancement for the existing Leaflet dashboard contract.
 * The dashboard keeps ownership of #map, #map-scope and all map runtime data.
 */

#map-scope {
  display: inline-flex;
  min-height: 1.75rem;
  align-items: center;
  gap: 0.375rem;
  border: 1px solid var(--lt-border);
  border-radius: 9999px;
  background: var(--lt-surface-muted);
  padding: 0.25rem 0.625rem;
  color: var(--lt-text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#map-scope::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  flex: 0 0 auto;
  border-radius: 9999px;
  background: var(--lt-neutral);
  box-shadow: 0 0 0 3px var(--lt-neutral-bg);
}

#map {
  position: relative;
  isolation: isolate;
  min-height: 24rem;
  overflow: hidden;
  border-color: var(--lt-border-strong);
  background: #e2e8f0;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.38);
}

#map:focus-visible,
#map .leaflet-control a:focus-visible,
#map .leaflet-marker-icon:focus-visible {
  outline: 3px solid var(--lt-focus);
  outline-offset: 2px;
}

#map .leaflet-control-zoom {
  overflow: hidden;
  border: 1px solid var(--lt-border-strong);
  border-radius: var(--lt-radius-sm);
  box-shadow: var(--lt-shadow-sm);
}

#map .leaflet-control-zoom a {
  border-bottom-color: var(--lt-border);
  background: var(--lt-surface);
  color: var(--lt-text-primary);
}

#map .leaflet-control-zoom a:hover {
  background: var(--lt-surface-subtle);
  color: var(--lt-accent);
}

#map .leaflet-popup-content-wrapper,
#map .leaflet-popup-tip {
  background: var(--lt-surface);
  color: var(--lt-text-secondary);
}

#map .leaflet-popup-content-wrapper {
  border: 1px solid var(--lt-border);
  border-radius: var(--lt-radius-md);
  box-shadow: var(--lt-shadow-md);
}

#map .leaflet-popup-content {
  margin: 0.875rem 1rem;
  font-size: 0.75rem;
  line-height: 1.25rem;
}

#map .leaflet-popup-content strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--lt-text-primary);
  font-size: 0.8125rem;
  font-weight: 800;
}

#map .leaflet-control-attribution {
  border-radius: 0.375rem 0 0 0;
  background: rgb(255 255 255 / 0.9);
  color: var(--lt-text-muted);
  font-size: 0.625rem;
}

#map .leaflet-control-attribution a {
  color: var(--lt-info);
}

.lt-geo-panel {
  min-width: 0;
}

.lt-geo-panel__header {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.lt-geo-panel__copy {
  min-width: 0;
}

.lt-geo-panel__title {
  margin: 0;
  color: var(--lt-text-primary);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.375rem;
}

.lt-geo-panel__description {
  margin: 0.25rem 0 0;
  color: var(--lt-text-muted);
  font-size: 0.75rem;
  line-height: 1.25rem;
}

.lt-geo-panel__viewport {
  position: relative;
  min-width: 0;
}

.lt-geo-panel__meta {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-top: 0.625rem;
  color: var(--lt-text-muted);
  font-size: 0.6875rem;
  line-height: 1rem;
}

.lt-geo-legend {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.lt-geo-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.lt-geo-legend__swatch {
  width: 0.625rem;
  height: 0.625rem;
  flex: 0 0 auto;
  border: 2px solid var(--lt-surface);
  border-radius: 9999px;
  background: var(--lt-accent);
  box-shadow: 0 0 0 1px var(--lt-border-strong);
}

@media (max-width: 639px) {
  #map {
    min-height: 20rem;
  }

  #map-scope {
    max-width: 100%;
    white-space: normal;
  }

  .lt-geo-panel__header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  #map .leaflet-zoom-animated,
  #map .leaflet-fade-anim .leaflet-popup {
    transition: none !important;
  }
}
