:root {
  --map-province-fill: rgba(20, 22, 26, 0.03);
  --map-dot: #8f3b2e;
}

/* navbar 已改为 position:fixed，脱离文档流 → 网格里只剩 .map-prototype 一个子元素。
   若仍写 `auto minmax(0,1fr)`，它会顶替到 auto 行、按内容只拿到约 300px（曾踩过这个坑），
   所以这里必须是单行；nav 占的高度用 padding-top 让出，box-sizing 保证 100vh 不被撑破。 */
body.prototype-map {
  height: 100vh;
  box-sizing: border-box;
  padding-top: calc(var(--global-nav-height) + 1px); /* +1px 为 nav 的 border-bottom */
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}

/* 嵌入进首页时 navbar 隐藏，不需要让位 */
body.prototype-map.is-embedded {
  padding-top: 0;
}

body.prototype-map.is-embedded .global-nav,
body.prototype-map.is-embedded .map-topbar,
body.prototype-map.is-embedded .map-controls {
  display: none;
}

/* 顶栏与控制条 display:none 后退出网格流，.map-stage 会顶替到第一行（auto，按内容
   只有 300px），真正的 minmax(0,1fr) 行反而空着。嵌入模式下改成单行占满。 */
body.prototype-map.is-embedded .map-prototype {
  grid-template-rows: minmax(0, 1fr);
}

.map-prototype {
  max-width: none;
  margin: 0;
  padding: 0;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--bg);
}

.map-topbar {
  padding: 18px 28px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}

.map-title {
  color: var(--heading);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.16em;
  line-height: 1.4;
}

.map-subtitle {
  margin-top: 4px;
  color: var(--ink-faint);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.sample-mark {
  color: var(--rust-ink);
  border: 1px solid rgba(194, 106, 88, 0.5);
  padding: 5px 9px;
  font-size: 13px;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.map-stage {
  min-height: 0;
  position: relative;
}

#mapSvg {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bg);
}

.map-dots-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.embed-year {
  display: none;
  position: absolute;
  z-index: 3;
  right: 28px;
  top: 18px;
  color: var(--heading);
  font-size: clamp(42px, 8vw, 86px);
  line-height: 1;
  letter-spacing: 0.08em;
  pointer-events: none;
}

.embed-trust {
  display: none;
  position: absolute;
  z-index: 3;
  right: 28px;
  bottom: 18px;
  width: min(430px, calc(100% - 56px));
  color: var(--verify);
  font-size: 11px;
  line-height: 1.7;
  letter-spacing: 0.06em;
  text-align: right;
  pointer-events: none;
}

.embed-trust span {
  display: block;
}

.embed-trust span:first-child {
  color: var(--rust-ink);
}

/* 图注压在南海那片空海面上：那里没有数据点，是全图唯一放得下大字又不遮内容的地方。 */
.embed-caption {
  display: none;
  position: absolute;
  z-index: 3;
  left: 28px;
  bottom: 62px;
  /* 宽度贴着文字走，不占满整行：定宽会让这个盒子横跨到右下角的可信度区块底下，
     两块在窄屏上会叠在一起。贴合内容后它只占左半边，与右下角天然错开。 */
  width: max-content;
  max-width: calc(100% - 56px);
  pointer-events: none;
}

.embed-caption-lead {
  color: var(--heading);
  font-size: clamp(24px, 3.6vw, 50px);
  line-height: 1.25;
  letter-spacing: 0.12em;
}

/* 这一行不能用 flex：里头的「2,500」是个 span，flex 会把它和前后的文本节点
   拆成三个独立的 flex item，gap 会插进数字两边，读起来像三段话。保持普通文本流，
   点用 inline-block 挂在行内。 */
.embed-caption-unit {
  margin-top: 10px;
  color: var(--ink-dim);
  font-size: clamp(12px, 1.2vw, 16px);
  letter-spacing: 0.1em;
}

/* 与图上的点同色同形（方点，不是圆点）：图例的作用是让读者把这行字和画面里的东西对上，
   形状对不上就对不上。 */
.embed-caption-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 9px;
  vertical-align: 0.06em;
  background: var(--map-dot);
}

