/* ========================================
   CodeNotes - Animations
   页面加载与交互动画
   ======================================== */

/* 页面加载动画 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}

/* 初始状态（等待JS触发） */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

/*  stagger 动画延迟 */
.stagger-1 { transition-delay: 0.1s; }
.stagger-2 { transition-delay: 0.2s; }
.stagger-3 { transition-delay: 0.3s; }
.stagger-4 { transition-delay: 0.4s; }
.stagger-5 { transition-delay: 0.5s; }

/* 文章卡片进入动画 */
.post-card {
  animation: fadeInUp 0.6s ease backwards;
}

.post-card:nth-child(1) { animation-delay: 0.1s; }
.post-card:nth-child(2) { animation-delay: 0.2s; }
.post-card:nth-child(3) { animation-delay: 0.3s; }
.post-card:nth-child(4) { animation-delay: 0.4s; }
.post-card:nth-child(5) { animation-delay: 0.5s; }

/* 侧边栏组件动画 */
.widget {
  animation: slideInRight 0.6s ease backwards;
}

.widget:nth-child(1) { animation-delay: 0.2s; }
.widget:nth-child(2) { animation-delay: 0.3s; }
.widget:nth-child(3) { animation-delay: 0.4s; }
.widget:nth-child(4) { animation-delay: 0.5s; }

/* 按钮悬停微动画 */
.btn:active {
  transform: scale(0.98);
}

/* 链接下划线动画 */
.link-animated {
  position: relative;
  text-decoration: none;
  color: var(--accent-primary);
}

.link-animated::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 2px;
  bottom: -2px;
  left: 0;
  background: var(--accent-gradient);
  transform: scaleX(0);
  transform-origin: bottom right;
  transition: transform 0.3s ease;
}

.link-animated:hover::after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

/* 图片悬停缩放 */
.img-zoom {
  overflow: hidden;
}

.img-zoom img {
  transition: transform 0.5s ease;
}

.img-zoom:hover img {
  transform: scale(1.08);
}

/* 加载骨架屏 */
.skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--border-color) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

/* 404/500页面动画 */
.error-page {
  animation: fadeIn 1s ease;
}

.error-code {
  font-size: 8rem;
  font-weight: 900;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: float 3s ease-in-out infinite;
  text-align: center;
  line-height: 1;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .error-code {
    font-size: 5rem;
  }
}

/* 主题切换过渡动画 */
.theme-transition {
  transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease;
}

/* 搜索框聚焦发光 */
.search-input:focus {
  animation: pulse 2s infinite;
}

/* 标签云悬停效果 */
.tag-cloud .tag {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tag-cloud .tag:hover {
  transform: translateY(-3px) rotate(2deg);
  box-shadow: 0 4px 12px var(--accent-glow);
}

/* 时间轴线条流动效果 */
.timeline::before {
  background: linear-gradient(to bottom, var(--accent-primary), var(--accent-secondary), var(--accent-primary));
  background-size: 100% 200%;
  animation: gradientFlow 3s ease infinite;
}

@keyframes gradientFlow {
  0% { background-position: 0% 0%; }
  50% { background-position: 0% 100%; }
  100% { background-position: 0% 0%; }
}

/* 移动端菜单动画 */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.nav-menu.active .nav-link {
  animation: slideDown 0.3s ease backwards;
}

.nav-menu.active .nav-link:nth-child(1) { animation-delay: 0.05s; }
.nav-menu.active .nav-link:nth-child(2) { animation-delay: 0.1s; }
.nav-menu.active .nav-link:nth-child(3) { animation-delay: 0.15s; }
.nav-menu.active .nav-link:nth-child(4) { animation-delay: 0.2s; }
.nav-menu.active .nav-link:nth-child(5) { animation-delay: 0.25s; }