/**
 * 风清扬技术团队 - 动画样式
 * Raycast/Linear级别的动画丰富度
 */

/* ==========================================================================
   1. 基础关键帧动画
   ========================================================================== */

/* 淡入 */
@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 scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 弹性缩放 */
@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 旋转淡入 */
@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-10deg) scale(0.9);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

/* 脉冲 */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* 轻微浮动 */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* 闪烁发光 */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(99, 102, 241, 0.6);
    }
}

/* 渐变流动 */
@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

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

/* 摇摆 */
@keyframes swing {
    0%, 100% {
        transform: rotate(-3deg);
    }
    50% {
        transform: rotate(3deg);
    }
}

/* 波纹扩散 */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* 打字机光标闪烁 */
@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

/* 弹跳 */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }
    50% {
        transform: translateY(-25%);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}

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

/* 心跳 */
@keyframes heartbeat {
    0%, 100% {
        transform: scale(1);
    }
    14% {
        transform: scale(1.1);
    }
    28% {
        transform: scale(1);
    }
    42% {
        transform: scale(1.1);
    }
    70% {
        transform: scale(1);
    }
}

/* 闪光效果 */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* 下划线展开 */
@keyframes underlineExpand {
    from {
        transform: scaleX(0);
    }
    to {
        transform: scaleX(1);
    }
}

/* 数字滚动 */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 模糊渐入 */
@keyframes blurIn {
    from {
        opacity: 0;
        filter: blur(10px);
    }
    to {
        opacity: 1;
        filter: blur(0);
    }
}

/* 翻转进入 */
@keyframes flipInX {
    from {
        opacity: 0;
        transform: perspective(400px) rotateX(90deg);
    }
    40% {
        transform: perspective(400px) rotateX(-10deg);
    }
    70% {
        transform: perspective(400px) rotateX(10deg);
    }
    to {
        opacity: 1;
        transform: perspective(400px) rotateX(0);
    }
}

/* 滑入显示 */
@keyframes slideReveal {
    from {
        clip-path: inset(0 100% 0 0);
    }
    to {
        clip-path: inset(0 0 0 0);
    }
}

/* 粒子漂浮 */
@keyframes particleFloat {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(10px, -20px) rotate(90deg);
    }
    50% {
        transform: translate(-5px, -40px) rotate(180deg);
    }
    75% {
        transform: translate(-15px, -20px) rotate(270deg);
    }
}

/* ==========================================================================
   2. 动画工具类
   ========================================================================== */

/* 延迟 */
.animate-delay-100 { animation-delay: 0.1s; }
.animate-delay-200 { animation-delay: 0.2s; }
.animate-delay-300 { animation-delay: 0.3s; }
.animate-delay-400 { animation-delay: 0.4s; }
.animate-delay-500 { animation-delay: 0.5s; }
.animate-delay-600 { animation-delay: 0.6s; }
.animate-delay-700 { animation-delay: 0.7s; }
.animate-delay-800 { animation-delay: 0.8s; }
.animate-delay-900 { animation-delay: 0.9s; }
.animate-delay-1000 { animation-delay: 1s; }

/* 时长 */
.animate-duration-fast { animation-duration: 0.2s; }
.animate-duration-normal { animation-duration: 0.4s; }
.animate-duration-slow { animation-duration: 0.6s; }
.animate-duration-slower { animation-duration: 0.8s; }
.animate-duration-slowest { animation-duration: 1s; }

/* 无限循环 */
.animate-infinite { animation-iteration-count: infinite; }

/* 填充模式 */
.animate-fill-forwards { animation-fill-mode: forwards; }
.animate-fill-backwards { animation-fill-mode: backwards; }
.animate-fill-both { animation-fill-mode: both; }

/* ==========================================================================
   3. 预设动画类
   ========================================================================== */

.animate-fadeIn {
    animation: fadeIn 0.6s var(--ease-out-expo) both;
}

.animate-fadeInUp {
    animation: fadeInUp 0.6s var(--ease-out-expo) both;
}

