/* ============================================
   《来电恐惧》—— 极简空屏风(强化版)
   ============================================ */

:root {
    --bg: #0a0a0a;
    --text: #f5f5f5;
    --text-mute: #b8b8b8;
    --text-faint: #707070;
    --text-ghost: rgba(245, 245, 245, 0.45);
    --accent: rgba(245, 245, 245, 0.85);

    --font-serif: "Noto Serif SC", "Noto Serif", "Songti SC", "Source Han Serif SC", "STSong", serif;
    --font-mono: "SF Mono", "Menlo", "Consolas", monospace;

    --ease: cubic-bezier(0.4, 0.0, 0.2, 1);
    --duration-slow: 1200ms;
    --duration-mid: 800ms;
    --duration-fast: 400ms;
}

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

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-serif);
    font-weight: 300;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    cursor: default;
}

button {
    font-family: inherit;
    color: inherit;
    background: transparent;
    border: none;
    cursor: pointer;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

button {
    font-family: var(--font-serif);
    font-weight: 400;
}

/* ============================================
   主舞台
   ============================================ */

.stage {
    position: fixed;
    inset: 0;
    display: grid;
    grid-template-rows: auto 1fr auto;
    padding: 4vh 7vw;
    transition: opacity var(--duration-mid) var(--ease);
}

.stage.phase-answering {
    background: #050505;
}

.stage.phase-restarting {
    background: #000;
}

/* ============================================
   来电头部(强化版)
   ============================================ */

.caller-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 3vw;
    padding: 1vh 0 3vh;
    color: var(--text-mute);
    opacity: 0.9;
    transition: opacity var(--duration-slow) var(--ease);
}

.caller-icon-wrap {
    position: relative;
    width: 96px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.caller-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-mute);
    z-index: 2;
    position: relative;
    animation: ring-shake 5s var(--ease) infinite;
}

@keyframes ring-shake {
    0%, 90%, 100% { transform: rotate(0deg); }
    92% { transform: rotate(-15deg); }
    94% { transform: rotate(15deg); }
    96% { transform: rotate(-8deg); }
    98% { transform: rotate(8deg); }
}

/* 脉冲光晕 */
.caller-pulse {
    position: absolute;
    inset: 0;
    border: 1px solid rgba(245, 245, 245, 0.18);
    border-radius: 50%;
    animation: pulse-ring 2.4s var(--ease) infinite;
}

.caller-pulse::before {
    content: "";
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(245, 245, 245, 0.10);
    border-radius: 50%;
    animation: pulse-ring 2.4s var(--ease) infinite 0.4s;
}

@keyframes pulse-ring {
    0% { transform: scale(0.7); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

.caller-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.caller-status {
    font-size: 18px;
    letter-spacing: 0.5em;
    color: var(--text);
    font-weight: 400;
    text-indent: 0.5em;
}

.caller-name {
    font-size: 14px;
    color: var(--text-ghost);
    letter-spacing: 0.2em;
}

.caller-hint {
    font-size: 12px;
    color: var(--text-faint);
    letter-spacing: 0.3em;
    font-style: italic;
    opacity: 0.7;
    margin-top: 4px;
}

.counter {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-faint);
    letter-spacing: 0.1em;
    align-self: start;
    padding: 4px 0;
    transition: color var(--duration-slow) var(--ease), font-size var(--duration-slow) var(--ease);
}

.counter.noticing {
    color: var(--text-mute);
    font-size: 15px;
}

/* ============================================
   主交互区
   ============================================ */

.main-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.stage-section {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 4vh 6vw;
    transition: opacity var(--duration-slow) var(--ease);
}

/* 当前开场白(字号变大) */
.current-phrase-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 3vh 0 2vh;
    min-height: 30vh;
}

/* 初始 placeholder:想想我该怎么说... */
.initial-placeholder {
    color: var(--text-faint);
    font-size: 26px;
    font-weight: 300;
    font-style: italic;
    letter-spacing: 0.4em;
    text-align: center;
    opacity: 0.7;
    animation: placeholder-pulse 3s var(--ease) infinite;
    transition: opacity 600ms var(--ease);
}

