/**
 * NVP Products - Motion Enhancements
 * 克制的产品卡片动效：渐进入场 + 悬停交互
 *
 * 原则：
 * - 尊重 prefers-reduced-motion
 * - 性能优先（GPU 加速）
 * - 引导视觉流，不分散注意力
 */

/* ===== 1. 产品卡片入场动画 ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 默认状态：隐藏（准备动画） */
.product-card {
  opacity: 0;
  animation: fadeInUp 0.5s ease-out forwards;
}

/* 渐进延迟：每个卡片延迟 80ms */
.product-card:nth-child(1) { animation-delay: 0ms; }
.product-card:nth-child(2) { animation-delay: 80ms; }
.product-card:nth-child(3) { animation-delay: 160ms; }
.product-card:nth-child(4) { animation-delay: 240ms; }
.product-card:nth-child(5) { animation-delay: 320ms; }
.product-card:nth-child(6) { animation-delay: 400ms; }
.product-card:nth-child(7) { animation-delay: 480ms; }
.product-card:nth-child(8) { animation-delay: 560ms; }
.product-card:nth-child(9) { animation-delay: 640ms; }
.product-card:nth-child(10) { animation-delay: 720ms; }
.product-card:nth-child(11) { animation-delay: 800ms; }
.product-card:nth-child(12) { animation-delay: 880ms; }

/* ===== 2. 悬停交互 ===== */
.product-card-button {
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
  will-change: transform;
}

.product-card-button:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.product-card-button:active {
  transform: translateY(-2px);
  transition-duration: 0.1s;
}

/* 图片缩放效果 */
.product-media {
  overflow: hidden;
}

.product-media img {
  transition: transform 0.3s ease-out;
  will-change: transform;
}

.product-card-button:hover .product-media img {
  transform: scale(1.05);
}

/* ===== 3. 模态框入场动画 ===== */
@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal[aria-hidden="false"] {
  animation: modalFadeIn 0.2s ease-out;
}

.modal[aria-hidden="false"] .modal-card {
  animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== 4. 筛选器切换动画 ===== */
.category-tabs button {
  transition: background-color 0.2s ease-out, color 0.2s ease-out, transform 0.15s ease-out;
}

.category-tabs button:hover {
  transform: translateY(-2px);
}

.category-tabs button:active {
  transform: translateY(0);
  transition-duration: 0.05s;
}

/* ===== 5. 无障碍：尊重用户偏好 ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .product-card {
    opacity: 1;
    animation: none;
  }

  .product-card-button:hover {
    transform: none;
  }

  .product-media img {
    transform: none;
  }
}

/* ===== 6. 低性能设备优化 ===== */
@media (prefers-reduced-data: reduce) {
  .product-card {
    animation: none;
    opacity: 1;
  }
}

/* ===== 7. 筛选后的重入场动画 ===== */
.product-grid[data-filtering] .product-card {
  animation: fadeInUp 0.4s ease-out forwards;
}
