/* Toggle “Ver mapa de calor” + leyenda + estado visual del mapa */

/* Contenedor del mapa: modo calor activo (mapa base + heat como foco) */
.home-map-main .mapa-wrapper.mapa-wrapper--heat-mode {
  outline: 2px solid rgba(234, 88, 12, 0.45);
  outline-offset: -2px;
  border-radius: var(--radius-md, 0.5rem);
  box-shadow: 0 0 0 1px rgba(251, 146, 60, 0.2);
}

/* Leyenda cálida (control Leaflet bottom-right) */
.home-heat-legend-stack {
  margin-bottom: 2.25rem;
  margin-right: 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-width: 12.5rem;
}

.home-heat-legend-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(251, 146, 60, 0.45);
  border-radius: 999px;
  box-shadow:
    0 2px 12px rgba(15, 23, 42, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.55) inset;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.home-heat-legend-toggle:hover {
  background: #fff;
  border-color: rgba(234, 88, 12, 0.55);
}

.home-heat-legend-toggle:focus-visible {
  outline: 2px solid #ea580c;
  outline-offset: 2px;
}

.home-heat-legend-panel {
  margin: 0;
  background: rgba(255, 253, 248, 0.97);
  border: 1px solid rgba(251, 146, 60, 0.4);
  border-radius: 0.5rem;
  padding: 0.45rem 0.55rem 0.5rem;
  font-size: 0.6875rem;
  line-height: 1.35;
  color: var(--color-text);
  box-shadow:
    0 2px 10px rgba(15, 23, 42, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  max-width: 12.25rem;
  align-self: flex-end;
}

.home-heat-legend__title {
  font-family: var(--font-display);
  font-weight: 700;
  margin: 0 0 0.25rem;
  font-size: 0.75rem;
  color: var(--color-text);
}

.home-heat-legend__sub {
  margin: 0 0 0.4rem;
  font-size: 0.625rem;
  line-height: 1.4;
  color: var(--color-text-muted);
}

.home-heat-legend__rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-heat-legend__rows li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.12rem;
}

.home-heat-legend__rows li:last-child {
  margin-bottom: 0;
}

.home-heat-legend__swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 0.15rem;
  border: 1px solid rgba(120, 53, 15, 0.35);
  flex-shrink: 0;
}

.home-heat-legend__label {
  font-weight: 600;
}

@media (max-width: 639px) {
  .home-heat-legend-toggle {
    display: inline-flex;
    align-self: flex-end;
  }

  .home-heat-legend-stack .home-heat-legend-panel {
    max-height: 0;
    opacity: 0;
    padding: 0;
    margin-top: 0;
    overflow: hidden;
    border-width: 0;
    pointer-events: none;
    visibility: hidden;
    box-shadow: none;
    transition:
      max-height 0.28s ease,
      opacity 0.22s ease,
      padding 0.22s ease,
      border-width 0.18s ease,
      box-shadow 0.22s ease,
      visibility 0s linear 0.28s;
  }

  .home-heat-legend-stack--open .home-heat-legend-panel {
    max-height: 320px;
    opacity: 1;
    margin-top: 0.35rem;
    padding: 0.45rem 0.55rem 0.5rem;
    border-width: 1px;
    pointer-events: auto;
    visibility: visible;
    box-shadow:
      0 2px 10px rgba(15, 23, 42, 0.08),
      0 0 0 1px rgba(255, 255, 255, 0.6) inset;
    transition:
      max-height 0.28s ease,
      opacity 0.22s ease,
      padding 0.22s ease,
      border-width 0.18s ease,
      box-shadow 0.22s ease,
      visibility 0s linear 0s;
  }
}

@media (min-width: 640px) {
  .home-heat-legend-toggle {
    display: none !important;
  }

  .home-heat-legend-stack .home-heat-legend-panel {
    max-height: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    margin-top: 0 !important;
    border-width: 1px !important;
    padding: 0.45rem 0.55rem 0.5rem !important;
    box-shadow:
      0 2px 10px rgba(15, 23, 42, 0.08),
      0 0 0 1px rgba(255, 255, 255, 0.6) inset !important;
  }
}

.home-map-filters__actions {
  gap: 0.5rem;
}

@media (max-width: 639px) {
  .home-map-filters__actions {
    flex-direction: column;
    align-items: stretch;
  }

  #home-map-heat-toggle.home-map-filters__heat-toggle {
    width: 100%;
  }
}

#home-map-heat-toggle.is-heat-active {
  border-color: #c2410c;
  color: #9a3412;
  background: linear-gradient(180deg, rgba(254, 215, 170, 0.55), rgba(251, 146, 60, 0.2));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 2px 8px rgba(234, 88, 12, 0.18);
  font-weight: 700;
}

#home-map-heat-toggle:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
