﻿/* 高级动效样式 - 性能优化�?v2 */

/* 全局平滑滚动 */
html {
    scroll-behavior: smooth;
}

/* 启用GPU加�?- 优化�?*/
.fade-in-up, .fade-in-left, .fade-in-right, .scale-in {
    will-change: opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
}

/* 悬浮卡片单独处理 */
.hover-card {
    will-change: transform;
    backface-visibility: hidden;
}

/* ==================== 滚动触发动画 ==================== */

/* 淡入上移动画 - 更流�?*/
.fade-in-up {
    opacity: 0;
    transform: translate3d(0, 20px, 0);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.fade-in-up.visible {
    opacity: 1;
    transform: translate3d(0, 0, 0);
}

/* 淡入左移动画 */
.fade-in-left {
    opacity: 0;
    transform: translate3d(-20px, 0, 0);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.fade-in-left.visible {
    opacity: 1;
    transform: translate3d(0, 0, 0);
}

/* 淡入右移动画 */
.fade-in-right {
    opacity: 0;
    transform: translate3d(20px, 0, 0);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.fade-in-right.visible {
    opacity: 1;
    transform: translate3d(0, 0, 0);
}

/* 缩放淡入 */
.scale-in {
    opacity: 0;
    transform: scale3d(0.95, 0.95, 1);
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.scale-in.visible {
    opacity: 1;
    transform: scale3d(1, 1, 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; }

/* ==================== 数字计数动画 ==================== */
.counter-section {
    background: linear-gradient(135deg, #008B8B 0%, #0ABAB5 50%, #81D8D0 100%);
    padding: 80px 0;
    position: relative;
    overflow: hidden;
}

.counter-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" fill="none" stroke="rgba(255,255,255,0.05)" stroke-width="0.5"/></svg>');
    background-size: 100px 100px;
    animation: bgMove 20s linear infinite;
}

@keyframes bgMove {
    0% { background-position: 0 0; }
    100% { background-position: 100px 100px; }
}

.counter-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 30px;
    position: relative;
    z-index: 1;
}

.counter-item {
    text-align: center;
    color: #fff;
    padding: 30px;
}

.counter-number {
    font-size: 56px;
    font-weight: bold;
    margin-bottom: 10px;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 5px;
}

.counter-number .count {
    display: inline-block;
}

.counter-number .suffix {
    font-size: 24px;
    opacity: 0.9;
}

.counter-label {
    font-size: 18px;
    opacity: 0.9;
}

/* ==================== 悬浮卡片效果 ==================== */
.hover-card {
    position: relative;
    overflow: hidden;
    border-radius: 15px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-card:hover {
    transform: translate3d(0, -10px, 0);
    box-shadow: 0 15px 35px rgba(10, 186, 181, 0.15);
}

/* ==================== 粒子背景效果 ==================== */
.particles-bg {
    position: relative;
    overflow: hidden;
}

.particles-bg::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(10, 186, 181, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(76, 175, 80, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(26, 92, 58, 0.05) 0%, transparent 30%);
    pointer-events: none;
    animation: particleFloat 15s ease-in-out infinite;
}

@keyframes particleFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(5deg); }
}

/* ==================== 文字打字效果 ==================== */
.typing-text {
    overflow: hidden;
    border-right: 3px solid #0ABAB5;
    white-space: nowrap;
    animation: typing 3s steps(30) 1s forwards, blink 0.75s step-end infinite;
    width: 0;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink {
    50% { border-color: transparent; }
}

/* ==================== 波浪分隔�?==================== */
.wave-divider {
    position: relative;
    height: 100px;
    overflow: hidden;
}

.wave-divider svg {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 100px;
}

.wave-divider .wave1 {
    animation: wave 8s ease-in-out infinite;
}

.wave-divider .wave2 {
    animation: wave 10s ease-in-out infinite reverse;
    opacity: 0.5;
}

@keyframes wave {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-25px); }
}

/* ==================== 3D卡片翻转 ==================== */
.flip-card {
    perspective: 1000px;
    height: 300px;
}

.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;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 30px;
}

.flip-card-front {
    background: linear-gradient(135deg, #fff 0%, #f5f5f5 100%);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.flip-card-back {
    background: linear-gradient(135deg, #0ABAB5 0%, #008B8B 100%);
    color: #fff;
    transform: rotateY(180deg);
}

/* ==================== 脉冲按钮 ==================== */
.pulse-btn {
    position: relative;
    padding: 15px 40px;
    background: linear-gradient(135deg, #81D8D0 0%, #0ABAB5 100%);
    color: #fff;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s;
}

.pulse-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.6s, height 0.6s;
}

.pulse-btn:hover::before {
    width: 300px;
    height: 300px;
}

.pulse-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(10, 186, 181, 0.4);
}

/* 脉冲动画�?*/
.pulse-ring {
    position: relative;
}

.pulse-ring::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border: 2px solid #0ABAB5;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: pulseRing 2s ease-out infinite;
}

@keyframes pulseRing {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}

/* ==================== 渐变边框动画 ==================== */
.gradient-border {
    position: relative;
    background: #fff;
    border-radius: 15px;
    padding: 30px;
}

.gradient-border::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: linear-gradient(45deg, #81D8D0, #0ABAB5, #008B8B, #81D8D0);
    background-size: 400% 400%;
    border-radius: 18px;
    z-index: -1;
    animation: gradientBorder 3s ease infinite;
}

@keyframes gradientBorder {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ==================== 图片悬浮效果 ==================== */
.img-hover-zoom {
    overflow: hidden;
    border-radius: 15px;
}

.img-hover-zoom img {
    transition: transform 0.5s ease;
}

.img-hover-zoom:hover img {
    transform: scale(1.1);
}

/* 图片遮罩效果 */
.img-overlay {
    position: relative;
    overflow: hidden;
    border-radius: 15px;
}

.img-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(10, 186, 181, 0.8) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.4s;
}

.img-overlay:hover::after {
    opacity: 1;
}

.img-overlay .overlay-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 30px;
    color: #fff;
    transform: translateY(100%);
    transition: transform 0.4s;
    z-index: 1;
}

