/* ═══════════════════════════════════════════════════════
   那条线，原来有人在走 · 共创图景人物篇 C
   28 手绘城市白板 × 27 手账剪报：白板笔、圆珠笔、便签、胶带
   交互两态门控：body[data-state] 驱动图层显隐；
   无 JS（html 无 .has-js）→ 交互区隐藏、图版模式完整展示。
   ═══════════════════════════════════════════════════════ */

:root {
  --board: #fbfaf6;        /* 白板面 */
  --wall: #eceae3;         /* 墙面底 */
  --ink: #3a362f;          /* 白板笔黑 */
  --ink-soft: #6b665c;
  --marker-red: #b3543a;   /* 马克红棕 */
  --pen-blue: #31589d;     /* 圆珠笔蓝 */
  --green: #3f7d5a;        /* 重画绿 */
  --note: #f7e9a0;         /* 便签黄 */
  --paper: #fffdf5;        /* 剪报纸 */
  --tape: rgba(224, 214, 168, .55);
  --hand: "Kaiti SC", "STKaiti", "KaiTi", "楷体", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.85;
  color: var(--ink);
  background:
    radial-gradient(1100px 500px at 85% -5%, rgba(179, 84, 58, .06), transparent 60%),
    radial-gradient(900px 460px at -5% 30%, rgba(49, 88, 157, .05), transparent 55%),
    var(--wall);
  overflow-x: hidden;
}

img, svg { max-width: 100%; }
a { color: var(--marker-red); }

:focus-visible { outline: 2px dashed var(--marker-red); outline-offset: 3px; border-radius: 4px; }

.skip { position: absolute; left: 12px; top: -52px; background: var(--ink); color: var(--board); padding: 8px 16px; border-radius: 6px; z-index: 99; transition: top .2s; }
.skip:focus { top: 12px; color: var(--board); }

