/* ============================================
   水墨金笺·立轴 - 《悦金陵》
   ============================================ */

/* === 字体引入 === */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@300;400;500;600;700&display=swap');

/* === 全局重置 === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* === 根变量 === */
:root {
    --xuan-paper: #F5F1E8;
    --ink-dark: #2B2520;
    --ink-light: #4A4238;
    --vermillion: #C8402E;
    --gold-line: #B8935F;
    --shadow-soft: rgba(43, 37, 32, 0.08);
    --shadow-deep: rgba(43, 37, 32, 0.15);
}

/* === 全局基础 === */
html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Serif SC', serif;
    background: var(--xuan-paper);
    color: var(--ink-dark);
    line-height: 1.8;
    overflow-x: hidden;
    position: relative;
}

/* === 落瓣背景动画 === */
.falling-petals {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.falling-petals::before,
.falling-petals::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: radial-gradient(circle, rgba(200, 64, 46, 0.3), transparent);
    border-radius: 50%;
    animation: fall 18s linear infinite;
}

.falling-petals::before {
    left: 20%;
    animation-delay: 0s;
}

.falling-petals::after {
    left: 70%;
    animation-delay: 6s;
}

@keyframes fall {
    0% {
        top: -10%;
        transform: translateX(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.4;
    }
    100% {
        top: 110%;
        transform: translateX(30px) rotate(360deg);
        opacity: 0;
    }
}

/* === 主容器 === */
.scroll-container {
    position: relative;
    z-index: 2;
    max-width: 900px;
    margin: 0 auto;
    padding: 80px 24px 120px;
}

/* === 标题区 === */
.title-section {
    text-align: center;
    margin-bottom: 80px;
    opacity: 0;
    animation: fadeInUp 1.2s ease forwards;
}

.main-title {
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 600;
    letter-spacing: 0.15em;
    color: var(--ink-dark);
    margin-bottom: 24px;
    position: relative;
    display: inline-block;
}

.main-title::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold-line), transparent);
}

/* 朱砂印章 */
.seal {
    display: inline-block;
    width: 60px;
    height: 60px;
    background: var(--vermillion);
    color: var(--xuan-paper);
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--vermillion);
    box-shadow: 0 2px 8px var(--shadow-soft);
    margin: 0 auto;
    writing-mode: vertical-rl;
    letter-spacing: 0.1em;
}

/* === 立轴诗文 === */
.poem-scroll {
    margin: 0 auto 80px;
    opacity: 0;
    animation: fadeInUp 1.4s ease 0.3s forwards;
}

.scroll-border {
    background: linear-gradient(135deg, #FDFBF7, #F8F5EE);
    padding: 48px 32px;
    border: 3px solid var(--gold-line);
    border-radius: 8px;
    box-shadow: 0 8px 24px var(--shadow-soft),
                inset 0 1px 2px rgba(255, 255, 255, 0.5);
    position: relative;
}

.scroll-border::before,
.scroll-border::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid var(--gold-line);
}

.scroll-border::before {
    top: 12px;
    left: 12px;
    border-right: none;
    border-bottom: none;
}

.scroll-border::after {
    bottom: 12px;
    right: 12px;
    border-left: none;
    border-top: none;
}

.poem-content {
    writing-mode: vertical-rl;
    text-align: left;
    font-size: clamp(1.125rem, 2.5vw, 1.375rem);
    line-height: 2.2;
    letter-spacing: 0.15em;
    color: var(--ink-dark);
    font-weight: 400;
    max-width: 100%;
    margin: 0 auto;
}

.poem-line {
    margin: 0 1.5em;
}

.poem-line:first-child {
    margin-right: 0;
}

.poem-line:last-child {
    margin-left: 0;
}

/* === 丹青画框区 === */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 48px;
    margin-bottom: 80px;
    opacity: 0;
    animation: fadeInUp 1.6s ease 0.6s forwards;
}

