/* ==========================================================================
   atlas-extra.css —— 自定义补充样式（独立文件，避免被补丁脚本重写 atlas.css 时覆盖）
   ========================================================================== */

/* ① 可点的点 vs 不可点的点
   ⚠ 只做"光标 + 悬停反馈"，**不改引擎绘制的图形**：
      给 SVG 里的圆统一加描边会把引擎自己的光晕圈也描上，
      结果实心点变成"空心环"（瓦埠暴动那类点被改成这样，已回退）。
   可点：手型光标；悬停时整组略微放大。
   不可点：略微减淡。 */
#dabie-svg g.is-clickable, #map-stage .is-clickable { cursor: pointer; }
#dabie-svg g.is-clickable { transition: transform .12s ease; transform-box: fill-box; transform-origin: center; }
#dabie-svg g.is-clickable:hover { transform: scale(1.25); }
#map-stage .am-marker.is-clickable { cursor: pointer; }
#map-stage .am-marker.is-clickable:hover { transform: scale(1.15); }
#dabie-svg g.not-clickable { opacity: .8; }
.is-clickable { cursor: pointer; }

/* ② 详情面板里的实图（一个点可对应多张） */
.dt-pics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 8px 0 6px; }
.dt-pics img { width: 100%; height: 96px; object-fit: cover; border-radius: 3px;
  border: 1px solid rgba(244, 239, 230, .18); }
@media (max-width: 720px) {
  .dt-pics { grid-template-columns: repeat(3, 1fr); }
  .dt-pics img { height: 74px; }
}

/* ③ 顶栏版本徽标与点击计数 */
.brandVersion, .clickBadge {
  margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 10.5px;
  color: #e8b563; border: 1px solid rgba(232, 181, 99, .45); background: rgba(244, 239, 230, .05);
  white-space: nowrap;
}

/* ==========================================================================
   范围轮廓的线型区分（range-sep）
   --------------------------------------------------------------------------
   三套范围大面积重合（蓝的"范围归属"、红的"老区/苏区"），只靠颜色分不开。
   办法：给它们不同的**线型与粗细**，重合时仍能逐条辨认。
   只作用于面（.area），不碰点位图形。
   ========================================================================== */
#dabie-svg .lao.area, #map-stage .lao.area {
  stroke-width: 2.4; stroke-dasharray: 12 6;              /* 老区：粗长虚线 */
}
#dabie-svg .su.area, #map-stage .su.area {
  stroke-width: 2.6; stroke-dasharray: none;              /* 苏区：粗实线 */
}
#dabie-svg .admin.area, #map-stage .admin.area {
  stroke-width: 1.2; stroke-dasharray: 3 3;               /* 范围归属：细密虚线 */
}
#dabie-svg .physio.area, #map-stage .physio.area {
  stroke-width: 1.8; stroke-dasharray: 7 4;               /* 自然范围：中短虚线 */
}

/* ==========================================================================
   把点的三层图形定死（point-core）
   --------------------------------------------------------------------------
   引擎每个点是三层叠出来的：战斗圆盘 + 光环圈 + 中心点。
   光环圈（蓝灰色描边圆）在多数缩放下看起来就是个"空环"，中心点又太细看不见，
   于是整点显得空心。这里：去掉光环圈，中心点与圆盘颜色写实、加描边。
   ========================================================================== */
#dabie-svg .map-node-halo, #map-stage .map-node-halo { display: none; }
#dabie-svg .map-battle-disc, #map-stage .map-battle-disc { fill: #c1272d; opacity: 1; }
#dabie-svg .map-node-dot, #map-stage .map-node-dot {
  fill: #fdf6e8; stroke: #7a1a1f; stroke-width: 0.6; opacity: 1;
}
#dabie-svg .map-node.is-focus .map-node-dot, #map-stage .map-node.is-focus .map-node-dot {
  fill: #ffd98a; stroke: #7a1a1f;
}

/* ==========================================================================
   操作手感（丝滑）—— 只做交互与动效，不改引擎图形
   ========================================================================== */
