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

: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;

    --green: #4dd06a;
    --green-bg: rgba(77, 208, 106, 0.08);
    --green-border: rgba(77, 208, 106, 0.25);
}

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

html, body {
    height: 100%;
    background: #000;
    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;
}

/* ============================================
   9:16 真实手机画布
   ============================================ */

.phone-frame {
    width: min(100vw, 56.25vh);    /* 9/16 = 0.5625 */
    height: min(177.77vw, 100vh);  /* 16/9 = 1.7777 */
    margin: auto;
    position: relative;
    overflow: hidden;
    background: radial-gradient(ellipse at top, #1a1a1a 0%, #000 75%);
}

.stage {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

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

/* ============================================
   顶部 status 栏(中国移动 + 计时)
   ============================================ */

.topbar {
    flex: 0 0 auto;
    padding: 14px 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.25em;
    z-index: 10;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 4px;
}

.carrier {
    letter-spacing: 0.1em;
}

.carrier-arrow {
    font-size: 8px;
    opacity: 0.7;
}

.counter {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.15em;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.55);
    transition: color var(--duration-fast) var(--ease);
}

.counter.noticing {
    color: var(--green);
}

/* ============================================
   主区域
   ============================================ */

.main-stage,
.stage-section {
    width: 100%;
}

.stage-section {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.preparation-section {
    padding: 0;
    position: relative;
}

/* ============================================
   来电 header(头像 + 名字 + 状态)
   ============================================ */

.caller-header {
    flex: 0 0 auto;
    padding: 80px 32px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 5;
}

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

.caller-icon {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #2a2a2a, #0a0a0a);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.06);
    z-index: 2;
}

.caller-icon svg {
    width: 50px;
    height: 50px;
    opacity: 0.5;
    stroke: white;
}

.caller-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.28);
    animation: caller-pulse 2.4s ease-out infinite;
    pointer-events: none;
    z-index: 1;
}

.caller-pulse-2 {
    animation-delay: 0.8s;
}

@keyframes caller-pulse {
    0% { transform: scale(0.96); opacity: 0.8; }
    100% { transform: scale(1.3); opacity: 0; }
}

.caller-meta {
    text-align: center;
}

.caller-name {
    font-size: 22px;
    font-weight: 300;
    letter-spacing: 0.06em;
    color: white;
}

.caller-status {
    font-size: 10px;
    letter-spacing: 0.5em;
    color: white;
    opacity: 0.45;
    margin-top: 6px;
    text-indent: 0.5em;
}

/* ============================================
   准备区(居中占中央) + 4 药丸按钮
   ============================================ */

.prep-block {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;                  /* 居中(让准备文案回到画面正中央) */
    padding: 0 40px;                          /* 不加 padding, 由 prep-actions margin 控制 */
    min-height: 0;
}

.current-phrase-wrap {
    width: 100%;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.initial-placeholder {
    font-family: var(--font-serif);
    font-size: 22px;
    font-weight: 200;
    color: rgba(255, 255, 255, 0.25);
    font-style: italic;
    letter-spacing: 0.1em;
}

.initial-placeholder.dismissed {
    display: none;
}

.current-phrase {
    font-family: var(--font-serif);
    font-size: 32px;
    line-height: 1.7;
    font-weight: 300;
    color: white;
    opacity: 0.9;
    letter-spacing: 0.12em;
    max-width: 88%;
    margin: 0 auto;
}

/* 8 个 tone 的字重字号微调 */
.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; }

/* 优化中: 变半透明 */
.current-phrase.optimizing {
    opacity: 0.4;
    transition: opacity 400ms var(--ease);
}

/* loading skeleton */
.current-phrase.loading {
    color: transparent;
    position: relative;
    user-select: none;
}

.current-phrase.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
    background-size: 200% 100%;
    animation: loading-shimmer 1.4s linear infinite;
}

@keyframes loading-shimmer {
    0% { background-position: -100% 0; }
    100% { background-position: 200% 0; }
}

.current-phrase.user-input {
    font-size: 28px;
    line-height: 1.8;
}

/* ============================================
   4 药丸按钮(嵌入准备区)
   ============================================ */

.prep-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 24px 32px 0;
    flex-wrap: wrap;
    margin-top: 0;
    margin-bottom: 80px;                  /* 与接听条之间留 80px 黑色空隙(让按钮组上挪) */
}

