/* ─── MAP PANEL ─────────────────────────────────────────── */
#mp {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--sea);
}
.map-wrap { width: 100%; height: 100%; position: relative; }
.map-svg { display: block; width: 100%; height: 100%; }

.map-loading {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  color: var(--ink3);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.map-loading-spin {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--ivory3);
  border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.country-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  fill: #1c0f06;
  paint-order: stroke;
  stroke: rgba(255,243,220,.78);
  stroke-width: 2.5px;
  letter-spacing: -.005em;
}
.country-label.small { font-size: 9px; font-weight: 500; }
.country-label.sel { font-size: 13px; font-weight: 700; stroke-width: 3.5px; }
body.theme-dark .country-label { fill: #f5ecd6; stroke: rgba(0,0,0,.5); }

.sea-label {
  fill: rgba(28, 58, 80, 0.72);
  font-style: italic;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: .03em;
}
body.theme-dark .sea-label { fill: rgba(160, 180, 195, .35); }
.sea-label-lg { font-size: 14px; letter-spacing: .1em; }
.sea-label-md { font-size: 11px; letter-spacing: .07em; }
.sea-label-sm { font-size: 9.5px; letter-spacing: .04em; }

/* Hover chip */
.hover-chip {
  position: absolute;
  pointer-events: none;
  bottom: 18px; left: 18px;
  background: rgba(20, 12, 6, 0.94);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.08);
  color: #f5ede0;
  padding: 10px 13px;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,.35);
  animation: chipIn 180ms ease;
  font-family: var(--font-ui);
  min-width: 180px;
}
@keyframes chipIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.hover-chip-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -.01em;
}
.hover-chip-meta {
  font-family: var(--font-display);
  font-size: 9.5px;
  color: rgba(245,237,224,.55);
  letter-spacing: .06em;
  margin-top: 3px;
  display: flex; align-items: center; gap: 6px;
  text-transform: uppercase;
}
.hover-chip-region { width: 8px; height: 8px; border-radius: 2px; }
.hover-chip-val {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-family: var(--font-display);
  font-size: 11px;
  color: #e8c779;
  display: flex; justify-content: space-between;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.hover-chip-val b { color: #fff; font-weight: 700; font-size: 13px; }

/* ─── LEGEND ────────────────────────────────────────────── */
#leg {
  position: absolute;
  top: 12px; left: 12px;
  display: flex; align-items: center; gap: 2px;
  background: color-mix(in oklab, var(--ivory) 90%, transparent);
  backdrop-filter: blur(14px);
  border: 1px solid var(--bdr);
  border-radius: 8px;
  padding: 4px 6px 4px 10px;
  box-shadow: 0 4px 14px rgba(0,0,0,.10);
  z-index: 5;
  max-width: calc(100% - 24px);
}
.lt {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--ink4);
  padding-right: 8px;
  margin-right: 4px;
  border-right: 1px solid var(--bdr);
  white-space: nowrap;
}
.li {
  display: flex; align-items: center; gap: 6px;
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 4px 7px;
  cursor: pointer;
  transition: background 150ms, border-color 150ms;
}
.li:hover { background: color-mix(in oklab, var(--sand) 35%, transparent); }
.li-active {
  background: color-mix(in oklab, var(--accent) 12%, transparent);
  border-color: color-mix(in oklab, var(--accent) 30%, transparent);
}
.li-clear {
  color: var(--ink3);
  font-family: var(--font-display);
  font-size: 11px;
  padding: 4px 7px;
  margin-left: 4px;
}
.ls { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0;
      box-shadow: 0 0 0 1px rgba(255,255,255,.5) inset; }
.ll { font-size: 11px; font-weight: 500; color: var(--ink2); white-space: nowrap; }
.lc {
  font-family: var(--font-display);
  font-size: 9.5px;
  color: var(--ink4);
  background: color-mix(in oklab, var(--ink) 6%, transparent);
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: .04em;
}

@media (max-width: 860px) {
  /* On narrow screens the region legend (title + up to 5 chips) is wider
     than the map, and its parent (#mp) clips overflow — so without this,
     part of it was silently cut off with no way to reach it. Scrolling
     matches the pattern already used for the toolbar. */
  #leg {
    overflow-x: auto;
    scrollbar-width: none;
  }
  #leg::-webkit-scrollbar { display: none; }
  .lt, .li, .li-clear { flex-shrink: 0; }
}

