/* ── Override readme-container for the map page ─────────────────────────────── */
.readme-container {
  overflow: visible;
  max-width: 100%;
}

/* ── Layout wrapper ────────────────────────────────────────────────────────── */
.map-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

/* ── Map container ─────────────────────────────────────────────────────────── */
#map {
  width: 100%;
  height: 62vh;
  min-height: 300px;
  border: 2px solid var(--border-color);
  background: var(--bg-main);
  flex-shrink: 0;
}

/* ── Sidebar area (wraps toggle + panel) ───────────────────────────────────── */
.sidebar-area {
  width: 100%;
}

/* ── Sidebar toggle button (visible on mobile only) ────────────────────────── */
.sidebar-toggle {
  display: flex;
  width: 100%;
  min-height: 44px;
  padding: 0.75rem 1rem;
  border-radius: 0;
  border: 2px solid var(--border-color);
  border-top: none;
  gap: 0.5rem;
  flex: none;
  text-align: left;
  justify-content: flex-start;
}

/* ── Sidebar panel ─────────────────────────────────────────────────────────── */
.map-panel {
  width: 100%;
  box-sizing: border-box;
  padding: 0 12px;
  border: 2px solid var(--border-color);
  border-top: none;
  background: var(--bg-container);
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.35s ease, padding 0.35s ease;
}

.map-panel.is-open {
  max-height: 2000px;
  padding: 12px;
}

.map-panel h2 {
  margin-top: 0;
  font-size: 0.85rem;
  border-bottom-color: var(--border-color);
}

/* ── Filter buttons ────────────────────────────────────────────────────────── */
.filter {
  width: 100%;
  margin: 5px 0;
  text-align: left;
  min-height: 44px;
  flex: none;
}

.filter--active {
  background: var(--accent-blue-bright);
  color: var(--bg-main);
  outline: 2px solid var(--accent-blue);
}

/* ── Small note ────────────────────────────────────────────────────────────── */
.small-note {
  margin-top: 12px;
  font-size: 11px;
  opacity: 0.7;
  line-height: 1.5;
}

.filter-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 6px 0;
  min-height: 44px;
}

/* ── Custom marker bubble ──────────────────────────────────────────────────── */
.map-marker {
  background: none;
  border: none;
}

.map-marker__bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  font-size: 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.map-marker__bubble > * {
  transform: rotate(45deg);
}

.map-marker:hover .map-marker__bubble {
  transform: rotate(-45deg) scale(1.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

/* ── POI popup ─────────────────────────────────────────────────────────────── */

/* Theme the Leaflet popup container so CSS vars work correctly */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--popup-bg) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-secondary) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35) !important;
}

/* Prevent popups from overflowing small screens */
.leaflet-container .leaflet-popup-content-wrapper {
  max-width: min(260px, 90vw);
}

.poi-popup {
  font-family: 'Hooge 05_55 Cyr', monospace;
  min-width: 160px;
}

.poi-popup__name {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.poi-popup__desc {
  margin: 4px 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.poi-popup__cat {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.75rem;
  opacity: 0.75;
  color: var(--text-quote);
}

/* ── Popup feature rows ─────────────────────────────────────────────────────── */
.poi-popup__features {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.poi-feat {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.poi-feat__icon {
  width: 1.2em;
  text-align: center;
  flex-shrink: 0;
}

.poi-feat__val {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-primary);
}

/* ── Safety score colours ───────────────────────────────────────────────────── */
.safety-score {
  font-weight: bold;
  padding: 1px 5px;
  border-radius: 3px;
}

.safety-high {
  background: #2d6a35;
  color: #b7f5bc;
}

.safety-mid {
  background: #6b4f00;
  color: #ffe08a;
}

.safety-low {
  background: #6b1f1f;
  color: #ffb3b3;
}

/* ── Desktop: 1024px+ ───────────────────────────────────────────────────────── */
@media (min-width: 1024px) {
  .map-wrapper {
    flex-direction: row;
    gap: 15px;
    padding: 1rem;
  }

  /* Move sidebar-area to the left of the map */
  .sidebar-area {
    order: -1;
    width: 240px;
    flex-shrink: 0;
  }

  #map {
    flex: 1;
    height: 75vh;
    min-height: 400px;
  }

  .sidebar-toggle {
    display: none;
  }

  /* Sidebar always expanded on desktop */
  .map-panel {
    max-height: 75vh;
    overflow: auto;
    padding: 12px;
    border: 2px solid var(--border-color);
    transition: none;
  }
}

/* ── Tablet tweaks ──────────────────────────────────────────────────────────── */
@media (min-width: 600px) and (max-width: 1023px) {
  #map {
    height: 65vh;
  }

  .filter {
    min-height: 38px;
  }
}