.frame {
    background: #FDFBF7;
    padding: 20px;
    border: 2px solid var(--gold-line);
    box-shadow: 0 8px 20px var(--shadow-soft);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.frame:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px var(--shadow-deep);
}

.photo {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid rgba(184, 147, 95, 0.3);
}

figcaption {
    text-align: center;
    font-size: 0.9rem;
    color: var(--ink-light);
    margin-top: 12px;
    letter-spacing: 0.1em;
    font-weight: 300;
}

/* === 落款 === */
.signature {
    text-align: right;
    font-size: 1rem;
    color: var(--ink-light);
    line-height: 1.8;
    opacity: 0;
    animation: fadeInUp 1.8s ease 0.9s forwards;
}

.sign-date {
    font-weight: 300;
    letter-spacing: 0.1em;
}

.sign-name {
    font-weight: 500;
    margin-top: 8px;
    letter-spacing: 0.15em;
}

/* === 背景音乐控件 === */
.music-toggle {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 56px;
    height: 56px;
    background: rgba(200, 64, 46, 0.9);
    border: 2px solid var(--vermillion);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(200, 64, 46, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.music-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(200, 64, 46, 0.45);
}

.music-toggle:active {
    transform: scale(0.95);
}

.music-toggle svg {
    width: 24px;
    height: 24px;
    color: var(--xuan-paper);
    transition: opacity 0.2s ease;
}

.icon-pause {
    display: none;
}

.music-toggle.playing .icon-music {
    display: none;
}

.music-toggle.playing .icon-pause {
    display: block;
}

/* === 入场动画 === */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === 诗句逐行浮现 === */
.poem-line {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.9s ease, transform 0.9s ease;
}

.poem-line.visible {
    opacity: 1;
    transform: translateY(0);
}

/* === 画框浮现 === */
.frame {
    opacity: 0;
    transform: translateY(20px);
    /* transition 已在上方定义 transform/box-shadow，补上 opacity */
    transition: transform 0.7s ease, box-shadow 0.3s ease, opacity 0.7s ease;
}

.frame.visible {
    opacity: 1;
    transform: translateY(0);
}

.frame.visible:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px var(--shadow-deep);
}

/* === 落瓣（JS 动态生成） === */
.petal {
    position: absolute;
    top: -20px;
    display: block;
    background: radial-gradient(circle at 30% 30%,
                rgba(200, 64, 46, 0.55),
                rgba(200, 64, 46, 0.15) 70%,
                transparent);
    border-radius: 50% 0 50% 50%;
    animation-name: petal-fall;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    will-change: transform, opacity;
}

@keyframes petal-fall {
    0% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.85;
    }
    90% {
        opacity: 0.5;
    }
    100% {
        transform: translate(var(--drift, 0px), 104vh) rotate(420deg);
        opacity: 0;
    }
}

/* 尊重"减少动态效果"偏好 */
@media (prefers-reduced-motion: reduce) {
    .poem-line,
    .frame {
        opacity: 1;
        transform: none;
        transition: none;
    }
    .title-section,
    .poem-scroll,
    .gallery,
    .signature {
        animation: none;
        opacity: 1;
    }
}

/* === 响应式 === */
@media (max-width: 768px) {
    .scroll-container {
        padding: 60px 20px 100px;
    }

    .title-section {
        margin-bottom: 60px;
    }

    .seal {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }

    .scroll-border {
        padding: 32px 20px;
    }

    .poem-content {
        font-size: 1.125rem;
    }

    .poem-line {
        margin: 0 1em;
    }

    .gallery {
        gap: 32px;
        grid-template-columns: 1fr;
    }

    .music-toggle {
        bottom: 24px;
        right: 24px;
        width: 48px;
        height: 48px;
    }

    .music-toggle svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 480px) {
    .main-title {
        font-size: 2rem;
    }

    .poem-content {
        font-size: 1rem;
        line-height: 2;
    }

    .scroll-border {
        padding: 24px 16px;
    }
}
