/* Scoped styles: include after your existing Leaflet/theme styles. */
.public-map-page .ecoguard-legend{
  --ecoguard-legend-teal: #087f79;
  --ecoguard-legend-surface: #ffffff;
  --ecoguard-legend-text: #173d38;
  --ecoguard-legend-border: #dce9e5;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  max-width: calc(var(--ecoguard-map-width, 320px) - 24px);
  font: 14px/1.5 system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ecoguard-legend-text);
}
.public-map-page .ecoguard-legend, .public-map-page .ecoguard-legend *{ box-sizing: border-box; }
.public-map-page .ecoguard-legend [hidden]{ display: none !important; }
.public-map-page .ecoguard-legend .ecoguard-legend__panel{
  width: 264px;
  max-width: 100%;
  max-height: max(48px, calc(var(--ecoguard-map-height, 500px) - 140px));
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--ecoguard-legend-surface);
  border: 1px solid var(--ecoguard-legend-border);
  border-radius: 16px;
  padding: 8px 12px 12px;
  box-shadow: 0 8px 28px rgb(18 65 58 / 16%);
  animation: ecoguard-legend-reveal 160ms ease-out;
}
.public-map-page .ecoguard-legend .ecoguard-legend__header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.public-map-page .ecoguard-legend .ecoguard-legend__title{
  margin: 0;
  color: var(--ecoguard-legend-text);
  font: 600 15px/1.4 system-ui, sans-serif;
}
.public-map-page .ecoguard-legend .ecoguard-legend__close{
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  color: var(--ecoguard-legend-text);
  background: transparent;
  font: 24px/1 system-ui, sans-serif;
  cursor: pointer;
}
.public-map-page .ecoguard-legend .ecoguard-legend__close:hover{ background: #edf5f2; }
.public-map-page .ecoguard-legend .ecoguard-legend__toggle{
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  background: var(--ecoguard-legend-teal);
  box-shadow: 0 4px 14px rgb(18 65 58 / 22%);
  font: 600 14px/1.5 system-ui, sans-serif;
  cursor: pointer;
}
.public-map-page .ecoguard-legend .ecoguard-legend__toggle:hover{ filter: brightness(.93); }
.public-map-page .ecoguard-legend button:focus-visible{
  outline: 3px solid #b75b00;
  outline-offset: 3px;
}
.public-map-page .ecoguard-legend .ecoguard-legend__glyph{
  display: grid;
  gap: 3px;
  width: 20px;
}
.public-map-page .ecoguard-legend .ecoguard-legend__glyph span{
  display: block;
  height: 4px;
  border-left: 4px solid currentColor;
  border-right: 11px solid currentColor;
}
.public-map-page .ecoguard-legend .ecoguard-legend__list{ list-style: none; margin: 0; padding: 0; }
.public-map-page .ecoguard-legend .ecoguard-legend__item{
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 36px;
  padding: 5px 4px;
}
.public-map-page .ecoguard-legend .ecoguard-legend__label{ overflow-wrap: anywhere; }
.public-map-page .ecoguard-legend .ecoguard-legend__swatch{
  display: grid;
  place-items: center;
  flex: 0 0 26px;
  width: 26px;
  min-height: 22px;
}
.public-map-page .ecoguard-legend .ecoguard-legend__swatch > img{ max-width: 26px; max-height: 26px; object-fit: contain; }
.public-map-page .ecoguard-legend .ecoguard-legend__swatch > .leaflet-marker-icon{
  position: static !important;
  margin: 0 !important;
  transform: none !important;
  max-width: 26px;
  max-height: 26px;
}
.public-map-page .ecoguard-legend .ecoguard-legend__mark{ display: block; color: var(--ecoguard-legend-teal); }
.public-map-page .ecoguard-legend .ecoguard-legend__mark--dot{ width: 12px; height: 12px; border-radius: 50%; background: currentColor; }
.public-map-page .ecoguard-legend .ecoguard-legend__mark--square{ width: 12px; height: 12px; border-radius: 2px; background: currentColor; }
.public-map-page .ecoguard-legend .ecoguard-legend__mark--line{ width: 24px; height: 0; border-top: 2px dashed currentColor; }
.public-map-page .ecoguard-legend .ecoguard-legend__mark--area{ width: 22px; height: 14px; border: 2px solid currentColor; border-radius: 3px; background: transparent; }
.public-map-page .ecoguard-legend .ecoguard-legend__empty{ margin: 6px 4px; }
@keyframes ecoguard-legend-reveal {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .ecoguard-legend .ecoguard-legend__panel { animation: none; }
}

.public-map-page .ecoguard-legend{margin:0 20px 90px 0;position:relative}
.public-map-page .ecoguard-legend .ecoguard-legend__panel{position:absolute;bottom:calc(100% + 10px);right:0;width:max-content;max-width:calc(var(--ecoguard-map-width,100vw) - 40px);max-height:max(48px,calc(100dvh - 250px))}
.public-map-page .ecoguard-legend .ecoguard-legend__label{white-space:nowrap;overflow-wrap:normal}
.public-map-page .ecoguard-legend .ecoguard-legend__title{white-space:nowrap}
.public-map-page .ecoguard-legend .legend-dot{display:block;flex:none;width:10px;height:10px;border-radius:50%;margin:0}
.public-map-page .ecoguard-legend .incident-dot{background:#dc2626}
.public-map-page .ecoguard-legend .closed-dot{background:#6b7280}
.public-map-page .ecoguard-legend .facility-dot{background:#15803d}
.public-map-page .ecoguard-legend .barangay-dot{background:#ea580c}
.public-map-page .ecoguard-legend .office-dot{background:#1467cc}
@media(max-width:900px){.public-map-page .ecoguard-legend{margin-right:12px;margin-bottom:calc(142px + env(safe-area-inset-bottom,0px))}.public-map-page .ecoguard-legend .ecoguard-legend__panel{max-width:calc(var(--ecoguard-map-width,100vw) - 24px);max-height:max(48px,calc(100dvh - 310px))}}
@media(prefers-reduced-motion:reduce){.public-map-page .ecoguard-legend__panel{animation:none}}

/* Icon toggle sits directly below the public closed-incident filter. */
.public-map-page .public-map-controls .ecoguard-legend{margin:0;width:48px;max-width:none;align-items:flex-start}
.public-map-page .public-map-controls .ecoguard-legend__toggle{width:48px;min-width:48px;height:48px;padding:0;font-size:21px;transition:transform 180ms ease,box-shadow 180ms ease}
.public-map-page .public-map-controls .ecoguard-legend__toggle:hover{transform:translateY(-2px);box-shadow:0 7px 18px #12413a40}
.public-map-page .public-map-controls .ecoguard-legend__toggle:active{transform:scale(.94)}
.public-map-page .public-map-controls .ecoguard-legend__toggle .bi{transition:transform 220ms ease}
.public-map-page .public-map-controls .ecoguard-legend__toggle[aria-expanded=true] .bi{transform:rotate(90deg)}
.public-map-page .public-map-controls .ecoguard-legend__panel{left:0;right:auto;bottom:calc(100% + 60px);animation:ecoguard-legend-reveal 200ms ease-out}
@media(max-width:900px){.public-map-page .public-map-controls{width:248px;max-width:calc(100vw - 24px)}}
@media(prefers-reduced-motion:reduce){.public-map-page .public-map-controls .ecoguard-legend__panel{animation:none}.public-map-page .public-map-controls .ecoguard-legend__toggle,.public-map-page .public-map-controls .ecoguard-legend__toggle .bi{transition:none;transform:none}}

.public-map-page .public-map-controls .ecoguard-legend__panel{bottom:calc(100% + 10px)}
.public-map-page .ecoguard-legend #toggleClosedIncidents{display:flex;align-items:center;justify-content:center;gap:9px;width:100%;min-height:44px;margin:0 0 8px;padding:8px 12px;border:1px solid #c8d8e7;border-radius:8px;background:#fff;color:#18354c;font:inherit;font-weight:600;cursor:pointer}
.public-map-page .ecoguard-legend #toggleClosedIncidents:hover{background:#edf7f7;border-color:#087f82}
.public-map-page .ecoguard-legend #toggleClosedIncidents[aria-pressed=true]{background:#e5f4f3;color:#06676a;border-color:#087f82}
