/* 空间预览：三维场景占满整屏，界面文字浮在纸外。 */
@font-face {
    font-family: "Shuguang Serif Preview";
    src: url("preview-serif.woff2?v=20261204a") format("woff2");
    font-weight: 400 500;
    font-display: swap;
}

:root, [data-theme="day"] {
    color-scheme: light;
    --paper: #f3ecdf;
    --ink: #252720;
    --muted: #5a5e51;
    --accent: #8a6b3e;
    --rule: rgba(135, 78, 45, 0.24);
    --seal: #a6382a;
    --seal-ink: #f6eee1;
    --ui-bg: rgba(247, 241, 227, 0.72);
    --ui-line: rgba(120, 96, 62, 0.28);
}
[data-theme="night"] {
    color-scheme: dark;
    --paper: #1f2320;
    --ink: #e4ddca;
    --muted: #aaa595;
    --accent: #d1ba87;
    --rule: rgba(200, 190, 155, 0.22);
    --seal: #b0493a;
    --seal-ink: #f1e6d4;
    --ui-bg: rgba(26, 31, 28, 0.66);
    --ui-line: rgba(190, 180, 150, 0.24);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); }
body {
    font-family: "Shuguang Serif Preview", "Noto Serif SC", "Songti SC", "SimSun", serif;
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}
canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
canvas.is-dragging { cursor: grabbing; }
[hidden] { display: none !important; }
a { color: inherit; }
button { color: inherit; font: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, a:focus-visible { outline: 1px solid var(--accent); outline-offset: 5px; }

.hud {
    position: fixed; z-index: 10; top: 26px; left: 34px; display: flex; gap: 1.1rem;
    color: var(--muted); font-size: 12px; letter-spacing: 0.18em; pointer-events: none;
}
.hud-brand { color: var(--ink); }
.grain { position: fixed; z-index: 3; inset: -20px; pointer-events: none; opacity: 0.10; mix-blend-mode: multiply;
    background: url("../assets/paper-grain.png?v=20261106a") repeat; background-size: 220px 220px; }
[data-theme="night"] .grain { opacity: 0.08; mix-blend-mode: multiply; }
.vignette { position: fixed; z-index: 3; inset: 0; pointer-events: none;
    background: radial-gradient(ellipse at 50% 45%, transparent 46%, rgba(52, 40, 22, 0.16) 100%); }
[data-theme="night"] .vignette { background: radial-gradient(ellipse at 50% 45%, transparent 40%, rgba(0, 0, 0, 0.42) 100%); }
.veil { position: fixed; z-index: 40; inset: 0; display: grid; place-items: center; background: var(--paper); color: var(--muted); font-size: 12px; letter-spacing: 0.4em; transition: opacity 700ms ease; }
.veil span { opacity: 0.7; }
.veil.is-gone { opacity: 0; pointer-events: none; }
.live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.hud-stage { opacity: 0.7; }

.hint {
    position: fixed; z-index: 10; left: 34px; bottom: 30px; margin: 0;
    color: var(--muted); font-size: 11px; letter-spacing: 0.2em; opacity: 0.7;
    transition: opacity 700ms ease; pointer-events: none;
}
body[data-stage]:not([data-stage="0"]) .hint { opacity: 0; }

.stops {
    position: fixed; z-index: 10; left: 34px; top: 50%; display: flex; flex-direction: column; gap: 18px;
    transform: translateY(-50%);
}
.stops button { display: flex; align-items: center; gap: 11px; min-height: 34px; color: var(--muted); }
.stops i { display: block; width: 18px; height: 1px; background: var(--ui-line); transition: width 400ms ease, background 400ms ease; }
.stops b { font-size: 10px; font-weight: 400; letter-spacing: 0.16em; opacity: 0.75; }
.stops button[aria-current="step"] i { width: 40px; background: var(--accent); }
.stops button[aria-current="step"] b { color: var(--ink); opacity: 1; }

.controls {
    position: fixed; z-index: 10; right: 34px; bottom: 28px; display: flex; gap: 1.6rem;
}
.controls button {
    min-height: 42px; padding: 0.4rem 0; color: var(--muted); font-size: 12px; letter-spacing: 0.18em;
    border-bottom: 1px solid var(--ui-line); transition: color 300ms ease, border-color 300ms ease;
}
.controls button:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.controls button:disabled { opacity: 0.28; cursor: default; }
.controls .next { color: var(--ink); }

.site-record {
    position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 1.4rem;
    padding: 0 16px max(10px, env(safe-area-inset-bottom));
    color: var(--muted); font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    font-size: 10px; pointer-events: none;
}
.site-record a { display: inline-flex; align-items: center; gap: 4px; pointer-events: auto; text-decoration: none; }
.site-record a span { opacity: 0.8; }
.site-record a:hover span { opacity: 1; }
.site-record img { width: 15px; height: 17px; }

.fallback {
    position: fixed; z-index: 20; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 1.2rem; padding: 2rem; text-align: center; background: var(--paper);
}
.fallback p { margin: 0; color: var(--muted); font-size: 0.95rem; letter-spacing: 0.08em; }
.fallback a { padding: 0.5rem 0; border-bottom: 1px solid var(--rule); text-decoration: none; letter-spacing: 0.14em; }

@media (max-width: 760px) {
    .hud { top: max(16px, env(safe-area-inset-top)); left: 18px; font-size: 10px; gap: 0.7rem; letter-spacing: 0.1em; }
    .stops { left: 16px; gap: 14px; }
    .stops b { display: none; }
    .stops i { width: 14px; }
    .stops button[aria-current="step"] i { width: 26px; }
    .hint { left: 18px; bottom: 76px; font-size: 10px; }
    .controls { left: 18px; right: 18px; bottom: max(22px, env(safe-area-inset-bottom)); justify-content: space-between; }
    .controls button { font-size: 12px; }
    .site-record { bottom: 62px; font-size: 9px; gap: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition-duration: 0.01ms !important; }
}
