/* ============ 设计 token ============ */
:root {
    --bg-0: #0b0a14;
    --bg-1: #171232;
    --ink: #f3ecdd;
    --ink-dim: #a89dc4;
    --gold: #d9b36c;
    --gold-hi: #f0d49a;
    --paper-0: #f6efdd;
    --paper-1: #e7dcc1;
    --cover-0: #17122b;
    --cover-1: #262042;
    --font-serif: "EB Garamond", Georgia, "Times New Roman", serif;
    --book-w: min(76vw, 330px);
}

/* ============ 基础 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { height: 100%; }

body {
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font-serif);
    color: var(--ink);
    background:
        radial-gradient(120% 90% at 50% 0%, var(--bg-1) 0%, transparent 55%),
        radial-gradient(140% 100% at 50% 115%, #100c22 0%, transparent 60%),
        var(--bg-0);
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

#stardust {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

/* 首屏体验容器:固定一屏,内容区自然跟在其后 */
.app {
    position: relative;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

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

:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ============ 顶栏 ============ */
.topbar {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: max(14px, env(safe-area-inset-top)) 20px 0;
}

.topbar__brand {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: .24em;
    color: var(--ink-dim);
}

/* ============ 舞台 ============ */
.stage {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100dvh - 170px);
    padding: 24px 0 150px;
}

.book-area {
    position: relative;
    width: var(--book-w);
    height: calc(var(--book-w) * 4.1 / 3);
}

