/* ============================================================
   地图页样式
   ============================================================ */

.map-page {
  display: grid;
  grid-template-columns: 288px 1fr;
  gap: 14px;
  align-items: start;
}

/* ── 左侧筛选栏 ── */
.map-side {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  max-height: calc(100dvh - 130px);
  overflow-y: auto;
}
.ms-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.ms-head h2 {
  margin: 0;
  font-size: 20px;
}
.ms-block {
  margin-bottom: 14px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--border);
}
.ms-block:last-child { border-bottom: 0; margin-bottom: 0; }
.ms-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 7px;
  letter-spacing: 0.4px;
}

/* 收集进度 */
.ms-progress {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}
.ms-progress i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #10b981, #34d399);
  border-radius: 999px;
  transition: width 0.3s;
}
.ms-progress-txt { font-size: 11.5px; margin-top: 5px; }

.ms-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.mini {
  flex: 1 1 auto;
  padding: 5px 8px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}
.mini:hover { background: rgba(255, 255, 255, 0.1); color: var(--ink); }
.mini.on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

/* 预设 */
.ms-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.preset {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 8px 9px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  text-align: left;
  transition: background 0.16s, border-color 0.16s, transform 0.16s;
}
.preset b { font-size: 13px; color: var(--ink); }
.preset .muted { font-size: 10.5px; }
.preset:hover { background: rgba(255, 255, 255, 0.1); transform: translateY(-1px); }
.preset.on {
  background: linear-gradient(135deg, rgba(109, 124, 255, 0.34), rgba(16, 185, 129, 0.24));
  border-color: var(--brand);
}

/* 搜索与选择 */
.ms-search {
  width: 100%;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  font-size: 13px;
}
.ms-search:focus { outline: none; border-color: var(--brand); }
.ms-select {
  width: 100%;
  padding: 7px 9px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  font-size: 12.5px;
}
.ms-select:focus { outline: none; border-color: var(--brand); }

/* 类别折叠 */
.ms-class {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 6px 7px;
  margin-bottom: 2px;
  transition: background 0.16s;
}
.ms-class:hover { background: rgba(255, 255, 255, 0.04); }
.ms-class.on { background: rgba(109, 124, 255, 0.14); border-color: rgba(109, 124, 255, 0.34); }
.ms-class-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: 13px;
}
.ms-class-hd b { font-weight: 600; }
.ms-genres {
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.ms-class.on .ms-genres { display: flex; }
.mg {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.mg i { font-style: normal; opacity: 0.6; font-size: 10px; }
.mg:hover { background: rgba(255, 255, 255, 0.12); color: var(--ink); }
.mg.on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* ── 地图主区 ── */
.map-main { position: relative; }
.map-canvas {
  position: relative;
  width: 100%;
  /* 地图 bounds 为正方形，容器保持 1:1 才能让点位与底图精确对齐 */
  aspect-ratio: 1 / 1;
  /* 浅色主题：地图底图未加载时用浅灰白，不再是深蓝 */
  background: #f4f7fb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.map-canvas.dragging { cursor: grabbing; }

/* 底图与点位层共用的定位 */
.map-tiles,
.map-points {
  position: absolute;
  inset: 0;
  transform-origin: center center;
}

/* 地底瓦片网格 */
.mtile-grid {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 0;
}
.mtile-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 底图整图
   注意：地图 bounds 为正方形（408000×408000），canvas 也是正方形，
   所以这里必须保持正方形且铺满，否则点位会与底图错位。 */
.map-base {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill; /* 不裁剪、不留边，保证与 bounds 精确对应 */
  display: block;
}

/* 区域多边形层 */
.map-region-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.map-region {
  fill: rgba(255, 255, 255, 0.04);
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 0.12;
  vector-effect: non-scaling-stroke;
  pointer-events: auto;
  cursor: help;
  transition: fill 0.15s;
}
.map-region:hover { fill: rgba(109, 124, 255, 0.28); stroke: rgba(160, 175, 255, 0.7); }

/* 点位 */
.mp-dot {
  position: absolute;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.14s;
}
.mp-dot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.7));
  pointer-events: none;
}
.mp-dot:hover { transform: scale(1.5); z-index: 5; }
.mp-dot.done { opacity: 0.34; filter: grayscale(0.7); }
.mp-dot.done::after {
  content: '';
  position: absolute;
  inset: -2px;
  border: 1.5px solid rgba(52, 211, 153, 0.7);
  border-radius: 50%;
}
/* 聚合点：显示数量而非图标 */
.mp-dot.agg {
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  background: rgba(59, 71, 201, 0.16);
  border: 1px solid rgba(59, 71, 201, 0.4);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  color: #1e3a8a;
}
.mp-dot.agg i {
  font-style: normal;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.mp-dot.agg:hover {
  background: rgba(109, 124, 255, 0.5);
}

/* 聚合点弹窗里的清单 */
.mpc-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mpc-li {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 7px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 12.5px;
}
.mpc-li img { width: 17px; height: 17px; object-fit: contain; flex: 0 0 auto; }
.mpc-li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mpc-li em { font-style: normal; font-size: 11px; color: var(--muted); }

/* 图例 */
.map-legend {
  position: absolute;
  right: 10px;
  top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 62%;
  overflow-y: auto;
  background: rgba(10, 14, 26, 0.78);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px;
  z-index: 6;
}
.lg {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  font-size: 11px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink-2);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}
.lg i { font-style: normal; opacity: 0.55; font-size: 10px; }
.lg:hover { background: rgba(255, 255, 255, 0.1); color: var(--ink); }
.lg.on { background: var(--brand); color: #fff; }

/* 底部：图层 + 缩放 */
.map-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  flex-wrap: wrap;
}
.map-layers { display: flex; gap: 6px; }
.ml {
  padding: 5px 13px;
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}
.ml:hover { background: rgba(255, 255, 255, 0.1); }
.ml.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

