/*-----------------------------------------------------------------------------------
    动画效果库 - 智慧安防科技官网
    Description: 现代化动画效果和交互组件
    Author: AI Assistant
    Version: 1.0
    Last Updated: 2024-01-15
-----------------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------------
    目录
    ===================
    1. 入场动画
    2. 悬浮效果
    3. 加载动画
    4. 滚动动画
    5. 按钮动画
    6. 卡片动画
    7. 文字动画
    8. 背景动画
    9. 3D效果
    10. 微交互动画
-----------------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------------
    1. 入场动画
-----------------------------------------------------------------------------------*/

/* 淡入动画系列 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 40px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translate3d(0, -40px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translate3d(-40px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translate3d(40px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale3d(0.3, 0.3, 0.3);
    }
    50% {
        opacity: 1;
    }
    to {
        transform: scale3d(1, 1, 1);
    }
}

@keyframes slideInUp {
    from {
        transform: translate3d(0, 100%, 0);
        visibility: visible;
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

@keyframes bounceIn {
    from,
    20%,
    40%,
    60%,
    80%,
    to {
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
    }
    0% {
        opacity: 0;
        transform: scale3d(0.3, 0.3, 0.3);
    }
    20% {
        transform: scale3d(1.1, 1.1, 1.1);
    }
    40% {
        transform: scale3d(0.9, 0.9, 0.9);
    }
    60% {
        opacity: 1;
        transform: scale3d(1.03, 1.03, 1.03);
    }
    80% {
        transform: scale3d(0.97, 0.97, 0.97);
    }
    to {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

/* 动画类 */
.animate-fade-in-up {
    animation: fadeInUp 0.8s ease-out;
}

.animate-fade-in-down {
    animation: fadeInDown 0.8s ease-out;
}

.animate-fade-in-left {
    animation: fadeInLeft 0.8s ease-out;
}

.animate-fade-in-right {
    animation: fadeInRight 0.8s ease-out;
}

.animate-zoom-in {
    animation: zoomIn 0.6s ease-out;
}

.animate-slide-in-up {
    animation: slideInUp 0.8s ease-out;
}

.animate-bounce-in {
    animation: bounceIn 0.8s ease-out;
}

/* 延迟动画 */
.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }
.animate-delay-4 { animation-delay: 0.4s; }
.animate-delay-5 { animation-delay: 0.5s; }

/*-----------------------------------------------------------------------------------
    2. 悬浮效果
-----------------------------------------------------------------------------------*/

/* 悬浮上升 */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

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

/* 悬浮缩放 */
.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);
}

/* 悬浮倾斜 */
.hover-skew {
    transition: transform 0.3s ease;
}

.hover-skew:hover {
    transform: skew(-5deg, -2deg);
}

/* 悬浮发光 */
.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 30px rgba(0, 86, 179, 0.5);
}

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

.hover-border::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s ease;
}

.hover-border:hover::before {
    left: 100%;
}

/*-----------------------------------------------------------------------------------
    3. 加载动画
-----------------------------------------------------------------------------------*/

/* 脉冲加载 */
.loading-pulse {
    display: inline-block;
    width: 40px;
    height: 40px;
    background-color: var(--primary-color);
    border-radius: 50%;
    animation: pulse-loading 1.5s ease-in-out infinite;
}

@keyframes pulse-loading {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* 旋转加载 */
.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 86, 179, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

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

/* 点点加载 */
.loading-dots {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 80px;
}

.loading-dots div {
    position: absolute;
    top: 33px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--primary-color);
    animation-timing-function: cubic-bezier(0, 1, 1, 0);
}

.loading-dots div:nth-child(1) {
    left: 8px;
    animation: dots1 0.6s infinite;
}

.loading-dots div:nth-child(2) {
    left: 8px;
    animation: dots2 0.6s infinite;
}

.loading-dots div:nth-child(3) {
    left: 32px;
    animation: dots2 0.6s infinite;
}

.loading-dots div:nth-child(4) {
    left: 56px;
    animation: dots3 0.6s infinite;
}