/* ============ 书(2D:纸页 + 封面) ============ */
.book__page {
    position: absolute;
    inset: 0;
    border-radius: 2px 8px 8px 2px;
    background: linear-gradient(165deg, var(--paper-0) 0%, var(--paper-1) 75%);
    box-shadow:
        inset 0 0 44px rgba(122, 96, 55, .14),
        6px 6px 0 -1px #efe6cf,
        10px 10px 0 -2px #e6dbc2,
        14px 14px 0 -3px #dccfae,
        16px 24px 50px rgba(0, 0, 0, .6);
    padding: 30px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.book__cover {
    position: absolute;
    inset: 0;
    border-radius: 2px 8px 8px 2px;
    background:
        radial-gradient(130% 100% at 30% 20%, rgba(240, 212, 154, .07), transparent 50%),
        linear-gradient(150deg, var(--cover-1), var(--cover-0) 70%);
    box-shadow:
        inset 0 0 0 1px rgba(217, 179, 108, .2),
        2px 4px 20px rgba(0, 0, 0, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .6s ease, transform .6s ease;
}

body:not([data-state="idle"]) .book__cover {
    opacity: 0;
    transform: translateY(-10px) scale(1.02);
    pointer-events: none;
}

.cover__frame {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 26px 18px;
    border: 1px solid rgba(217, 179, 108, .45);
    outline: 1px solid rgba(217, 179, 108, .18);
    outline-offset: 5px;
    border-radius: 4px;
}

.cover__star {
    color: var(--gold-hi);
    font-size: 15px;
    text-shadow: 0 0 12px rgba(240, 212, 154, .8);
}

.cover__title {
    font-size: clamp(25px, 7.6vw, 32px);
    font-weight: 600;
    font-style: italic;
    line-height: 1.3;
    letter-spacing: .05em;
    color: var(--gold-hi);
    text-shadow: 0 2px 14px rgba(217, 179, 108, .35);
}

.cover__sub {
    font-size: 10px;
    letter-spacing: .32em;
    color: var(--ink-dim);
    opacity: .8;
}

/* ============ 点击热区 ============ */
.book-hit {
    position: absolute;
    inset: -6%;
    z-index: 5;
    background: none;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
    border-radius: 10px;
}

body[data-state="revealed"] .book-hit { display: none; }

/* ============ 答案页内容(纸面墨字) ============ */
.page__question {
    font-size: 14px;
    font-style: italic;
    line-height: 1.5;
    color: #7a7195;
    margin-bottom: 20px;
    max-width: 92%;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    opacity: 0;
    transition: opacity 2.8s ease .8s;
}

.page__number {
    margin-top: 26px;
    font-size: 11px;
    font-style: italic;
    letter-spacing: .18em;
    color: #8b8160;
    opacity: 0;
    transition: opacity 2.4s ease 2.6s;
}

.book__page.pg-in .page__question,
.book__page.pg-in .page__number { opacity: 1; }

.page__answer {
    font-size: clamp(25px, 7.8vw, 38px);
    font-weight: 500;
    line-height: 1.45;
    letter-spacing: .02em;
    color: #2b2542;
    max-width: 100%;
    overflow-wrap: break-word;
}

/* 逐字母浮现:按词分组保证换行,词内字母不拆行 */
.page__answer .wd {
    display: inline-block;
}

.page__answer .ch {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    filter: blur(5px);
    transition: opacity 3.2s ease, transform 3.2s ease, filter 3.2s ease;
}

.page__answer.ch-in .ch {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
}

/* tone 墨色 */
.page__answer[data-tone="yes"]     { color: #8a6519; }
.page__answer[data-tone="act"]     { color: #8a6519; }
.page__answer[data-tone="no"]      { color: #a34848; }
.page__answer[data-tone="wait"]    { color: #7d6a35; }
.page__answer[data-tone="reflect"] { color: #4f62a8; }
.page__answer[data-tone="playful"] { color: #96547f; }

/* ============ 底部控制槽 ============ */
.controls {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: 2;
    height: 150px;
    padding: 0 24px max(18px, env(safe-area-inset-bottom));
}

.controls__slot {
    position: absolute;
    left: 24px; right: 24px; bottom: max(18px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity .45s ease, transform .45s ease, visibility 0s .45s;
}

body[data-state="idle"] .controls__slot--idle,
body[data-state="waiting"] .controls__slot--waiting,
body[data-state="revealed"] .controls__slot--revealed {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity .45s ease .15s, transform .45s ease .15s;
}

/* 等待提示:呼吸式明暗 */
.controls__slot--waiting .hint {
    animation: hint-pulse 1.5s ease-in-out infinite alternate;
}

@keyframes hint-pulse {
    from { opacity: .5; }
    to { opacity: 1; }
}

/* 书页中央的三点等待动画(墨金色,纸面上清晰) */
.page-waiting {
    display: flex;
    gap: 11px;
}

.page-waiting i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #a97f2f;
    opacity: .22;
    animation: dot-wave 1.2s ease-in-out infinite;
}

.page-waiting i:nth-child(2) { animation-delay: .2s; }
.page-waiting i:nth-child(3) { animation-delay: .4s; }

@keyframes dot-wave {
    0%, 60%, 100% { opacity: .22; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-5px); }
}

/* 减少动态下使用的纯明暗版(无位移) */
@keyframes dot-wave-rm {
    0%, 60%, 100% { opacity: .22; }
    30% { opacity: 1; }
}

.hint {
    font-size: 14px;
    font-style: italic;
    letter-spacing: .12em;
    color: var(--ink-dim);
}

.hint--sub { font-size: 12px; opacity: .7; letter-spacing: .2em; font-style: normal; }

.ask-input {
    width: min(320px, 86vw);
    padding: 11px 18px;
    font-family: var(--font-serif);
    font-size: 16px;
    text-align: center;
    color: var(--ink);
    letter-spacing: .06em;
    background: rgba(35, 29, 62, .55);
    border: 1px solid rgba(217, 179, 108, .22);
    border-radius: 999px;
    outline: none;
    transition: border-color .3s, box-shadow .3s;
}

.ask-input::placeholder { color: rgba(168, 157, 196, .55); }

.ask-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(217, 179, 108, .12);
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.btn {
    padding: 11px 22px;
    font-family: var(--font-serif);
    font-size: 14px;
    letter-spacing: .1em;
    color: var(--ink);
    background: rgba(35, 29, 62, .55);
    border: 1px solid rgba(217, 179, 108, .3);
    border-radius: 999px;
    cursor: pointer;
    touch-action: manipulation;
    transition: border-color .25s, color .25s, transform .15s, background .25s;
}

.btn:hover { border-color: var(--gold); color: var(--gold-hi); }
.btn:active { transform: scale(.96); }

.btn--primary {
    color: #1a1530;
    background: linear-gradient(150deg, var(--gold-hi), var(--gold));
    border-color: transparent;
    font-weight: 600;
}

.btn--primary:hover { color: #1a1530; filter: brightness(1.08); }

/* ============ noscript ============ */
.noscript-box {
    position: absolute;
    inset: auto 20px 40px;
    z-index: 10;
    padding: 18px;
    text-align: center;
    font-size: 14px;
    line-height: 2;
    color: var(--ink);
    background: rgba(23, 18, 50, .92);
    border: 1px solid rgba(217, 179, 108, .35);
    border-radius: 12px;
}

/* ============ 首屏以下内容(SEO) ============ */
.about {
    position: relative;
    z-index: 1;
    max-width: 680px;
    margin: 0 auto;
    padding: 64px 24px max(96px, env(safe-area-inset-bottom));
    border-top: 1px solid rgba(217, 179, 108, .14);
    user-select: text;
}

.about h2 {
    font-size: clamp(26px, 6vw, 34px);
    font-weight: 500;
    font-style: italic;
    color: var(--gold-hi);
    margin-bottom: 20px;
}

.about h3 {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .28em;
    text-transform: uppercase;
    color: var(--gold);
    margin: 44px 0 18px;
}

.about p {
    font-size: 17px;
    line-height: 1.8;
    color: var(--ink-dim);
    margin-bottom: 16px;
}

.about__steps {
    padding-left: 22px;
    display: grid;
    gap: 12px;
}

.about__steps li {
    font-size: 17px;
    line-height: 1.7;
    color: var(--ink-dim);
}

.about__steps li::marker {
    color: var(--gold);
}

.about__faq details {
    border-bottom: 1px solid rgba(217, 179, 108, .12);
}

.about__faq details:first-child {
    border-top: 1px solid rgba(217, 179, 108, .12);
}

.about__faq summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 0;
    font-size: 17px;
    color: var(--ink);
    cursor: pointer;
    list-style: none;
    -webkit-tap-highlight-color: transparent;
}

.about__faq summary::-webkit-details-marker { display: none; }

.about__faq summary::after {
    content: "+";
    flex: none;
    color: var(--gold);
    font-size: 22px;
    font-weight: 400;
    line-height: 1;
}

.about__faq details[open] summary::after { content: "–"; }

.about__faq p {
    margin: 0;
    padding-bottom: 20px;
}

.about .about__footer {
    margin: 56px 0 0;
    text-align: center;
    font-style: italic;
    font-size: 14px;
    letter-spacing: .12em;
    opacity: .8;
}

/* ============ 横屏矮屏 ============ */
@media (min-aspect-ratio: 5/4) and (max-height: 560px) {
    :root { --book-w: min(52vh, 300px); }
    .stage { min-height: calc(100dvh - 120px); padding-bottom: 110px; }
    .controls { height: 110px; }
    .controls__slot--idle .hint--sub { display: none; }
}

/* ============ 减少动态 ============ */
/* 保留全部纯明暗动画(呼吸文字、等待点),只移除位移/模糊 */
@media (prefers-reduced-motion: reduce) {
    .page-waiting i { animation-name: dot-wave-rm; }
    .page__answer .ch {
        transition: opacity 3.2s ease;
        transform: none;
        filter: none;
    }
}
