html, body { height: 100%; }

body.map-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.map-header .wrap {
  padding-top: 12px;
  padding-bottom: 12px;
}

.map-main {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex; /* map + panel share the row side-by-side, not overlaid */
  overflow: hidden;
}

#map {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
}

/* MapLibre attribution tidy-up */
.maplibregl-ctrl-bottom-right { font-size: 11px; }

/* Search box */
.map-search {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
  width: min(320px, calc(100vw - 32px));
}

.map-search input {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14.5px;
  font-family: "Inter", sans-serif;
  background: var(--color-surface);
  box-shadow: 0 2px 10px rgba(43, 36, 32, 0.08);
  outline: none;
}

.map-search input:focus {
  border-color: var(--color-primary);
}

.map-search-results {
  margin-top: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(43, 36, 32, 0.1);
  overflow: hidden;
  display: none;
}

.map-search-results.open { display: block; }

.map-search-result {
  padding: 9px 14px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-search-result:hover { background: var(--color-bg); }

.map-search-result .muted { color: var(--color-muted); font-size: 12.5px; }

/* Bubble markers */
.map-bubble {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}

.map-bubble-photo {
  width: var(--bubble-size, 46px);
  height: var(--bubble-size, 46px);
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  border: 3px solid var(--color-primary);
  box-shadow: 0 2px 8px rgba(43, 36, 32, 0.28);
  transition: width 0.15s ease-out, height 0.15s ease-out, transform 0.15s ease;
}

.map-bubble-country .map-bubble-photo {
  width: calc(var(--bubble-size, 46px) * 1.18);
  height: calc(var(--bubble-size, 46px) * 1.18);
  border-color: var(--color-accent);
}

.map-bubble-continent .map-bubble-photo {
  width: calc(var(--bubble-size, 46px) * 1.5);
  height: calc(var(--bubble-size, 46px) * 1.5);
  border-color: var(--color-primary-dark);
  border-width: 4px;
}

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

.map-bubble:hover .map-bubble-photo {
  transform: scale(1.1);
}

.map-bubble-label {
  margin-top: 4px;
  font-size: clamp(10.5px, calc(var(--bubble-size, 46px) / 4.6), 15px);
  font-weight: 600;
  color: var(--color-text);
  background: rgba(251, 247, 240, 0.92);
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(43, 36, 32, 0.12);
  transition: font-size 0.15s ease-out;
}

/* Legend */
.map-legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 5;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--color-muted);
  box-shadow: 0 2px 10px rgba(43, 36, 32, 0.08);
  display: flex;
  gap: 14px;
}

.map-legend .item { display: flex; align-items: center; gap: 6px; }

.map-legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.map-legend .swatch.country { background: var(--color-accent); }
.map-legend .swatch.city { background: var(--color-primary); }

/* Side panel (desktop) / bottom sheet (mobile).
   Desktop: a real flex sibling of #map that expands/collapses its own
   width, so the map is resized to the remaining space rather than
   sitting underneath an overlay. */
.map-panel {
  position: relative;
  height: 100%;
  width: 0;
  max-width: 90vw;
  flex-shrink: 0;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: -6px 0 20px rgba(43, 36, 32, 0.08);
  z-index: 6;
  overflow: hidden;
  transition: width 0.25s ease;
}

.map-panel.open { width: 360px; }

.map-panel .map-panel-inner {
  width: 360px; /* fixed so content doesn't reflow while the panel animates */
  height: 100%;
  overflow-y: auto;
}

.map-panel-inner { padding: 20px; }

.map-panel-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  color: var(--color-muted);
}

.map-panel-close:hover { color: var(--color-text); }

.map-panel-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: #fff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.map-panel-photo img {
  width: 88%;
  height: 88%;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.map-panel-eyebrow {
  font-size: 13px;
  color: var(--color-muted);
  margin-bottom: 4px;
}

.map-panel h2 {
  font-size: 22px;
  margin-bottom: 6px;
}

.map-panel .product-name {
  font-weight: 600;
  color: var(--color-primary-dark);
  font-size: 15.5px;
  margin: 0 0 8px;
}

.map-panel .product-blurb {
  color: var(--color-muted);
  font-size: 14px;
  margin: 0 0 18px;
}

.map-panel-country-list {
  display: grid;
  gap: 8px;
}

.map-panel-country-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  width: 100%;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--color-text);
}

.map-panel-country-list button:hover { border-color: var(--color-primary); }

/* Back-to-list link (shown on single-item and country detail views) */
.map-panel-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
  cursor: pointer;
  padding: 0 0 14px;
  margin: 0;
}

.map-panel-back:hover { color: var(--color-primary-dark); }

/* All-places list */
.map-list-header { margin-bottom: 14px; }

.map-list-header h2 { font-size: 19px; margin-bottom: 3px; }

.map-list-header .section-note { font-size: 13px; margin: 0; }

.map-list-group { margin-bottom: 18px; }

.map-list-group > h3 {
  font-family: "Inter", sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  margin: 0 0 8px;
}

.map-list-group .cities { padding: 0; gap: 8px; }

.map-list-card {
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.map-list-card:hover { border-color: var(--color-primary); }

/* Drag handle (mobile only) */
.map-panel-handle {
  display: none;
}

@media (max-width: 640px) {
  .map-panel-handle {
    display: block;
    width: 100%;
    padding: 10px 0 6px;
    border: none;
    background: none;
    cursor: pointer;
  }

  .map-panel-handle::after {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    margin: 0 auto;
    border-radius: 999px;
    background: var(--color-border);
  }

  .map-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 40vh;
    border-left: none;
    border-top: 1px solid var(--color-border);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    box-shadow: 0 -6px 20px rgba(43, 36, 32, 0.12);
    transition: transform 0.25s ease, max-height 0.25s ease;
    display: flex;
    flex-direction: column;
    overflow-y: hidden;
  }
  .map-panel.open { width: 100%; transform: translateY(0); }
  .map-panel.expanded { max-height: 60vh; }
  .map-panel .map-panel-inner { width: 100%; overflow-y: auto; flex: 1; min-height: 0; }
  .map-legend { display: none; }
}
