/* Brand Logo Carousel - CSS-only infinite scroll */

.brand-carousel {
  overflow: hidden;
  width: 100%;
  padding: 2rem 0 0 0; /* Top padding only, no bottom padding */
  position: relative;
  background-color: transparent;
}

.brand-carousel-container {
  width: 100%;
  overflow: hidden;
  position: relative;
  max-width: 100%;
  /* Container already has padding, so carousel uses full available width */
}

.brand-carousel-track {
  display: flex;
  gap: 1rem; /* Reduced from 2rem for tighter spacing */
  animation: scroll-logos 40s linear infinite;
  width: max-content;
  will-change: transform;
}

/* Pause animation on hover */
.brand-carousel-container:hover .brand-carousel-track {
  animation-play-state: paused;
}

.brand-carousel-item {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto; /* Let it size to content instead of fixed width */
  min-width: 120px; /* Minimum size to prevent too small */
  max-width: 280px; /* Maximum size to prevent too large */
  height: 100px;
  padding: 1rem;
  background-color: transparent; /* Changed from white to transparent */
  border-radius: 8px;
  box-shadow: none; /* Removed box-shadow */
  transition: transform 0.3s ease;
  /* Force container to constrain image size */
  overflow: hidden;
}

.brand-carousel-item:hover {
  transform: translateY(-4px);
}

.brand-carousel-item img {
  max-width: 100%;
  height: 60px;
  width: auto;
  object-fit: contain;
  object-position: center;
  filter: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 1;
  min-height: 60px;
  max-height: 60px;
  display: block;
  box-sizing: border-box;
}

/* Ensure SVGs respect the height constraint */
.brand-carousel-item img[src$=".svg"],
.brand-carousel-item img[src*=".svg"] {
  height: 60px;
  width: auto;
  min-height: 60px;
  max-height: 60px;
}

/* Ensure Caterpillar logo renders at correct height */
.brand-carousel-item img[src*="Caterpillar_logo"],
.brand-carousel-item img[src*="Caterpillar_logo.svg"] {
  height: 60px;
  width: auto;
  min-height: 60px;
  max-height: 60px;
}

/* Ensure Bell logo renders at correct height */
.brand-carousel-item img[src*="Bell_mining"],
.brand-carousel-item img[src*="Bell_mining_construction.svg"] {
  height: 60px;
  width: auto;
  min-height: 60px;
  max-height: 60px;
}

.brand-carousel-item:hover img {
  filter: none;
  opacity: 0.9;
}

/* Hover effect for logos that already have transform scale - combine transforms */
.brand-carousel-item:hover img[src*="caterpillar"],
.brand-carousel-item:hover img[src*="Caterpillar"],
.brand-carousel-item:hover img[src*="Bell"],
.brand-carousel-item:hover img[src*="bell"] {
  opacity: 0.9;
  /* Keep existing scale, just change opacity */
}

.brand-carousel-item:hover
  img:not([src*="caterpillar"]):not([src*="Caterpillar"]):not(
    [src*="Bell"]
  ):not([src*="bell"]) {
  transform: scale(1.05);
  transform-origin: center center;
}

@keyframes scroll-logos {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* Mobile: 1 logo visible at a time (< 768px) */
@media screen and (max-width: 767px) {
  .brand-carousel-item {
    width: auto; /* Let it size to content */
    max-width: 90%; /* Let it use most of the viewport but not 100% */
    min-width: 200px;
    height: 80px;
    padding: 0.75rem;
  }

  .brand-carousel-item img {
    height: 50px;
    min-height: 50px;
    max-height: 50px;
  }

  .brand-carousel-item img[src$=".svg"],
  .brand-carousel-item img[src*=".svg"] {
    height: 50px;
    max-height: 50px;
  }

  .brand-carousel-item img[src*="Caterpillar_logo"] {
    height: 50px;
    max-height: 50px;
  }

  .brand-carousel-item img[src*="Bell_mining"] {
    height: 50px;
    max-height: 50px;
  }

  .brand-carousel-track {
    gap: 0.75rem; /* Reduced from 1.5rem for tighter spacing */
    animation-duration: 35s; /* Slightly faster on mobile */
  }

  .brand-carousel {
    padding: 1.5rem 0 0 0; /* Top padding only, no bottom padding */
  }
}

/* Tablet & Smaller Desktop: 2 logos visible (768px - 1023px) */
@media screen and (min-width: 768px) and (max-width: 1023px) {
  .brand-carousel-item {
    width: auto; /* Let it size to content */
    max-width: calc(50% - 0.5rem); /* Half width minus half gap */
    min-width: 180px;
    height: 90px;
    padding: 0.875rem;
  }

  .brand-carousel-item img {
    height: 55px;
    min-height: 55px;
    max-height: 55px;
  }

  .brand-carousel-item img[src$=".svg"],
  .brand-carousel-item img[src*=".svg"] {
    height: 55px;
    max-height: 55px;
  }

  .brand-carousel-item img[src*="Caterpillar_logo"] {
    height: 55px;
    max-height: 55px;
  }

  .brand-carousel-item img[src*="Bell_mining"] {
    height: 55px;
    max-height: 55px;
  }

  .brand-carousel-track {
    gap: 1rem; /* Reduced from 2rem for tighter spacing */
    animation-duration: 40s;
  }

  .brand-carousel {
    padding: 1.75rem 0 0 0; /* Top padding only, no bottom padding */
  }
}

/* Desktop: 4 logos visible (>= 1024px) */
@media screen and (min-width: 1024px) {
  .brand-carousel-item {
    width: auto; /* Let it size to content */
    max-width: calc(25% - 0.75rem); /* Quarter width minus portion of gap */
    min-width: 150px;
    height: 100px;
    padding: 1rem;
  }

  .brand-carousel-item img {
    height: 60px;
    min-height: 60px;
    max-height: 60px;
  }

  .brand-carousel-item img[src$=".svg"],
  .brand-carousel-item img[src*=".svg"] {
    height: 60px;
    max-height: 60px;
  }

  .brand-carousel-item img[src*="Caterpillar_logo"] {
    height: 60px;
    max-height: 60px;
  }

  .brand-carousel-item img[src*="Bell_mining"] {
    height: 60px;
    max-height: 60px;
  }

  .brand-carousel-track {
    gap: 1rem; /* Reduced from 2rem for tighter spacing */
    animation-duration: 40s;
  }

  .brand-carousel {
    padding: 2rem 0 0 0; /* Top padding only, no bottom padding */
  }
}

/* Large Desktop: 5 logos visible (>= 1400px) - optional enhancement */
@media screen and (min-width: 1400px) {
  .brand-carousel-item {
    width: auto; /* Let it size to content */
    max-width: calc(20% - 0.8rem); /* Fifth width minus portion of gap */
    min-width: 140px;
  }

  .brand-carousel-track {
    gap: 1rem; /* Reduced from 2rem for tighter spacing */
    animation-duration: 45s; /* Slightly slower on very large screens */
  }
}

/* Accessibility: Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .brand-carousel-track {
    animation: none;
    transform: translateX(0);
  }

  .brand-carousel-item {
    transition: none;
  }
}
