/* -------------------------------------------------------------
   《森林来信：寻找你的灵魂动物》核心设计系统 (CSS)
   ------------------------------------------------------------- */

:root {
    --color-forest: #8DAA91;
    --color-sage: #B9C9B3;
    --color-cream: #F6F3EA;
    --color-moonlight: #A8C3D9;
    --color-apricot: #E8D2B5;
    
    --color-bg-dark: #0f1c1b;
    --color-bg-light: #162a27;
    --color-text-light: #f7fcf9;
    --color-text-dark: #2a3c37;
    --color-primary: #8DAA91;
    --color-accent: #ffd166;
    
    --font-serif: 'Noto Serif SC', serif;
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    --glass-bg: rgba(22, 42, 39, 0.65);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* 页面基本重置与安全区域适配 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--color-bg-dark);
    font-family: var(--font-serif);
    color: var(--color-text-light);
    line-height: 1.6;
}

/* 核心移动端画布容器居中 */
#app-container {
    position: relative;
    width: 100%;
    max-width: 480px;
    height: 100%;
    margin: 0 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

/* 全局背景图与流光粒子层 */
.forest-bg-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('forest_bg.png');
    background-size: cover;
    background-position: center;
    transition: filter 1.5s ease;
    z-index: 1;
}

.forest-bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 40%, rgba(10, 20, 18, 0.9) 100%);
    z-index: 2;
}

/* SPA 单页状态 */
.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.98);
    transition: opacity 0.8s cubic-bezier(0.25, 1, 0.5, 1), 
                transform 0.8s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 5;
}

.page.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
    z-index: 6;
}

/* 梦幻磨砂面板样式 */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 32px 24px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: var(--glass-shadow);
    overflow-y: auto;
    position: relative;
}

.glass-panel.highlight-border {
    border: 1.5px solid var(--color-apricot);
    box-shadow: 0 0 25px rgba(232, 210, 181, 0.25), var(--glass-shadow);
}

.dark-panel {
    background: rgba(10, 20, 18, 0.95);
    border-radius: 24px;
    padding: 32px 24px;
    width: 100%;
    height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* 音控与月亮控制 */
.global-controls {
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    pointer-events: none;
}

.control-btn, .moon-egg-target {
    pointer-events: auto;
    background: rgba(22, 42, 39, 0.6);
    border: 1px solid var(--glass-border);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-cream);
    cursor: pointer;
    font-size: 0.95rem;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.moon-egg-target {
    font-size: 1.2rem;
    line-height: 38px;
    user-select: none;
}

.control-btn:active, .moon-egg-target:active {
    transform: scale(0.9);
}

.control-btn.muted i::after {
    content: "/";
    position: absolute;
    font-weight: bold;
    transform: rotate(45deg);
    color: #e63946;
}

/* 各种排版微动效 */
.badge {
    background: rgba(141, 170, 145, 0.2);
    border: 1px solid var(--color-forest);
    color: var(--color-sage);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    letter-spacing: 2px;
    margin-bottom: 16px;
    font-family: var(--font-serif);
}

.main-title {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--color-cream);
    letter-spacing: 6px;
    margin-bottom: 8px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.subtitle {
    font-size: 1rem;
    color: var(--color-moonlight);
    letter-spacing: 4px;
    margin-bottom: 30px;
}

.poetic-text {
    font-size: 1.05rem;
    color: var(--color-cream);
    line-height: 1.8;
    letter-spacing: 1px;
    margin-bottom: 24px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.guide-text {
    font-size: 0.8rem;
    color: var(--color-sage);
    letter-spacing: 2px;
    margin-top: 15px;
}

.outfit-font {
    font-family: var(--font-sans);
}

/* 信封交互 */
.envelope-trigger {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 20px 0;
    cursor: pointer;
}

.pulse-mail {
    width: 100%;
    height: 100%;
    object-fit: contain;
    animation: bounceMail 3s infinite ease-in-out;
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.4));
}