.sr-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 站点入口（纸条） ---------- */
.portal-back {
  display: flex; gap: 10px; align-items: center;
  padding: 10px max(calc((100vw - 1060px) / 2), 18px);
  background: var(--paper);
  border-bottom: 1px dashed #c9c2b2;
  font-size: 14px;
}
.portal-back a {
  color: var(--ink); text-decoration: none;
  background: var(--note);
  box-shadow: 0 2px 5px rgba(58, 54, 47, .18);
  padding: 4px 16px; transform: rotate(-1.2deg);
}
.portal-back a:first-child { transform: rotate(1deg); }
.portal-back a:hover { background: #f2dc82; color: var(--ink); }

/* ---------- 页头：单列紧凑，舞台紧随其后 ---------- */
.board-head {
  max-width: 1060px; margin: 0 auto;
  padding: clamp(22px, 3.6vw, 44px) 22px 4px;
}
.kicker { font-size: 14px; letter-spacing: .2em; color: var(--ink-soft); margin-bottom: 10px; }
h1 {
  font-family: var(--hand);
  font-size: clamp(30px, 4.6vw, 46px);
  line-height: 1.32; font-weight: 700;
  margin-bottom: 12px;
}
.intro { max-width: 38em; font-size: 16.5px; }
.intro strong { color: #8a4a33; }
.fiction-note {
  display: inline-block; margin-left: 10px;
  font-size: 14px; color: var(--ink-soft);
  border-bottom: 1.5px dashed #b7b1a2;
  transform: rotate(-.5deg);
}

/* ---------- 章节 ---------- */
main { max-width: 1060px; margin: 0 auto; padding: 0 22px; }
.chapter { padding: clamp(30px, 4vw, 52px) 0 6px; }
.chapter h2 {
  font-family: var(--hand);
  font-size: clamp(23px, 3vw, 30px);
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 16px;
}
.no {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 2.5px solid var(--marker-red); color: var(--marker-red);
  font-size: 19px; transform: rotate(-4deg);
  flex-shrink: 0;
}
.chapter p { max-width: 38em; margin-bottom: 14px; }
.chapter strong { color: #8a4a33; }
.lead-line {
  font-family: var(--hand); font-size: 19px;
  border-left: 4px solid var(--marker-red);
  padding-left: 14px;
}

/* ---------- 白板舞台 ---------- */
.stage-chapter { padding-top: clamp(18px, 2.6vw, 30px); }
.stage-title {
  font-family: var(--hand);
  font-size: clamp(21px, 2.6vw, 27px);
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 10px;
}
.stage-hint { font-size: 15px; color: var(--ink-soft); max-width: 40em; margin-bottom: 16px; }

.stage {
  position: relative;
  background: var(--board);
  border: 8px solid #d9d6cc;
  border-radius: 16px;
  box-shadow: 0 14px 34px rgba(58, 54, 47, .14), inset 0 0 0 2px #efece3;
  padding: clamp(6px, 1.4vw, 18px);
  touch-action: pan-y;
}
.board { width: 100%; height: auto; display: block; cursor: crosshair; }

.svg-hand { font-family: var(--hand); }

/* 斜径段与擦痕 */
.seg { opacity: 1; }
.seg.wiped { opacity: 0; }
.sm { opacity: 0; }
.sm.wiped { opacity: 1; }

/* 端点热区 */
.anchor {
  fill: rgba(179, 84, 58, .16);
  stroke: var(--marker-red); stroke-width: 2.5; stroke-dasharray: 6 6;
  opacity: 0; pointer-events: all; cursor: pointer;
}
body[data-state="erased"] .anchor,
body[data-state="pick-a"] .anchor { opacity: 1; }
body[data-state="pick-a"] #anchorA { fill: rgba(63, 125, 90, .3); }
body[data-state="pick-b"] #anchorB { fill: rgba(63, 125, 90, .3); }

/* 图层2：王婶轨迹（擦除后显影） */
.traj-layer { opacity: 0; pointer-events: none; }
body[data-state="erased"] .traj-layer,
body[data-state="pick-a"] .traj-layer,
body[data-state="pick-b"] .traj-layer,
body[data-state="redrawn"] .traj-layer { opacity: 1; }
.t-line, .t-detour { stroke: var(--pen-blue); stroke-width: 3.5; fill: none; stroke-dasharray: 2 6; stroke-linecap: round; }
.t-broken { stroke: var(--pen-blue); stroke-width: 3.5; stroke-dasharray: 2 6; opacity: .45; }
.t-restored { stroke: var(--green); stroke-width: 4.5; fill: none; stroke-linecap: round; opacity: 0; }

.t-ok-note { opacity: 0; }

/* 按所选模式只显示对应的恢复轨迹与注记 */
body[data-mode="original"] .t-ro, body[data-mode="new"] .t-rn { opacity: 1; }
body[data-mode="original"] .t-ok-ro, body[data-mode="new"] .t-ok-rn { opacity: 1; }
body[data-state="redrawn"] .t-detour, body[data-state="redrawn"] .t-broken,
body[data-state="redrawn"] .cross, body[data-state="redrawn"] .t-detour-note { opacity: 0; }

/* 图层3：重画线 */
.rd { opacity: 0; stroke-width: 7; }
.rd-original { stroke: var(--marker-red); }
.rd-new { stroke: var(--green); }
body[data-state="redrawn"] .rd.rd-on { opacity: 1; }
body[data-state="redrawn"] .seg, body[data-state="redrawn"] .sm { opacity: 1; }
body[data-state="redrawn"] #pathSegs { display: none; }

/* 板擦光标 */
.eraser-cursor {
  position: absolute; top: 0; left: 0;
  background: #4a463f; color: #fbfaf6;
  font-family: var(--hand); font-size: 14px;
  padding: 3px 10px; border-radius: 8px;
  transform: translate(-50%, -130%);
  opacity: 0; pointer-events: none;
  transition: opacity .15s ease;
  white-space: nowrap;
}
.stage.erasing .eraser-cursor { opacity: .92; }

/* ---------- 操作条 ---------- */
.ops { margin: 18px 0 8px; display: grid; gap: 12px; }
.ops-phase {
  font-family: var(--hand); font-size: 18px; color: #8a4a33;
}
.ops-group { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.ops-group[hidden] { display: none; } /* 恢复原生 hidden（不被 flex 覆盖） */
.op-btn {
  font-family: var(--hand); font-size: 17px;
  padding: 10px 22px; border-radius: 12px;
  border: 2.5px solid var(--ink); background: var(--paper);
  color: var(--ink); cursor: pointer;
  box-shadow: 3px 3px 0 rgba(58, 54, 47, .8);
  transition: transform .12s ease, box-shadow .12s ease, background-color .15s ease;
}
.op-btn:hover { background: #fff8e8; }
.op-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(58, 54, 47, .8); }
.op-erase { border-color: var(--marker-red); color: var(--marker-red); box-shadow: 3px 3px 0 rgba(179, 84, 58, .75); }
.op-new { border-color: var(--green); color: var(--green); box-shadow: 3px 3px 0 rgba(63, 125, 90, .7); }
.op-again { border-style: dashed; }
.ops-tip { font-size: 14px; color: var(--ink-soft); }

/* ---------- 剪报注记 ---------- */
.clipnote {
  position: relative;
  background: var(--paper);
  border: 1.5px solid #ddd6c4;
  box-shadow: 0 10px 26px rgba(58, 54, 47, .14);
  padding: 22px 26px 18px;
  margin: 26px 0 10px;
  max-width: 46em;
  opacity: 0; transform: translateY(16px) rotate(-.6deg);
  visibility: hidden;
}
body[data-state="erased"] .clip-1,
body[data-state="pick-a"] .clip-1,
body[data-state="pick-b"] .clip-1,
body[data-state="redrawn"] .clip-1,
body[data-state="redrawn"] .clip-2 { opacity: 1; transform: translateY(0) rotate(-.6deg); visibility: visible; }
/* 无 JS：两条注记作为并列两态直接呈现（不删交互含义） */
html:not(.has-js) .clipnote { opacity: 1; visibility: visible; transform: none; }
.clip-2 { margin-left: auto; margin-right: clamp(0px, 4vw, 48px); }
.clip-tape {
  position: absolute; top: -13px; left: 42px;
  width: 110px; height: 28px; background: var(--tape);
  transform: rotate(-2deg);
}
.clipnote h3 { font-family: var(--hand); font-size: 21px; margin-bottom: 10px; color: #8a4a33; }
.clipnote p { font-size: 15.5px; margin-bottom: 10px; max-width: 40em; }
.clipnote strong { color: #8a4a33; }
.clip-hand {
  font-family: var(--hand); font-size: 17.5px;
  border-top: 1.5px dashed #d5cdb8; padding-top: 10px;
}

/* ---------- 页脚 ---------- */
.page-foot {
  margin: 56px 0 0; padding: 26px 0 40px;
  border-top: 1.5px dashed #c9c2b2;
  font-size: 14px; color: var(--ink-soft);
}
.foot-fiction { max-width: 46em; margin-bottom: 10px; }
.foot-fiction strong { color: #8a4a33; }
.page-foot p { margin-bottom: 6px; }
.foot-links a { margin-right: 6px; }

/* ---------- 无 JS / 图版模式 ---------- */
.nojs { display: none; }
html:not(.has-js) .nojs { display: block; }
html:not(.has-js) .hasjs { display: none; }
.static-frames {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 18px; margin: 18px 0;
}
.static-frames figure { background: var(--paper); border: 1.5px solid #ddd6c4; padding: 12px; }
.static-frames figcaption { font-size: 14px; color: var(--ink-soft); margin-top: 8px; line-height: 1.7; }
.nojs h2 { font-family: var(--hand); font-size: 24px; margin-bottom: 12px; }
.nojs p { max-width: 40em; }

/* ---------- reduce：一切变化瞬时，保留操作与结果 ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .static-frames { grid-template-columns: 1fr; }
  .clip-2 { margin-left: 0; }
}
@media (max-width: 430px) {
  h1 { font-size: 33px; }
  .chapter p, .clipnote p { font-size: 16px; }
  .ops-group { gap: 10px; }
  .op-btn { font-size: 16px; padding: 9px 16px; }
  .stage { border-width: 5px; padding: 4px; }
}
