/**
 * Banner Scroller - Frontend Styles
 */

.banner-scroller {
  overflow: hidden;
  position: relative;
  /* Ensure hover events work properly */
  z-index: 1;
  /* Isolate render tree - prevents other DOM changes from affecting animation */
  contain: layout style paint;
}

.banner-scroller__track {
  display: flex;
  will-change: transform;
  align-items: center;
  height: 100%;
  /* Force GPU compositing from the start */
  transform: translateZ(0);
  backface-visibility: hidden;
}

.banner-scroller--horizontal .banner-scroller__track {
  flex-direction: row;
}

.banner-scroller--vertical .banner-scroller__track {
  flex-direction: column;
  width: 100%;
}

.banner-scroller__item {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
}

/* Default image styles */
.banner-scroller__image {
  max-height: 100%;
  width: auto;
  object-fit: contain;
  display: block;
  max-width: 100px;
}

/* Fit to banner height - horizontal scroll */
.banner-scroller--size-fit.banner-scroller--horizontal .banner-scroller__item {
  height: 100%;
}

.banner-scroller--size-fit.banner-scroller--horizontal .banner-scroller__image {
  height: 100%;
  max-height: 100%;
}

.banner-scroller__image--fit {
  height: 100%;
  width: auto;
}

/* Fit to banner width - vertical scroll */
.banner-scroller--size-fit.banner-scroller--vertical .banner-scroller__item {
  width: 100%;
  height: auto;
}

.banner-scroller--size-fit.banner-scroller--vertical .banner-scroller__image {
  width: 100%;
  height: auto;
  max-width: 100%;
}

/* Fixed size options - images use their natural size from WordPress */
.banner-scroller--size-thumbnail .banner-scroller__image,
.banner-scroller--size-medium .banner-scroller__image,
.banner-scroller--size-large .banner-scroller__image,
.banner-scroller--size-full .banner-scroller__image {
  height: auto;
  max-height: 100%;
}

.banner-scroller--vertical .banner-scroller__image {
  max-width: 100%;
  height: auto;
}

