/* =====================================================================
 * Layer panel · Legend · Basemap switcher  (premium light theme v2)
 * ===================================================================== */

/* ================================================================== */
/* Layer panel  (left sidebar)                                         */
/* ================================================================== */

.mp-layer-panel {
  position: absolute; left: 16px; top: 70px; z-index: 20;
  width: 400px;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 130px);
  display: none;
  flex-direction: column;
  background: var(--surface-strong);
  color: var(--text-strong);
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-glass);
  overflow: hidden;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  transform-origin: top left;
  animation: panelIn .25s ease;
}
.mp-layer-panel.is-open { display: flex; }
@keyframes panelIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

.is-dark .mp-layer-panel {
  background: rgba(15, 30, 55, .88);
  color: #e9eef7;
  border-color: rgba(255,255,255,.08);
}

/* Reopen tab when collapsed */
.mp-panel-reopen {
  position: absolute; left: 14px; top: 70px; z-index: 30;
  width: 36px; height: 36px;
  border: 1px solid var(--border-soft); padding: 0;
  display: none;
  align-items: center; justify-content: center;
  background: var(--surface-strong);
  color: var(--c-700);
  border-radius: 10px;
  box-shadow: var(--shadow-glass);
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.mp-panel-reopen:hover { background: #fff; transform: translateX(2px); }
.mp-panel-reopen.is-visible { display: inline-flex; }
.is-dark .mp-panel-reopen { background: rgba(15,30,55,.88); color: #fff; border-color: rgba(255,255,255,.08); }

/* Header */
.mp-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  background: transparent;
  color: var(--text-strong);
  border-bottom: 1px solid var(--border-soft);
}
.mp-panel-head-l { display: flex; align-items: center; gap: 10px; }
.mp-panel-head-l > .mp-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--c-50);
  color: var(--c-600);
  display: inline-flex; align-items: center; justify-content: center;
}
.mp-panel-eyebrow {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .2em;
  color: var(--text-muted);
  margin-bottom: 1px;
}
.mp-panel-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text-strong);
  letter-spacing: -.005em;
}
.is-dark .mp-panel-head { border-color: rgba(255,255,255,.08); }
.is-dark .mp-panel-title { color: #fff; }
.is-dark .mp-panel-head-l > .mp-icon { background: rgba(255,255,255,.06); color: #c8d3e3; }

/* Search */
.mp-panel-search {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.is-dark .mp-panel-search { border-color: rgba(255,255,255,.06); }

.mp-search-wrap {
  position: relative; flex: 1;
}
.mp-search-wrap > .mp-icon {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.mp-search-input {
  width: 100%;
  padding: 7px 10px 7px 28px;
  font: 500 12px var(--font);
  background: var(--c-50);
  color: var(--text-strong);
  border: 1px solid transparent;
  border-radius: 8px;
  outline: none;
  transition: border-color .15s ease, background .15s ease;
}
.mp-search-input::placeholder { color: var(--text-muted); }
.mp-search-input:focus {
  border-color: var(--c-300);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(63, 123, 182, .12);
}
.is-dark .mp-search-input {
  background: rgba(255,255,255,.06); color: #fff;
}
.is-dark .mp-search-input::placeholder { color: #8a99b1; }
.is-dark .mp-search-input:focus { background: rgba(255,255,255,.1); border-color: var(--c-500); }

/* Body */
.mp-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
}
.mp-empty {
  text-align: center; padding: 24px;
  color: var(--text-muted); font-size: 11px;
}

/* Group row */
.mp-group { margin-bottom: 12px; }
.mp-group:last-child { margin-bottom: 0; }
.mp-group-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background .15s ease;
}
.mp-group-head:hover { background: var(--c-50); }
.is-dark .mp-group-head:hover { background: rgba(255,255,255,.04); }
.mp-group-label {
  flex: 1;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--text-soft);
}
.is-dark .mp-group-label { color: #c8d3e3; }
.mp-group-count {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  background: var(--c-50);
  border-radius: 9999px;
}
.is-dark .mp-group-count { background: rgba(255,255,255,.06); color: #c8d3e3; }

.mp-chevron-btn {
  width: 18px; height: 18px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  transition: color .15s, background .15s;
}
.mp-chevron-btn:hover { color: var(--c-700); background: rgba(15,35,65,.06); }
.mp-chevron-btn.small { width: 16px; height: 16px; }
.is-dark .mp-chevron-btn:hover { color: #fff; background: rgba(255,255,255,.08); }

/* ----------- Custom GIS toggle switch (theme-isolated) -----------
 * All selectors are namespaced under `.mp-app` so WordPress / theme
 * checkbox or button rules can never override them.
 * The element is a <button>, but we still hard-reset every inheritable
 * surface property to neutralise theme styles. */
.mp-app .mp-cb,
.mp-app .mp-cb:hover,
.mp-app .mp-cb:focus,
.mp-app .mp-cb:active {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 42px;
  height: 22px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(15, 35, 65, .18);
  border-radius: 9999px;
  background: #e5edf6;
  background-image: none;
  cursor: pointer;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(15, 35, 65, .12);
  transition: background-color .25s ease, border-color .25s ease, box-shadow .25s ease;
  vertical-align: middle;
  text-align: left;
  line-height: 1;
  font: inherit;
  color: transparent;
  -webkit-tap-highlight-color: transparent;
}
.mp-app .mp-cb:focus-visible {
  box-shadow: inset 0 1px 2px rgba(15, 35, 65, .12),
              0 0 0 3px rgba(63, 123, 182, .25);
}

/* Sliding thumb (always renders, regardless of theme) */
.mp-app .mp-cb::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 2px;
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 9999px;
  background: #ffffff;
  background-image: linear-gradient(180deg, #ffffff 0%, #f3f7fc 100%);
  box-shadow: 0 1px 2px rgba(15, 35, 65, .25), 0 0 0 1px rgba(15, 35, 65, .04);
  transform: translateY(-50%);
  transition: left .25s ease, background .25s ease, box-shadow .25s ease;
  pointer-events: none;
}
.mp-app .mp-cb::after { content: none; }       /* defeat theme ::after */

/* Hide any inner SVG / mixed marker that the JS appends */
.mp-app .mp-cb > * { display: none !important; }
.mp-app .mp-cb svg,
.mp-app .mp-cb .mp-mixed { display: none !important; }

/* ON state — ONHYM brand gradient + soft glow */
.mp-app .mp-cb.on {
  background: linear-gradient(135deg, #2f86c8 0%, #1a5a99 50%, #194878 100%);
  border-color: rgba(15, 35, 65, .22);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .25),
              0 0 0 1px rgba(63, 123, 182, .15),
              0 0 10px rgba(63, 123, 182, .35);
}
.mp-app .mp-cb.on::before {
  left: 22px;
  box-shadow: 0 2px 4px rgba(15, 35, 65, .3), 0 0 0 1px rgba(15, 35, 65, .04);
}

/* MIXED (indeterminate) — half slide, soft accent */
.mp-app .mp-cb.mixed {
  background: #c8d8ec;
  border-color: rgba(15, 35, 65, .18);
  box-shadow: inset 0 1px 2px rgba(15, 35, 65, .15);
}
.mp-app .mp-cb.mixed::before { left: 12px; }

/* Hover */
.mp-app .mp-cb:hover { border-color: rgba(15, 35, 65, .28); }
.mp-app .mp-cb.on:hover {
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .25),
              0 0 0 1px rgba(63, 123, 182, .25),
              0 0 14px rgba(63, 123, 182, .45);
}

/* Dark mode variant */
.mp-app.is-dark .mp-cb {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .14);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35);
}
.mp-app.is-dark .mp-cb.on {
  background: linear-gradient(135deg, #3f8fd0 0%, #235e9a 60%, #102e54 100%);
  border-color: rgba(63, 123, 182, .5);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35),
              0 0 12px rgba(63, 123, 182, .45);
}

/* Leaf rows */
.mp-leaf-list {
  list-style: none;
  margin: 6px 0 0 26px;
  padding: 0 0 0 14px;
  border-left: 1px solid var(--border-soft);
}
.is-dark .mp-leaf-list { border-color: rgba(255,255,255,.08); }
.mp-leaf { margin-bottom: 2px; }
.mp-leaf-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background .15s ease;
}
.mp-leaf-row:hover { background: var(--c-50); }
.is-dark .mp-leaf-row:hover { background: rgba(255,255,255,.04); }
.mp-leaf-dot {
  width: 8px; height: 8px;
  border-radius: 9999px;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--border-strong);
  flex-shrink: 0;
}
.is-dark .mp-leaf-dot { box-shadow: 0 0 0 2px var(--c-900), 0 0 0 3px rgba(255,255,255,.15); }
.mp-leaf-label {
  flex: 1;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-strong);
  letter-spacing: -.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.is-dark .mp-leaf-label { color: #e9eef7; }
.mp-leaf-row > .mp-icon { color: var(--text-muted); }
.mp-spacer { display: inline-block; width: 16px; height: 16px; }

/* Opacity slider */
.mp-opa-row {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 12px 10px 50px;
}
.mp-opa-label {
  width: 32px;
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--text-muted);
}
.mp-opa-row input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 14px;
  outline: none;
  cursor: pointer;
}
.mp-opa-row input[type=range]::-webkit-slider-runnable-track {
  height: 3px;
  background: var(--c-100);
  border-radius: 9999px;
}
.mp-opa-row input[type=range]::-moz-range-track {
  height: 3px;
  background: var(--c-100);
  border-radius: 9999px;
}
.mp-opa-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px; height: 12px;
  margin-top: -4.5px;
  border-radius: 9999px;
  background: #fff;
  border: 2px solid var(--c-600);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(15,35,65,.18);
}
.mp-opa-row input[type=range]::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 9999px;
  background: #fff;
  border: 2px solid var(--c-600);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(15,35,65,.18);
}
.mp-opa-pct {
  width: 30px; text-align: right;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-soft);
}
.is-dark .mp-opa-row input[type=range]::-webkit-slider-runnable-track { background: rgba(255,255,255,.12); }
.is-dark .mp-opa-row input[type=range]::-moz-range-track { background: rgba(255,255,255,.12); }

