/* 增强动画效果 */

/* 基础动画类 */
.animate-on-scroll,
.fade-in,
.slide-up,
.slide-down,
.slide-left,
.slide-right,
.scale-in,
.rotate-in,
.bounce-in {
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.25, 0.1, 0.25, 1.0);
    transition-property: opacity, transform;
    will-change: opacity, transform;
}

/* 可见状态 */
.animate-on-scroll.visible,
.fade-in.visible,
.slide-up.visible,
.slide-down.visible,
.slide-left.visible,
.slide-right.visible,
.scale-in.visible,
.rotate-in.visible,
.bounce-in.visible {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0deg);
}

/* 淡入效果 */
.fade-in {
    opacity: 0;
}

/* 向上滑动效果 */
.slide-up {
    transform: translateY(50px);
}

/* 向下滑动效果 */
.slide-down {
    transform: translateY(-50px);
}

/* 向左滑动效果 */
.slide-left {
    transform: translateX(50px);
}

/* 向右滑动效果 */
.slide-right {
    transform: translateX(-50px);
}

/* 缩放效果 */
.scale-in {
    transform: scale(0.8);
}

/* 旋转效果 */
.rotate-in {
    transform: rotate(-10deg) scale(0.9);
}

/* 弹跳效果 */
.bounce-in {
    transform: scale(0.9);
}

.bounce-in.visible {
    animation: bounce 0.5s ease-out;
}

@keyframes bounce {
    0% {
        transform: scale(0.9);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* 延迟类 */
.delay-1 {
    transition-delay: 0.1s;
}

.delay-2 {
    transition-delay: 0.2s;
}

.delay-3 {
    transition-delay: 0.3s;
}

.delay-4 {
    transition-delay: 0.4s;
}

.delay-5 {
    transition-delay: 0.5s;
}

/* 持续时间类 */
.duration-1 {
    transition-duration: 0.5s;
}

.duration-2 {
    transition-duration: 0.8s;
}

.duration-3 {
    transition-duration: 1.2s;
}

/* 特殊动画效果 */

/* 浮动动画 */
.animate-float {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
    100% {
        transform: translateY(0px);
    }
}

/* 脉冲动画 */
.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* 闪烁动画 */
.animate-blink {
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* 波纹动画 */
.animate-ripple {
    position: relative;
    overflow: hidden;
}

.animate-ripple:after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: scale(0);
    animation: ripple 2s infinite;
    z-index: 1;
}

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* 摇晃动画 */
.animate-shake {
    animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) infinite;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
}

@keyframes shake {
    10%, 90% {
        transform: translate3d(-1px, 0, 0);
    }
    
    20%, 80% {
        transform: translate3d(2px, 0, 0);
    }

    30%, 50%, 70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%, 60% {
        transform: translate3d(4px, 0, 0);
    }
}

/* 打字机效果 */
.typewriter h1, .typewriter h2, .typewriter h3 {
    overflow: hidden;
    border-right: 0.15em solid #315EDA;
    white-space: nowrap;
    margin: 0 auto;
    letter-spacing: 0.05em;
    animation: typing 3.5s steps(40, end), blink-caret 0.75s step-end infinite;
}

@keyframes typing {
    from { width: 0 }
    to { width: 100% }
}

@keyframes blink-caret {
    from, to { border-color: transparent }
    50% { border-color: #315EDA }
}

/* 渐变背景动画 */
.animate-gradient {
    background: linear-gradient(-45deg, #315EDA, #4a7dff, #23a6d5, #23d5ab);
    background-size: 400% 400%;
    animation: gradient 15s ease infinite;
}

@keyframes gradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* 闪光效果 */
.animate-shine {
    position: relative;
    overflow: hidden;
}

.animate-shine:after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 20%;
    height: 200%;
    opacity: 0;
    transform: rotate(30deg);
    background: rgba(255, 255, 255, 0.13);
    background: linear-gradient(
        to right, 
        rgba(255, 255, 255, 0.13) 0%,
        rgba(255, 255, 255, 0.13) 77%,
        rgba(255, 255, 255, 0.5) 92%,
        rgba(255, 255, 255, 0.0) 100%
    );
    animation: shine 3s infinite;
}

@keyframes shine {
    10% {
        opacity: 1;
        left: 130%;
        transition-property: left, opacity;
        transition-duration: 0.7s, 0.15s;
        transition-timing-function: ease;
    }
    100% {
        opacity: 0;
        left: 130%;
    }
}

/* 3D翻转效果 */
.flip-card {
    perspective: 1000px;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
}

.flip-card-back {
    transform: rotateY(180deg);
}

/* 悬停效果 */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.hover-scale {
    transition: transform 0.3s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-rotate {
    transition: transform 0.3s ease;
}

.hover-rotate:hover {
    transform: rotate(5deg);
}

/* 响应式调整 */
@media (max-width: 768px) {
    .slide-up, .slide-down {
        transform: translateY(30px);
    }
    
    .slide-left, .slide-right {
        transform: translateX(30px);
    }
}

/* 禁用动画（用于减少动作或节省性能） */
@media (prefers-reduced-motion: reduce) {
    .animate-on-scroll,
    .fade-in,
    .slide-up,
    .slide-down,
    .slide-left,
    .slide-right,
    .scale-in,
    .rotate-in,
    .bounce-in {
        transition: none;
        opacity: 1;
        transform: none;
    }
    
    .animate-float,
    .animate-pulse,
    .animate-blink,
    .animate-ripple,
    .animate-shake,
    .typewriter h1,
    .typewriter h2,
    .typewriter h3,
    .animate-gradient,
    .animate-shine:after {
        animation: none;
    }
}