.map-zoom {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}
.map-zoom button {
  width: 26px;
  height: 26px;
  font-size: 15px;
  line-height: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--ink-2);
  cursor: pointer;
}
.map-zoom button:hover { background: rgba(255, 255, 255, 0.12); color: var(--ink); }
#mz-fit { width: auto; padding: 0 9px; font-size: 12px; }
#map-zoomv { min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; }

.map-hint {
  margin-top: 7px;
  font-size: 11.5px;
  text-align: center;
}

/* ── 点位详情弹窗 ── */
.map-pop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 15, 0.66);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 60;
}
.map-pop[hidden] { display: none; }
.mpc {
  position: relative;
  width: min(360px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: fadeUp 0.22s ease both;
}
.mpc-x {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 26px;
  height: 26px;
  font-size: 17px;
  line-height: 1;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--ink-2);
  cursor: pointer;
}
.mpc-x:hover { background: rgba(255, 255, 255, 0.15); color: var(--ink); }
.mpc-art {
  width: 68px;
  height: 68px;
  margin: 0 auto 10px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.06);
}
.mpc-art img { width: 50px; height: 50px; object-fit: contain; }
.mpc h3 {
  margin: 0 0 8px;
  font-size: 18px;
  text-align: center;
}
.mpc-tags {
  display: flex;
  gap: 5px;
  justify-content: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.mpc-meta {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 11px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  margin-bottom: 13px;
}
.mpc-meta > div {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
}
.mpc-meta em { font-style: normal; color: var(--muted); }
.mpc-collect {
  width: 100%;
  padding: 9px;
  font-size: 13px;
  font-weight: 600;
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  transition: filter 0.16s;
}
.mpc-collect:hover { filter: brightness(1.12); }
.mpc-collect.on {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
}

/* ── 响应式 ── */
@media (max-width: 900px) {
  .map-page { grid-template-columns: 1fr; }
  .map-side { max-height: 300px; order: 2; }
  .map-main { order: 1; }
  .map-legend { max-height: 40%; }
}