/* =============================================
   anim.css — 主题切换动画与通用关键帧
   ============================================= */

:root {
    --transition-speed: 0.45s;
}

/* ========== 主题切换遮罩层 ========== */
#theme-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transition: none;
}

#theme-overlay.active {
    pointer-events: all;
    animation: themeSweep 0.7s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

/* P5 版本 — 红色半调扫屏 */
#theme-overlay.p5 {
    background:
        repeating-linear-gradient(
            0deg,
            transparent 0px, transparent 2px,
            rgba(255,255,255,0.03) 2px, rgba(255,255,255,0.03) 4px
        ),
        linear-gradient(135deg, #e50000 0%, #8b0000 40%, #000000 100%);
    box-shadow: 0 0 60px rgba(229, 0, 0, 0.4) inset;
}

/* P3 版本 — 蓝色渐变扫屏 */
#theme-overlay.p3 {
    background:
        linear-gradient(135deg, #0050d2 0%, #003399 40%, #f0f8ff 100%);
    box-shadow: 0 0 60px rgba(0, 80, 210, 0.3) inset;
}

/* 扫屏主动画：从左侧切入，右侧切出 */
@keyframes themeSweep {
    0% {
        opacity: 1;
        clip-path: inset(0 100% 0 0);
    }
    40% {
        opacity: 1;
        clip-path: inset(0 0 0 0);
    }
    60% {
        opacity: 1;
        clip-path: inset(0 0 0 0);
    }
    100% {
        opacity: 0;
        clip-path: inset(0 0 0 100%);
    }
}

/* ========== 页面入场动画 ========== */

/* section 从下方渐入 */
.section {
    opacity: 0;
    transform: translateY(40px);
    animation: sectionEnter 0.8s ease forwards;
}

.section:nth-child(1) { animation-delay: 0.1s; }
.section:nth-child(2) { animation-delay: 0.2s; }
.section:nth-child(3) { animation-delay: 0.3s; }
.section:nth-child(4) { animation-delay: 0.4s; }
.section:nth-child(5) { animation-delay: 0.5s; }

@keyframes sectionEnter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== Hero 标题字符动画 ========== */
@keyframes titleReveal {
    from {
        opacity: 0;
        transform: skew(var(--ui-skew)) translateY(60px);
        filter: blur(8px);
    }
    to {
        opacity: 1;
        transform: skew(var(--ui-skew)) translateY(0);
        filter: blur(0);
    }
}

.hero-title .title-line {
    animation: titleReveal 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

.hero-title .title-line:nth-child(1) { animation-delay: 0.2s; }
.hero-title .title-line:nth-child(2) { animation-delay: 0.4s; }

/* ========== 浮动粒子 (P5) ========== */
[data-theme="p5"] .particle {
    position: fixed;
    width: 4px;
    height: 4px;
    background: rgba(229, 0, 0, 0.4);
    pointer-events: none;
    z-index: -1;
    animation: floatUp linear infinite;
}

@keyframes floatUp {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-10vh) rotate(720deg);
        opacity: 0;
    }
}

/* ========== P3 浮动光点 ========== */
[data-theme="p3"] .particle {
    position: fixed;
    width: 3px;
    height: 3px;
    background: rgba(0, 80, 210, 0.15);
    border-radius: 50%;
    pointer-events: none;
    z-index: -1;
    animation: floatUp linear infinite;
}

/* ========== 响应式入场动画调整 ========== */
@media (prefers-reduced-motion: reduce) {
    .section,
    .hero-title .title-line,
    #theme-overlay.active {
        animation: none;
        opacity: 1;
        transform: none;
    }

    #theme-overlay {
        display: none;
    }
}
