/* ===== Map Page Layout ===== */
#map-container {
  position: relative;
  height: calc(100vh - 62px);
}

#map {
  width: 100%;
  height: 100%;
  background: #1a2744;
}

/* ===== Filter Controls Panel ===== */
.map-controls {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  padding: 1.25rem;
  width: 240px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.map-controls h3 {
  font-family: 'Playfair Display', serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--gold);
}

.map-filter-options {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.map-filter-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
  padding: 0.2rem 0;
  transition: color var(--transition);
}

.map-filter-option:hover {
  color: var(--navy);
}

.map-filter-option input[type="checkbox"] {
  accent-color: var(--gold);
  flex-shrink: 0;
}

.color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.15);
}

/* ===== Legend-only item (non-interactive) ===== */
.map-legend-divider {
  border-top: 1px solid var(--parchment-dark);
  margin: 0.5rem 0;
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-light);
  padding: 0.2rem 0;
}

/* ===== Map Stats ===== */
.map-stats {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--parchment-dark);
  font-size: 0.8rem;
  color: var(--text-light);
  line-height: 1.5;
}

/* ===== Leaflet Popup Styling ===== */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2) !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  font-family: 'Source Sans 3', sans-serif !important;
  min-width: 200px;
}

.map-popup {
  padding: 1rem;
}

.map-popup-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.4rem;
}

.map-popup-count {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 0.6rem;
}

.map-popup-periods {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.map-popup-period {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-light);
}

.map-popup-period .color-swatch {
  width: 10px;
  height: 10px;
}

.map-popup-link {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  background: var(--navy);
  color: var(--white);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 500;
  transition: background var(--transition);
}

.map-popup-link:hover {
  background: var(--navy-light);
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
  #map-container {
    height: calc(100vh - 52px);
  }

  .map-controls {
    top: auto;
    bottom: 1rem;
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
    max-height: 40vh;
    padding: 1rem;
  }

  .map-controls h3 {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .map-controls h3::after {
    content: '\25B2';
    font-size: 0.6rem;
    transition: transform var(--transition);
  }

  .map-controls.collapsed h3::after {
    transform: rotate(180deg);
  }

  .map-controls.collapsed .map-filter-options,
  .map-controls.collapsed .map-stats {
    display: none;
  }
}