.animate-fadeInDown {
    animation: fadeInDown 0.6s var(--ease-out-expo) both;
}

.animate-fadeInLeft {
    animation: fadeInLeft 0.6s var(--ease-out-expo) both;
}

.animate-fadeInRight {
    animation: fadeInRight 0.6s var(--ease-out-expo) both;
}

.animate-scaleIn {
    animation: scaleIn 0.5s var(--ease-out-back) both;
}

.animate-bounceIn {
    animation: bounceIn 0.8s var(--ease-out-expo) both;
}

.animate-rotateIn {
    animation: rotateIn 0.6s var(--ease-out-back) both;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

.animate-glow {
    animation: glow 2s ease-in-out infinite;
}

.animate-gradientFlow {
    background-size: 200% 200%;
    animation: gradientFlow 3s ease infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-swing {
    animation: swing 1s ease-in-out infinite;
}

.animate-bounce {
    animation: bounce 1s infinite;
}

.animate-shake {
    animation: shake 0.5s ease-in-out;
}

.animate-heartbeat {
    animation: heartbeat 1.5s ease-in-out infinite;
}

.animate-blurIn {
    animation: blurIn 0.6s var(--ease-out-expo) both;
}

.animate-flipInX {
    animation: flipInX 0.8s ease both;
}

/* ==========================================================================
   4. 滚动触发动画（配合 AOS 或 GSAP ScrollTrigger）
   ========================================================================== */

/* 
 * 滚动动画由 AOS 库控制
 * data-animate 属性只是标记，不设置初始隐藏状态
 * 这样即使 JS 加载失败，内容也能正常显示
 */

/* AOS 动画触发后的过渡效果 */
[data-animate] {
    transition: all 0.8s var(--ease-out-expo);
}

/* ==========================================================================
   5. 文字动画
   ========================================================================== */

/* 文字逐字显示 */
.text-reveal .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px) rotateX(-90deg);
    transform-origin: bottom;
}

.text-reveal.animated .char {
    animation: charReveal 0.5s var(--ease-out-back) forwards;
}

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

/* 文字渐变色动画 */
.text-gradient-animate {
    background: linear-gradient(
        90deg,
        var(--accent-primary),
        var(--accent-secondary),
        var(--accent-tertiary),
        var(--accent-primary)
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientFlow 4s ease infinite;
}

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

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

/* 文字闪光效果 */
.text-shimmer {
    background: linear-gradient(
        90deg,
        var(--light-text-primary) 0%,
        var(--accent-primary) 50%,
        var(--light-text-primary) 100%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 2s linear infinite;
}

/* ==========================================================================
   6. 加载动画
   ========================================================================== */

/* 加载点 */
.loading-dots {
    display: inline-flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: loadingDot 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes loadingDot {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* 加载圆环 */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--light-border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 骨架屏闪光 */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--light-bg-tertiary) 25%,
        var(--light-bg-secondary) 50%,
        var(--light-bg-tertiary) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* 进度条动画 */
.progress-bar {
    height: 4px;
    background: var(--light-bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transform-origin: left;
    animation: progressFill 2s var(--ease-out-expo) forwards;
}

@keyframes progressFill {
    from {
        transform: scaleX(0);
    }
    to {
        transform: scaleX(1);
    }
}

/* ==========================================================================
   7. 悬停动画
   ========================================================================== */

/* 悬停上浮 */
.hover-lift {
    transition: transform var(--duration-normal) var(--ease-out-expo),
                box-shadow var(--duration-normal) var(--ease-out-expo);
}

.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
}

/* 悬停缩放 */
.hover-scale {
    transition: transform var(--duration-normal) var(--ease-out-back);
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* 悬停旋转 */
.hover-rotate {
    transition: transform var(--duration-normal) var(--ease-out-expo);
}

.hover-rotate:hover {
    transform: rotate(5deg);
}

/* 悬停发光 */
.hover-glow {
    transition: box-shadow var(--duration-normal) var(--ease-out-expo);
}

.hover-glow:hover {
    box-shadow: var(--glow-primary);
}

/* 悬停边框动画 */
.hover-border {
    position: relative;
    overflow: hidden;
}

.hover-border::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 2px solid transparent;
    border-radius: inherit;
    transition: border-color var(--duration-normal);
}

.hover-border:hover::before {
    border-color: var(--accent-primary);
}

/* 悬停背景滑入 */
.hover-bg-slide {
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.hover-bg-slide::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-primary);
    transform: translateX(-100%);
    transition: transform var(--duration-normal) var(--ease-out-expo);
    z-index: -1;
}

.hover-bg-slide:hover::before {
    transform: translateX(0);
}

/* 图片悬停效果 */
.hover-img-zoom {
    overflow: hidden;
}

.hover-img-zoom img {
    transition: transform var(--duration-slow) var(--ease-out-expo);
}

.hover-img-zoom:hover img {
    transform: scale(1.1);
}

/* 图片悬停叠加层 */
.hover-overlay {
    position: relative;
    overflow: hidden;
}

.hover-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(0, 0, 0, 0.6) 100%
    );
    opacity: 0;
    transition: opacity var(--duration-normal);
}

