/**
 * Products Section - Optimized CSS
 * Based on Partners section but without blur effects
 */

/* ===== PRODUCTS SECTION BASE ===== */
.products-section {
  --products-gap: 24px;
  --products-card-width: 320px;
  --products-card-padding: 0;
  --products-image-size: 285px;
  
  /* Responsive variables */
  --products-mobile-gap: 12px;
  --products-mobile-card-width: 240px;
  --products-mobile-image-size: 205px;
  
  --products-tablet-gap: 18px;
  --products-tablet-card-width: 300px;
  --products-tablet-image-size: 245px;
  
  --products-desktop-gap: 24px;
  --products-desktop-card-width: 320px;
  --products-desktop-image-size: 285px;
}

/* ===== PRODUCTS CONTAINER ===== */
.products-container {
  position: relative;
  margin-top: 32px;
  overflow: hidden;
  width: 100%;
  contain: layout style paint;
  isolation: isolate;
}

/* ===== PRODUCTS CAROUSEL ===== */
.products-carousel {
  margin-top: 32px;
  padding: 16px 0;
  overflow: hidden;
  width: 100%;
  position: relative;
  contain: layout style paint;
  isolation: isolate;
}

.products-track {
  display: flex;
  animation: infiniteScroll var(--products-animation-duration, 30s) linear infinite;
  width: max-content;
  gap: var(--products-gap);
  will-change: transform;
}

.products-carousel:hover .products-track {
  animation-play-state: paused;
}

/* ===== PRODUCT CARDS ===== */
.product-card {
  flex: 0 0 auto;
  width: var(--products-card-width);
  min-width: var(--products-card-width);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  padding: 0;
  text-align: center;
  box-shadow: 0 4px 12px rgba(4, 53, 79, 0.1);
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.2);
  margin: 0 12px;
  will-change: transform;
  backface-visibility: hidden;
  transform: translateZ(0);
  overflow: hidden;
  position: relative;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(4, 53, 79, 0.15);
  border: 2px solid var(--brand-secondary);
  outline: none;
}

.product-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  height: 100%;
}

.product-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
}

.product-image-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 4px;
  transition: transform 0.3s ease;
}

.product-card:hover .product-image-img {
  transform: scale(1.02);
}

/* Specific zoom for product_4 */
.product-card[data-product-id="product_4"] .product-image-img {
  transform: scale(1.2); /* 20% zoom */
}

.product-card[data-product-id="product_4"]:hover .product-image-img {
  transform: scale(1.22); /* 22% zoom on hover */
}

/* Category-based styling */
.product-card[data-category="machinery"] {
  border-left: 3px solid var(--brand-primary);
}

.product-card[data-category="equipment"] {
  border-left: 3px solid var(--brand-secondary);
}

.product-card[data-category="tools"] {
  border-left: 3px solid var(--gray-600);
}