.banner-scroller__caption {
  font-size: 14px;
  margin-top: 8px;
  text-align: center;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Image links */
.banner-scroller__link {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-decoration: none;
  transition: opacity 0.2s ease;
  cursor: pointer;
}

.banner-scroller__link:hover {
  opacity: 0.85;
}

.banner-scroller__link:focus {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Override Gutenberg's flex-wrap: nowrap on Row groups containing this block */
.is-layout-flex:has(> .banner-scroller),
.is-layout-flex:has(.banner-scroller),
.is-nowrap:has(> .banner-scroller),
.is-nowrap:has(.banner-scroller) {
  flex-wrap: wrap !important;
}

.banner-scroller-empty {
  padding: 40px;
  text-align: center;
  background: var(--color-bg-alt);
  color: var(--color-text-light);
  border-radius: 4px;
}

/* Fixed width mode - forces all images to same width */
.banner-scroller--fixed-width .banner-scroller__item {
  height: 100%;
}

.banner-scroller.banner-scroller--fixed-width .banner-scroller__image {
  height: 100%;
  object-fit: cover;
  max-width: none;
}

.banner-scroller--fixed-width .banner-scroller__link {
  height: 100%;
  display: block;
}

/* Responsive width mode - JS sets item widths, images fill 80% */
.banner-scroller--responsive-width .banner-scroller__item {
  height: 100%;
  box-sizing: border-box;
}

.banner-scroller.banner-scroller--responsive-width .banner-scroller__image {
  width: 80%;
  height: auto;
  max-height: 90%;
  max-width: none;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.banner-scroller--responsive-width .banner-scroller__link {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
}

/* Loading skeleton styles */
.banner-scroller--loading {
  position: relative;
}

.banner-scroller--loading::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    rgba(200, 200, 200, 0.2) 0%,
    rgba(200, 200, 200, 0.4) 50%,
    rgba(200, 200, 200, 0.2) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  z-index: 10;
  pointer-events: none;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.banner-scroller--loading .banner-scroller__track {
  opacity: 0;
}

.banner-scroller--loaded .banner-scroller__track {
  opacity: 1;
  transition: opacity 0.3s ease;
}

.banner-scroller--loaded::before {
  display: none;
}

/* Animation classes added by JavaScript */
.banner-scroller--animating .banner-scroller__track {
  animation: banner-scroll linear infinite;
}

.banner-scroller--paused .banner-scroller__track {
  animation-play-state: paused !important;
}

/* CSS-based hover pause as fallback - only when pauseOnHover is enabled (data attribute) */
.banner-scroller[data-pause-hover="true"]:not(.banner-scroller--carousel):hover
  .banner-scroller__track {
  animation-play-state: paused !important;
}

/* ========================================
   CAROUSEL MODE
   ======================================== */

.banner-scroller--carousel {
  position: relative;
  overflow: visible;
  contain: none;
}

.banner-scroller__viewport {
  overflow: hidden;
  width: 100%;
  height: 100%;
  position: relative;
}

/* Track uses CSS transition instead of animation */
.banner-scroller--carousel .banner-scroller__track {
  display: flex;
  height: 100%;
  will-change: transform;
  transition: transform 500ms ease;
  animation: none !important;
}

.banner-scroller--carousel.banner-scroller--vertical .banner-scroller__track {
  flex-direction: column;
}

/* Slides */
.banner-scroller__slide {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  box-sizing: border-box;
}

/* Slide sizing is set by JavaScript based on viewport and items-per-view.
   JS sets width (horizontal) or height (vertical) in px on each slide. */
.banner-scroller--carousel.banner-scroller--vertical .banner-scroller__slide {
  width: 100%;
}

/* Image sizing: 80% of slide width, centered */
.banner-scroller--carousel .banner-scroller__image {
  width: 80%;
  height: auto;
  max-height: 90%;
  max-width: none;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

/* Carousel link styling */
.banner-scroller--carousel .banner-scroller__link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* Navigation Arrows - use high specificity to override theme button styles */
.banner-scroller--carousel > .banner-scroller__arrow {
  position: absolute !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  z-index: 10;
  background: none !important;
  background-color: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  width: 32px !important;
  min-width: 0 !important;
  max-width: 32px !important;
  height: 32px !important;
  min-height: 0 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text);
  padding: 0 !important;
  margin: 0 !important;
  opacity: 0.6;
  transition: opacity 0.2s ease;
  font-size: 0;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  text-decoration: none;
}

.banner-scroller--carousel > .banner-scroller__arrow:hover {
  opacity: 1;
  background: none !important;
  background-color: transparent !important;
}

.banner-scroller--carousel > .banner-scroller__arrow:focus {
  outline: 2px solid #007cba;
  outline-offset: 2px;
}

.banner-scroller__arrow--prev {
  left: 4px !important;
  right: auto !important;
}

.banner-scroller__arrow--next {
  right: 4px !important;
  left: auto !important;
}

/* Vertical carousel arrows */
.banner-scroller--carousel.banner-scroller--vertical .banner-scroller__arrow {
  top: auto;
  left: 50%;
  transform: translateX(-50%) rotate(90deg);
}

.banner-scroller--carousel.banner-scroller--vertical
  .banner-scroller__arrow--prev {
  top: 4px;
  bottom: auto;
}

.banner-scroller--carousel.banner-scroller--vertical
  .banner-scroller__arrow--next {
  bottom: 4px;
  top: auto;
}

/* ── Mobile (≤ 782px) ── */

@media (max-width: 782px) {
  .banner-scroller {
    height: var(--bs-mobile-height) !important;
    width: var(--bs-mobile-width) !important;
    margin-left: var(--bs-mobile-ml, auto) !important;
    margin-right: var(--bs-mobile-mr, auto) !important;
  }
}
