* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: #1f2937;
}

#map {
  position: absolute;
  inset: 0;
}

#map-after {
  position: absolute;
  inset: 0;
}

#compare-slider {
  position: absolute;
  inset: 0;
  /* Must outrank #panel (z-index: 1): dragging the handle near the left edge would otherwise
     put it underneath the sidebar, which shares the same z-index but sits later in the DOM
     and so wins the tie — the panel would capture the drag and the slider would get stuck. */
  z-index: 2;
  /* The slider fills the whole map, but only its own handle/line should intercept clicks/drags
     — everywhere else needs to fall through to the map underneath for panning/zooming. */
  pointer-events: none;
}

/* maplibre-gl-compare injects these elements into #compare-slider at runtime; re-enable
   pointer events just on them so the drag handle stays interactive under the rule above. */
#compare-slider .maplibregl-compare,
#compare-slider .compare-swiper-vertical,
#compare-slider .compare-swiper-horizontal {
  pointer-events: auto;
}

#panel {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1;
  width: 280px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  background-color: rgba(255, 255, 255, 0.95);
  /* Accent stripe echoing the OSM/NHD swatch colors, so the panel's own chrome nods to the data
     it's presenting rather than sitting there as plain gray-on-white. */
  background-image: linear-gradient(90deg, #3420d1, #71e9e5);
  background-repeat: no-repeat;
  background-size: 100% 6px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  padding: 18px 16px 14px;
}

#panel h1 {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 2px;
  color: #111827;
}

#panel .subtitle {
  margin: 0 0 12px;
  color: #6b7280;
  font-size: 12px;
}

#panel section {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #7a7e87;
}

#panel section:last-of-type {
  border-bottom: none;
}

#panel h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #6b7280;
  margin: 0 0 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px -4px;
  padding: 3px 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.row:hover {
  background-color: #f3f4f6;
}

.swatch {
  display: inline-block;
  width: 18px;
  height: 3px;
  border-radius: 2px;
}

/* Must match the 'line-color' values for the osm/nhd entries in js/config.js's STREAM_LAYERS —
   these swatches are the static checkbox-legend colors; STREAM_LAYERS drives the actual map. */
.swatch-osm { background: #3420d1; }
.swatch-nhd { background: #71e9e5; }

.picklist {
  width: 100%;
  margin: 0 0 10px;
  padding: 4px 6px;
  font-size: 13px;
}

.muted {
  color: #6b7280;
  font-size: 12px;
}

.coming-soon {
  font-style: italic;
  margin: -2px 0 0;
}

#info-content {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 10px 12px;
}

#info-content p:first-child {
  margin-top: 0;
}

#info-name {
  color: #3420d1;
}

#info-stats {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#info-stats td {
  padding: 3px 0;
}

#info-stats td:first-child {
  color: #6b7280;
}

#info-stats td:last-child {
  text-align: right;
}

.info-breakdown-group {
  margin-top: 8px;
}

.info-breakdown-label {
  margin: 0 0 2px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #6b7280;
}

.info-breakdown {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.info-breakdown td {
  padding: 2px 0 2px 10px;
}

.info-breakdown td:first-child {
  color: #6b7280;
}

.info-breakdown td:last-child {
  text-align: right;
}

.panel-btn {
  width: 100%;
  padding: 8px;
  font-size: 13px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #e4e8ee;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.panel-btn:hover {
  background: #a3afc6;
  border-color: #8996b8;
}

.panel-btn:active {
  transform: scale(0.98);
}

.side-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 13px;
}

.side-row .side-row-label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.side-row .side-options {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: #6b7280;
}

.side-row .side-options label {
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(17, 24, 39, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* [hidden] { display: none } is only a browser-default (user-agent stylesheet) rule, so it
   loses to this page's own .modal { display: flex } rule above regardless of selector order
   or specificity -- hiding has to be restated here, scoped to .modal, to actually take effect. */
.modal[hidden] {
  display: none;
}

.modal-content {
  position: relative;
  background: #fff;
  border-radius: 10px;
  max-width: 480px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
  margin-top: 0;
}

.modal-content ul {
  padding-left: 20px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 22px;
  line-height: 1;
  border: none;
  background: none;
  cursor: pointer;
  color: #6b7280;
}

.modal-close:hover {
  color: #1f2937;
}

/* Basemap toggle control (see BasemapControl in js/basemap.js) — a maplibregl-ctrl-group like
   NavigationControl, so it reads as part of the same top-right cluster; only the active-state
   highlight is custom. */
.basemap-ctrl button {
  font-size: 15px;
  line-height: 29px;
}

.basemap-ctrl button.active {
  background-color: #d7dae0;
}

/* MapLibre popup tweaks */
.maplibregl-popup-content {
  font-family: inherit;
  font-size: 13px;
}

.maplibregl-popup-content h3 {
  margin: 0 0 4px;
  font-size: 13px;
}

.maplibregl-popup-content table td {
  padding: 1px 6px 1px 0;
  vertical-align: top;
}

.maplibregl-popup-content table td:first-child {
  color: #6b7280;
}

.maplibregl-popup-content .popup-divider {
  margin: 8px 0;
  border: none;
  border-top: 1px solid #7a7e87;
}
