/* ============================================================
   legend.css — Map legend floating panel
   ============================================================ */

.legend {
  position: absolute;
  bottom: 24px;
  left: 16px;
  z-index: 50;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
  padding: 12px 16px;
  min-width: 160px;
  max-width: 220px;
  transition: opacity 0.3s;
}

.legend__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.legend__title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--color-text-muted);
}

.legend__toggle-all {
  font-size: 11px;
  color: var(--color-primary);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-family);
  padding: 0;
  font-weight: 500;
}

.legend__toggle-all:hover {
  text-decoration: underline;
}

.legend__items {
  list-style: none;
  padding: 0;
  margin: 0;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  transition: opacity 0.2s;
  user-select: none;
}

.legend__item:hover {
  opacity: 0.8;
}

.legend__item--hidden {
  opacity: 0.35;
}

.legend__swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid transparent;
}

.legend__item--hidden .legend__swatch {
  background: #ccc !important;
}

.legend__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
}

.legend__count {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-left: auto;
}

/* --- Divider between properties and annotations --- */
.legend__divider {
  border-top: 1px solid var(--color-border);
  margin: 6px 0;
}

/* --- Annotation swatch shapes --- */
.legend__swatch--star {
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  border-radius: 0;
}

.legend__swatch--diamond {
  transform: rotate(45deg);
  border-radius: 2px;
  width: 10px;
  height: 10px;
}

.legend__swatch--line {
  width: 18px;
  height: 3px;
  border-radius: 2px;
}

.legend__swatch--polygon {
  border-radius: 2px;
  opacity: 0.7;
}

.legend__swatch--label {
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  width: 14px;
  height: 14px;
}

/* --- Mobile: collapsible --- */
@media (max-width: 768px) {
  .legend {
    bottom: 12px;
    left: 8px;
    padding: 8px 12px;
    min-width: auto;
  }

  .legend--collapsed .legend__items,
  .legend--collapsed .legend__toggle-all {
    display: none;
  }

  .legend--collapsed {
    min-width: auto;
    padding: 8px 12px;
    cursor: pointer;
  }
}
