/* 《打进大金陵》江宁攻城动画 —— 墨金线描 · 移动端竖屏优先 */
:root {
  --ink: #2b1d16;
  --ink-soft: #4a3527;
  --paper: #efe6d4;
  --paper-deep: #e4d7bd;
  --accent: #8c2f1f;
  --accent-deep: #6e2417;
  --gold: #a9863f;
  --line: #c8b58c;
  --water: #6ea3c8;
  --hill: #6a8e4f;
  --shadow: rgba(43, 29, 22, 0.4);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: radial-gradient(120% 80% at 50% 0%, #3a2820 0%, #271a13 60%, #1d130d 100%);
  color: var(--paper);
  font-family: "Songti SC", "SimSun", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  -webkit-text-size-adjust: 100%;
}
body {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* 顶栏 */
.topbar {
  width: 100%; max-width: 640px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; padding: 12px 18px 6px;
}
.brand h1 { margin: 0; font-size: 1.3rem; letter-spacing: 2px; color: var(--paper); text-shadow: 0 1px 0 #000; }
.brand h1 .sep { color: var(--gold); margin: 0 2px; }
.subtitle-brand, .subtitle { }
.brand .subtitle { margin: 3px 0 0; font-size: 0.72rem; letter-spacing: 1px; color: var(--gold); opacity: 0.9; }
.char-btn {
  flex: 0 0 auto; background: transparent; color: var(--paper); border: 1px solid var(--gold);
  border-radius: 4px; padding: 8px 12px; font-size: 0.84rem; font-family: inherit; cursor: pointer; white-space: nowrap;
}
.char-btn:active { background: rgba(169, 134, 63, 0.2); }

/* 舞台 */
.stage {
  position: relative; width: 100%; max-width: 640px; flex: 1 1 auto;
  padding: 6px 14px 4px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; min-height: 0;
}
.scene { width: 100%; max-width: 460px; margin: 0 auto; }
.scene-svg {
  width: 100%; height: auto; display: block;
  background: radial-gradient(120% 100% at 55% 35%, #efe6d2 0%, #ddcfb0 70%, #d2c2a0 100%);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 26px var(--shadow);
  overflow: hidden;
}
.world { transition: transform 0.9s cubic-bezier(.4,.0,.2,1); transform-origin: 0 0; }

/* 江河 / 地标 / 城墙 */
.s-river { stroke: var(--water); stroke-width: 4.5; opacity: 0.62; }
.s-qinhuai { stroke: var(--water); stroke-width: 2.2; opacity: 0.5; }
.s-label { font-size: 3.4px; }
.s-label.water { fill: #3d6e8c; }
.s-label.poi { fill: #4f6a37; text-anchor: middle; }
.s-hill { fill: rgba(106,142,79,0.55); stroke: #5c7240; stroke-width: 0.5; }
.s-wall { stroke: var(--accent-deep); stroke-width: 2.4; fill: rgba(169,134,63,0.13); }
.s-city { fill: var(--accent-deep); font-size: 7px; letter-spacing: 3px; text-anchor: middle; opacity: 0.5; }

/* 城门 */
.s-gate circle { fill: rgba(239,230,212,0.92); stroke: var(--ink-soft); stroke-width: 1.1; }
.s-gate text { fill: var(--ink); font-size: 4px; text-anchor: middle; font-weight: bold; }
.gate-yifeng circle { stroke: var(--accent); }   /* 史实主攻门略点出 */

/* 简笔小人 */
.fig { stroke-width: 1.7; }
.fig.taiping { stroke: var(--accent-deep); }
.fig.taiping.miner { stroke: #5b3a1e; }
.fig.qing { stroke: var(--ink-soft); }
.fig.banner { stroke: var(--accent); }
.fig.ship { stroke: #3d6e8c; }

/* 行军路线(stroke-dashoffset 绘出) */
.route { stroke-width: 1.4; stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0.85; }
.enc-route { stroke: var(--accent); stroke-dasharray: 0.06 0.04; }
.river-route { stroke: var(--water); }
.force-route { stroke: var(--accent-deep); }
.tunnel-path { stroke: #6b4a22; stroke-width: 1.6; stroke-dasharray: 0.05 0.03; }
.storm-route { stroke: var(--accent); stroke-dasharray: 0.06 0.04; }

/* 逐拍揭示:默认隐藏,reveal 类点亮 */
.layer { opacity: 0; }
.tianjing { opacity: 0; fill: var(--accent); font-size: 9px; letter-spacing: 4px; text-anchor: middle; font-weight: bold; }
.mv { transform: translate(0,0); }

@keyframes drawRoute { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* 1 合围 */
.r-encircle .encircle-layer { opacity: 1; }
.r-encircle .enc-route { animation: drawRoute 1s ease forwards; }
.r-encircle .mv-west { animation: marchWest 1.1s ease forwards; }
.r-encircle .mv-south { animation: marchSouth 1.1s ease forwards; }
.r-encircle .mv-ship { animation: marchShip 1.2s ease forwards; }
@keyframes marchWest { from { transform: translate(0,0); } to { transform: translate(18px,-1px); } }
@keyframes marchSouth { from { transform: translate(0,0); } to { transform: translate(1px,-14px); } }
@keyframes marchShip { from { transform: translate(0,0); } to { transform: translate(15px,0); } }

/* 2 主攻仪凤门 */
.r-yifeng .force-yifeng { opacity: 1; }
.r-yifeng .force-route { animation: drawRoute 0.9s ease forwards; }
.r-yifeng .force-flag { animation: marchYifeng 1s ease forwards; }
@keyframes marchYifeng { from { transform: translate(0,0); } to { transform: translate(9px,6px); } }

/* 3 挖地道 */
.r-tunnel .tunnel-grp { opacity: 1; }
.r-tunnel .tunnel-path { animation: drawRoute 1.4s ease forwards; }
.r-tunnel .tunnel-grp .fig.miner { animation: dig 0.5s ease-in-out infinite alternate; }
@keyframes dig { from { transform: translate(0,0) rotate(0); } to { transform: translate(0.6px,0.4px) rotate(3deg); } }

/* 4 炸城 */
.r-boom .breach-fx { opacity: 1; }
.r-boom .blast { fill: url(#none); fill: rgba(255,170,80,0.0); stroke: none; animation: blast 0.7s ease-out forwards; transform-box: fill-box; transform-origin: center; }
.r-boom .shard { stroke: var(--accent); stroke-width: 1.2; animation: shardFly 0.7s ease-out forwards; }
.r-boom .breach-gap { stroke: var(--ink); stroke-width: 1.6; opacity: 0; animation: fadeIn 0.5s ease 0.25s forwards; }
.r-boom .world { animation: shake 0.55s ease; }
.r-boom .qing-defenders { animation: scatter 0.8s ease 0.2s forwards; }
@keyframes blast {
  0% { fill: rgba(255,210,120,0.95); transform: scale(0.2); }
  60% { fill: rgba(192,57,43,0.55); }
  100% { fill: rgba(192,57,43,0); transform: scale(1.3); }
}
@keyframes shardFly { 0% { transform: translate(0,0); opacity: 1; } 100% { transform: translate(var(--sx), var(--sy)); opacity: 0; } }
@keyframes shake {
  0%,100% { transform: translate(var(--cx,0),var(--cy,0)); }
  20% { transform: translate(calc(var(--cx,0px) - 1.5px), var(--cy,0)); }
  45% { transform: translate(calc(var(--cx,0px) + 1.5px), var(--cy,0)); }
  70% { transform: translate(calc(var(--cx,0px) - 1px), var(--cy,0)); }
}
@keyframes scatter { to { opacity: 0.25; transform: translate(3px,-2px); } }

/* 5 破城涌入 */
.r-breach .stormers { opacity: 1; }
.r-breach .storm-route { animation: drawRoute 0.9s ease forwards; }
.r-breach .mv-storm { animation: stormIn 1.1s ease forwards; }
.r-breach .breach-fx { opacity: 1; }   /* 缺口保留 */
@keyframes stormIn { from { transform: translate(0,0); } to { transform: translate(13px,9px); } }

/* 6 收尾:天京 */
.r-epilogue .tianjing { animation: tianjingIn 1.1s ease forwards; }
@keyframes tianjingIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 0.92; transform: translateY(0); } }

/* 字幕 */
.subtitle {
  width: 100%; max-width: 560px; min-height: 3.2em; padding: 12px 20px;
  font-size: 1.08rem; line-height: 1.7; color: var(--paper); text-align: center;
  display: flex; align-items: center; justify-content: center;
}
/* 史实对照 */
.lesson {
  width: 100%; max-width: 560px; margin: 0 14px 4px; padding: 11px 16px;
  font-size: 0.86rem; line-height: 1.65; color: var(--paper-deep);
  border: 1px dashed var(--gold); border-radius: 8px; background: rgba(169,134,63,0.1);
}
.lesson[hidden] { display: none; }

/* 控制条 */
.controlbar { width: 100%; max-width: 560px; padding: 4px 14px 8px; }
.progress { display: flex; gap: 7px; justify-content: center; margin-bottom: 10px; }
.pdot { width: 7px; height: 7px; border-radius: 50%; background: rgba(239,230,212,0.25); transition: background 0.3s; }
.pdot.past { background: var(--gold); }
.pdot.here { background: var(--accent); box-shadow: 0 0 0 2px rgba(140,47,31,0.35); }
.controls { display: flex; }
.opt {
  flex: 1 1 auto; font-family: inherit; font-size: 1.12rem; letter-spacing: 2px; color: var(--paper);
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  border: 1px solid var(--accent-deep); border-radius: 8px; padding: 14px; cursor: pointer;
  box-shadow: 0 2px 6px var(--shadow); transition: transform 0.08s, filter 0.15s;
}
.opt:active { transform: scale(0.98); filter: brightness(0.95); }
.opt.restart { background: linear-gradient(180deg, var(--ink-soft) 0%, var(--ink) 100%); border-color: var(--ink); }

/* 页脚 */
.foot { width: 100%; max-width: 640px; padding: 2px 18px 16px; }
.foot p { margin: 0; font-size: 0.68rem; line-height: 1.6; color: rgba(239,230,212,0.42); text-align: center; }

/* 人物小传弹窗 */
.modal {
  position: fixed; inset: 0; display: none; align-items: flex-start; justify-content: center;
  background: rgba(20,13,9,0.74); padding: 24px 14px; z-index: 50; overflow-y: auto;
}
.modal.open { display: flex; }
.modal-box {
  width: 100%; max-width: 600px; background: linear-gradient(180deg, var(--paper) 0%, var(--paper-deep) 100%);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 14px 40px rgba(0,0,0,0.5); color: var(--ink);
}
.modal-head {
  position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: linear-gradient(180deg, var(--ink) 0%, var(--ink-soft) 100%); border-radius: 8px 8px 0 0;
}
.modal-head h2 { margin: 0; font-size: 1.05rem; letter-spacing: 1px; color: var(--paper); }
.modal-close {
  background: transparent; border: 1px solid rgba(239,230,212,0.5); color: var(--paper);
  width: 34px; height: 34px; border-radius: 4px; font-size: 1rem; cursor: pointer;
}
.modal-body { padding: 6px 16px 18px; }
.bio { padding: 14px 0; border-bottom: 1px dashed var(--line); }
.bio:last-child { border-bottom: none; }
.bio-name { margin: 0; font-size: 1.16rem; color: var(--accent-deep); letter-spacing: 1px; }
.bio-role { margin: 4px 0 10px; font-size: 0.8rem; color: var(--gold); }
.bio-p { margin: 0 0 8px; font-size: 0.94rem; line-height: 1.76; color: var(--ink-soft); text-align: justify; }

/* boomFlash 占位(整屏闪一下,可选) */
.boom-flash { position: absolute; inset: 0; pointer-events: none; border-radius: 10px; }

/* ── 可访问性:减少动态 ── */
@media (prefers-reduced-motion: reduce) {
  .world { transition: none; }
  .layer, .route, .mv, .tianjing, .breach-gap { animation: none !important; }
  .route { stroke-dashoffset: 0; }
  .r-encircle .encircle-layer, .r-yifeng .force-yifeng, .r-tunnel .tunnel-grp,
  .r-boom .breach-fx, .r-breach .stormers { opacity: 1; }
  .r-epilogue .tianjing { opacity: 0.92; }
  .r-boom .blast { animation: none; fill: rgba(192,57,43,0.2); }
}
.reduced .world { transition: none; }
.reduced .layer, .reduced .route, .reduced .mv, .reduced .tianjing, .reduced .breach-gap { animation: none !important; }
.reduced .route { stroke-dashoffset: 0; }
.reduced .r-encircle .encircle-layer, .reduced .r-yifeng .force-yifeng, .reduced .r-tunnel .tunnel-grp,
.reduced .r-boom .breach-fx, .reduced .r-breach .stormers { opacity: 1; }
.reduced .r-epilogue .tianjing { opacity: 0.92; }
.reduced .r-boom .blast { animation: none; fill: rgba(192,57,43,0.2); }

/* 窄屏微调 */
@media (max-width: 380px) {
  .brand h1 { font-size: 1.14rem; }
  .subtitle { font-size: 1rem; }
  .opt { font-size: 1.02rem; }
}