body.prototype-map.is-embedded .embed-year,
body.prototype-map.is-embedded .embed-caption {
  display: block;
}

/* 嵌入模式下把口径细节收起来：这一屏是首页的一个画面，不是资料页。
   完整的推定比例、折算规则、各战出处都在完整地图上，一个链接之外。 */
body.prototype-map.is-embedded .embed-trust,
body.prototype-map.is-embedded .map-note {
  display: none;
}

.neighbor {
  fill: #171a1f;
  stroke: var(--line);
  stroke-width: 0.55;
  vector-effect: non-scaling-stroke;
}

.province {
  fill: var(--map-province-fill);
  stroke: var(--line);
  stroke-width: 0.5;
  vector-effect: non-scaling-stroke;
  cursor: default;
}

.province.is-hovered {
  stroke: var(--rust-ink);
  stroke-width: 0.9;
}

.map-note {
  position: absolute;
  z-index: 3;
  left: 28px;
  bottom: 18px;
  color: var(--verify);
  font-size: 12px;
  letter-spacing: 0.06em;
  pointer-events: none;
}

.map-tooltip {
  position: fixed;
  z-index: 10;
  display: none;
  min-width: 180px;
  max-width: 260px;
  padding: 9px 11px;
  background: rgba(20, 22, 26, 0.94);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.7;
  pointer-events: none;
}

.map-tooltip strong {
  display: block;
  color: var(--heading);
  font-size: 15px;
  font-weight: 600;
}

.map-tooltip .verify-tip {
  color: var(--verify);
}

.map-controls {
  border-top: 1px solid var(--line);
  background: var(--bg-panel);
  padding: 15px 28px 20px;
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.control-button,
.segmented button {
  font-family: var(--serif);
  color: var(--ink-dim);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 2px;
  min-height: 34px;
  padding: 5px 12px;
  cursor: pointer;
}

.control-button:hover,
.segmented button:hover {
  color: var(--ink);
  border-color: #4a4038;
}

.segmented {
  display: flex;
  gap: 0;
}

.segmented button + button {
  margin-left: -1px;
}

.segmented button.is-active {
  color: var(--heading);
  border-color: var(--rust);
}

.timeline-control {
  min-width: 0;
}

.timeline-meta {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--ink-faint);
  font-size: 12px;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

#yearLabel {
  color: var(--heading);
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0.08em;
}

/* 不用 accent-color：浏览器会把未填充轨道渲染成亮白，违反姿态条款。
   显式压暗轨道，滑块用方块而非圆钮——与全站「方形碑点」的视觉语言统一。 */
#yearRange {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

#yearRange::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--line);
}
#yearRange::-moz-range-track {
  height: 2px;
  background: var(--line);
}

#yearRange::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 9px;
  height: 9px;
  margin-top: -3.5px;
  border: 0;
  border-radius: 0;
  background: var(--rust);
}
#yearRange::-moz-range-thumb {
  width: 9px;
  height: 9px;
  border: 0;
  border-radius: 0;
  background: var(--rust);
}

#yearRange:focus {
  outline: 1px solid var(--rust);
  outline-offset: 5px;
}

#yearRange:focus:not(:focus-visible) {
  outline-color: rgba(143, 59, 46, 0.45);
}

.legend {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-faint);
  font-size: 12px;
  letter-spacing: 0.06em;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border: 1px solid var(--line);
  background: var(--map-dot);
}

.legend-note,
.legend-method {
  flex-basis: 100%;
  text-align: right;
}

.legend-note {
  color: var(--verify);
}

.legend-method {
  color: var(--verify);
  font-size: 11px;
}

@media (max-width: 860px) {
  body.prototype-map {
    overflow: hidden;
  }

  .map-prototype {
    min-height: 0;
    height: 100%;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .map-topbar,
  .map-controls {
    padding-left: 16px;
    padding-right: 16px;
  }

  .map-topbar,
  .map-controls {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .map-controls {
    display: grid;
  }

  .legend {
    justify-content: flex-start;
  }

  .legend-note,
  .legend-method {
    text-align: left;
  }

  .map-note {
    left: 16px;
    right: 16px;
  }
}
