/* 页面切换状态类 */
html.is-leaving .transition-leaving {
    transform: translateY(-1rem);
    opacity: 0;
}

html.is-entering .transition-main {
    transform: translateY(1.5rem);
    opacity: 0;
}

/* 离开动画类 */
.animate-leave {
    transform: translateY(-1rem) !important;
    opacity: 0 !important;
    transition: 
        transform 250ms cubic-bezier(0.4, 0, 0.6, 1),
        opacity 250ms cubic-bezier(0.4, 0, 0.6, 1) !important;
}

/* 增强的组件动画 */
.enhanced-fade-in {
    opacity: 0;
    transform: translateY(1.5rem) scale(0.98);
    transition: 
        opacity 350ms cubic-bezier(0.4, 0, 0.2, 1),
        transform 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

.enhanced-fade-in.animate {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* 侧边栏动画 */
.sidebar-animate {
    opacity: 0;
    transform: translateX(-2rem);
    transition: 
        opacity 300ms cubic-bezier(0.4, 0, 0.2, 1),
        transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-animate.animate {
    opacity: 1;
    transform: translateX(0);
}

/* 卡片动画 */
.card-animate {
    opacity: 0;
    transform: translateY(2rem) scale(0.95);
    transition: 
        opacity 400ms cubic-bezier(0.4, 0, 0.2, 1),
        transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

.card-animate.animate {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* 文章内容动画 */
.post-content-animate {
    opacity: 0;
    transform: translateY(1rem);
    transition: 
        opacity 320ms cubic-bezier(0.4, 0, 0.2, 1),
        transform 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

.post-content-animate.animate {
    opacity: 1;
    transform: translateY(0);
}

/* 导航栏动画增强 */
.navbar-animate {
    opacity: 0;
    transform: translateY(-1rem);
    transition: 
        opacity 280ms cubic-bezier(0.4, 0, 0.2, 1),
        transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

.navbar-animate.animate {
    opacity: 1;
    transform: translateY(0);
}

/* 页脚动画 */
.footer-animate {
    opacity: 0;
    transform: translateY(1rem);
    transition: 
        opacity 300ms cubic-bezier(0.4, 0, 0.2, 1),
        transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.footer-animate.animate {
    opacity: 1;
    transform: translateY(0);
}

/* 按钮悬停动画增强 */
.button-enhance {
    transition: 
        transform 200ms cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.button-enhance:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.button-enhance:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 链接动画增强 */
.link-enhance {
    position: relative;
    transition: color 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.link-enhance::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: currentColor;
    transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.link-enhance:hover::after {
    width: 100%;
}

/* 图片加载动画 */
.image-animate {
    opacity: 0;
    transform: scale(1.05);
    transition: 
        opacity 400ms cubic-bezier(0.4, 0, 0.2, 1),
        transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

.image-animate.loaded {
    opacity: 1;
    transform: scale(1);
}

/* 搜索框动画 */
.search-animate {
    transform: scale(0.95);
    opacity: 0;
    transition: 
        transform 250ms cubic-bezier(0.4, 0, 0.2, 1),
        opacity 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.search-animate.animate {
    transform: scale(1);
    opacity: 1;
}

/* 标签云动画 */
.tag-animate {
    opacity: 0;
    transform: translateY(0.5rem) scale(0.9);
    transition: 
        opacity 200ms cubic-bezier(0.4, 0, 0.2, 1),
        transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.tag-animate.animate {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* 分页动画 */
.pagination-animate {
    opacity: 0;
    transform: translateY(1rem);
    transition: 
        opacity 300ms cubic-bezier(0.4, 0, 0.2, 1),
        transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.pagination-animate.animate {
    opacity: 1;
    transform: translateY(0);
}

/* 减少动画的媒体查询 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    /* 保留TOC的平滑滚动，但减少其他滚动动画 */
    html {
        scroll-behavior: auto !important;
    }
    
    /* 确保TOC组件仍然有平滑滚动 */
    table-of-contents#toc {
        scroll-behavior: smooth !important;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .enhanced-fade-in,
    .card-animate,
    .post-content-animate {
        border: 1px solid currentColor;
    }
}

/* 暗色模式动画调整 */
@media (prefers-color-scheme: dark) {
    .button-enhance:hover {
        box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
    }
    
    .button-enhance:active {
        box-shadow: 0 2px 4px rgba(255, 255, 255, 0.05);
    }
}

/* 性能优化 */
.animate-gpu {
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* 动画完成后清理 */
.animation-complete {
    will-change: auto;
}