/* ============================================================
   Public Map — popups, legend, markers, Leaflet overrides
   ============================================================ */

/* Remove default divIcon background/border */
.map-marker-icon {
  background: none !important;
  border: none !important;
}

/* ============================================================
   Cluster icons
   ============================================================ */

.map-cluster-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--tt-text, #222);
  color: var(--tt-bg, #fff);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  border: 2px solid var(--tt-bg, #fff);
  opacity: 0.9;
  transition: opacity 150ms ease, transform 150ms ease;
}

.map-cluster-icon:hover {
  opacity: 1;
  transform: scale(1.1);
}


/* ============================================================
   Popup styling
   ============================================================ */

.map-popup-container .leaflet-popup-content-wrapper {
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  padding: 0;
  overflow: hidden;
  background: var(--tt-bg, #fff);
}

.map-popup-container .leaflet-popup-content {
  margin: 0;
  min-width: 400px;
}

.map-popup-container .leaflet-popup-tip {
  background: var(--tt-bg, #fff);
}

[data-theme="dark"] .map-popup-container .leaflet-popup-content-wrapper {
  background: var(--tt-bg, #2f2f2f);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

[data-theme="dark"] .map-popup-container .leaflet-popup-tip {
  background: var(--tt-bg, #2f2f2f);
}

.map-popup-container .leaflet-popup-close-button {
  text-decoration: none !important;
  font-size: 1.4rem;
  color: var(--tt-text-muted, rgba(0,0,0,0.4));
  padding: 6px 8px;
  transition: color 150ms ease;
}

.map-popup-container .leaflet-popup-close-button:hover {
  color: var(--tt-text, #222);
}

[data-theme="dark"] .map-popup-container .leaflet-popup-close-button {
  color: rgba(255,255,255,0.4);
}

[data-theme="dark"] .map-popup-container .leaflet-popup-close-button:hover {
  color: var(--tt-text, #f5f5f5);
}

/* Popup content */
.map-popup {
  font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.map-popup-thumb {
  width: 100%;
  aspect-ratio: 3/2;
  overflow: hidden;
  background: var(--tt-bg-secondary, #f5f5f4);
}

.map-popup-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.map-popup-body {
  padding: 1rem 1rem 0.85rem;
}

.map-popup-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--tt-text, #222);
  line-height: 1.3;
  margin-bottom: 0.3rem;
}

.map-popup-meta {
  font-size: 0.82rem;
  color: var(--tt-text-muted, rgba(0,0,0,0.5));
  margin-bottom: 0.5rem;
}

.map-popup-private {
  font-size: 0.75rem;
  color: #f59e0b;
  font-style: italic;
  margin-bottom: 0.4rem;
}

.map-popup-link {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--tt-text-secondary, #464646);
  text-decoration: none !important;
  transition: color 150ms ease;
}

.map-popup-link:hover {
  color: var(--tt-text, #222);
}

/* ============================================================
   Hover tooltip (thumbnail + title)
   ============================================================ */

.map-tooltip {
  padding: 0 !important;
  border: none !important;
  border-radius: 3px !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2) !important;
  background: var(--tt-bg, #fff) !important;
  overflow: hidden;
}

.map-tooltip::before {
  border-top-color: var(--tt-bg, #fff) !important;
}

[data-theme="dark"] .map-tooltip {
  background: var(--tt-bg, #2f2f2f) !important;
}

[data-theme="dark"] .map-tooltip::before {
  border-top-color: var(--tt-bg, #2f2f2f) !important;
}

.map-tt {
  width: 160px;
}

.map-tt-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  image-rendering: auto;
}

.map-tt-title {
  display: block;
  padding: 6px 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--tt-text, #222);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ============================================================
   Grayscale map tiles
   ============================================================ */

.leaflet-tile-pane {
  filter: grayscale(0.5);
}

.leaflet-tile {
  outline: 1px solid transparent;
}

[data-theme="dark"] .leaflet-tile-pane {
  filter: grayscale(0.5) contrast(1.1) brightness(0.85);
}

/* ============================================================
   Leaflet control overrides (theme-aware)
   ============================================================ */

.leaflet-control-zoom a,
.leaflet-control-zoom a:hover {
  text-decoration: none;
}

[data-theme="dark"] .leaflet-control-zoom a {
  background-color: var(--tt-bg, #2f2f2f);
  color: var(--tt-text, #f5f5f5);
  border-color: var(--tt-border-strong, rgba(255,255,255,0.18));
}

[data-theme="dark"] .leaflet-control-attribution {
  background-color: rgba(47, 47, 47, 0.8);
  color: var(--tt-text-faint, rgba(255,255,255,0.35));
}

[data-theme="dark"] .leaflet-control-attribution a {
  color: var(--tt-text-muted, rgba(255,255,255,0.55));
}

/* ============================================================
   Mobile
   ============================================================ */

@media (max-width: 768px) {
  .map-popup-container .leaflet-popup-content {
    min-width: 240px;
  }

  .map-popup-thumb {
    aspect-ratio: 2/1;
  }

  .map-popup-body {
    padding: 0.7rem 0.8rem 0.6rem;
  }

  .map-popup-title {
    font-size: 0.95rem;
  }
}
