/* -----------------------------
   Map Container
----------------------------- */
.climate-map-wrap {
  position: relative;
  height: 600px;
  width: 100%;
  box-sizing: border-box;
  line-height: 1.4;
}

.elementor .climate-map-wrap * {
  box-sizing: content-box;
}


#climate-map {
  width: 100%;
  height: 100%;
}

/* -----------------------------
   Panels (controls + legend)
----------------------------- */
#climate-map-controls,
#climate-map-legend {
  position: absolute;
  z-index: 2;
  max-width: 300px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: rgba(0, 0, 0, 0.5) 1px 2px 5px 0px;
  color: #1D1D1D;
  padding: 16px;
  border-radius: 6px;
  box-sizing: border-box;
  font-family: sans-serif; 
}

#climate-map-controls { top: 10px; left: 12px; }
#climate-map-legend   { top: 10px; right: 12px; }

#climate-map-legend h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
}

.mapboxgl-popup {
  max-width: 250px !important;
}
.mapboxgl-map {
  font-family: inherit !important;
}
.mapboxgl-popup-content {
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

.mapboxgl-ctrl-group:not(:empty) {
  box-shadow: #00000080 1px 2px 5px 0px;
}



/* -----------------------------
   Range / Scale Control
----------------------------- */
.climate-scale {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}
#scaleRange { width: 160px; }
#scaleVal { font-variant-numeric: tabular-nums; }

#legend-items {
  margin-top: 6px;
}

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

.legend-row input[type="checkbox"] {
  margin: 0;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 10px;
  flex: 0 0 14px;
  display: inline-block;
}

.legend-label {
  font-weight: normal;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-count {
  display: none !important;
}

.legend-title {
  font-size: 20px;
  font-weight: 400;
}

.legend-actions {
  margin-top: 16px;
  padding-top: 16px;
  gap: 16px;
  border-top: 1px solid #e0e7eb;
  display: flex;
}
.climate-btn {
  all: unset;
  display: inline-block;
  cursor: pointer;
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
}

/* Styling to match elbowsupforclimate.ca */
.climate-btn {
  appearance: button;
  padding: 12px 24px;
  border-radius: 3px;
  font-size: 15px;
  line-height: 1;
  text-align: center;
  color: white;
  background-color: #a2a2a2;
  white-space: nowrap;
  transition: all 0.3s;
}
/* More room for French text in the buttons */
.climate-map-wrap[data-lang="fr"] .climate-btn { padding: 12px 16px; }
.climate-btn:hover {
  background-color: #7a7a7a;
}

.climate-btn:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}


/* -----------------------------
   Legend Header / Toggle Caret
----------------------------- */
.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

/* Replace plus/minus with caret SVG */
.legend-toggle {
  width: 28px;
  height: 28px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  background-color: #a2a2a2;
  border: none;
  color: white;
  padding: 0;
}
.legend-toggle svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 0;
  transition: transform 0.3s ease;
  transform: rotate(180deg);
}

/* Rotate caret when collapsed */
#climate-map-legend.collapsed .legend-toggle svg {
  transform: rotate(0deg);
}

.legend-toggle:hover { background-color: #7a7a7a; }

/* -----------------------------
   Collapsible Legend Behaviour
----------------------------- */
#climate-map-legend {
  right: 56px;
  transition: max-height 0.35s ease, padding 0.35s ease;
  overflow: hidden;
}

#climate-map-legend:not(.collapsed) {
  max-height: 600px;
}
#climate-map-legend.collapsed {
  max-height: 60px;
}

#climate-map-legend.collapsed #legend-items,
#climate-map-legend.collapsed .legend-actions {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

#climate-map-legend:not(.collapsed) #legend-items,
#climate-map-legend:not(.collapsed) .legend-actions {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.25s ease 0.1s;
}

/* -----------------------------
   Popup (Incident Boxes)
----------------------------- */
.incident-popup {
  width: 270px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 2px 2px 2px #0003;
  color: #1D1D1D;
  overflow: hidden;
}

.incident-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 41px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  position: relative;
}

.incident-popup.multiple .incident-header { height: 31px; }

.incident-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: inherit;
}

.incident-body {
  padding: 16px;
  font-size: 14px;
}
.location { font-weight: 600; margin: 0 0 4px; }
.population { margin: 0 0 8px; }
.article-link {
  text-decoration: none;
  color: #2a4252;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.article-link:hover { text-decoration: underline; }
.icon-external { width: 12px; height: 12px; stroke: currentColor; }

/* Category colors */
.evacuation { background: #fb2200; }
.wildfire { background: #fa7a28; }
.wildfire-risk { background: #fcd045; color: #1D1D1D; }
.local-state-of-emergency { background: #5c8f1d; }
.evacuation-alert { background: #1798f7; }
.unsafe-air-quality { background: #9dd1e1; color: #1D1D1D; }
.severe-storm { background: #a230f3; }
.flood-watch { background: #2054aa; }
.extreme-heat { background: #6e0000; }
.drought { background: #715a34; }

/* Subtle focus outline for accessibility */
.climate-map-wrap button:focus,
.climate-map-wrap button:focus-visible,
.climate-map-wrap a:focus,
.climate-map-wrap a:focus-visible {
  outline: 1px solid rgba(0, 0, 0, 0.2); 
  outline-offset: 2px;
  box-shadow: none !important;
}

/* Remove legacy heavy borders on mapbox buttons (like the caret toggle) */
.legend-toggle:focus,
.legend-toggle:focus-visible,
.article-link:focus,
.article-link:focus-visible {
  outline: 1px solid rgba(0, 0, 0, 0.15);
  outline-offset: 3px;
  box-shadow: none !important;
}

/* Close button */
.mapboxgl-popup-close-button {
  position: absolute !important;
  top: 7px !important;
  right: -12px !important;
  width: 28px !important;
  height: 28px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  line-height: 1 !important;
  cursor: pointer !important;
  z-index: 10 !important;
}
.mapboxgl-popup-close-button svg {
  width: 22px;
  height: 22px;
}
.mapboxgl-popup .incident-popup.multiple ~ .mapboxgl-popup-close-button {
  top: 3px !important;
}

/* Elementor workarounds/fixes */
button.mapboxgl-ctrl-attrib-button {
  display: none;
  border: none;
  padding: 0;
  width: 24px;
  border-radius: 12px;
  background-color: #ffffff80;
}
button.mapboxgl-ctrl-attrib-button:focus {
  background-color: #ffffff80;
}

/* Responsive heights */
@media (max-width: 900px) { .climate-map-wrap { height: 540px; } }
@media (max-width: 640px) {
  .climate-map-wrap { height: 480px; }
  #climate-map-controls,
  #climate-map-legend {
    top: 10px;
    right: 50px;
    left: 10px;
    max-width: none;
    padding: 10px;
  }
  #climate-map-legend.collapsed {
    max-height: 48px;
  }
  .legend-actions { 
    flex-wrap: wrap; 
    padding-top: 10px;
    margin-top: 10px;
    gap: 10px;
  }
}