.glow-ring {
    position: absolute;
    top: 10%;
    left: 10%;
    width: 80%;
    height: 80%;
    border-radius: 50%;
    box-shadow: 0 0 30px 10px rgba(232, 210, 181, 0.4);
    animation: pulseGlow 2s infinite alternate ease-in-out;
    pointer-events: none;
}

/* 按钮通用设计 */
.next-btn {
    background: linear-gradient(135deg, var(--color-forest), #6a8c70);
    border: none;
    color: var(--color-cream);
    padding: 12px 36px;
    border-radius: 25px;
    font-family: var(--font-serif);
    font-size: 0.95rem;
    letter-spacing: 2px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(106, 140, 112, 0.4);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.next-btn:active {
    transform: scale(0.96);
    box-shadow: 0 2px 8px rgba(106, 140, 112, 0.2);
}

/* 信件主体页 */
.letter-panel {
    background: #eae3d2;
    color: var(--color-text-dark);
    padding: 40px 30px;
    border-radius: 12px;
    width: 100%;
    height: 75vh;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    position: relative;
    border: 8px double #d7cdb7;
}

.letter-body {
    width: 100%;
    font-size: 1.05rem;
    line-height: 2;
    text-align: left;
}

.letter-greeting {
    font-weight: 700;
    margin-bottom: 16px;
    color: #43544c;
    border-bottom: 1px dashed rgba(0,0,0,0.1);
    padding-bottom: 8px;
}

.letter-text {
    min-height: 150px;
    white-space: pre-wrap;
}

/* 火印章 */
.seal-container {
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin: 30px 0;
}

.wax-seal {
    width: 70px;
    height: 70px;
    background: radial-gradient(circle, #bc3838 60%, #891f1f 100%);
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3), inset 0 2px 4px rgba(255,255,255,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-cream);
    font-size: 1.8rem;
    cursor: pointer;
    border: 3px solid #ab2d2d;
    animation: pulseSeal 1.8s infinite alternate ease-in-out;
}

/* 上滑指示器 */
.swipe-indicator {
    font-size: 1.8rem;
    color: var(--color-cream);
    animation: bounceIndicator 1.8s infinite;
    cursor: pointer;
    margin: 20px 0;
}

/* 答题环节 */
.progress-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--color-sage);
}

.progress-bar-outer {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    margin-left: 12px;
    overflow: hidden;
}

.progress-bar-inner {
    height: 100%;
    width: 8.3%;
    background: linear-gradient(90deg, var(--color-forest), var(--color-moonlight));
    border-radius: 3px;
    transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.question-title {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--color-cream);
    margin-bottom: 30px;
    line-height: 1.6;
    text-align: left;
    width: 100%;
}

.options-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.option-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 14px 20px;
    border-radius: 16px;
    text-align: left;
    font-size: 0.95rem;
    color: var(--color-cream);
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
}

.option-item:hover, .option-item:active {
    background: rgba(141, 170, 145, 0.25);
    border-color: var(--color-forest);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(141, 170, 145, 0.15);
}

.option-prefix {
    font-family: var(--font-sans);
    font-weight: 600;
    color: var(--color-apricot);
    margin-right: 12px;
}

/* 加载计算页 */
.loader-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255,255,255,0.1);
    border-top: 4px solid var(--color-forest);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
    margin-bottom: 30px;
}

.calc-progress-outer {
    width: 80%;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    margin: 20px 0 10px 0;
    overflow: hidden;
}

.calc-progress-inner {
    height: 100%;
    width: 0%;
    background: var(--color-forest);
    border-radius: 2px;
}

#calc-percent {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-forest);
}

/* 召唤与剪影 */
.light-pillar {
    width: 8px;
    height: 150px;
    background: linear-gradient(to top, var(--color-forest), transparent);
    box-shadow: 0 0 30px 10px rgba(141, 170, 145, 0.6);
    border-radius: 4px;
    margin-bottom: 40px;
    animation: pillarPulse 2.5s infinite alternate ease-in-out;
}