.hover-overlay:hover::after {
    opacity: 1;
}

/* 悬停图标动画 */
.hover-icon-bounce i {
    transition: transform var(--duration-normal) var(--ease-out-back);
}

.hover-icon-bounce:hover i {
    transform: scale(1.3);
}

.hover-icon-rotate i {
    transition: transform var(--duration-normal) var(--ease-out-expo);
}

.hover-icon-rotate:hover i {
    transform: rotate(360deg);
}

/* ==========================================================================
   8. 按钮点击动画
   ========================================================================== */

/* 波纹效果 */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

/* 按下缩放 */
.btn-press:active {
    transform: scale(0.95);
}

/* ==========================================================================
   9. 页面过渡
   ========================================================================== */

/* 页面淡入 */
.page-transition-fade {
    animation: fadeIn 0.5s var(--ease-out-expo);
}

/* 页面滑入 */
.page-transition-slide {
    animation: fadeInUp 0.6s var(--ease-out-expo);
}

/* ==========================================================================
   10. 特殊效果
   ========================================================================== */

/* 霓虹发光文字 */
.neon-text {
    text-shadow:
        0 0 5px var(--accent-primary),
        0 0 10px var(--accent-primary),
        0 0 20px var(--accent-primary),
        0 0 40px var(--accent-secondary);
}

/* 玻璃态模糊 */
.glass-blur {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* 3D 卡片倾斜 */
.tilt-card {
    transform-style: preserve-3d;
    transition: transform var(--duration-normal) var(--ease-out-expo);
}

/* 视差层 */
.parallax-layer {
    will-change: transform;
}

/* 磁性效果区域 */
.magnetic {
    transition: transform var(--duration-fast) var(--ease-out-expo);
}

/* ==========================================================================
   11. 性能优化
   ========================================================================== */

/* GPU加速 */
.gpu-accelerate {
    transform: translateZ(0);
    will-change: transform;
}

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

/* 低性能设备降级 */
body[data-gpu-tier="1"] [data-animate],
body[data-is-mobile="true"][data-gpu-tier="2"] [data-animate] {
    transition-duration: 0.1s !important;
}

body[data-gpu-tier="1"] .animate-gradientFlow,
body[data-gpu-tier="1"] .animate-float,
body[data-gpu-tier="1"] .animate-pulse {
    animation: none !important;
}

/* ==========================================================================
   12. 数字滚动计数
   ========================================================================== */

.count-up {
    display: inline-block;
}

.count-up.counting {
    animation: countUp 0.3s var(--ease-out-expo);
}

/* ==========================================================================
   13. 导航栏动画
   ========================================================================== */

/* 导航栏滚动缩小 */
.header-shrink {
    transition: padding var(--duration-normal) var(--ease-out-expo),
                background var(--duration-normal) var(--ease-out-expo);
}

/* 菜单项hover下划线 */
.nav-underline {
    position: relative;
}

.nav-underline::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--gradient-primary);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform var(--duration-normal) var(--ease-out-expo);
}

