/* 离线权威矢量中国地图：SVG 布局 / 省界两色 / 标注层级 / 图例 / 提示 / 合规署名
   视觉方案：测绘档案——纸底、注册级细描边、分级标注、朱砂唯一强调；交互函数与 DOM class 一律不动。 */

.vm-root {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--km-paper);
}
.vm-svg {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--km-paper);
}
.vm-ocean { fill: transparent; }
.vm-svg-interactive { cursor: grab; touch-action: none; }
.vm-svg-interactive.is-dragging { cursor: grabbing; }
.vm-viewport { will-change: transform; }

/* 测绘刻度尺式缩放控件：右上角，不遮挡图例与署名 */
.vm-zoom-control {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 35;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 10px 6px;
  border: 1px solid var(--km-line);
  border-radius: var(--km-radius);
  background: var(--km-panel);
  box-shadow: 0 1px 2px rgba(23, 42, 50, .06);
}
.vm-zoom-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--km-line);
  border-radius: var(--km-radius);
  background: var(--km-panel);
  color: var(--km-ink);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.vm-zoom-btn:hover:not(:disabled) { background: rgba(47, 107, 138, .06); border-color: var(--km-primary); color: var(--km-primary); }
.vm-zoom-btn:disabled { color: var(--km-muted); opacity: .55; cursor: not-allowed; }
.vm-zoom-reset { font-size: 11px; width: 28px; height: 28px; }
.vm-zoom-level {
  min-width: 36px;
  text-align: center;
  color: var(--km-ink);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  border-top: 1px solid var(--km-line);
  border-bottom: 1px solid var(--km-line);
  padding: 2px 0;
}

/* 省界：两色交替填充 + 纸白细描边，删去 drop-shadow */
.vm-layer-provinces { filter: none; }

/* 图层顺序：省界 -> 十段线 -> 路线 -> 城市 -> 知识点 -> 省名 -> 闪动 */
.vm-layer-provinces .vm-province {
  stroke: var(--km-panel);
  stroke-width: 0.9;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  transition: fill 0.16s ease, stroke 0.16s ease;
  cursor: default;
}
.vm-layer-provinces .vm-province:hover {
  fill: #EFE3C6 !important; /* 保留 !important：压过行内 fill，命中色为鎏金 */
  /* 注意：描边不在本层加粗。SVG 按文档顺序绘制，湖北(16)先于湖南(17)/重庆(21)/陕西(26)绘制，
   * 本层加粗描边会被后绘制邻省的填充盖掉外半段，表现为边沿线缺一段。
   * 完整高亮描边改由顶层 vm-highlight-outline 绘制（见 vector-map.js bindTooltip）。 */
}
.vm-layer-highlight { pointer-events: none; }
.vm-highlight-outline {
  fill: none;
  stroke: var(--km-gold);
  stroke-width: 1.5;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
/* 行政区联动高亮：素材命中区域后脉冲 1.3s × 3，3.9s 后自动复原 */
.vm-layer-provinces .vm-province.vm-region-highlight {
  fill: #EFE3C6 !important;
  stroke: var(--km-gold);
  stroke-width: 2;
  animation: vmRegionGlow 1.3s ease-in-out 3;
}
@keyframes vmRegionGlow {
  0%, 100% { stroke-width: 1.5; }
  50% { stroke-width: 3; }
}
.vm-layer-nine-dash .vm-nine-dash {
  fill: var(--km-accent);
  stroke: var(--km-ink);
  stroke-width: 0.5;
  pointer-events: auto;
}

/* 屏幕空间标注：字号恒定，按优先级碰撞避让（minScale/maxScale/priority 在 JS 中不动） */
.vm-label {
  paint-order: stroke;
  stroke: rgba(243, 245, 241, .92);
  stroke-width: 2.4px;
  stroke-linejoin: round;
  pointer-events: none;
  user-select: none;
}
.vm-label-province { opacity: 1; }
.vm-label-capital { stroke-width: 3px; }
.vm-label-knowledge { stroke-width: 2.8px; }

.vm-city { cursor: default; }
.vm-city-dot {
  stroke: var(--km-panel);
  stroke-width: 1.4;
  paint-order: stroke;
  vector-effect: non-scaling-stroke;
}
.vm-city-capital .vm-city-dot { fill: var(--km-accent); }
.vm-city-province .vm-city-dot { fill: var(--km-primary); }
.vm-city-tier12 .vm-city-dot { fill: var(--km-moss); }
/* 城市标注样式已统一到 .vm-label-*（屏幕空间恒定字号） */

.vm-knowledge-halo {
  fill: rgba(138, 106, 31, .14);
  stroke: var(--km-gold);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.vm-knowledge-dot {
  fill: var(--km-gold);
  stroke: var(--km-panel);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}
.vm-knowledge:hover .vm-knowledge-halo { fill: rgba(138, 106, 31, .28); }

.vm-route-line {
  fill: none;
  stroke: var(--km-accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 7 5;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.vm-flash circle {
  fill: rgba(178, 58, 46, .22);
  stroke: var(--km-accent);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  animation: vm-pulse 1.2s ease-out 3;
}
.vm-flash-text {
  fill: var(--km-accent);
  font-size: 13px;
  font-weight: 800;
  paint-order: stroke;
  stroke: var(--km-paper);
  stroke-width: 3px;
  pointer-events: none;
}
/* 业务动效时序保持 1.2s × 3：去掉半径弹跳，只保留透明度 + 描边扩散 */
@keyframes vm-pulse {
  0% { opacity: .9; stroke-width: 1.5; }
  100% { opacity: 0; stroke-width: 6; }
}

/* 悬浮提示 */
.vm-tooltip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 40;
  max-width: 260px;
  padding: 6px 10px;
  border: 1px solid var(--km-line);
  border-radius: var(--km-radius);
  background: var(--km-panel);
  box-shadow: 0 2px 8px rgba(23, 42, 50, .10);
  color: var(--km-ink);
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.1s ease;
}
.vm-tooltip.is-visible { opacity: 1; visibility: visible; }

/* 图例：左上 38px 方角「图例扣」，hover / focus 才悬浮展开（纯 CSS，JS 无监听） */
.vm-legend {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 36;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--km-line);
  border-radius: var(--km-radius);
  background: var(--km-panel);
  box-shadow: 0 1px 2px rgba(23, 42, 50, .06);
  font-size: 11px;
  color: var(--km-ink);
  cursor: help;
  transition: background 0.18s ease, box-shadow 0.18s ease;
}
.vm-legend:hover,
.vm-legend:focus,
.vm-legend:focus-within {
  background: var(--km-panel);
  box-shadow: 0 2px 8px rgba(23, 42, 50, .12);
}
.vm-legend:focus { outline: none; }
.vm-legend:focus-visible { outline: 2px solid var(--km-primary); outline-offset: 2px; }
.vm-legend-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  line-height: 1;
  pointer-events: none;
}
.vm-legend-icon svg { display: block; color: var(--km-ink); }
.vm-legend-caption { font-size: 11px; font-weight: 500; letter-spacing: 0; color: var(--km-ink); }

.vm-legend-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  width: 216px;
  padding: 10px 12px;
  border: 1px solid var(--km-line);
  border-radius: var(--km-radius);
  background: var(--km-panel);
  box-shadow: 0 6px 18px rgba(23, 42, 50, .12);
  font-size: 12px;
  color: var(--km-ink);
  text-align: left;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}