.animal-silhouette-container {
    width: 180px;
    height: 180px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 40px;
    filter: drop-shadow(0 0 15px rgba(255,255,255,0.3));
}

.animal-silhouette-container svg {
    width: 100%;
    height: 100%;
    fill: #222;
    stroke: rgba(255, 255, 255, 0.4);
    stroke-width: 1.5;
    animation: outlineGlow 3s infinite alternate ease-in-out;
}

/* 结果揭晓 */
.animal-name {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--color-cream);
    letter-spacing: 4px;
    margin-bottom: 20px;
}

.animal-visual {
    width: 200px;
    height: 200px;
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.animal-visual svg {
    width: 100%;
    height: 100%;
}

.animal-one-liner {
    font-size: 1.1rem;
    color: var(--color-apricot);
    margin-bottom: 30px;
    font-style: italic;
}

/* 雷达图页面 */
.section-title {
    font-size: 1.3rem;
    letter-spacing: 3px;
    margin-bottom: 20px;
    color: var(--color-cream);
}

.radar-chart-container {
    width: 260px;
    height: 260px;
    margin-bottom: 24px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 50%;
    padding: 10px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.4);
}

.keyword-tags {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.tag {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--color-cream);
}

.letter-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: #43544c;
    border-bottom: 1.5px solid #d7cdb7;
    padding-bottom: 8px;
    text-align: center;
    width: 100%;
}

.letter-content-text {
    font-size: 1rem;
    line-height: 2.1;
    color: var(--color-text-dark);
}

/* 分享海报页面 */
.share-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 85vh;
}

.canvas-preview-container {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    overflow: hidden;
}

#share-poster-canvas {
    max-width: 100%;
    max-height: 60vh;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    background: #112320;
    border: 1px solid rgba(255,255,255,0.1);
}

.action-buttons {
    width: 100%;
    display: flex;
    gap: 16px;
    margin-top: 15px;
}

.action-btn {
    flex: 1;
    padding: 12px 0;
    border-radius: 25px;
    border: none;
    font-family: var(--font-serif);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.restart-btn {
    background: rgba(255,255,255,0.1);
    color: var(--color-cream);
    border: 1px solid rgba(255,255,255,0.25);
}

.share-btn {
    background: linear-gradient(135deg, var(--color-apricot), #ccae87);
    color: var(--color-text-dark);
    font-weight: 600;
}

.action-btn:active {
    transform: scale(0.96);
}

.opacity-text {
    opacity: 0.7;
}

/* -------------------------------------------------------------
   动画关键帧定义
   ------------------------------------------------------------- */

@keyframes bounceMail {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(2deg); }
}

@keyframes pulseGlow {
    0% { transform: scale(0.9); opacity: 0.4; }
    100% { transform: scale(1.1); opacity: 0.8; }
}

@keyframes pulseSeal {
    0% { transform: scale(0.98); box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
    100% { transform: scale(1.04); box-shadow: 0 8px 20px rgba(188,56,56,0.6); }
}

@keyframes bounceIndicator {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(-8px); opacity: 1; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pillarPulse {
    0% { opacity: 0.5; transform: scaleX(0.8); }
    100% { opacity: 1; transform: scaleX(1.2); }
}

@keyframes outlineGlow {
    0% { stroke-dasharray: 4, 4; stroke: rgba(255,255,255,0.3); }
    100% { stroke-dasharray: 8, 2; stroke: rgba(255,255,255,0.8); }
}

/* 适配超短屏幕 */
@media (max-height: 600px) {
    .glass-panel {
        padding: 20px 16px;
    }
    .main-title {
        font-size: 1.8rem;
    }
    .animal-visual {
        width: 140px;
        height: 140px;
    }
    .radar-chart-container {
        width: 200px;
        height: 200px;
    }
}