html { scroll-behavior: smooth; }                    /* 点导航平滑滚动 */
.readProgress {
  position: fixed; left: 0; top: 0; height: 2px; width: 0; z-index: 9998;
  background: linear-gradient(90deg, #e8b563, #f4c98a);
  box-shadow: 0 0 6px rgba(232, 181, 99, .7);
  transition: width .12s linear; pointer-events: none;
}
.panel, .ch-head, .ch-foot { transition: opacity .28s ease, transform .28s ease, border-color .28s ease; }
.panel.is-cur { transform: translateY(-2px); }
.detail { animation: dtIn .16s ease-out; }
@keyframes dtIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* 移动端：触摸区加大 + 去掉点击高亮闪烁 + 惯性滚动 */
@media (max-width: 900px) {
  .tools button, .tool-link, .chnav a, .snav a, .nav-arrow {
    min-height: 40px; display: inline-flex; align-items: center;
    -webkit-tap-highlight-color: transparent;
  }
  .chnav, .snav { -webkit-overflow-scrolling: touch; scroll-behavior: smooth; }
  .dt-close { width: 34px; height: 34px; }
}
button, a { -webkit-tap-highlight-color: transparent; }

/* ==========================================================================
   chnav-boxed —— 六章导航项都做成"金色边框的块"（与工具按钮同一观感）
   当前章：边框更亮 + 底色更明显；悬停：轻微提亮。
   ========================================================================== */
.chnav a {
  border: 1px solid rgba(232, 181, 99, .8);
  background: rgba(232, 181, 99, .07);
  border-radius: 4px;
  margin-right: 2px;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.chnav a:hover {
  border-color: rgba(232, 181, 99, .55);
  background: rgba(244, 239, 230, .075);
  color: var(--cream, #f4efe6);
}
.chnav a.on {
  border-color: rgba(232, 181, 99, .95);
  background: rgba(232, 181, 99, .14);
  color: var(--gold, #e8b563);
  box-shadow: 0 0 0 1px rgba(232, 181, 99, .18) inset;
}
/* 小节导航同样做成小方块，层级更清楚 */
.snav a {
  border: 1px solid rgba(232, 181, 99, .18);
  background: rgba(244, 239, 230, .03);
  border-radius: 3px;
  margin-right: 2px;
}
.snav a.on { border-color: rgba(232, 181, 99, .75); background: rgba(232, 181, 99, .12); }

/* ==========================================================================
   admin-gold —— 行政范围（范围归属）线改金色：浅底图上比蓝色醒目得多
   保留"细密虚线"，仍与老区的"粗长虚线"、苏区的"粗实线"区分得开。
   同时同步图例色块，保证图例与地图一致（否则会误导）。
   ========================================================================== */
#dabie-svg .admin.area, #map-stage .admin.area {
  stroke: rgba(232, 181, 99, .95);
  stroke-width: 1.7;
  stroke-dasharray: 4 3;
  fill: rgba(232, 181, 99, .05);
}
#dabie-svg .admin-label, #map-stage .admin-label { fill: rgba(240, 205, 140, .95); }
/* 图例色块（几种可能的写法都覆盖） */
.lg-item .sw.admin, .lg-item .admin, .legend .admin,
.lg-item .sw[data-cls="admin"] { background: rgba(232, 181, 99, .95) !important; border-color: rgba(232, 181, 99, .95) !important; }

/* ==========================================================================
   mobile-perf —— 移动端流畅度（纯样式，不动结构与脚本）
   --------------------------------------------------------------------------
   卡顿的两个主因：
     ① backdrop-filter 毛玻璃在手机 GPU 上极贵，滚动/缩放时逐帧重算；
     ② 图集 469 张图的 DOM 全量参与布局与绘制（懒加载只省下载，不省渲染）。
   ========================================================================== */
#map-stage, .stage { contain: paint; }          /* 重绘范围限制在地图容器内 */

@media (max-width: 900px) {
  /* ① 关掉毛玻璃，改用更实的底色（观感几乎不变，帧率明显改善） */
  .panel, .ch-head, .ch-foot, .detail, .toTop, .loadingVeil {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
  .panel { background: rgba(8, 11, 15, .94) !important; }
  .ch-head, .ch-foot { background: rgba(8, 11, 15, .96) !important; }
  .detail { background: rgba(8, 11, 15, .97) !important; }
  /* ④ 触屏上没有 hover，关掉相关过渡，少一次重排 */
  #dabie-svg g.is-clickable { transition: none; }
  #dabie-svg g.is-clickable:hover { transform: none; }
  .panel, .ch-head, .ch-foot { transition: opacity .18s ease; }
}

/* ② 图集：只渲染可见项（content-visibility 是浏览器原生能力，零风险） */
.gallery figure {
  content-visibility: auto;
  contain-intrinsic-size: 120px 150px;
}
/* 长名单同样受益 */
.list-wrap { content-visibility: auto; contain-intrinsic-size: 400px 600px; }

/* 悬停放大只在有真实指针时启用（手机不做无用的 transform 计算） */
@media (hover: none) {
  #dabie-svg g.is-clickable:hover { transform: none; }
}

/* ==========================================================================
   pan-hide-text —— 拖动/缩放期间隐藏文字标注
   --------------------------------------------------------------------------
   手机上文字（SVG text + 高德 HTML 标注）绘制最贵，逐帧重排文字就是"一卡一卡"
   的主要来源。拖动时用 display:none 把它们移出绘制（只在开始/结束各变一次布局），
   中间每帧都是纯位移 —— 手感明显跟手；松手 120ms 后恢复。
   ========================================================================== */
body.is-panning #dabie-svg text,
body.is-panning #map-stage .am-label,
body.is-panning #map-stage .am-lbl,
body.is-panning #map-stage .am-sub,
body.is-panning #map-stage .am-province,
body.is-panning #map-stage .am-ridge { display: none !important; }
/* 点位本身也简化成小圆点，少画一层光晕 */
body.is-panning #dabie-svg .map-node-halo { display: none !important; }

/* ==========================================================================
   long-list-perf —— 长列表的渲染成本（手机上第六章很长：176 行表 + 14 份名单 + 469 张图）
   思路：屏幕外的内容不参与布局与绘制（content-visibility），
        块内重排不外溢（contain），横向导航滚动不触发整页重排。
   ========================================================================== */
.tbl tbody tr { content-visibility: auto; contain-intrinsic-size: 32px; }
.tbl, .list-wrap, .gallery { contain: layout paint; }
.chnav, .snav { contain: content; }
/* 章节卡片与小结面板：内容不溢出（长文本重排不外扩） */
.panel, .ch-head, .ch-foot { contain: layout style; }

/* ==========================================================================
   pan-fastrender —— 手势期间走"快速绘制"路径（只在 is-panning 生效）
   静态时观感不变；拖动/捏合时明显省 GPU 时间。
   ========================================================================== */
body.is-panning #dabie-svg { shape-rendering: optimizeSpeed; text-rendering: optimizeSpeed; }
body.is-panning #dabie-svg path,
body.is-panning #dabie-svg circle,
body.is-panning #dabie-svg polygon { filter: none !important; }
body.is-panning #dabie-svg .map-node-dot { stroke: none !important; }
body.is-panning #map-stage img,
body.is-panning #map-stage canvas { image-rendering: -webkit-optimize-contrast; }

/* ==========================================================================
   zoom-label-scale —— 标注字号随缩放自动分档（远 / 中 / 近）
   --------------------------------------------------------------------------
   只用固定 px，不用 calc 缩放、不强制换行（那两种写法都曾造成巨字或竖排 ✗）。
   分档由 atlas-page.js 按当前 span 加类：.zoom-far / .zoom-mid / .zoom-near
   ========================================================================== */
/* 远：视野大 → 字小、少占地方 */
#map-stage.zoom-far .am-lbl, #map-stage.zoom-far .am-sub,
#map-stage.zoom-far .am-uplbl, #map-stage.zoom-far .am-sitelbl,
#map-stage.zoom-far .am-ridge, #map-stage.zoom-far .am-peaklbl { font-size: 10px !important; }
#map-stage.zoom-far .am-label { font-size: 13px !important; }
#map-stage.zoom-far .am-province { font-size: 17px !important; }
/* 中：默认 */
#map-stage.zoom-mid .am-lbl, #map-stage.zoom-mid .am-sub,
#map-stage.zoom-mid .am-uplbl, #map-stage.zoom-mid .am-sitelbl,
#map-stage.zoom-mid .am-ridge, #map-stage.zoom-mid .am-peaklbl { font-size: 12px !important; }
#map-stage.zoom-mid .am-label { font-size: 15px !important; }
#map-stage.zoom-mid .am-province { font-size: 20px !important; }
/* 近：视野小 → 字略大、便于阅读（但有上限，不会变巨字） */
#map-stage.zoom-near .am-lbl, #map-stage.zoom-near .am-sub,
#map-stage.zoom-near .am-uplbl, #map-stage.zoom-near .am-sitelbl,
#map-stage.zoom-near .am-ridge, #map-stage.zoom-near .am-peaklbl { font-size: 13px !important; }
#map-stage.zoom-near .am-label { font-size: 16px !important; }
#map-stage.zoom-near .am-province { font-size: 22px !important; }
/* 自绘引擎的点名（SVG 文本）：按档位给上限，避免近景过大 */
#dabie-svg .map-node-label { font-size: 12px; }
#map-stage.zoom-far #dabie-svg .map-node-label { font-size: 11px; }
#map-stage.zoom-near #dabie-svg .map-node-label { font-size: 13px; }

/* ==========================================================================
   smooth-label-scale —— 标注字号随缩放**平滑过渡**
   --------------------------------------------------------------------------
   字号 = 固定基准 px × var(--lbl-k)（由 atlas-page.js 按视野连续计算，范围 0.85–1.15）。
   关键：基准是固定 px（不是"跟着缩放走的量"）✓ → 既平滑，也绝不会出现巨字；
        也不做强制换行（曾导致中文竖排 ✗）。
   ========================================================================== */
#map-stage .am-lbl, #map-stage .am-sub, #map-stage .am-uplbl,
#map-stage .am-sitelbl, #map-stage .am-ridge, #map-stage .am-peaklbl,
#map-stage .am-nodelbl-battle, #map-stage .am-nodelbl-minor,
#map-stage .am-nodelbl-place, #map-stage .am-passlbl, #map-stage .am-ancientlbl {
  font-size: calc(12px * var(--lbl-k, 1)) !important;
}
#map-stage .am-sub, #map-stage .am-nodelbl-place, #map-stage .am-peaklbl {
  font-size: calc(10.5px * var(--lbl-k, 1)) !important;
}
#map-stage .am-label { font-size: calc(15px * var(--lbl-k, 1)) !important; }
#map-stage .am-province { font-size: calc(20px * var(--lbl-k, 1)) !important; }
/* 自绘引擎的点名列同样平滑 */
#dabie-svg .map-node-label { font-size: calc(12px * var(--lbl-k, 1)); }
#map-stage .snav, #map-stage .chnav { font-size: inherit; }   /* 不影响界面文字 */

/* ==========================================================================
   label-fade —— 标注淡入淡出：手势结束后不再"突然跳出"
   只过渡透明度（opacity 便宜 ✓，不改 font-size 那种会引起重排的属性 ✗）
   ========================================================================== */
#map-stage .am-lbl, #map-stage .am-sub, #map-stage .am-label,
#map-stage .am-uplbl, #map-stage .am-sitelbl, #map-stage .am-ridge,
#map-stage .am-peaklbl, #map-stage .am-provider,
#dabie-svg text { transition: opacity .18s ease; }
body.is-panning #map-stage .am-lbl, body.is-panning #map-stage .am-sub,
body.is-panning #map-stage .am-label, body.is-panning #dabie-svg text { opacity: 0; }