.img-overlay:hover .overlay-content {
    transform: translateY(0);
}

/* ==================== 浮动元素 ==================== */
.float-element {
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

.float-element-slow {
    animation: float 8s ease-in-out infinite;
}

.float-element-fast {
    animation: float 4s ease-in-out infinite;
}

/* ==================== 旋转图标 ==================== */
.rotate-icon {
    transition: transform 0.5s ease;
}

.rotate-icon:hover {
    transform: rotate(360deg);
}

/* ==================== 闪烁效果 ==================== */
.shimmer {
    position: relative;
    overflow: hidden;
}

.shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 200%; }
}

/* ==================== 进度条动�?==================== */
.progress-bar {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #81D8D0, #0ABAB5);
    border-radius: 4px;
    width: 0;
    transition: width 1.5s ease-out;
}

.progress-fill.animate {
    width: var(--progress, 80%);
}

/* ==================== 标题装饰动画 ==================== */
.animated-title {
    position: relative;
    display: inline-block;
}

.animated-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 0;
    height: 4px;
    background: linear-gradient(90deg, #81D8D0, #0ABAB5);
    border-radius: 2px;
    transition: width 0.6s ease;
}

.animated-title.visible::after {
    width: 100%;
}

/* ==================== 响应式调�?==================== */
@media (max-width: 768px) {
    .counter-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .counter-number {
        font-size: 40px;
    }
    
    .flip-card {
        height: 250px;
    }
}

@media (max-width: 480px) {
    .counter-grid {
        grid-template-columns: 1fr;
    }
    
    .counter-number {
        font-size: 36px;
    }
}


/* ==================== 减少动画选项 (Accessibility) ==================== */
/* 为偏好减少动画的用户禁用或简化动画效果 */
@media (prefers-reduced-motion: reduce) {
    /* 禁用所有动画和过渡 */
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    /* 保持基本的透明度变化，但移除移动效果 */
    .fade-in-up,
    .fade-in-left,
    .fade-in-right,
    .scale-in {
        opacity: 0;
        transform: none !important;
        transition: opacity 0.2s ease !important;
    }
    
    .fade-in-up.visible,
    .fade-in-left.visible,
    .fade-in-right.visible,
    .scale-in.visible {
        opacity: 1;
    }
    
    /* 禁用悬停动画 */
    .hover-card:hover,
    .service-card:hover,
    .product-card:hover,
    .news-card:hover {
        transform: none !important;
    }
    
    /* 禁用浮动动画 */
    .float-element,
    .float-element-slow,
    .float-element-fast {
        animation: none !important;
    }
    
    /* 禁用旋转效果 */
    .rotate-icon:hover {
        transform: none !important;
    }
    
    /* 禁用粒子背景动画 */
    .particles-bg canvas {
        display: none !important;
    }
    
    /* 禁用渐变边框动画 */
    .gradient-border::before {
        animation: none !important;
    }
    
    /* 禁用轮播图自动播放 */
    .carousel-inner {
        animation: none !important;
    }
    
    /* 保持平滑滚动为自动 */
    html {
        scroll-behavior: auto !important;
    }
}

/* ==================== 高对比度模式支持 ==================== */
@media (prefers-contrast: high) {
    /* 增强边框和阴影的对比度 */
    .hover-card,
    .service-card,
    .product-card {
        border: 2px solid currentColor;
    }
    
    /* 确保文本有足够的对比度 */
    .overlay-content {
        background: rgba(0, 0, 0, 0.9);
    }
}

/* ==================== 性能优化提示 ==================== */
/* 
 * 动画性能最佳实践：
 * 1. 只对 transform 和 opacity 属性做动画
 * 2. 使用 will-change 提示浏览器优化（但不要过度使用）
 * 3. 使用 requestAnimationFrame 进行 JavaScript 动画
 * 4. 避免在滚动事件中直接操作 DOM
 * 5. 使用 Intersection Observer 替代滚动监听
 * 6. 为动画元素添加 backface-visibility: hidden
 * 7. 使用 CSS 变量统一管理过渡时间
 */
