/* ============================================================
   فاز ۵ / بخش ۲ — انیمیشن/ترنزیشن‌های ظریف
   مثل responsive.css، مشترک بین هر سه قالب است چون فقط رفتار اضافه
   می‌کند نه رنگ؛ رنگ‌ها همچنان از متغیرهای همان theme-<name>.css
   می‌آیند. همه‌چیز پشت prefers-reduced-motion غیرفعال می‌شود تا برای
   کاربرانی که حرکت زیاد را در سیستم‌عامل خاموش کرده‌اند، سایت آرام بماند.
   ============================================================ */

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

@keyframes popIn {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

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

@keyframes imgFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* --- ورودِ نرمِ محتوای اصلی هر صفحه (فقط یک‌بار، هنگام لود) --- */
main.container { animation: fadeInUp 0.35s ease both; }

/* --- کارت‌های محصول: ظاهر شدن آبشاری در گرید + هاور قوی‌تر --- */
.product-card {
  animation: fadeInUp 0.35s ease both;
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  transition: border-color 0.15s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.product-card:hover { box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08); }
.product-card .thumb { position: relative; }
.product-card .thumb img {
  transition: transform 0.35s ease;
  animation: imgFadeIn 0.3s ease both;
}
.product-card:hover .thumb img { transform: scale(1.06); }

/* تأخیر آبشاری برای ۸ کارت اول (بیشتر از این، تفاوت محسوس نیست و فقط
   selector اضافه می‌کند) */
.product-grid .product-card:nth-child(1) { animation-delay: 0.02s; }
.product-grid .product-card:nth-child(2) { animation-delay: 0.05s; }
.product-grid .product-card:nth-child(3) { animation-delay: 0.08s; }
.product-grid .product-card:nth-child(4) { animation-delay: 0.11s; }
.product-grid .product-card:nth-child(5) { animation-delay: 0.14s; }
.product-grid .product-card:nth-child(6) { animation-delay: 0.17s; }
.product-grid .product-card:nth-child(7) { animation-delay: 0.20s; }
.product-grid .product-card:nth-child(8) { animation-delay: 0.23s; }

/* --- بازخورد لمسیِ دکمه‌ها و پیل‌های تعاملی --- */
.btn,
.variant-option,
.category-nav a,
.qty-stepper button,
.qty-stepper-sm button,
.cart-item-remove {
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn:active,
.variant-option:active,
.qty-stepper button:active,
.qty-stepper-sm button:active { transform: scale(0.96); }

.btn-primary:hover { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12); }

.variant-option.selected { animation: popIn 0.22s ease; }

/* --- دکمه‌ی «افزودن به سبد»: هنگام کلیک (کلاس .just-added از product.js اضافه می‌شود) --- */
[data-role="add-to-cart"].just-added { animation: popIn 0.28s ease; }

/* --- آیتم سبد خرید: ورود نرم + یک کلاس برای حذفِ نرم قبل از پاک شدن از DOM
   (کلاس .removing از cart.js اضافه می‌شود) --- */
.cart-item {
  animation: fadeInUp 0.25s ease both;
  transition: opacity 0.18s ease, transform 0.18s ease, max-height 0.18s ease, margin 0.18s ease, padding 0.18s ease;
}
.cart-item.removing {
  opacity: 0;
  transform: translateX(12px);
}

/* --- حالت‌های خالی: آیکن با یک نوسان خیلی ملایم، نه حواس‌پرت‌کن --- */
.empty-state .big { display: inline-block; animation: floaty 3s ease-in-out infinite; }

/* --- سایه‌ی ظریف نوار دسته‌بندی هنگام اسکرول (کلاس .is-scrolled از site.js) --- */
.category-nav { transition: box-shadow 0.2s ease; }
.category-nav.is-scrolled { box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06); }

/* --- Toast: کمی فنری‌تر از یک ease‌ی خطی ساده --- */
.toast { transition: opacity 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* --- نتیجه‌ی پیگیری سفارش / پیام موفقیت تسویه‌حساب --- */
.track-result,
.checkout-success .empty-state,
.payment-box { animation: fadeInUp 0.3s ease both; }

/* --- افزایش سرعت رندر لمسی: روی موبایل هاورهای سنگین (translateY/scale روی
   کارت) با tap اجرا نشوند و فقط active باشند --- */
@media (hover: hover) and (pointer: fine) {
  .product-card:hover { transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
