/* ============================================================
   51知识 — 动效与渲染性能
   ============================================================ */

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

/* 500 条卡片也能流畅滚动：跳过视口外渲染 */
.resource-card {
  content-visibility: auto;
  contain-intrinsic-size: 0 120px;
}

/* backwards 而非 both：动画结束后不锁定 transform，hover 上浮仍生效 */
.card-grid .resource-card {
  animation: arrive 380ms var(--ease) backwards;
}

.hero > * {
  animation: arrive 420ms var(--ease) backwards;
}

.card-grid .resource-card:nth-child(2) { animation-delay: 40ms; }
.card-grid .resource-card:nth-child(3) { animation-delay: 80ms; }
.card-grid .resource-card:nth-child(4) { animation-delay: 120ms; }
.card-grid .resource-card:nth-child(5) { animation-delay: 160ms; }
.card-grid .resource-card:nth-child(6) { animation-delay: 200ms; }
.card-grid .resource-card:nth-child(7) { animation-delay: 240ms; }
.card-grid .resource-card:nth-child(8) { animation-delay: 280ms; }

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .resource-card:hover,
  .theme-btn:hover,
  .theme-btn:active,
  .nav-item:hover,
  .fav-btn:hover,
  .filterbar button:hover,
  .filterbar .filter-btn:hover,
  .filterbar .filter-chip:hover {
    transform: none;
  }
}
