/* ========================================
   动画效果样式文件
   参考 huohuo90.com 的优雅动画
   ======================================== */

/* 关键帧动画定义 */
@keyframes fadeInUp {
    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 fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translateY(0);
    }
    40%, 43% {
        transform: translateY(-10px);
    }
    70% {
        transform: translateY(-5px);
    }
    90% {
        transform: translateY(-2px);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes loading {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* 页面加载动画 */
.page-load {
    animation: fadeIn 0.6s ease-out;
}

/* 导航栏动画 */
.navbar {
    animation: slideInDown 0.5s ease-out;
}

.nav-link {
    position: relative;
    overflow: hidden;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* 英雄区域动画 */
.hero-avatar {
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.hero-title {
    animation: fadeInUp 0.8s ease-out 0.4s both;
}

.hero-subtitle {
    animation: fadeInUp 0.8s ease-out 0.6s both;
}

.hero-description {
    animation: fadeInUp 0.8s ease-out 0.8s both;
}

.social-links {
    animation: fadeInUp 0.8s ease-out 1s both;
}

.hero-actions {
    animation: fadeInUp 0.8s ease-out 1.2s both;
}

/* 作品卡片动画 */
.work-item {
    animation: fadeInUp 0.6s ease-out;
    animation-fill-mode: both;
}

.work-item:nth-child(1) { animation-delay: 0.1s; }
.work-item:nth-child(2) { animation-delay: 0.2s; }
.work-item:nth-child(3) { animation-delay: 0.3s; }
.work-item:nth-child(4) { animation-delay: 0.4s; }
.work-item:nth-child(5) { animation-delay: 0.5s; }
.work-item:nth-child(6) { animation-delay: 0.6s; }

.work-item:hover {
    animation: pulse 0.6s ease-in-out;
}

.work-img {
    transition: transform 0.4s ease;
}

.work-item:hover .work-img {
    transform: scale(1.1);
}

.work-overlay {
    transition: opacity 0.3s ease;
}

/* 按钮动画 */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

/* 加载按钮动画 */
.btn-loading .btn-text {
    display: none;
}

.btn-loading .btn-loading {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
}

.loading-icon {
    width: 16px;
    height: 16px;
    animation: loading 1s linear infinite;
}

/* 图片懒加载动画 */
.lazy-load {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease;
}

.lazy-load.loaded {
    opacity: 1;
    transform: translateY(0);
}

/* 滚动动画 */
.scroll-animate {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease;
}

.scroll-animate.animate {
    opacity: 1;
    transform: translateY(0);
}

/* 画廊动画 */
.gallery-item {
    animation: fadeInUp 0.6s ease-out;
    animation-fill-mode: both;
}

.gallery-item:nth-child(1) { animation-delay: 0.1s; }
.gallery-item:nth-child(2) { animation-delay: 0.2s; }
.gallery-item:nth-child(3) { animation-delay: 0.3s; }
.gallery-item:nth-child(4) { animation-delay: 0.4s; }
.gallery-item:nth-child(5) { animation-delay: 0.5s; }
.gallery-item:nth-child(6) { animation-delay: 0.6s; }
.gallery-item:nth-child(7) { animation-delay: 0.7s; }
.gallery-item:nth-child(8) { animation-delay: 0.8s; }

.gallery-img {
    transition: transform 0.4s ease;
}

.gallery-item:hover .gallery-img {
    transform: scale(1.05);
}

.gallery-overlay {
    transition: all 0.3s ease;
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
    transform: translateY(0);
}

/* 模态框动画 */
.lightbox {
    animation: fadeIn 0.3s ease-out;
}

.lightbox-content {
    animation: scaleIn 0.3s ease-out;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
    transition: all 0.3s ease;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    transform: scale(1.1);
}

/* 表单动画 */
.form-group {
    animation: fadeInUp 0.6s ease-out;
    animation-fill-mode: both;
}

.form-group:nth-child(1) { animation-delay: 0.1s; }
.form-group:nth-child(2) { animation-delay: 0.2s; }
.form-group:nth-child(3) { animation-delay: 0.3s; }
.form-group:nth-child(4) { animation-delay: 0.4s; }
.form-group:nth-child(5) { animation-delay: 0.5s; }

.form-input,
.form-textarea {
    transition: all 0.3s ease;
}

.form-input:focus,
.form-textarea:focus {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* 成功消息动画 */
.form-success {
    animation: fadeInUp 0.6s ease-out;
}

.success-icon {
    animation: bounce 0.6s ease-out;
}

/* FAQ 动画 */
.faq-item {
    animation: fadeInUp 0.6s ease-out;
    animation-fill-mode: both;
}

.faq-item:nth-child(1) { animation-delay: 0.1s; }
.faq-item:nth-child(2) { animation-delay: 0.2s; }
.faq-item:nth-child(3) { animation-delay: 0.3s; }
.faq-item:nth-child(4) { animation-delay: 0.4s; }

.faq-question {
    transition: all 0.3s ease;
}

.faq-item:hover .faq-question {
    transform: translateX(5px);
}

.faq-icon {
    transition: transform 0.3s ease;
}

.faq-item.active .faq-icon {
    transform: rotate(180deg);
}

.faq-answer {
    transition: all 0.3s ease;
    overflow: hidden;
}

/* 技能条动画 */
.skill-progress {
    transition: width 1.5s ease-out;
    animation: shimmer 2s ease-in-out infinite;
}

/* 时间线动画 */
.timeline-item {
    animation: fadeInLeft 0.6s ease-out;
    animation-fill-mode: both;
}

.timeline-item:nth-child(1) { animation-delay: 0.1s; }
.timeline-item:nth-child(2) { animation-delay: 0.2s; }
.timeline-item:nth-child(3) { animation-delay: 0.3s; }

/* 奖项动画 */
.award-item {
    animation: fadeInRight 0.6s ease-out;
    animation-fill-mode: both;
}

.award-item:nth-child(1) { animation-delay: 0.1s; }
.award-item:nth-child(2) { animation-delay: 0.2s; }
.award-item:nth-child(3) { animation-delay: 0.3s; }

/* 浮动动画 */
.float {
    animation: float 3s ease-in-out infinite;
}

/* 脉冲动画 */
.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* 旋转动画 */
.rotate {
    animation: rotate 2s linear infinite;
}

/* 闪烁动画 */
.shimmer {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    background-size: 200% 100%;
    animation: shimmer 2s ease-in-out infinite;
}

/* 页面切换动画 */
.page-transition {
    animation: fadeIn 0.5s ease-out;
}

/* 滚动指示器动画 */
.scroll-indicator {
    animation: bounce 2s ease-in-out infinite;
}

/* 加载状态动画 */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 1.5s ease-in-out infinite;
}

/* 悬停效果增强 */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.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);
}

/* 文字动画 */
.text-reveal {
    overflow: hidden;
}

.text-reveal span {
    display: inline-block;
    animation: fadeInUp 0.6s ease-out;
    animation-fill-mode: both;
}

.text-reveal span:nth-child(1) { animation-delay: 0.1s; }
.text-reveal span:nth-child(2) { animation-delay: 0.2s; }
.text-reveal span:nth-child(3) { animation-delay: 0.3s; }
.text-reveal span:nth-child(4) { animation-delay: 0.4s; }

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .scroll-animate {
        opacity: 1;
        transform: none;
    }
}

/* 性能优化 */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

/* 动画性能优化 */
.animate-optimized {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}
