/* ===================================================================
   SAFARI SHOP – Unified Visual Experience (Final Optimized Build)
   Version: 1.3.0
   CSS custom properties (--safari-shadow, --color-*) defined in theme-variables.css
   =================================================================== */

/* ===============================================================
   1. FADE-IN & ANIMATION BASE
   =============================================================== */
.fade-in-element {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  will-change: opacity, transform;
}

.fade-in-visible {
  opacity: 1 !important;
  transform: translateY(0);
}

/* Shimmer Keyframes */
@keyframes safari-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Spinner Keyframes */
@keyframes safari-spin {
  to { transform: translateX(-50%) rotate(360deg); }
}

/* ===============================================================
   2. SKELETONS & PLACEHOLDERS
   =============================================================== */
.skeleton-image,
.skeleton-line {
  background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
  background-size: 200% 100%;
  animation: safari-shimmer 1.5s infinite linear;
  will-change: background-position;
}

.skeleton-image {
  width: 100%;
  height: 180px;
  border-radius: 0.5rem;
}

.skeleton-line {
  height: 12px;
  border-radius: 6px;
}

.skeleton-card {
  position: relative;
  overflow: hidden;
  background: var(--color-background);
  border-radius: 1rem;
  contain: layout paint;
}

.skeleton-card.removing {
  opacity: 0;
  transition: opacity 0.4s ease;
}

/* Skeleton overlay fix */
.skeleton-overlay {
  position: absolute;
  inset: 0;
  background: var(--color-background);
  z-index: 20;
  pointer-events: none;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.skeleton-overlay.opacity-0 {
  opacity: 0;
  visibility: hidden;
}

/* ===============================================================
   3. PRODUCT CARDS
   =============================================================== */
.product-card {
  width: 100%;
  max-width: 320px;
  min-height: 440px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--color-background);
  border-radius: 1rem;
  box-shadow: var(--safari-shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  will-change: transform, opacity;
  contain: layout paint;
}

.product-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--safari-shadow-strong);
}

.product-card .product-img {
  width: 100%;
  height: 200px !important;
  object-fit: cover;
  border-top-left-radius: 1rem;
  border-top-right-radius: 1rem;
}

.product-card .p-5 {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* ===============================================================
   4. HORIZONTAL SCROLL CONTAINERS
   =============================================================== */
#safari-shop .products-container {
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  position: relative;
}

#safari-shop .products-container > * {
  scroll-snap-align: center;
}

/* Edge Gradients (for visual polish) */
.category-row .products-container::before,
.category-row .products-container::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 48px;
  z-index: 3;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.category-row .products-container::before {
  left: 0;
  background: linear-gradient(to right, rgba(255, 255, 255, 1) 70%, rgba(255, 255, 255, 0));
}

.category-row .products-container::after {
  right: 0;
  background: linear-gradient(to left, rgba(255, 255, 255, 1) 70%, rgba(255, 255, 255, 0));
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .category-row .products-container::before {
    background: linear-gradient(to right, rgba(17, 24, 39, 1) 70%, rgba(17, 24, 39, 0));
  }
  .category-row .products-container::after {
    background: linear-gradient(to left, rgba(17, 24, 39, 1) 70%, rgba(17, 24, 39, 0));
  }
}

/* ===============================================================
   5. SCROLL BUTTONS
   =============================================================== */
.category-row .relative.group > button {
  z-index: 6;
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--safari-shadow);
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.25s ease;
}

.category-row .relative.group > button:hover {
  background: var(--color-background);
  box-shadow: var(--safari-shadow-strong);
  transform: scale(1.06);
}

.category-row .relative.group > button:active {
  transform: scale(0.96);
}

.category-row .relative.group > button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--color-primary) 35%, transparent);
  outline-offset: 2px;
}

.category-row[data-done="true"] .relative.group > button {
  opacity: 0.25;
  pointer-events: none;
}

/* ===============================================================
   6. SCROLLBAR STYLING
   =============================================================== */
.scrollbar-thin {
  scrollbar-width: thin;
  scrollbar-color: rgba(156, 163, 175, 0.6) rgba(243, 244, 246, 0.4);
}

.scrollbar-thin::-webkit-scrollbar {
  height: 6px;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  background-color: rgba(156, 163, 175, 0.6);
  border-radius: 4px;
}

.scrollbar-thin::-webkit-scrollbar-track {
  background-color: rgba(243, 244, 246, 0.4);
}

/* ===============================================================
   7. LOADER SPINNER
   =============================================================== */
#small-products-loader {
  font-size: 0.95rem;
  color: var(--color-secondary);
  position: relative;
}

#small-products-loader.loading::before {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -8px;
  width: 18px;
  height: 18px;
  border-radius: 9999px;
  border: 2px solid rgba(107, 114, 128, 0.3);
  border-top-color: var(--color-primary);
  animation: safari-spin 0.9s linear infinite;
}

/* ===============================================================
   8. RESPONSIVE GRID SYSTEM
   =============================================================== */

/* Default: 3–4 cards per row */
.products-grid {
  display: grid;
  gap: 2rem;
  justify-content: center;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Desktop (≥1280px): 4 cards */
@media (min-width: 1280px) and (max-width: 1535px) {
  .products-grid {
    grid-template-columns: repeat(4, minmax(280px, 1fr));
    gap: 2rem;
    justify-items: center;
  }
}

/* Large Desktop / 1440px+ */
@media (min-width: 1536px) and (max-width: 1919px) {
  .products-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 2.5rem;
    justify-content: center;
    max-width: 1400px;
    margin: 0 auto;
  }
  .product-card {
    max-width: 320px;
  }
}

/* Ultra-Wide (≥1920px) */
@media (min-width: 1920px) {
  .products-grid {
    grid-template-columns: repeat(4, minmax(320px, 1fr));
    gap: 3rem;
    justify-content: center;
    max-width: 1600px;
    margin-inline: auto;
  }
  .product-card {
    max-width: 340px;
    min-height: 460px;
  }
}

/* Tablet (≥768px & <1280px): 2–3 cards */
@media (min-width: 768px) and (max-width: 1279px) {
  .products-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
  }
}

/* Mobile (<768px): 1–2 cards */
@media (max-width: 767px) {
  .products-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
  }

  .product-card {
    max-width: 100%;
    min-height: 420px;
  }

  .product-card .product-img {
    height: 180px !important;
  }

  #safari-shop .products-container > .product-card {
    min-width: 260px;
  }

  .category-row .products-container::before,
  .category-row .products-container::after {
    width: 24px;
  }

  .category-row .relative.group > button {
    width: 32px;
    height: 32px;
  }
}

/* ===============================================================
   9. ACCESSIBILITY & REDUCED MOTION
   =============================================================== */
@media (prefers-reduced-motion: reduce) {
  .fade-in-element {
    transition: none;
    transform: none;
  }

  .skeleton-image,
  .skeleton-line {
    animation: none;
  }

  #safari-shop .products-container {
    scroll-behavior: auto;
  }

  .category-row .relative.group > button {
    transition: none;
  }
}