@keyframes dots1 {
    0% {
        transform: scale(0);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes dots3 {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(0);
    }
}

@keyframes dots2 {
    0% {
        transform: translate(0, 0);
    }
    100% {
        transform: translate(24px, 0);
    }
}

/*-----------------------------------------------------------------------------------
    4. 滚动动画
-----------------------------------------------------------------------------------*/

/* 滚动视差 */
.parallax-element {
    transform: translateZ(0);
    will-change: transform;
}

/* 滚动淡入 */
.scroll-fade {
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

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

/* 滚动缩放 */
.scroll-scale {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.scroll-scale.in-view {
    opacity: 1;
    transform: scale(1);
}

/* 滚动旋转 */
.scroll-rotate {
    opacity: 0;
    transform: rotate(-10deg);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.scroll-rotate.in-view {
    opacity: 1;
    transform: rotate(0deg);
}

/*-----------------------------------------------------------------------------------
    5. 按钮动画
-----------------------------------------------------------------------------------*/

/* 按钮波纹效果 */
.btn-ripple {
    position: relative;
    overflow: hidden;
    transform: translate3d(0, 0, 0);
}

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

.btn-ripple:active::before {
    width: 300px;
    height: 300px;
}

/* 按钮摇摆 */
.btn-wobble {
    transition: transform 0.3s ease;
}

.btn-wobble:hover {
    animation: wobble 0.8s ease-in-out;
}

@keyframes wobble {
    0% { transform: translateX(0%); }
    15% { transform: translateX(-25px) rotate(-5deg); }
    30% { transform: translateX(20px) rotate(3deg); }
    45% { transform: translateX(-15px) rotate(-3deg); }
    60% { transform: translateX(10px) rotate(2deg); }
    75% { transform: translateX(-5px) rotate(-1deg); }
    100% { transform: translateX(0%); }
}

/* 按钮弹跳 */
.btn-bounce {
    transition: transform 0.3s ease;
}

.btn-bounce:hover {
    animation: bounce 0.6s ease;
}

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

/*-----------------------------------------------------------------------------------
    6. 卡片动画
-----------------------------------------------------------------------------------*/

/* 卡片翻转 */
.card-flip {
    perspective: 1000px;
}

.card-flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

.card-flip:hover .card-flip-inner {
    transform: rotateY(180deg);
}

.card-flip-front,
.card-flip-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--border-radius);
}

.card-flip-back {
    transform: rotateY(180deg);
}

/* 卡片展开 */
.card-expand {
    transition: all 0.3s ease;
    overflow: hidden;
}

.card-expand:hover {
    transform: scale(1.02);
}

.card-expand .card-content {
    transition: all 0.3s ease;
    max-height: 200px;
    overflow: hidden;
}

.card-expand:hover .card-content {
    max-height: 400px;
}

/*-----------------------------------------------------------------------------------
    7. 文字动画
-----------------------------------------------------------------------------------*/

/* 打字机效果 */
.typewriter {
    overflow: hidden;
    border-right: 2px solid var(--primary-color);
    white-space: nowrap;
    margin: 0 auto;
    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: var(--primary-color); }
}

/* 文字渐现 */
.text-reveal {
    position: relative;
    overflow: hidden;
}

.text-reveal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-color);
    transform: translateX(-100%);
    transition: transform 0.8s ease;
}

.text-reveal.active::before {
    transform: translateX(100%);
}

/* 文字高亮 */
.text-highlight {
    background: linear-gradient(120deg, transparent 0%, transparent 50%, var(--accent-color) 50%);
    background-size: 240% 100%;
    background-position: 100% 0;
    transition: background-position 0.8s ease;
}

.text-highlight.active {
    background-position: 0 0;
}

/*-----------------------------------------------------------------------------------
    8. 背景动画
-----------------------------------------------------------------------------------*/

/* 渐变动画 */
.bg-gradient-animate {
    background: linear-gradient(-45deg, #0056b3, #00a0e9, #667eea, #764ba2);
    background-size: 400% 400%;
    animation: gradient-shift 15s ease infinite;
}

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* 粒子背景 */
.bg-particles {
    position: relative;
    overflow: hidden;
}

.bg-particles::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.2), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255, 255, 255, 0.4), transparent);
    background-repeat: repeat;
    background-size: 100px 100px;
    animation: particles-float 20s linear infinite;
}

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

/*-----------------------------------------------------------------------------------
    9. 3D效果
-----------------------------------------------------------------------------------*/

/* 3D卡片 */
.card-3d {
    perspective: 1000px;
    transform-style: preserve-3d;
}

.card-3d-inner {
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card-3d:hover .card-3d-inner {
    transform: rotateX(10deg) rotateY(10deg);
}

/* 3D按钮 */
.btn-3d {
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.3s;
}

.btn-3d::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    transform: translateZ(-6px);
    border-radius: inherit;
}

.btn-3d:hover {
    transform: translateZ(6px);
}

/*-----------------------------------------------------------------------------------
    10. 微交互动画
-----------------------------------------------------------------------------------*/

/* 点击反馈 */
.click-feedback {
    position: relative;
    overflow: hidden;
}

.click-feedback::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.click-feedback:active::after {
    width: 200px;
    height: 200px;
}

/* 悬浮提示 */
.tooltip-animate {
    position: relative;
}

.tooltip-animate::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: var(--dark-color);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1000;
}

.tooltip-animate:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px);
}

/* 进度条动画 */
.progress-animate {
    width: 100%;
    height: 8px;
    background: rgba(0, 86, 179, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.progress-animate::before {
    content: '';
    display: block;
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 4px;
    transform: translateX(-100%);
    transition: transform 1.5s ease;
}

.progress-animate.active::before {
    transform: translateX(0);
}

/* 数字计数动画 */
.counter-animate {
    font-weight: bold;
    font-size: 2rem;
}

/* 响应式动画控制 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

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

/* 动画暂停控制 */
.animation-paused {
    animation-play-state: paused;
}

.animation-running {
    animation-play-state: running;
}