/* Inline mini-legend per leaf */
.mp-leaf-legend {
  list-style: none;
  margin: 4px 12px 8px 50px;
  padding: 8px 12px;
  background: var(--c-50);
  border-radius: 8px;
}
.mp-leaf-legend li {
  display: flex; align-items: center; gap: 10px;
  font-size: 11.5px;
  color: var(--text-soft);
  padding: 3px 0;
}
.is-dark .mp-leaf-legend { background: rgba(255,255,255,.04); }
.is-dark .mp-leaf-legend li { color: #c8d3e3; }
.mp-leaf-sym { display: inline-flex; width: 14px; height: 14px; }
.mp-leaf-code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 1px 5px;
  background: rgba(15,35,65,.06);
  border-radius: 4px;
}
.is-dark .mp-leaf-code { background: rgba(255,255,255,.06); color: #c8d3e3; }

/* Footer */
.mp-panel-foot {
  padding: 12px 18px;
  background: transparent;
  border-top: 1px solid var(--border-soft);
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mp-panel-foot .mp-attrib {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: 10px;
  color: var(--text-muted);
}
.mp-panel-foot .mp-attrib a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}
.mp-panel-foot .mp-attrib a:hover { color: var(--c-700); }
.is-dark .mp-panel-foot { border-color: rgba(255,255,255,.06); }

/* ================================================================== */
/* Legend (bottom-right card)                                          */
/* ================================================================== */
.mp-legend {
  position: absolute; bottom: 76px; right: 14px; z-index: 20;
  width: 252px;
  display: none;
  background: var(--surface-strong);
  color: var(--text-strong);
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-glass);
  overflow: hidden;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  animation: legendIn .25s ease;
}
.mp-legend.is-open { display: block; }
@keyframes legendIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.is-dark .mp-legend {
  background: rgba(15, 30, 55, .88); color: #e9eef7;
  border-color: rgba(255,255,255,.08);
}
.mp-legend-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 10px;
  background: transparent;
  color: var(--text-strong);
  border-bottom: 1px solid var(--border-soft);
}
.mp-legend-title {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .18em;
  color: var(--text-soft);
}
.is-dark .mp-legend-head { border-color: rgba(255,255,255,.06); }
.is-dark .mp-legend-title { color: #c8d3e3; }
.mp-legend-body {
  padding: 12px;
  max-height: 56vh;
  overflow-y: auto;
}
.mp-legend-sec { margin-bottom: 14px; }
.mp-legend-sec:last-child { margin-bottom: 0; }
.mp-legend-sec-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.mp-legend-sec-dot { width: 8px; height: 8px; border-radius: 9999px; }
.mp-legend-sec-title {
  font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .14em;
  color: var(--text-soft);
}
.is-dark .mp-legend-sec-title { color: #c8d3e3; }
.mp-legend-list {
  list-style: none;
  margin: 0 0 0 4px;
  padding: 0;
}
.mp-legend-list li {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 0;
  color: var(--text-strong);
}
.is-dark .mp-legend-list li { color: #e9eef7; }
.mp-legend-sym { display: inline-flex; width: 16px; height: 16px; }
.mp-legend-code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 1px 5px;
  background: rgba(15,35,65,.06);
  border-radius: 4px;
}
.is-dark .mp-legend-code { background: rgba(255,255,255,.06); color: #c8d3e3; }
.mp-legend-swatch {
  display: inline-block;
  width: 16px; height: 12px;
  border-radius: 3px;
}
.mp-legend-dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 9999px;
}


