/* ============================================
   Caleb 个人网站 - 动画样式
   ============================================ */

/* ============================================
   基础淡入动画
   ============================================ */
.animate-fade-in {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s ease-out forwards;
}

.animate-fade-in.delay-1 {
  animation-delay: 0.5s;
}

.animate-fade-in.delay-2 {
  animation-delay: 0.9s;
}

.animate-fade-in.delay-3 {
  animation-delay: 1.2s;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   页面切换动画
   ============================================ */
.page-transition-exit {
  opacity: 1;
  transform: translateY(0);
}

.page-transition-exit-active {
  opacity: 0;
  transform: translateY(-10px);
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.page-transition-enter {
  opacity: 0;
  transform: translateY(10px);
}

.page-transition-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
  transition-delay: 50ms;
}

/* ============================================
   滚动触发动画
   ============================================ */
.scroll-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.scroll-reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* 卡片依次出现动画 */
.stagger-item {
  opacity: 0;
  transform: translateY(20px);
}

.stagger-item.visible {
  animation: staggerFadeIn 0.5s ease-out forwards;
}

.stagger-item:nth-child(1).visible { animation-delay: 0s; }
.stagger-item:nth-child(2).visible { animation-delay: 0.1s; }
.stagger-item:nth-child(3).visible { animation-delay: 0.2s; }
.stagger-item:nth-child(4).visible { animation-delay: 0.3s; }
.stagger-item:nth-child(5).visible { animation-delay: 0.4s; }
.stagger-item:nth-child(6).visible { animation-delay: 0.5s; }
.stagger-item:nth-child(7).visible { animation-delay: 0.6s; }
.stagger-item:nth-child(8).visible { animation-delay: 0.7s; }
.stagger-item:nth-child(9).visible { animation-delay: 0.8s; }
.stagger-item:nth-child(10).visible { animation-delay: 0.9s; }

@keyframes staggerFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   Hover 发光动画
   ============================================ */
.glow-on-hover {
  position: relative;
}

.glow-on-hover::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: linear-gradient(
    45deg,
    transparent,
    rgba(255, 138, 105, 0.3),
    transparent
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
}

.glow-on-hover:hover::before {
  opacity: 1;
}

/* ============================================
   脉冲动画
   ============================================ */
.pulse {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.8;
  }
}

/* ============================================
   浮动动画
   ============================================ */
.float {
  animation: float 3s ease-in-out infinite;
}

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

/* ============================================
   闪烁动画（用于加载状态）
   ============================================ */
.shimmer {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ============================================
   旋转动画
   ============================================ */
.spin {
  animation: spin 1s linear infinite;
}

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

/* ============================================
   弹跳动画
   ============================================ */
.bounce {
  animation: bounce 0.5s ease;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-20px);
  }
  60% {
    transform: translateY(-10px);
  }
}

/* ============================================
   抖动动画（错误提示）
   ============================================ */
.shake {
  animation: shake 0.5s ease;
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

/* ============================================
   渐变流动动画
   ============================================ */
.gradient-flow {
  background: linear-gradient(
    270deg,
    var(--color-morning-primary),
    var(--color-sunset-primary),
    var(--color-dusk-primary),
    var(--color-night-primary)
  );
  background-size: 400% 400%;
  animation: gradientFlow 15s ease infinite;
}

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

/* ============================================
   打字机效果
   ============================================ */
.typewriter {
  overflow: hidden;
  white-space: nowrap;
  border-right: 2px solid var(--text-primary);
  animation: 
    typing 3s steps(30, end),
    blinkCursor 0.75s step-end infinite;
}

@keyframes typing {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes blinkCursor {
  from, to {
    border-color: transparent;
  }
  50% {
    border-color: var(--text-primary);
  }
}

/* ============================================
   减少动画（用户偏好）
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
