/* ========================================
   滚动渐变效果 - 完整实现
   ======================================== */

/* ——————————————————————————————————————————————
   1. CSS 变量定义 - 颜色主题
   —————————————————————————————————————————————— */
:root {
    /* 浪漫粉起始 */
    --bg-romantic-pink: rgba(255, 240, 245, 1);
    --bg-romantic-gradient: linear-gradient(180deg, #FFF0F5 0%, #FFE4E1 100%);

    /* 过渡紫 */
    --bg-transition-purple: rgba(155, 114, 170, 1);
    --bg-transition-gradient: linear-gradient(180deg, #D8BFD8 0%, #9B72AA 100%);

    /* 深邃蓝 */
    --bg-deep-blue: rgba(26, 26, 64, 1);
    --bg-deep-gradient: linear-gradient(180deg, #4B0082 0%, #1A1A40 100%);

    /* 星空黑 */
    --bg-starry-black: rgba(10, 10, 30, 1);
    --bg-starry-gradient: linear-gradient(180deg, #0A0A1E 0%, #050510 100%);

    /* 月亮颜色 */
    --moon-color: #fff9e6;
    --moon-glow: rgba(255, 249, 230, 0.6);
}

/* ——————————————————————————————————————————————
   2. 页面整体结构 - 5屏设计
   —————————————————————————————————————————————— */
html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg-romantic-pink);
    transition: background 0.3s ease;
    min-height: 500vh; /* 5屏高度 */
    position: relative;
}

/* 背景渐变层 - 使用固定定位实现平滑过渡 */
.scroll-background-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: -2;
    background: var(--bg-romantic-gradient);
    transition: background 0.15s ease-out;
    will-change: background;
}

/* 星云背景层增强 */
.nebula-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: -1;
    opacity: 0.3;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(255, 107, 157, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(138, 43, 226, 0.1) 0%, transparent 50%);
    transition: opacity 0.5s ease, background 0.3s ease;
    pointer-events: none;
}

/* ——————————————————————————————————————————————
   3. 五屏区块样式
   —————————————————————————————————————————————— */
.scroll-section {
    position: relative;
    min-height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    box-sizing: border-box;
}

/* 第1屏：浪漫开场 */
.section-romantic {
    z-index: 10;
}

/* 第2屏：过渡地带 */
.section-transition {
    z-index: 20;
}

/* 第3屏：星夜降临 */
.section-starry-1 {
    z-index: 30;
}

/* 第4屏：璀璨星空 */
.section-starry-2 {
    z-index: 40;
}

/* 第5屏：深情回忆 */
.section-starry-3 {
    z-index: 50;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 80px;
}

/* ——————————————————————————————————————————————
   4. 月亮系统
   —————————————————————————————————————————————— */
#moon-container {
    position: fixed;
    top: 8vh;
    right: 12vw;
    width: 120px;
    height: 120px;
    z-index: 60;
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 1.5s ease-in-out,
        transform 0.1s linear; /* 滚动时快速响应 */
    will-change: opacity, transform;
}

#moon-container.visible {
    opacity: 1;
}

#moon-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 30px var(--moon-glow));
}

.moon-body {
    fill: var(--moon-color);
    filter: blur(0.5px);
}

/* 移动端月亮缩小 */
@media (max-width: 768px) {
    #moon-container {
        width: 80px;
        height: 80px;
        top: 5vh;
        right: 8vw;
    }
}

/* ——————————————————————————————————————————————
   5. 滚动指示器
   —————————————————————————————————————————————— */
.scroll-indicator {
    position: fixed;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.scroll-indicator:hover {
    opacity: 1;
}

.scroll-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.scroll-dot.active {
    background: rgba(255, 107, 157, 0.9);
    border-color: rgba(255, 107, 157, 1);
    transform: scale(1.3);
    box-shadow: 0 0 15px rgba(255, 107, 157, 0.6);
}

.scroll-dot:hover::after {
    content: attr(data-section);
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
}

/* 移动端隐藏滚动指示器 */
@media (max-width: 768px) {
    .scroll-indicator {
        display: none;
    }
}

/* ——————————————————————————————————————————————
   6. 滚动提示文字
   —————————————————————————————————————————————— */
.scroll-hint {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    text-align: center;
    animation: bounce-hint 2s ease-in-out infinite;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.scroll-hint.hidden {
    opacity: 0;
}

@keyframes bounce-hint {
    0%, 20%, 50%, 80%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    40% {
        transform: translateX(-50%) translateY(-10px);
    }
    60% {
        transform: translateX(-50%) translateY(-5px);
    }
}

/* 移动端调整 */
@media (max-width: 768px) {
    .scroll-hint {
        bottom: 20px;
        font-size: 12px;
        padding: 0 20px;
    }
}

/* ——————————————————————————————————————————————
   7. 内容淡入动画
   —————————————————————————————————————————————— */
.fade-in-section {
    opacity: 0;
    transform: translateY(40px);
    transition:
        opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

.fade-in-section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* 延迟动画类 */
.delay-100 { transition-delay: 0.1s; }
.delay-200 { transition-delay: 0.2s; }
.delay-300 { transition-delay: 0.3s; }
.delay-400 { transition-delay: 0.4s; }
.delay-500 { transition-delay: 0.5s; }

/* 滑动进入方向 */
.slide-in-left {
    transform: translateX(-60px);
}

.slide-in-right {
    transform: translateX(60px);
}

.slide-in-left.visible,
.slide-in-right.visible {
    transform: translateX(0);
}

/* ——————————————————————————————————————————————
   8. 过渡文案样式
   —————————————————————————————————————————————— */
.transition-text {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 24px;
    font-family: 'Georgia', serif;
    font-style: italic;
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 1s ease;
}

.transition-text.visible {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 768px) {
    .transition-text {
        font-size: 18px;
        padding: 15px;
        margin: 0 20px;
    }
}

/* ——————————————————————————————————————————————
   9. 情话/回忆录卡片
   —————————————————————————————————————————————— */
.memory-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
    width: 100%;
    box-sizing: border-box;
}

.memory-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 30px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.95);
    font-size: 18px;
    line-height: 1.8;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.memory-card::before {
    content: '"';
    position: absolute;
    top: -10px;
    left: 20px;
    font-size: 120px;
    color: rgba(255, 255, 255, 0.05);
    font-family: 'Georgia', serif;
    line-height: 1;
    pointer-events: none;
}

.memory-card p {
    margin: 0;
    position: relative;
    z-index: 1;
}

.memory-card .author {
    text-align: right;
    margin-top: 15px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
}

@media (max-width: 768px) {
    .memory-cards-container {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 0 15px;
        margin: 20px auto;
    }

    .memory-card {
        padding: 25px;
        font-size: 16px;
    }
}

/* ——————————————————————————————————————————————
   10. 背景颜色过渡辅助类（JS动态添加）
   —————————————————————————————————————————————— */
body.phase-romantic {
    background: var(--bg-romantic-pink);
}

body.phase-transition {
    background: var(--bg-transition-purple);
}

body.phase-starry {
    background: var(--bg-deep-blue);
}

body.phase-deep {
    background: var(--bg-starry-black);
}

/* 星星层可调透明度 */
.constellation-canvas-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* ——————————————————————————————————————————————
   11. 性能优化
   —————————————————————————————————————————————— */
.scroll-section,
.fade-in-section,
#moon-container {
    transform: translateZ(0);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 减少重绘 */
.scroll-background-layer,
.nebula-layer {
    transform: translate3d(0, 0, 0);
}
