/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 配色：黑白灰 + 雾蓝（降低5%饱和度） */
    --color-bg: #1a1a1a;
    --color-text: #ffffff;
    --color-text-secondary: #a0a0a0;
    --color-mist-blue: #7ba0b0;
    --color-mist-blue-light: #95bccf;
    --color-surface: #2a2a2a;
    --color-border: #3a3a3a;
    
    /* 字体 */
    --font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

body {
    font-family: var(--font-family);
    background: radial-gradient(ellipse at center, #1a1f24 0%, #0a0a0a 100%);
    color: var(--color-text);
    min-height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 页面切换 */
.page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), 
                visibility 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.page.active {
    opacity: 1;
    visibility: visible;
}

.container {
    width: 90%;
    max-width: 400px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
    padding-bottom: 15vh;
}

/* 品牌头部 */
.brand-header {
    text-align: center;
    margin-bottom: 4rem;
}

/* 标题 */
.title {
    font-size: 2.2rem;
    font-weight: 400;
    text-align: center;
    margin-bottom: 0.8rem;
    color: var(--color-mist-blue-light);
    letter-spacing: 0.12em;
    text-shadow: 0 2px 8px rgba(149, 188, 207, 0.2);
}

/* 副标题 */
.subtitle {
    font-size: 0.75rem;
    font-weight: 300;
    color: rgba(160, 160, 160, 0.5);
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* 设置面板 - 液态设计 */
.settings-panel {
    background: transparent;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    margin-bottom: 2.5rem;
    overflow: hidden;
    border: 1px solid rgba(149, 188, 207, 0.08);
}

.settings-toggle {
    width: 100%;
    padding: 1.1rem 1.5rem;
    background: rgba(26, 31, 36, 0.3);
    border: none;
    color: var(--color-mist-blue-light);
    font-family: var(--font-family);
    font-size: 0.95rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.05em;
}

.settings-toggle:active {
    background: rgba(26, 31, 36, 0.5);
}

.settings-icon {
    transition: transform 0.3s ease;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.settings-toggle.open .settings-icon {
    transform: rotate(180deg);
}

.settings-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.settings-content.open {
    max-height: 500px;
}

.setting-item {
    padding: 1.5rem 1.5rem;
    border-top: 1px solid rgba(149, 188, 207, 0.08);
    background: rgba(26, 31, 36, 0.2);
}

.setting-item label {
    display: block;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

/* 辅助文字：动态显示当前选中的时长 */
.setting-hint {
    font-size: 0.75rem;
    color: var(--color-mist-blue-light);
    opacity: 0.5;
    margin: 0 0 0.75rem 0;
    font-weight: 300;
    letter-spacing: 0.02em;
}

.button-group {
    display: flex;
    gap: 0.5rem;
}

.option-btn {
    flex: 1;
    padding: 0.75rem;
    background: transparent;
    border: 1px solid rgba(149, 188, 207, 0.15);
    border-radius: 50px;
    color: var(--color-text-secondary);
    font-family: var(--font-family);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.option-btn:active {
    transform: scale(0.95);
}

.option-btn.active {
    background: transparent;
    border-color: var(--color-mist-blue-light);
    color: var(--color-mist-blue-light);
}

/* 选中指示器 - 小圆点 */
.option-btn.active::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--color-mist-blue-light);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(149, 188, 207, 0.6);
}

/* 主按钮 - 微呼吸胶囊 */
.primary-btn {
    width: 100%;
    padding: 1.3rem;
    background: var(--color-mist-blue);
    border: none;
    border-radius: 100px;
    color: var(--color-bg);
    font-family: var(--font-family);
    font-size: 1.2rem;
    font-weight: 500;
    cursor: pointer;
    letter-spacing: 0.1em;
    will-change: transform;
    animation: micro-breathing 6s ease-in-out infinite;
    /* 初始光晕 */
    box-shadow: 0 4px 20px rgba(123, 163, 184, 0.3);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 微呼吸动效：1.0 到 1.03 的极微缩放 + 光晕同步 */
@keyframes micro-breathing {
    0%, 100% {
        transform: scale(1.0);
        box-shadow: 0 4px 20px rgba(123, 163, 184, 0.3);
    }
    50% {
        transform: scale(1.03);
        box-shadow: 0 4px 25px rgba(123, 163, 184, 0.5);
    }
}

.primary-btn:hover {
    transform: scale(1.04) translateY(-2px);
    box-shadow: 0 6px 28px rgba(123, 163, 184, 0.45);
    animation: none;
}

/* 点击态：物理按压触感 */
.primary-btn:active {
    transform: scale(0.96) translateY(1px);
    box-shadow: 0 2px 12px rgba(123, 163, 184, 0.25);
    animation: none;
}

/* 次要按钮（练习页结束按钮） */
.secondary-btn {
    padding: 1rem 3rem;
    background: var(--color-mist-blue);
    border: none;
    border-radius: 50px;
    color: var(--color-bg);
    font-family: var(--font-family);
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(123, 163, 184, 0.25);
    min-width: 140px;
}

.secondary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(123, 163, 184, 0.35);
}

.secondary-btn:active {
    transform: scale(0.97) translateY(0);
    box-shadow: 0 2px 10px rgba(123, 163, 184, 0.2);
}

/* 练习页面 */
.practice-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem 3rem;
    gap: 2.5rem;
}

.animation-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    transform: translateY(-5vh);
}

/* 水滴容器 */
.droplet-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 水滴动画 */
.droplet {
    width: 200px;
    height: 280px;
    color: var(--color-mist-blue);
    filter: drop-shadow(0 15px 40px rgba(123, 163, 184, 0.4));
    transition: transform 0.6s ease, filter 0.6s ease;
}

/* 倒计时 - 在水滴内部 */
.timer {
    position: absolute;
    top: 56%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-weight: 300;
    color: rgba(26, 26, 26, 0.7);
    font-variant-numeric: tabular-nums;
    pointer-events: none;
    z-index: 10;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    width: 100%;
    text-align: center;
    transition: transform 0.3s ease;
}

/* 🔑 核心改变：完全使用 CSS Transition + JS 控制 transform
   不再使用 CSS 动画类切换，避免所有类切换导致的跳动问题 */

.droplet {
    /* 平滑过渡：使用 ease-in-out 让呼吸更自然 */
    transition: transform 3s ease-in-out, filter 0.5s ease;
}

/* 吸气状态：蓝色光晕 */
.droplet.inhale {
    filter: drop-shadow(0 15px 45px rgba(123, 163, 184, 0.5));
}

/* 屏息状态（吸气后）：保持蓝色光晕 + 脉动效果 */
.droplet.hold-after-inhale {
    filter: drop-shadow(0 15px 45px rgba(123, 163, 184, 0.5));
    animation: glow 4s ease-in-out infinite;
}

/* 呼气状态：青色光晕 */
.droplet.exhale {
    filter: drop-shadow(0 15px 45px rgba(100, 180, 180, 0.45));
}

/* 屏息状态（呼气后）：保持青色光晕 + 脉动效果 */
.droplet.hold-after-exhale {
    filter: drop-shadow(0 15px 45px rgba(100, 180, 180, 0.45));
    animation: glow 4s ease-in-out infinite;
}

/* 屏息：光晕呼吸效果 - 柔和扩散收缩 */
@keyframes glow {
    0%, 100% {
        filter: drop-shadow(0 15px 35px rgba(123, 163, 184, 0.35))
                drop-shadow(0 0 60px rgba(123, 163, 184, 0.15));
    }
    50% {
        filter: drop-shadow(0 20px 55px rgba(123, 163, 184, 0.55))
                drop-shadow(0 0 90px rgba(123, 163, 184, 0.25));
    }
}

.phase-text {
    font-size: 2.8rem;
    color: var(--color-mist-blue-light);
    font-weight: 300;
    letter-spacing: 0.15em;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    animation: phase-change 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 阶段切换动画 - 柔和渐入上浮 */
@keyframes phase-change {
    0% {
        opacity: 0;
        transform: translateY(15px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 完成页面 */
.complete-title {
    font-size: 3rem;
    font-weight: 300;
    text-align: center;
    margin-bottom: 3rem;
    color: var(--color-mist-blue);
    animation: complete-appear 1s ease-out;
}

@keyframes complete-appear {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    60% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 响应式：平板和桌面 */
@media (min-width: 768px) {
    .container {
        max-width: 500px;
    }
    
    .droplet {
        width: 250px;
        height: 350px;
    }
    
    .timer {
        font-size: 3rem;
    }
    
    .title {
        font-size: 3rem;
    }
}

/* iOS Safari 特定优化 */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }
}

/* 禁用点击高亮 */
button, .settings-toggle {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