.nav-underline:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

/* ==========================================================================
   14. 卡片动画
   ========================================================================== */

/* 卡片入场序列 */
.card-stagger {
    opacity: 0;
    transform: translateY(40px);
}

.card-stagger.visible {
    animation: cardEnter 0.6s var(--ease-out-expo) forwards;
}

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

/* 卡片悬停3D效果样式 */
.card-3d {
    transform-style: preserve-3d;
    transition: transform var(--duration-fast) var(--ease-out-expo);
}

.card-3d-content {
    transform: translateZ(20px);
}

/* ==========================================================================
   15. 滚动进度条
   ========================================================================== */

.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    z-index: calc(var(--z-header) + 1);
}

.scroll-progress-bar {
    height: 100%;
    background: var(--gradient-primary);
    transform-origin: left;
    transform: scaleX(0);
    transition: transform 0.1s linear;
}

/* ==========================================================================
   16. Hero区域特效
   ========================================================================== */

/* Hero背景光晕 */
.hero-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.3;
    animation: heroGlowFloat 8s ease-in-out infinite;
}

.hero-glow-1 {
    top: -200px;
    left: -100px;
    background: var(--accent-primary);
    animation-delay: 0s;
}

.hero-glow-2 {
    bottom: -200px;
    right: -100px;
    background: var(--accent-secondary);
    animation-delay: -4s;
}

@keyframes heroGlowFloat {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(30px, -30px) scale(1.1);
    }
    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

/* Hero文字光效 */
.hero-title-glow {
    position: relative;
}

.hero-title-glow::before {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: blur(30px);
    opacity: 0.5;
    animation: titleGlow 3s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 0.6;
    }
}

/* ==========================================================================
   17. 搜索框动画
   ========================================================================== */

.search-input-animate {
    transition: all var(--duration-normal) var(--ease-out-expo);
}

.search-input-animate:focus {
    transform: scale(1.02);
}

/* 搜索图标动画 */
.search-icon-animate {
    transition: transform var(--duration-normal) var(--ease-out-back);
}

.search-input-animate:focus ~ .search-icon-animate,
.search-input-animate:hover ~ .search-icon-animate {
    transform: scale(1.1);
}

/* ==========================================================================
   18. 分类图标动画
   ========================================================================== */

.category-icon-animate {
    transition: all var(--duration-normal) var(--ease-out-back);
}

.category-item:hover .category-icon-animate {
    transform: scale(1.15) rotate(-8deg);
    box-shadow: var(--glow-primary);
}

/* 图标内部元素动画 */
.category-icon-animate i {
    transition: transform var(--duration-fast);
}

.category-item:hover .category-icon-animate i {
    transform: scale(1.1);
}

/* ==========================================================================
   19. 购买按钮动画
   ========================================================================== */

.buy-btn-animate {
    position: relative;
    overflow: hidden;
}

.buy-btn-animate::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300%;
    height: 300%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.6s var(--ease-out-expo);
}

.buy-btn-animate:hover::before {
    transform: translate(-50%, -50%) scale(1);
}

/* TG按钮特殊动画 */
.btn-tg-animate {
    animation: tgPulse 2s ease-in-out infinite;
}

@keyframes tgPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 136, 204, 0.4);
    }
    50% {
        box-shadow: 0 0 0 15px rgba(0, 136, 204, 0);
    }
}

/* ==========================================================================
   20. 标签动画
   ========================================================================== */

.tag-animate {
    transition: all var(--duration-fast) var(--ease-out-back);
}

.tag-animate:hover {
    transform: translateY(-2px) scale(1.05);
}

/* 热门标签闪烁 */
.tag-hot {
    animation: tagHot 2s ease-in-out infinite;
}

@keyframes tagHot {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 10px 5px rgba(239, 68, 68, 0);
    }
}
