/* ==========================================================================
   晏然自若 · 一根线 —— 全站唯一样式层
   结构：设计变量与三套主题 → 底层骨架 → 图框 / 图签 / 目录 → 图纸舞台
        → SVG 图元词汇 → 震撼节点 → 终端 → 流式图纸（服务 / 文摘）→ 响应式与降级
   ========================================================================== */

/* ===== 设计变量：沿用旧站森林绿 + 米白血统 ===== */
:root {
    /* 旧站品牌绿 */
    --green: #1e5c3a;

    /* 旧站深绿画布 */
    --green-canvas: #0d2a1b;

    /* 旧站米白纸 */
    --paper-white: #fafaf7;

    /* 字体：工程长仿宋、等宽、正文 */
    --font-fs: "FangSong", "STFangsong", "仿宋", "FangSong_GB2312", serif;
    --font-mono: "JetBrains Mono", "Cascadia Mono", Consolas, "SFMono-Regular", monospace;
    --font-cn: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;

    /* 主线线宽，随全页进度由脚本改写（线重 1.50 → 1.20） */
    --lw: 2.2px;

    /* 缓动 */
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* 主题·图纸：米白图纸 + 森林绿线条 */
.theme-paper {
    --bg: #f6f5ee;
    --grid: rgba(30, 92, 58, 0.06);
    --grid-strong: rgba(30, 92, 58, 0.12);
    --ink: #1e5c3a;
    --ink-dim: rgba(30, 92, 58, 0.55);
    --ink-faint: rgba(30, 92, 58, 0.16);
    --text: #1c2a22;
    --accent: #2b8a57;
    --card: #fbfbf7;
    --run: #13b356;
    --amber: #d9890c;
    --glow: rgba(19, 179, 86, 0.55);
}

/* 主题·屏幕：旧站深绿画布 + 荧光薄荷字 */
.theme-screen {
    --bg: #0d2a1b;
    --grid: rgba(143, 240, 181, 0.035);
    --grid-strong: rgba(143, 240, 181, 0.07);
    --ink: #8ff0b5;
    --ink-dim: rgba(143, 240, 181, 0.5);
    --ink-faint: rgba(143, 240, 181, 0.14);
    --text: #dff7e8;
    --accent: #5fe39a;
    --card: #10331f;
    --run: #5fe39a;
    --amber: #f2b33d;
    --glow: rgba(95, 227, 154, 0.6);
}

/* 主题·AI：更深的绿，留给光点 */
.theme-ai {
    --bg: #071a10;
    --grid: rgba(238, 247, 240, 0.02);
    --grid-strong: rgba(238, 247, 240, 0.04);
    --ink: #eef7f0;
    --ink-dim: rgba(238, 247, 240, 0.5);
    --ink-faint: rgba(238, 247, 240, 0.12);
    --text: #eef7f0;
    --accent: #7ff0b0;
    --card: #0b2418;
    --run: #7ff0b0;
    --amber: #f2b33d;
    --glow: rgba(127, 240, 176, 0.6);
}

/* 主题·铅笔：施工中的草图，灰绿虚线 */
.theme-pencil {
    --bg: #f4f3ec;
    --grid: rgba(107, 125, 114, 0.06);
    --grid-strong: rgba(107, 125, 114, 0.11);
    --ink: #55675c;
    --ink-dim: rgba(85, 103, 92, 0.55);
    --ink-faint: rgba(85, 103, 92, 0.16);
    --text: #2b3830;
    --accent: #1e5c3a;
    --card: #fbfaf5;
    --run: #13b356;
    --amber: #d9890c;
    --glow: rgba(19, 179, 86, 0.45);
}

/* ===== 底层骨架 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--paper-white); }
html, body { overflow-x: clip; }
body {
    background: var(--bg); color: var(--text); font-family: var(--font-cn);
    -webkit-font-smoothing: antialiased; transition: background-color 0.7s var(--ease), color 0.7s var(--ease);
}
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* 图纸底：细网格 + 粗网格 + 中心微光 */
.paper {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background:
        radial-gradient(ellipse 75% 65% at 50% 45%, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 70%),
        repeating-linear-gradient(0deg, var(--grid-strong) 0 1px, transparent 1px 100px),
        repeating-linear-gradient(90deg, var(--grid-strong) 0 1px, transparent 1px 100px),
        repeating-linear-gradient(0deg, var(--grid) 0 1px, transparent 1px 20px),
        repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 20px);
}