/* ===== ANIMATION ===== */
@keyframes infiniteScroll {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* ===== LANGUAGE SWITCHING ===== */
.products-carousel[data-lang="vi"] {
  display: block;
}

.products-carousel[data-lang="en"] {
  display: none;
}

.products-carousel[data-lang="vi"].hidden {
  display: none !important;
}

.products-carousel[data-lang="en"].visible {
  display: block !important;
}

/* ===== RESPONSIVE DESIGN ===== */

/* Mobile First - Small screens (320px - 479px) */
@media (max-width: 479px) {
  .products-section {
    --products-gap: var(--products-mobile-gap);
    --products-card-width: var(--products-mobile-card-width);
    --products-image-size: var(--products-mobile-image-size);
    --products-animation-duration: 25s;
  }
  
  .products-carousel {
    margin-top: 24px;
    padding: 12px 0;
    touch-action: pan-x;
  }
  
  .product-card {
    padding: 0;
  }
  
  .product-image {
    padding: 0;
  }
}

/* Mobile - Medium screens (480px - 767px) */
@media (min-width: 480px) and (max-width: 767px) {
  .products-section {
    --products-gap: 14px;
    --products-card-width: 260px;
    --products-image-size: 225px;
    --products-animation-duration: 28s;
  }
  
  .products-carousel {
    margin-top: 28px;
    padding: 14px 0;
  }
  
  .product-card {
    padding: 0;
  }
  
  .product-image {
    padding: 0;
  }
}

/* Tablet (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .products-section {
    --products-gap: var(--products-tablet-gap);
    --products-card-width: var(--products-tablet-card-width);
    --products-image-size: var(--products-tablet-image-size);
    --products-animation-duration: 30s;
  }
  
  .products-carousel {
    margin-top: 30px;
    padding: 15px 0;
  }
  
  .product-card {
    padding: 0;
  }
  
  .product-image {
    padding: 0;
  }
}

/* Desktop (1024px - 1439px) */
@media (min-width: 1024px) and (max-width: 1439px) {
  .products-section {
    --products-gap: var(--products-desktop-gap);
    --products-card-width: var(--products-desktop-card-width);
    --products-image-size: var(--products-desktop-image-size);
    --products-animation-duration: 35s;
  }
  
  .products-carousel {
    margin-top: 32px;
    padding: 16px 0;
  }
  
  .product-card {
    padding: 0;
  }
  
  .product-image {
    padding: 0;
  }
}

/* Large Desktop (1440px+) */
@media (min-width: 1440px) {
  .products-section {
    --products-gap: 26px;
    --products-card-width: 340px;
    --products-image-size: 305px;
    --products-animation-duration: 40s;
  }
  
  .products-carousel {
    margin-top: 36px;
    padding: 18px 0;
  }
  
  .product-card {
    padding: 0;
  }
  
  .product-image {
    padding: 0;
  }
}

/* Ultra-wide (1920px+) */
@media (min-width: 1920px) {
  .products-section {
    --products-gap: 28px;
    --products-card-width: 360px;
    --products-image-size: 325px;
    --products-animation-duration: 40s;
  }
  
  .products-carousel {
    margin-top: 40px;
    padding: 20px 0;
  }
  
  .product-card {
    padding: 0;
  }
  
  .product-image {
    padding: 0;
  }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  .products-track {
    animation: none;
  }
  
  .products-carousel:hover .products-track {
    animation-play-state: running;
  }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
.products-track {
  backface-visibility: hidden;
  perspective: 1000px;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.product-card {
  backface-visibility: hidden;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

/* ===== UTILITY CLASSES ===== */
.products-loading {
  opacity: 0.6;
  pointer-events: none;
}

.products-error {
  background: rgba(255, 0, 0, 0.1);
  border: 1px solid rgba(255, 0, 0, 0.3);
}

.product-card-hidden {
  display: none;
}

.product-card-highlight {
  border: 2px solid var(--brand-primary);
  box-shadow: 0 8px 32px rgba(4, 53, 79, 0.2);
}

/* ===== IMAGE OPTIMIZATION ===== */
.product-image-img {
  loading: eager;
  decoding: async;
  fetch-priority: high;
}

/* ===== LOADING STATES ===== */
.product-image-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 4px;
  z-index: 1;
}

.product-image-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid var(--brand-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.product-image {
  position: relative;
  overflow: hidden;
}

.product-image-img {
  position: relative;
  z-index: 2;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.product-image-img.loaded {
  opacity: 1;
}

.product-image-img.loading {
  opacity: 0;
}

/* ===== NO BLUR EFFECTS ===== */
/* Intentionally no blur effects as requested */

/* ===== RESPONSIVE ZOOM OPTIMIZATIONS ===== */
/* Responsive zoom adjustments for product_4 */

/* Small screens (320px - 479px) */
@media (max-width: 479px) {
  .product-card[data-product-id="product_4"] .product-image-img {
    transform: scale(1.05); /* Reduced zoom for very small screens */
  }
  
  .product-card[data-product-id="product_4"]:hover .product-image-img {
    transform: scale(1.07); /* Reduced hover zoom for very small screens */
  }
}

/* Medium screens (480px - 767px) */
@media (min-width: 480px) and (max-width: 767px) {
  .product-card[data-product-id="product_4"] .product-image-img {
    transform: scale(1.1); /* Slightly reduced zoom for medium screens */
  }
  
  .product-card[data-product-id="product_4"]:hover .product-image-img {
    transform: scale(1.12); /* Slightly reduced hover zoom for medium screens */
  }
}

/* Tablet screens (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .product-card[data-product-id="product_4"] .product-image-img {
    transform: scale(1.15); /* Moderate zoom for tablets */
  }
  
  .product-card[data-product-id="product_4"]:hover .product-image-img {
    transform: scale(1.17); /* Moderate hover zoom for tablets */
  }
}

/* Desktop screens (1024px+) */
@media (min-width: 1024px) {
  .product-card[data-product-id="product_4"] .product-image-img {
    transform: scale(1.2); /* Full zoom for desktop */
  }
  
  .product-card[data-product-id="product_4"]:hover .product-image-img {
    transform: scale(1.22); /* Full hover zoom for desktop */
  }
}
