/* 动画效果 - 柔和流畅的过渡 */

/* 标准缓动函数 */
:root {
    --ease-standard: cubic-bezier(0.4, 0.0, 0.2, 1);
    --ease-in: cubic-bezier(0.0, 0.0, 0.2, 1);
    --ease-out: cubic-bezier(0.4, 0.0, 1, 1);
    --ease-in-out: cubic-bezier(0.4, 0.0, 0.6, 1);
}

/* 页面加载淡入 */
@keyframes fadeIn {
    from { 
        opacity: 0;
    }
    to { 
        opacity: 1;
    }
}

/* 内容滑入 */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 向上滑入 */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 从左滑入 */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 从右滑入 */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 打字效果 */
@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* 脉冲效果 */
@keyframes pulse {
    0%, 100% { 
        opacity: 1;
        transform: scale(1);
    }
    50% { 
        opacity: 0.8;
        transform: scale(0.98);
    }
}

/* 弹出效果 */
@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 旋转加载 */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* 微妙摇摆 */
@keyframes gentle-sway {
    0%, 100% {
        transform: translateX(0);
    }
    50% {
        transform: translateX(2px);
    }
}

/* 光泽扫过效果 */
@keyframes shine {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

/* 应用动画到元素 */
.container {
    animation: fadeIn 0.5s var(--ease-standard);
}

.content {
    animation: slideIn 0.6s var(--ease-standard) 0.1s both;
}

.nav-item {
    animation: slideInLeft 0.4s var(--ease-standard) both;
}

.nav-item:nth-child(1) { animation-delay: 0.05s; }
.nav-item:nth-child(2) { animation-delay: 0.1s; }
.nav-item:nth-child(3) { animation-delay: 0.15s; }
.nav-item:nth-child(4) { animation-delay: 0.2s; }
.nav-item:nth-child(5) { animation-delay: 0.25s; }

.toc-item {
    animation: slideInRight 0.4s var(--ease-standard) both;
}

.toc-item:nth-child(1) { animation-delay: 0.05s; }
.toc-item:nth-child(2) { animation-delay: 0.1s; }
.toc-item:nth-child(3) { animation-delay: 0.15s; }
.toc-item:nth-child(4) { animation-delay: 0.2s; }
.toc-item:nth-child(5) { animation-delay: 0.25s; }

/* 主题切换动画 */
.theme-toggle-btn {
    transition: all 0.35s var(--ease-standard);
}

.theme-toggle-btn:hover {
    animation: gentle-sway 0.5s var(--ease-in-out) infinite;
}

/* 卡片悬停效果 */
.chapter-list li,
.nav-book-title,
.category-btn {
    transition: all 0.25s var(--ease-standard);
}

/* 平滑滚动 */
html {
    scroll-behavior: smooth;
}

/* 减少动画（尊重用户偏好） */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