/* Indicator chooser on the map */
#indpick {
  position: absolute;
  top: 12px; right: 12px;
  background: color-mix(in oklab, var(--ivory) 90%, transparent);
  backdrop-filter: blur(14px);
  border: 1px solid var(--bdr);
  border-radius: 8px;
  padding: 7px 10px 7px 12px;
  z-index: 5;
  box-shadow: 0 4px 14px rgba(0,0,0,.10);
  display: flex; align-items: center; gap: 10px;
}
.indpick-lbl {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--ink4);
}
.indpick-sel {
  background: var(--ivory);
  border: 1px solid var(--bdr2);
  border-radius: 5px;
  padding: 4px 24px 4px 8px;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M3 5l3 3 3-3' stroke='%23877' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 10px;
}

/* Choropleth swatch strip */
#chropleg {
  position: absolute;
  bottom: 62px; right: 14px;
  background: color-mix(in oklab, var(--ivory) 95%, transparent);
  border: 1px solid var(--bdr);
  border-radius: 8px;
  padding: 9px 12px;
  z-index: 5;
  box-shadow: 0 4px 14px rgba(0,0,0,.10);
  min-width: 220px;
}
.chl-title {
  font-family: var(--font-display);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--ink4);
  margin-bottom: 6px;
}
.chl-strip {
  display: flex; height: 8px; border-radius: 2px; overflow: hidden;
  border: 1px solid var(--bdr);
}
.chl-stop { flex: 1; }
.chl-bounds {
  display: flex; justify-content: space-between;
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 9.5px;
  color: var(--ink3);
}

/* Map zoom control */
#zctl {
  position: absolute;
  bottom: 14px; left: 14px;
  display: flex; flex-direction: column;
  background: color-mix(in oklab, var(--ivory) 95%, transparent);
  border: 1px solid var(--bdr);
  border-radius: 6px;
  overflow: hidden;
  z-index: 5;
  box-shadow: 0 4px 14px rgba(0,0,0,.10);
}
.zb {
  width: 28px; height: 28px;
  background: none; border: none;
  color: var(--ink2);
  cursor: pointer;
  font-size: 15px;
  border-bottom: 1px solid var(--bdr);
  transition: background 150ms;
}
.zb:last-child { border-bottom: none; }
.zb:hover { background: var(--ivory3); }
.zb-reset { font-family: var(--font-display); font-size: 9.5px; text-transform: uppercase; letter-spacing: .04em; }

/* Map download-data button (bottom-right) */
.map-dl {
  position: absolute;
  bottom: 14px; right: 14px;
  z-index: 6;
  display: flex; align-items: center; gap: 9px;
  padding: 9px 14px 9px 12px;
  background: color-mix(in oklab, var(--ivory) 95%, transparent);
  border: 1px solid var(--bdr);
  border-radius: 7px;
  color: var(--ink2);
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.10);
  transition: border-color 150ms, color 150ms, background 150ms, transform 150ms;
}
.map-dl:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.map-dl:active { transform: translateY(0); }
.map-dl svg { display: block; }
.map-dl .map-dl-x {
  font-family: var(--font-display);
  font-size: 8px; font-weight: 600;
  letter-spacing: .12em;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
}
body.theme-dark .map-dl .map-dl-x { color: #1c140c; }

/* Hint */
.hint {
  position: absolute;
  bottom: 18px;
  left: 50%; transform: translateX(-50%);
  background: rgba(20, 12, 6, .88);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.06);
  color: rgba(245,237,224,.85);
  padding: 8px 16px 8px 12px;
  border-radius: 100px;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.2);
  pointer-events: none;
  animation: hintIn 400ms ease;
}
@keyframes hintIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.hint-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 25%, transparent);
  animation: hintPulse 1.8s ease-in-out infinite;
}
@keyframes hintPulse {
  0%,100% { box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 25%, transparent); }
  50% { box-shadow: 0 0 0 7px color-mix(in oklab, var(--accent) 0%, transparent); }
}