.initial-placeholder.dismissed {
    opacity: 0;
    pointer-events: none;
}

@keyframes placeholder-pulse {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 0.75; }
}

.current-phrase {
    font-family: var(--font-serif);
    text-align: center;
    line-height: 1.8;
    letter-spacing: 0.1em;
    color: var(--text);
    max-width: 50ch;
    opacity: 0;
    transform: translateY(8px);
    animation: phrase-in var(--duration-slow) var(--ease) forwards;
    word-break: break-word;
}

@keyframes phrase-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 7 种语气的 typographic 物理差异(字号增大) */
.current-phrase.tone-1 { font-weight: 200; font-size: 36px; line-height: 2.0; letter-spacing: 0.15em; }
.current-phrase.tone-2 { font-weight: 700; font-size: 32px; line-height: 1.5; letter-spacing: 0.05em; }
.current-phrase.tone-3 { font-weight: 400; font-size: 38px; line-height: 1.7; letter-spacing: 0.1em; }
.current-phrase.tone-4 { font-weight: 600; font-size: 40px; line-height: 2.2; letter-spacing: 0.15em; }
.current-phrase.tone-5 { font-weight: 500; font-size: 36px; line-height: 1.6; letter-spacing: 0.1em; }
.current-phrase.tone-6 { font-weight: 200; font-size: 34px; line-height: 1.9; letter-spacing: 0.15em; }
.current-phrase.tone-7 { font-weight: 800; font-size: 30px; line-height: 1.3; letter-spacing: 0.05em; }
.current-phrase.tone-8 { font-weight: 800; font-size: 34px; line-height: 1.4; letter-spacing: 0.02em; color: #f5e0e0; }

/* 「听一遍」后的内心自我评价(浮在当前回应文字下方) */
.self-evaluation {
    margin-top: 18px;
    font-family: var(--font-serif);
    font-size: 14px;
    line-height: 1.6;
    color: rgba(245, 245, 245, 0.42);
    font-style: italic;
    letter-spacing: 0.15em;
    text-align: center;
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    user-select: none;
}

.self-evaluation.self-evaluation-show {
    animation: self-eval-in 600ms var(--ease) forwards;
}

@keyframes self-eval-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 加载态 */
.current-phrase.loading {
    opacity: 0.4;
    font-style: italic;
    color: var(--text-faint);
    font-weight: 200;
    font-size: 24px;
    animation: pulse 1.6s var(--ease) infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.5; }
}

/* 用户输入生成的开场白 */
.current-phrase.user-input {
    font-weight: 700;
    font-size: 34px;
    color: var(--text);
    letter-spacing: 0.18em;
    background: linear-gradient(180deg, transparent 60%, rgba(245, 245, 245, 0.06) 60%);
}

/* ============================================
   按钮区(新布局)
   ============================================ */

.actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5vh;
    padding: 2vh 0;
    width: 100%;
}

