/* ==========================================================================
   Animations
   Keyframes only — components apply these via class or inline animation
   property. Kept centralized so timing/easing stays consistent site-wide.
   ========================================================================== */

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fade-in-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@keyframes scale-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

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

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

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(16px); }
}

.animate-fade-in    { animation: fade-in var(--duration-slow) var(--ease-out) both; }
.animate-fade-in-up { animation: fade-in-up var(--duration-slow) var(--ease-out) both; }
.animate-scale-in   { animation: scale-in var(--duration-base) var(--ease-out) both; }

/* --------------------------------------------------------------------- */
/* Scroll-reveal — applied to "feature" elements (trust strip, category   */
/* cards, supplier cards). JS toggles .is-visible via IntersectionObserver*/
/* once the element enters the viewport; --reveal-delay staggers a row.   */
/* --------------------------------------------------------------------- */
@keyframes reveal-up {
  from { opacity: 0; transform: translateY(22px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.reveal {
  opacity: 0;
  transform: translateY(22px) scale(0.98);
}

.reveal.is-visible {
  animation: reveal-up 0.65s var(--ease-out) both;
  animation-delay: var(--reveal-delay, 0s);
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; animation: none; }
}

/* --------------------------------------------------------------------- */
/* Infinite product loop (marquee)                                       */
/* --------------------------------------------------------------------- */
@keyframes marquee-loop {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .product-marquee__track { animation: none !important; }
}

/* Skeleton loading placeholder — used by loader.js / product cards while
   fetch() is in flight */
.skeleton {
  background: linear-gradient(90deg, var(--color-border) 25%, #f1f5f9 37%, var(--color-border) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------- */
/* Product card micro-interactions                                       */
/* --------------------------------------------------------------------- */
@keyframes wishlist-pop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.35); }
  60%  { transform: scale(0.92); }
  100% { transform: scale(1); }
}

.product-card__wishlist.is-popping {
  animation: wishlist-pop 0.45s var(--ease-out);
}

@keyframes added-flash {
  0%   { box-shadow: 0 0 0 0 rgba(var(--color-secondary-rgb, 217, 80, 0), 0.35); }
  100% { box-shadow: 0 0 0 14px rgba(var(--color-secondary-rgb, 217, 80, 0), 0); }
}

.product-card.is-added-flash {
  animation: added-flash 0.7s var(--ease-out);
}

.product-card__add.is-added {
  background: var(--color-secondary, #FF6A00) !important;
  transition: background 0.2s ease;
}

/* Cart / wishlist badge bump — toggled briefly by navbar.js whenever the
   count changes, so the header notices the update instead of it silently
   changing in place. */
@keyframes badge-bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.45); }
  70%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.is-bumped {
  animation: badge-bump 0.4s var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
  .product-card__wishlist.is-popping,
  .product-card.is-added-flash,
  .is-bumped { animation: none; }
}

/* --------------------------------------------------------------------- */
/* Back to top                                                           */
/* --------------------------------------------------------------------- */
.back-to-top {
  position: fixed;
  right: var(--space-5, 20px);
  bottom: var(--space-5, 20px);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  z-index: var(--z-sticky, 40);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.9);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0.25s, background 0.2s ease;
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s ease;
}

.back-to-top:hover {
  background: var(--color-secondary, #D95000);
}

.back-to-top svg {
  width: 20px;
  height: 20px;
}

@media (prefers-reduced-motion: reduce) {
  .back-to-top { transition: opacity 0.15s linear; transform: none; }
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(var(--color-primary-rgb), 0.15);
  border-top-color: var(--color-secondary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