.pill {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
    letter-spacing: 0.3em;
    padding: 9px 16px;
    border-radius: 18px;
    cursor: pointer;
    white-space: nowrap;
    text-indent: 0.3em;
    transition: color var(--duration-fast) var(--ease),
                border-color var(--duration-fast) var(--ease),
                background var(--duration-fast) var(--ease),
                opacity 600ms var(--ease),
                transform 600ms var(--ease);
    opacity: 0;
    transform: translateY(8px);
}

.pill.visible,
.pill:not([hidden]) {
    opacity: 1;
    transform: translateY(0);
}

.pill[hidden] { display: none !important; }

#btn-replace {
    opacity: 1;
    transform: translateY(0);
}

.pill:hover {
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.04);
}

.pill:active {
    transform: scale(0.96);
}

/* ============================================
   「读一遍」后的内心自我评价
   ============================================ */

.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);
    }
}

/* 「继续优化」执行中提示 */
.optimize-hint {
    margin-top: 18px;
    font-family: var(--font-serif);
    font-size: 17px;
    line-height: 1.6;
    color: rgba(245, 245, 245, 0.7);
    font-style: italic;
    letter-spacing: 0.3em;
    text-align: center;
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    user-select: none;
}

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

.optimize-hint.optimize-hint-show.optimize-hint-active {
    color: rgba(245, 245, 245, 0.95);
    font-size: 19px;
}

/* 累积层「优化幽灵」 */
.accumulated-phrase.optimize-ghost {
    font-size: 11px;
    color: rgba(245, 245, 245, 0.18);
    font-style: italic;
    letter-spacing: 0.2em;
    cursor: help;
}

.accumulated-phrase.optimize-ghost:hover {
    color: rgba(245, 245, 245, 0.35);
}

/* ============================================
   底部: 滑动接听条
   ============================================ */

.bottom {
    flex: 0 0 auto;
    padding: 56px 28px 48px;            /* 上 24 → 56, 与准备按钮组拉开 */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.slider-wrap {
    position: relative;
    width: 100%;
    height: 56px;
    background: var(--green-bg);
    border: 1px solid var(--green-border);
    border-radius: 28px;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;  /* 禁止滚动, 保证滑动跟手 */
}

.slider-wrap.slider-answered {
    pointer-events: none;
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    transition: background 400ms var(--ease), border-color 400ms var(--ease);
}

.slider-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 16%;
    background: linear-gradient(90deg, var(--green) 0%, rgba(77, 208, 106, 0.4) 100%);
    border-radius: 28px 0 0 28px;
    transition: width 80ms linear;
    pointer-events: none;
}

.slider-wrap.slider-answered .slider-fill {
    width: 100%;
    transition: width 400ms var(--ease);
    border-radius: 28px;
}

.slider-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
    letter-spacing: 0.4em;
    pointer-events: none;
    text-indent: 0.4em;
    transition: opacity 200ms var(--ease);
}

.slider-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 50px;
    height: 50px;
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(77, 208, 106, 0.4), 0 2px 8px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    z-index: 2;
    transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 200ms var(--ease);
}

.slider-knob:active {
    cursor: grabbing;
    box-shadow: 0 4px 24px rgba(77, 208, 106, 0.6), 0 2px 8px rgba(0, 0, 0, 0.5);
}

.slider-knob.dragging {
    transition: none;
}

.slider-knob svg {
    width: 20px;
    height: 20px;
    color: white;
}

.slider-hint {
    font-size: 10px;
    opacity: 0.35;
    letter-spacing: 0.35em;
    text-indent: 0.35em;
    transition: opacity 200ms var(--ease);
}

.slider-wrap.slider-answered + .slider-hint {
    opacity: 0;
}

.btn-answer-fallback {
    margin-top: 8px;
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
    letter-spacing: 0.3em;
    cursor: pointer;
    text-indent: 0.3em;
    transition: color var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease);
}

.btn-answer-fallback[hidden] { display: none !important; }

.btn-answer-fallback:hover {
    color: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.3);
}

/* ============================================
   内心独白(更换 2 次后浮现)
   ============================================ */

.inner-monologue {
    position: absolute;
    bottom: 270px;                          /* 200 → 270, 在输入框上方 */
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    transition: opacity 800ms var(--ease), transform 800ms var(--ease);
    text-align: center;
    z-index: 6;
    pointer-events: none;
    width: 90%;
    max-width: 360px;
}

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

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