.actions-row {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

/* 主行(接听/再想想)初始隐藏,浮现有动画 */
.actions-row-primary {
    gap: 18vw;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transform: translateY(-8px);
    transition: max-height 800ms var(--ease), opacity 800ms var(--ease), transform 800ms var(--ease), margin 800ms var(--ease);
    margin: 0;
}

.actions-row-primary.visible {
    max-height: 80px;
    opacity: 1;
    transform: translateY(0);
    margin-top: 0.5vh;
}

.actions-row-secondary {
    margin-top: 0.5vh;
}

.btn {
    font-size: 16px;
    letter-spacing: 0.5em;
    padding: 12px 24px;
    color: var(--text-faint);
    background: transparent;
    border: 1px solid rgba(245, 245, 245, 0.22);
    border-radius: 4px;
    transition: color var(--duration-fast) var(--ease),
                border-color var(--duration-fast) var(--ease),
                background var(--duration-fast) var(--ease),
                opacity var(--duration-fast) var(--ease),
                transform var(--duration-fast) var(--ease);
    white-space: nowrap;
    text-indent: 0.5em;
    cursor: pointer;
}

.btn:hover {
    color: var(--text-mute);
    border-color: rgba(245, 245, 245, 0.45);
    background: rgba(245, 245, 245, 0.03);
}

.btn:active {
    transform: scale(0.98);
    background: rgba(245, 245, 245, 0.06);
}

.btn[disabled] {
    opacity: 0.2;
    cursor: not-allowed;
    pointer-events: none;
}

/* 接听/读一遍 是主按钮,边框稍亮,字号略大 */
.btn-primary, .btn-answer {
    color: var(--text-mute);
    font-size: 17px;
    padding: 14px 28px;
    border-color: rgba(245, 245, 245, 0.35);
}

.btn-primary:hover, .btn-answer:hover {
    color: var(--text);
    border-color: rgba(245, 245, 245, 0.6);
    background: rgba(245, 245, 245, 0.05);
}

/* 措辞/换一个 是次按钮,字号略小,边框更淡 */
.btn-secondary {
    color: var(--text-faint);
    font-size: 14px;
    letter-spacing: 0.6em;
    border-color: rgba(245, 245, 245, 0.15);
}

.btn-secondary:hover {
    border-color: rgba(245, 245, 245, 0.35);
}

.btn-answer {
    color: var(--text-mute);
    position: relative;
}

.btn-answer:hover {
    color: var(--text);
}

/* 接听按钮的微弱发光 */
.btn-answer::after {
    content: "";
    position: absolute;
    inset: -2px -8px;
    border: 1px solid transparent;
    border-radius: 2px;
    transition: border-color var(--duration-slow) var(--ease);
    pointer-events: none;
}

.btn-answer:hover::after {
    border-color: rgba(245, 245, 245, 0.15);
}

/* ============================================
   内心独白(浮现动画)
   ============================================ */

.inner-monologue {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-top: 3vh;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 1500ms var(--ease), transform 1500ms var(--ease);
    text-align: center;
}

.inner-monologue[hidden] {
    display: none;
}

.inner-monologue.visible {
    opacity: 1;
    transform: translateY(0);
}

.inner-monologue-text {
    font-size: 14px;
    color: var(--text-faint);
    letter-spacing: 0.3em;
    font-style: italic;
}

.inner-monologue-hint {
    font-size: 13px;
    color: var(--text-ghost);
    letter-spacing: 0.4em;
    margin-top: 2px;
}

/* ============================================
   用户输入(初始隐藏)
   ============================================ */

.user-input-form {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 48ch;
    margin-top: 1.5vh;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 1200ms var(--ease) 600ms, transform 1200ms var(--ease) 600ms;
}

.user-input-form[hidden] {
    display: none;
}

.user-input-form.visible {
    opacity: 1;
    transform: translateY(0);
}

.user-input {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(245, 245, 245, 0.45);
    padding: 14px 8px;
    color: var(--text);
    font-family: var(--font-serif);
    font-weight: 400;
    font-size: 20px;
    letter-spacing: 0.15em;
    text-align: center;
    outline: none;
    transition: border-color var(--duration-fast) var(--ease);
}

.user-input::placeholder {
    color: rgba(245, 245, 245, 0.28);
    letter-spacing: 0.2em;
    font-weight: 300;
    font-size: 14px;
}

.user-input:focus {
    border-bottom-color: rgba(245, 245, 245, 0.85);
}

.btn-input-submit {
    margin-left: 12px;
    padding: 10px;
    color: rgba(245, 245, 245, 0.7);
    display: flex;
    align-items: center;
    transition: color var(--duration-fast) var(--ease);
}

.btn-input-submit:hover {
    color: var(--text);
}

/* ============================================
   接听阶段
   ============================================ */

.answer-section {
    z-index: 2;
}

.answer-section[hidden] {
    display: none;
}

.answer-subtitle {
    font-family: var(--font-serif);
    font-size: 28px;
    line-height: 2;
    text-align: center;
    letter-spacing: 0.15em;
    color: var(--text);
    opacity: 0;
    transform: translateY(8px);
    animation: subtitle-in var(--duration-slow) var(--ease) forwards;
    max-width: 40ch;
    transition: color var(--duration-slow) var(--ease), font-style var(--duration-slow) var(--ease);
}

@keyframes subtitle-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 用户说的(imagined self):略斜体,字距稍宽,色温稍冷 */
.answer-subtitle[data-speaker="user"] {
    color: var(--text-mute);
    font-style: italic;
    letter-spacing: 0.18em;
    font-size: 26px;
}

/* 对方说的:正常,色温稍暖,字号略大 */
.answer-subtitle[data-speaker="other"] {
    color: var(--text);
    font-size: 30px;
}

/* ============================================
   循环重启过场
   ============================================ */

.restart-section {
    background: #000;
    z-index: 3;
}

.restart-section[hidden] {
    display: none;
}

.restart-msg {
    color: var(--text-faint);
    font-size: 12px;
    letter-spacing: 0.5em;
    opacity: 0;
    animation: fade-in 600ms var(--ease) 200ms forwards;
}

@keyframes fade-in {
    to { opacity: 1; }
}

/* ============================================
   累积层(显著化:聊天气泡式)
   ============================================ */

.accumulation {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.accumulated-phrase {
    position: absolute;
    font-family: var(--font-serif);
    white-space: nowrap;
    color: var(--text);
    opacity: 0;
    padding: 6px 12px;
    border-radius: 2px;
    background: rgba(245, 245, 245, 0.025);
    border-left: 1px solid rgba(245, 245, 245, 0.12);
    transition: opacity 1800ms var(--ease), transform 1800ms var(--ease), font-size 1800ms var(--ease), background 1800ms var(--ease);
    will-change: opacity, transform, font-size;
}

.accumulated-phrase.tone-1 { font-weight: 200; }
.accumulated-phrase.tone-2 { font-weight: 700; }
.accumulated-phrase.tone-3 { font-weight: 400; }
.accumulated-phrase.tone-4 { font-weight: 600; }
.accumulated-phrase.tone-5 { font-weight: 500; }
.accumulated-phrase.tone-6 { font-weight: 200; }
.accumulated-phrase.tone-7 { font-weight: 800; }
.accumulated-phrase.tone-8 { font-weight: 800; color: rgba(245, 200, 200, 0.5); }

/* ============================================
   状态栏
   ============================================ */

.status-bar {
    position: fixed;
    bottom: 3vh;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-ghost);
    letter-spacing: 0.2em;
    opacity: 0;
    transition: opacity var(--duration-slow) var(--ease);
    pointer-events: none;
}

.status-bar.visible {
    opacity: 1;
}

/* ============================================
   阶段切换
   ============================================ */

.preparation-section {
    z-index: 2;
}

.preparation-section[hidden],
.answer-section[hidden],
.restart-section[hidden] {
    display: none;
}

.stage.phase-answering .caller-header {
    opacity: 0.25;
}

.stage.phase-restarting .caller-header,
.stage.phase-restarting .accumulation {
    opacity: 0;
}

/* ============================================
   响应式
   ============================================ */

@media (max-width: 768px) {
    .stage {
        padding: 3vh 5vw;
    }

    .actions-row-primary {
        gap: 14vw;
    }

    .btn-primary, .btn-answer {
        font-size: 15px;
        padding: 12px 20px;
    }

    .btn-secondary {
        font-size: 13px;
    }

    .current-phrase.tone-1 { font-size: 26px; }
    .current-phrase.tone-2 { font-size: 24px; }
    .current-phrase.tone-3 { font-size: 28px; }
    .current-phrase.tone-4 { font-size: 30px; }
    .current-phrase.tone-5 { font-size: 26px; }
    .current-phrase.tone-6 { font-size: 26px; }
    .current-phrase.tone-7 { font-size: 24px; }
    .current-phrase.tone-8 { font-size: 26px; }

    .caller-icon-wrap {
        width: 80px;
        height: 80px;
    }

    .caller-icon svg {
        width: 52px;
        height: 52px;
    }

    .caller-status {
        font-size: 16px;
    }

    .caller-hint {
        display: none;
    }

    .counter {
        font-size: 11px;
    }
}

/* 触摸设备禁用 ring-shake 动画(性能) */
@media (prefers-reduced-motion: reduce) {
    .caller-icon {
        animation: none;
    }
    .caller-pulse, .caller-pulse::before {
        animation: none;
    }
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}