/**
 * ============================================
 * 动画效果库 (Animations)
 * ============================================
 * 
 * 包含各种科技感动画效果
 * 
 * @author 廖斌
 * @version 1.0.0
 * @date 2025-10-16
 */

/* ==================== 入场动画 ==================== */

/* 淡入 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.animate-fadeIn {
  animation: fadeIn 0.6s ease-out;
}

/* 从上滑入 */
@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-slideInDown {
  animation: slideInDown 0.6s ease-out;
}

/* 从下滑入 */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-slideInUp {
  animation: slideInUp 0.6s ease-out;
}

/* 从左滑入 */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-slideInLeft {
  animation: slideInLeft 0.6s ease-out;
}

/* 从右滑入 */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-slideInRight {
  animation: slideInRight 0.6s ease-out;
}

/* 缩放进入 */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-scaleIn {
  animation: scaleIn 0.6s ease-out;
}

/* 弹跳进入 */
@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);
  }
}

.animate-bounceIn {
  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;
}

/* ==================== 悬停动画 ==================== */

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

.hover-lift:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg), var(--shadow-glow-primary);
}

/* 放大 */
.hover-scale {
  transition: transform 0.3s ease;
}

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

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

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

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

.hover-tilt:hover {
  transform: perspective(1000px) rotateX(2deg) rotateY(2deg);
}

/* ==================== 加载动画 ==================== */

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

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

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

/* 脉冲 */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* 心跳 */
@keyframes heartbeat {
  0%, 100% {
    transform: scale(1);
  }
  10%, 30% {
    transform: scale(1.1);
  }
  20%, 40% {
    transform: scale(0.9);
  }
}

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

/* 闪烁 */
@keyframes blink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

.animate-blink {
  animation: blink 1s step-end infinite;
}

/* ==================== 科技感特效动画 ==================== */

/* 扫描线 */
@keyframes scanline {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(100%);
  }
}

.tech-scanline {
  position: relative;
  overflow: hidden;
}

.tech-scanline::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, 
    transparent, 
    var(--color-primary), 
    transparent);
  animation: scanline 2s linear infinite;
  opacity: 0.5;
}

/* 霓虹光晕 */
@keyframes neonGlow {
  0%, 100% {
    box-shadow: 
      0 0 10px var(--color-primary),
      0 0 20px var(--color-primary),
      0 0 30px var(--color-primary);
  }
  50% {
    box-shadow: 
      0 0 20px var(--color-primary),
      0 0 40px var(--color-primary),
      0 0 60px var(--color-primary);
  }
}

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

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

.gradient-flow {
  background: var(--gradient-rainbow);
  background-size: 200% 200%;
  animation: gradientFlow 3s ease infinite;
}

/* 数字雨效果(文字) */
@keyframes matrixRain {
  0% {
    transform: translateY(-100%);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh);
    opacity: 0;
  }
}

.matrix-rain {
  animation: matrixRain 3s linear infinite;
}

/* 粒子漂浮 */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
}

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

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

.ripple-effect {
  position: relative;
  overflow: hidden;
}

.ripple-effect::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--color-primary);
  transform: translate(-50%, -50%) scale(0);
  animation: ripple 1.5s ease-out infinite;
}

/* ==================== 成功/错误动画 ==================== */

/* 成功√动画 */
@keyframes checkmark {
  0% {
    stroke-dashoffset: 100;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

.checkmark-animation {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: checkmark 0.6s ease-out forwards;
}

/* 错误×动画 */
@keyframes errorX {
  0% {
    transform: scale(0) rotate(0deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.2) rotate(45deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(45deg);
    opacity: 1;
  }
}

.error-x-animation {
  animation: errorX 0.6s ease-out forwards;
}

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

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

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

.count-up {
  animation: countUp 0.6s ease-out;
}

/* ==================== 进度条动画 ==================== */
@keyframes progressBar {
  from {
    width: 0%;
  }
}

.progress-bar-animate {
  animation: progressBar 1.5s ease-out forwards;
}

/* ==================== 打字机效果 ==================== */
@keyframes typing {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes blink-caret {
  50% {
    border-color: transparent;
  }
}

.typewriter {
  overflow: hidden;
  border-right: 2px solid var(--color-primary);
  white-space: nowrap;
  animation: 
    typing 3s steps(40) forwards,
    blink-caret 0.75s step-end infinite;
}

/* ==================== 翻转动画 ==================== */
@keyframes flip {
  0% {
    transform: perspective(400px) rotateY(0);
  }
  100% {
    transform: perspective(400px) rotateY(360deg);
  }
}

.animate-flip {
  animation: flip 1s ease;
}

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

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  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);
}

/* ==================== 彩纸爆炸(成功庆祝) ==================== */
@keyframes confetti-fall {
  0% {
    transform: translateY(-100vh) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  background: var(--gradient-rainbow);
  animation: confetti-fall 3s linear forwards;
}

/* ==================== 页面转场动画 ==================== */
@keyframes pageSlideIn {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.page-transition {
  animation: pageSlideIn 0.6s ease-out;
}

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

@media (max-width: 768px) {
  /* 移动端动画优化 - 减少复杂动画 */
  .neon-glow,
  .matrix-rain,
  .tech-scanline {
    animation: none;
  }
  
  .hover-lift:hover,
  .hover-scale:hover,
  .hover-tilt:hover {
    transform: none;
  }
}