/* ===== 图框与坐标格 ===== */
.frame { position: fixed; inset: 14px; z-index: 30; pointer-events: none; border: 1.5px solid var(--ink-dim); transition: border-color 0.7s; }
.frame::after { content: ""; position: absolute; inset: 22px; border: 1px solid var(--ink-faint); }
.ticks-x, .ticks-y { position: absolute; display: flex; font-family: var(--font-mono); font-size: 10px; color: var(--ink-dim); }
.ticks-x { left: 22px; right: 22px; top: 4px; justify-content: space-around; }
.ticks-y { top: 22px; bottom: 22px; left: 6px; flex-direction: column; justify-content: space-around; }

/* ===== 快进按钮：来路段浮动，跳到服务区 ===== */
.skip-btn {
    position: fixed; right: 36px; bottom: 130px; z-index: 40;
    padding: 8px 18px; border-radius: 999px;
    border: 1.5px solid var(--ink); background: var(--bg);
    color: var(--ink); font-family: var(--font-mono); font-size: 13px;
    cursor: pointer; opacity: 0; pointer-events: none;
    transition: opacity 0.4s, background 0.2s;
}
.skip-btn.visible { opacity: 1; pointer-events: auto; }
.skip-btn:hover { background: var(--ink); color: var(--bg); }
.skip-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== 图签 ===== */
.titleblock {
    position: fixed; right: 36px; bottom: 36px; z-index: 31;
    display: grid; grid-template-columns: 56px 150px 56px 104px; border: 1.5px solid var(--ink);
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(3px);
    font-family: var(--font-fs); font-size: 13px; color: var(--text);
    transition: border-color 0.7s, background-color 0.7s, color 0.7s;
}
.titleblock > div { border-right: 1px solid var(--ink-faint); border-bottom: 1px solid var(--ink-faint); padding: 5px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titleblock .k { color: var(--ink-dim); }
.titleblock .v { font-family: var(--font-mono); font-size: 12px; }
.titleblock .name { grid-column: span 3; font-size: 18px; letter-spacing: 0.3em; color: var(--ink); }
.titleblock .v.hot { color: var(--run); }

/* ===== 图纸目录 ===== */
.index-tab {
    position: fixed; left: 36px; top: 36px; z-index: 32; padding: 6px 12px;
    font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em; color: var(--ink);
    border: 1.5px solid var(--ink); background: color-mix(in srgb, var(--bg) 85%, transparent);
    transition: background-color 0.3s, color 0.3s;
}
.index-tab:hover, .index-tab[aria-expanded="true"] { background: var(--ink); color: var(--bg); }
.index-drawer {
    position: fixed; left: 36px; top: 74px; z-index: 32; width: 300px; max-height: calc(100vh - 120px); overflow: auto;
    border: 1.5px solid var(--ink); background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(6px);
    padding: 14px 16px; font-family: var(--font-fs);
}
.index-drawer h4 { font-size: 15px; letter-spacing: 0.3em; color: var(--ink); margin: 10px 0 6px; border-bottom: 1px solid var(--ink-faint); padding-bottom: 4px; }
.index-drawer h4:first-child { margin-top: 0; }
.index-drawer a { display: grid; grid-template-columns: 82px 1fr; gap: 8px; padding: 4px 6px; text-decoration: none; font-size: 14px; color: var(--text); }
.index-drawer a span { font-family: var(--font-mono); font-size: 11px; color: var(--ink-dim); padding-top: 2px; }
.index-drawer a:hover, .index-drawer a.current { background: var(--ink-faint); }
.index-drawer a.current span { color: var(--run); }

/* ===== 图纸舞台 ===== */
.sheet { position: relative; z-index: 2; }
.sheet .stage { position: sticky; top: 0; height: 100vh; width: 100%; overflow: hidden; }
.sheet.flow .stage { position: relative; height: auto; min-height: 100vh; overflow: visible; }
.stage svg.drawing { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ===== SVG 图元词汇：颜色全部取主题变量（样式表优先于属性，故颜色只在这里定） ===== */
.ln { stroke: var(--ink); stroke-width: 1.6; fill: none; }
.ln-dim { stroke: var(--ink-dim); stroke-width: 1; fill: none; }
.ln-faint { stroke: var(--ink-faint); stroke-width: 1; fill: none; }
.ln-accent { stroke: var(--accent); stroke-width: 1.6; fill: none; }
.ln-amber { stroke: var(--amber); stroke-width: 1.6; fill: none; }
.dashdot { stroke: var(--accent); stroke-width: 1; fill: none; stroke-dasharray: 18 4 2 4; opacity: 0.7; }
.main { stroke: var(--ink); stroke-width: var(--lw); fill: none; stroke-linecap: round; stroke-linejoin: round; }
.on { stroke: var(--run) !important; filter: drop-shadow(0 0 5px var(--glow)); }
.lit { filter: drop-shadow(0 0 9px var(--glow)); }
.fill-card { fill: var(--card); }
.fill-ink { fill: var(--ink); }
.fill-run { fill: var(--run); }
.fill-amber { fill: var(--amber); }
.fill-faint { fill: var(--ink-faint); }
.tx { fill: var(--ink-dim); font-family: var(--font-mono); }
.tx-ink { fill: var(--ink); font-family: var(--font-mono); }
.tx-accent { fill: var(--accent); font-family: var(--font-mono); }
.tx-amber { fill: var(--amber); font-family: var(--font-mono); }
.tx-fs { fill: var(--text); font-family: var(--font-fs); }
.hit { cursor: pointer; }
.pen { fill: var(--run); filter: drop-shadow(0 0 6px var(--glow)) drop-shadow(0 0 14px var(--glow)); }

/* ===== 震撼节点 ===== */
.flash { position: fixed; inset: 0; z-index: 60; background: #fff; opacity: 0; pointer-events: none; }
.shards { position: absolute; inset: 0; perspective: 1400px; pointer-events: none; z-index: 5; }
.shard { position: absolute; inset: 0; background: var(--bg); will-change: transform, opacity; }
.shard svg { width: 100%; height: 100%; }
canvas.sparks { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 7; pointer-events: none; }
.ai-layer { position: fixed; inset: 0; z-index: 1; opacity: 0; pointer-events: none; transition: opacity 0.8s; }
.ai-layer canvas { width: 100%; height: 100%; display: block; }
body.ai-on .ai-layer { opacity: 1; }

/* ===== 终端 ===== */
.terminal {
    position: absolute; inset: 0; z-index: 1; color: var(--ink);
    font-family: var(--font-mono); font-size: clamp(13px, 1.15vw, 18px); line-height: 1.75; padding: 12vh 12vw;
    opacity: 0; background: #0d2a1b;
}
.terminal::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px); }
.terminal .ln-t { white-space: pre; color: #8ff0b5; text-shadow: 0 0 8px rgba(143, 240, 181, 0.45); }
.terminal .c { color: rgba(143, 240, 181, 0.45); }
.caret { display: inline-block; width: 0.6em; height: 1.1em; background: var(--run); vertical-align: -0.2em; animation: blink 1s steps(1) infinite; box-shadow: 0 0 10px var(--glow); }
@keyframes blink { 50% { opacity: 0; } }

/* ===== 流式图纸通用版心（服务 / 文摘等非粘性图纸） ===== */
.flow-wrap { max-width: 1180px; margin: 0 auto; padding: 120px 48px 140px; position: relative; }
.flow-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 1.5px solid var(--ink); padding-bottom: 12px; margin-bottom: 36px; }
.flow-head h2 { font-family: var(--font-fs); font-size: 40px; letter-spacing: 0.3em; color: var(--ink); font-weight: 600; }
.flow-head small { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.2em; color: var(--ink-dim); }

/* 提示条 */
.noscript { padding: 40vh 10vw; text-align: center; font-family: var(--font-fs); font-size: 20px; }

/* ===== 响应式：窄屏收起图签与坐标格 ===== */
@media (max-width: 900px) {
    .frame { inset: 8px; }
    .ticks-x, .ticks-y { display: none; }
    .titleblock { right: 12px; bottom: 12px; grid-template-columns: 44px 100px; font-size: 12px; }
    .titleblock > div:nth-child(n + 7) { display: none; }
    .titleblock .name { grid-column: span 1; font-size: 14px; }
    .titleblock > div:nth-child(5), .titleblock > div:nth-child(6) { display: none; }
    .index-tab { left: 14px; top: 14px; }
    .index-drawer { left: 14px; top: 50px; width: calc(100vw - 28px); }
    .flow-wrap { padding: 90px 20px 120px; }
    .flow-head h2 { font-size: 28px; }
}

/* ===== 低动效偏好：关闭闪白、震屏与长动画 ===== */
@media (prefers-reduced-motion: reduce) {
    .flash { display: none; }
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
