/* Mobile Tile Carousel - Stock ticker style with manual scroll */

.tiles-carousel {
  display: none; /* Hidden by default, shown on mobile */
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch; /* Smooth momentum scrolling on iOS */
  scrollbar-width: none; /* Hide scrollbar Firefox */
  position: relative;
  padding: 1rem 0;
  margin: auto 0;
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 1.2s ease 0.75s, transform 2.5s ease 0.75s;
}

.tiles-carousel.carousel--show {
  opacity: 1;
  transform: translateX(0);
}

.tiles-carousel::-webkit-scrollbar {
  display: none; /* Hide scrollbar Chrome/Safari */
}

.tiles-carousel-track {
  display: flex;
  gap: 0.75rem;
  padding: 0 0rem;
  animation: carousel-scroll 15s linear infinite 3s;
  will-change: transform;
  backface-visibility: hidden;
}

/* Pause animation when user is interacting */
.tiles-carousel.paused .tiles-carousel-track {
  animation-play-state: paused;
}

/* Auto-scroll animation - uses CSS custom property set by JS */
@keyframes carousel-scroll {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(var(--carousel-distance, -50%), 0, 0); /* 3D transform for better GPU handling */
  }
}

/* Carousel Tile Item */
.carousel-tile {
  flex-shrink: 0;
  width: 90px;
  height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface-elevated, var(--surface));
  border-radius: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.carousel-tile:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.15);
}

.carousel-tile img,
.carousel-tile svg {
  width: 47%;
  height: 47%;
  object-fit: contain;
  flex-shrink: 0;
  margin-bottom: auto;
  margin-top: 0.75rem;
  color: var(--primary);
}

/* Carousel Tile Label */
.carousel-tile__label {
  position: absolute;
  bottom: 0;
  top: 60%;
  left: 0;
  right: 0;
  background: transparent;
  color: var(--primary);
  font-size: 10px;
  line-height: 1.1;
  padding: 0 0.25rem;
  text-align: center;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  word-wrap: break-word;
}

/* Responsive behaviour */
@media (max-width: 767px) {
  #tilesCarousel {
    display: block;
    /* Counteract stage padding to extend to viewport edges */
    margin-left: calc(-1 * clamp(16px, 6vh, 32px));
    margin-right: calc(-1 * clamp(16px, 6vh, 32px));
    width: calc(100% + 2 * clamp(16px, 6vh, 32px));
  }

  #tilesOrbit { display: none; }
  #tilesCarouselTablet { display: none; }
}

@media (min-width: 769px) and (max-width: 1200px) {
  #tilesCarousel { display: none; }
  #tilesCarouselTablet {
    display: block;
    /* Counteract stage padding to extend to viewport edges */
    margin-left: calc(-1 * clamp(16px, 3vh, 24px));
    margin-right: calc(-1 * clamp(16px, 3vh, 24px));
    width: calc(100% + 2 * clamp(16px, 3vh, 24px));
  }

  #tilesCarouselTablet .tiles-carousel-track {
    gap: 1.25rem;
    animation-duration: 20s;
  }

  #tilesCarouselTablet .carousel-tile {
    width: 110px;
    height: 110px;
    border-radius: 16px;
  }

  #tilesCarouselTablet .carousel-tile__label {
    font-size: 11px;
  }
}

/* Mobile landscape - hide carousel tile icons to save vertical space */
@media (max-width: 767px) and (orientation: landscape) {
  .carousel-tile img,
  .carousel-tile svg {
    display: none;
  }
  
  .carousel-tile {
    height: 60px;
    padding: 8px 12px;
  }
  
  .carousel-tile__label {
    position: static;
    margin: 0;
  }
}