.inner-monologue-text {
    font-family: var(--font-serif);
    font-size: 13px;
    font-weight: 300;
    color: rgba(245, 245, 245, 0.4);
    font-style: italic;
    letter-spacing: 0.2em;
    margin-bottom: 6px;
}

.inner-monologue-hint {
    font-family: var(--font-serif);
    font-size: 11px;
    font-weight: 300;
    color: rgba(245, 245, 245, 0.25);
    letter-spacing: 0.3em;
    text-indent: 0.3em;
}

/* ============================================
   用户输入(浮现后保留)
   ============================================ */

.user-input-form {
    position: absolute;
    bottom: 200px;                         /* 130 → 200, 与接听条拉开 */
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    transition: opacity 800ms var(--ease), transform 800ms var(--ease);
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 7;
    pointer-events: none;
}

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

.user-input-form.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.user-input {
    width: 200px;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-serif);
    font-size: 13px;
    letter-spacing: 0.15em;
    padding: 6px 4px;
    outline: none;
    text-align: center;
}

.user-input::placeholder {
    color: rgba(255, 255, 255, 0.25);
    font-style: italic;
}

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

.btn-input-submit {
    width: 28px;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease);
}

.btn-input-submit:hover {
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.4);
}

/* ============================================
   接听阶段(4 句对话)
   ============================================ */

.answer-section {
    align-items: center;
    justify-content: center;
    padding: 0 40px;
}

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

.answer-subtitle {
    font-family: var(--font-serif);
    font-size: 32px;
    line-height: 1.7;
    font-weight: 300;
    color: white;
    text-align: center;
    letter-spacing: 0.12em;
    opacity: 0;
    animation: subtitle-in 800ms var(--ease) forwards;
}

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

.answer-subtitle[data-speaker="user"] {
    color: rgba(255, 255, 255, 0.85);
}

.answer-subtitle[data-speaker="other"] {
    color: rgba(255, 255, 255, 0.65);
}

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

.restart-section {
    align-items: center;
    justify-content: center;
    background: #000;
}

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

.restart-msg {
    font-family: var(--font-serif);
    font-size: 14px;
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 0.3em;
    text-indent: 0.3em;
}

/* ============================================
   累积层(被废弃的开场白)
   ============================================ */

.accumulation {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.accumulated-phrase {
    position: absolute;
    font-family: var(--font-serif);
    font-size: 12px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.12);
    letter-spacing: 0.15em;
    user-select: none;
    transition: color 1200ms var(--ease);
    white-space: nowrap;
    animation: ghost-fade 800ms var(--ease) forwards;
    text-indent: 0.15em;
}

@keyframes ghost-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.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;
    top: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    font-family: var(--font-serif);
    font-size: 11px;
    letter-spacing: 0.3em;
    color: rgba(255, 255, 255, 0.55);
    text-indent: 0.3em;
    opacity: 0;
    pointer-events: none;
    transition: opacity 600ms var(--ease), transform 600ms var(--ease);
    z-index: 20;
    text-align: center;
}

.status-bar.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   阶段显隐
   ============================================ */

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

/* 通话中: 隐藏来电 header, 让 .answer-section 占满 */
.stage.phase-answering .caller-header { display: none; }
.stage.phase-answering .bottom { display: none; }
.stage.phase-answering .prep-block { display: none; }
.stage.phase-answering .topbar { display: none; }
.stage.phase-answering .inner-monologue { display: none; }
.stage.phase-answering .user-input-form { display: none; }
.stage.phase-answering .accumulation { display: none; }

/* 重启过场: 全部隐藏 */
.stage.phase-restarting .caller-header,
.stage.phase-restarting .prep-block,
.stage.phase-restarting .bottom,
.stage.phase-restarting .topbar,
.stage.phase-restarting .inner-monologue,
.stage.phase-restarting .user-input-form,
.stage.phase-restarting .accumulation {
    display: none;
}

/* ============================================
   媒体查询: 极小屏
   ============================================ */

@media (max-width: 320px) {
    .caller-icon-wrap, .caller-icon {
        width: 90px;
        height: 90px;
    }
    .caller-icon svg { width: 40px; height: 40px; }
    .caller-name { font-size: 18px; }
    .prep-actions { gap: 6px; }
    .pill { font-size: 10px; padding: 7px 12px; letter-spacing: 0.2em; }
    .slider-wrap { height: 50px; }
    .slider-knob { width: 44px; height: 44px; }
    .current-phrase { font-size: 26px; }
}
