/* ==================== 动画效果库 ==================== */

/* 基础动画关键帧 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        transform: translate3d(0, -30px, 0);
    }
    70% {
        transform: translate3d(0, -15px, 0);
    }
    90% {
        transform: translate3d(0, -4px, 0);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-10px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(10px);
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(41, 128, 185, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(41, 128, 185, 0.8);
    }
}

@keyframes typewriter {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

/* ==================== 页面加载动画 ==================== */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

.loader-text {
    margin-top: 1rem;
    color: var(--text-lighter);
    font-size: 0.875rem;
    animation: pulse 1.5s ease-in-out infinite;
}

/* ==================== 导航栏动画 ==================== */
.navbar {
    animation: slideInDown 0.6s ease-out;
}

.navbar.scrolled {
    animation: fadeInDown 0.3s ease-out;
}

.nav-menu-list li {
    animation: fadeInUp 0.6s ease-out;
    animation-fill-mode: both;
}

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

.mobile-menu-toggle {
    transition: transform 0.3s ease;
}

.mobile-menu-toggle:hover {
    transform: scale(1.1);
}

.mobile-menu-toggle.active {
    transform: rotate(90deg);
}

/* ==================== 英雄区动画 ==================== */
.hero-section {
    animation: fadeIn 1s ease-out;
}

.hero-content h1 {
    animation: fadeInUp 0.8s ease-out;
    animation-delay: 0.2s;
    animation-fill-mode: both;
}

.hero-content p {
    animation: fadeInUp 0.8s ease-out;
    animation-delay: 0.4s;
    animation-fill-mode: both;
}

.search-box {
    animation: fadeInUp 0.8s ease-out;
    animation-delay: 0.6s;
    animation-fill-mode: both;
}

.hero-decoration {
    animation: float 6s ease-in-out infinite;
}

/* ==================== 文章卡片动画 ==================== */
.article-card {
    animation: fadeInUp 0.6s ease-out;
    animation-fill-mode: both;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.article-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}

.article-card:hover .article-image img {
    transform: scale(1.1);
}

.article-card.sticky {
    animation: bounce 1s ease-out;
    animation-delay: 0.5s;
}

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

.article-image {
    overflow: hidden;
    position: relative;
}

.article-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s ease;
    z-index: 1;
}

.article-card:hover .article-image::before {
    left: 100%;
}

/* ==================== 按钮动画 ==================== */
.btn,
.search-btn,
.quick-like-btn,
.quick-share-btn,
.back-to-top {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn::before,
.search-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.btn:hover::before,
.search-btn:hover::before {
    width: 300px;
    height: 300px;
}

.quick-like-btn:hover,
.quick-share-btn:hover {
    transform: scale(1.1) rotate(5deg);
}

.quick-like-btn.liked {
    animation: pulse 0.6s ease-out;
}

.back-to-top {
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.back-to-top.show {
    transform: translateY(0);
    opacity: 1;
}

.back-to-top:hover {
    transform: translateY(-5px) scale(1.1);
    animation: glow 1s ease-in-out infinite;
}

/* ==================== 表单动画 ==================== */
.search-input,
.comment-form input,
.comment-form textarea {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.search-input:focus,
.comment-form input:focus,
.comment-form textarea:focus {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(41, 128, 185, 0.2);
}

/* ==================== 加载动画 ==================== */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

/* ==================== 通知动画 ==================== */
.notification {
    animation: slideInRight 0.3s ease-out;
}

.notification.hide {
    animation: slideOutRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ==================== 模态框动画 ==================== */
.modal,
.share-popup,
.wechat-qr-modal {
    animation: fadeIn 0.3s ease-out;
}

.modal-content,
.share-popup-content,
.wechat-qr-content {
    animation: scaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== 图片懒加载动画 ==================== */
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[data-src].loaded {
    opacity: 1;
}

img.lazyload {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img.lazyloaded {
    opacity: 1;
}

/* ==================== 滚动触发动画 ==================== */
.scroll-animate {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-animate.in-view {
    opacity: 1;
    transform: translateY(0);
}

.scroll-animate.from-left {
    transform: translateX(-30px);
}

.scroll-animate.from-right {
    transform: translateX(30px);
}

.scroll-animate.from-left.in-view,
.scroll-animate.from-right.in-view {
    transform: translateX(0);
}

/* ==================== 打字机效果 ==================== */
.typewriter {
    overflow: hidden;
    border-right: 2px solid var(--primary-color);
    white-space: nowrap;
    animation: typewriter 3s steps(40, end), blink 0.75s step-end infinite;
}

/* ==================== 粒子效果 ==================== */
.particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--primary-color);
    border-radius: 50%;
    opacity: 0.7;
    animation: float 6s ease-in-out infinite;
}

.particle:nth-child(1) { left: 10%; animation-delay: 0s; }
.particle:nth-child(2) { left: 20%; animation-delay: 1s; }
.particle:nth-child(3) { left: 30%; animation-delay: 2s; }
.particle:nth-child(4) { left: 40%; animation-delay: 3s; }
.particle:nth-child(5) { left: 50%; animation-delay: 4s; }
.particle:nth-child(6) { left: 60%; animation-delay: 5s; }
.particle:nth-child(7) { left: 70%; animation-delay: 0.5s; }
.particle:nth-child(8) { left: 80%; animation-delay: 1.5s; }
.particle:nth-child(9) { left: 90%; animation-delay: 2.5s; }

/* ==================== 进度条动画 ==================== */
.progress-bar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5));
    animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-20px);
    }
    100% {
        transform: translateX(20px);
    }
}

/* ==================== 响应式动画优化 ==================== */
@media (max-width: 768px) {
    .article-card:hover {
        transform: translateY(-4px) scale(1.01);
    }
    
    .hero-content h1,
    .hero-content p,
    .search-box {
        animation-duration: 0.6s;
    }
    
    .nav-menu-list li {
        animation-duration: 0.4s;
    }
}

/* ==================== 减少动画模式 ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .hero-decoration,
    .particle,
    .float {
        animation: none !important;
    }
}

/* ==================== 高性能动画 ==================== */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* ==================== 主题切换动画 ==================== */
.theme-transition {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.dark-theme .theme-transition {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ==================== 微交互动画 ==================== */
.micro-interaction {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.micro-interaction:hover {
    transform: translateY(-1px);
}

.micro-interaction:active {
    transform: translateY(0);
    transition-duration: 0.1s;
}

/* ==================== 自定义缓动函数 ==================== */
.ease-out-back {
    transition-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ease-in-out-quart {
    transition-timing-function: cubic-bezier(0.77, 0, 0.175, 1);
}

.ease-out-expo {
    transition-timing-function: cubic-bezier(0.19, 1, 0.22, 1);
}