.vm-legend:hover .vm-legend-popover,
.vm-legend:focus .vm-legend-popover,
.vm-legend:focus-within .vm-legend-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}
.vm-legend-title {
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--km-line);
  font-family: var(--km-serif);
  font-size: 13px;
  font-weight: 600;
  color: var(--km-ink);
}
.vm-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 22px;
  border-bottom: 1px solid var(--km-line);
}
.vm-lg {
  display: inline-block;
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--km-panel);
  box-shadow: 0 0 0 1px var(--km-line);
}
.vm-lg-capital { background: var(--km-accent); width: 14px; height: 14px; }
.vm-lg-province { background: var(--km-primary); }
.vm-lg-tier12 { background: var(--km-moss); }
.vm-lg-knowledge { background: var(--km-gold); }
.vm-lg-nine { border-radius: 0; background: var(--km-accent); width: 14px; height: 6px; }
.vm-legend-note {
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid var(--km-line);
  font-size: 11px;
  line-height: 1.55;
  color: var(--km-muted);
}

/* 合规署名（主视图与独立预览页共用）：字号 11px、次级色，文字内容逐字不改 */
.km-attribution {
  position: absolute;
  right: 12px;
  bottom: 10px;
  z-index: 31;
  max-width: calc(100% - 210px);
  padding: 4px 8px;
  border-top: 1px solid var(--km-line);
  border-radius: 0;
  background: transparent;
  color: var(--km-muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: right;
  pointer-events: none;
}

/* 首屏唯一自动动效：省界描线 700ms，仅一次；fill 不受影响，描线不遮挡省界合规呈现 */
.vm-layer-provinces .vm-province {
  stroke-dasharray: 1400;
  stroke-dashoffset: 1400;
  animation: vmDraw 700ms ease-out forwards;
}
@keyframes vmDraw {
  0% { stroke-dashoffset: 1400; stroke-dasharray: 1400; }
  99% { stroke-dashoffset: 0; stroke-dasharray: 1400; }
  100% { stroke-dashoffset: 0; stroke-dasharray: none; }
}

@media (prefers-reduced-motion: reduce) {
  .vm-layer-provinces .vm-province { animation: none !important; stroke-dasharray: none !important; stroke-dashoffset: 0 !important; }
  .vm-flash circle { animation: none !important; opacity: 1; }
  .vm-region-highlight { animation: none !important; }
}

/* 比例尺读数与刻度条（SDK 轨/后续比例尺展示复用；默认 offline 未注入节点，视觉零变更） */
.vm-scale-readout {
  position: absolute;
  left: 14px;
  bottom: 42px;
  z-index: 12;
  padding: 2px 6px;
  border: 1px solid var(--km-line);
  border-radius: var(--km-radius);
  background: var(--km-panel);
  color: var(--km-muted);
  font-family: var(--km-sans);
  font-size: 11px;
  line-height: 1.4;
  pointer-events: none;
}
.vm-scale-bar {
  position: absolute;
  left: 14px;
  bottom: 30px;
  z-index: 12;
  width: 72px;
  height: 5px;
  border: 1px solid var(--km-muted);
  border-top: 0;
  background: transparent;
  pointer-events: none;
}

/* B3 封面外链缩略图：仅白名单域名渲染，我方不缓存封面字节（no-store 语义） */
.km-result-cover-host {
  margin: 6px 0 8px;
  line-height: 0;
  overflow: hidden;
  border: 1px solid var(--km-line);
  border-radius: var(--km-radius);
  background: var(--km-panel);
}
.km-result-cover {
  display: block;
  width: 100%;
  max-height: 120px;
  object-fit: cover;
}
