/* Infinite Logo Carousel - Inspired by Gaia.gs */

.carousel-section {
  padding: var(--spacing-3xl) 0;
  background: var(--color-bg-secondary);
  overflow: hidden;
  position: relative;
}

.carousel-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: var(--spacing-2xl);
  color: var(--color-text-primary);
}

.infinite-carousel {
  position: relative;
  width: 100%;
  overflow: hidden;
  mask: linear-gradient(
    to right,
    transparent 0%,
    black 10%,
    black 90%,
    transparent 100%
  );
  -webkit-mask: linear-gradient(
    to right,
    transparent 0%,
    black 10%,
    black 90%,
    transparent 100%
  );
}

.carousel-track {
  display: flex;
  gap: var(--spacing-2xl);
  animation: carouselMove 30s linear infinite;
  will-change: transform;
  white-space: nowrap;
}

/* Gaia.gs style - Right to left movement */
@keyframes carouselMove {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

.logo-item {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Remove internal padding so logos can fill the tile completely */
  padding: 0;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: all var(--transition-medium);
  height: 80px;
  min-width: 160px;
  position: relative;
  overflow: hidden;
}

.logo-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    45deg,
    transparent 0%,
    rgba(79, 70, 229, 0.05) 50%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity var(--transition-medium);
}

.logo-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-accent);
}

.logo-item:hover::before {
  opacity: 1;
}

.logo-item img {
  /* Allow the logo to completely fill its tile. Remove fixed max sizing so
     logos scale to the frame set on .logo-item. Maintain aspect ratio via
     object-fit. */
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  /* Preserve aspect ratio and fill the tile without cropping */
  object-fit: contain;
  opacity: 0.7;
  transition: all var(--transition-medium);
  filter: grayscale(100%);
}

.logo-item:hover img {
  opacity: 1;
  filter: grayscale(0%);
}

/* Variable widths for different logos (Gaia.gs style) */
.logo-item:nth-child(1) { min-width: 180px; }
.logo-item:nth-child(2) { min-width: 140px; }
.logo-item:nth-child(3) { min-width: 200px; }
.logo-item:nth-child(4) { min-width: 160px; }
.logo-item:nth-child(5) { min-width: 170px; }
.logo-item:nth-child(6) { min-width: 150px; }
.logo-item:nth-child(7) { min-width: 190px; }
.logo-item:nth-child(8) { min-width: 145px; }
.logo-item:nth-child(9) { min-width: 165px; }
.logo-item:nth-child(10) { min-width: 185px; }

/* Pause on hover for accessibility */
.infinite-carousel:hover .carousel-track {
  animation-play-state: paused;
}

/* Different heights for variety (subtle) */
.logo-item:nth-child(2n) {
  height: 85px;
}

.logo-item:nth-child(3n) {
  height: 75px;
}

.logo-item:nth-child(5n) {
  height: 90px;
}

/* Enhanced hover effects for individual logos */
.logo-item:nth-child(odd):hover {
  background: linear-gradient(135deg, var(--color-bg-primary) 0%, var(--color-bg-tertiary) 100%);
}

.logo-item:nth-child(even):hover {
  background: linear-gradient(45deg, var(--color-bg-tertiary) 0%, var(--color-bg-primary) 100%);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  /*
   * Mobile carousel tuning
   *
   * A recent regression sped up the animation and enlarged the logo tiles on
   * handheld devices. Here we slow the animation back down to a more
   * comfortable pace and reduce the tile widths so multiple logos can
   * appear onscreen at once. All logos are given the same dimensions to
   * maintain a clean rhythm.
   */
  .carousel-track {
    animation-duration: 25s;
    gap: var(--spacing-lg);
  }

  .logo-item {
    min-width: 110px;
    height: 60px;
    /* Remove padding on mobile so logos fill the entire tile */
    padding: 0;
  }

  .logo-item img {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
  }

  /* Uniform sizing on mobile */
  .logo-item:nth-child(n) {
    min-width: 110px;
    height: 60px;
  }
}

@media (max-width: 480px) {
  .carousel-section {
    padding: var(--spacing-2xl) 0;
  }

  /*
   * Very small screens (≤480px)
   *
   * Further slow the animation and reduce tile widths so the carousel
   * feels effortless on mobile portrait devices. The reduced gap helps
   * keep the track continuous without large empty spaces.
   */
  .carousel-track {
    animation-duration: 20s;
    gap: var(--spacing-md);
  }

  .logo-item {
    min-width: 90px;
    height: 50px;
    /* Remove padding on smaller devices to allow logos to fill */
    padding: 0;
  }

  .logo-item img {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
  }

  .logo-item:nth-child(n) {
    min-width: 90px;
    height: 50px;
  }
}

/* Accessibility - Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .carousel-track {
    animation: none;
  }

  .infinite-carousel {
    overflow-x: auto;
    mask: none;
    -webkit-mask: none;
  }

  .carousel-track {
    justify-content: flex-start;
    padding: 0 var(--spacing-lg);
  }
}

/* Enhanced focus styles for keyboard navigation */
.logo-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  transform: translateY(-4px);
}

/* Light theme adjustments */
[data-theme="light"] .logo-item {
  background: var(--color-bg-primary);
  border-color: var(--color-border);
}

[data-theme="light"] .logo-item:hover {
  background: var(--color-bg-secondary);
}

[data-theme="light"] .logo-item img {
  opacity: 0.8;
}

[data-theme="light"] .logo-item:hover img {
  opacity: 1;
}