/**
 * Product gallery carousel — aligns with common theme markup (.product-gallery-item).
 */

.vsw-product-gallery-carousel {
  width: 100%;
  position: relative;
  box-sizing: border-box;
}

.vsw-product-gallery-carousel *,
.vsw-product-gallery-carousel *::before,
.vsw-product-gallery-carousel *::after {
  box-sizing: inherit;
}

.vsw-product-gallery-carousel__swiper {
  position: relative;
  overflow: hidden;
}

/* Swiper 尚未 init 时：initialized 类加在 .swiper 上，不是外层根节点 */
.vsw-product-gallery-carousel .swiper:not(.swiper-initialized) .swiper-wrapper {
  display: flex;
}

.vsw-product-gallery-carousel .swiper-slide {
  height: auto;
  max-height: 85vh;
  overflow: hidden;
}

.vsw-product-gallery-carousel .product-gallery-item {
  margin: 0;
}

.vsw-product-gallery-carousel .product-gallery-item__wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: inherit;
}

/**
 * Reserve space before images load (avoid huge intrinsic height / “full screen” flash).
 * Elementor “Slide height” still wins when set (higher-specificity rules on the same node).
 */
.vsw-product-gallery-carousel__slide-inner {
  position: relative;
  width: 100%;
  min-height: clamp(11rem, 32vw, 22rem);
  aspect-ratio: 3 / 2;
  background-color: #eceef1;
  background-image: linear-gradient(
    110deg,
    #eceef1 0%,
    #f4f5f7 45%,
    #e4e6ea 55%,
    #eceef1 100%
  );
  background-size: 200% 100%;
}

.vsw-product-gallery-carousel.vsw-pgc-layout-ready .vsw-product-gallery-carousel__slide-inner.vsw-pgc-loaded {
  animation: none;
  background-image: none;
  background-color: transparent;
}

/* 占位：未解码完成，或已解码但 Swiper 尚未量完宽（避免先透明块再闪图） */
.vsw-product-gallery-carousel__slide-inner:not(.vsw-pgc-loaded),
.vsw-product-gallery-carousel:not(.vsw-pgc-layout-ready) .vsw-product-gallery-carousel__slide-inner.vsw-pgc-loaded {
  animation: vsw-pgc-placeholder-shimmer 1.1s ease-in-out infinite;
}

@keyframes vsw-pgc-placeholder-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.vsw-product-gallery-carousel__slide-inner > img,
.vsw-product-gallery-carousel .product-gallery-item__img.bg-cover {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  z-index: 1;
  display: block;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.vsw-product-gallery-carousel.vsw-pgc-layout-ready .vsw-product-gallery-carousel__slide-inner.vsw-pgc-loaded > img,
.vsw-product-gallery-carousel.vsw-pgc-layout-ready .vsw-product-gallery-carousel__slide-inner.vsw-pgc-loaded .product-gallery-item__img.bg-cover {
  opacity: 1;
}

.vsw-product-gallery-carousel--single .vsw-product-gallery-carousel__nav,
.vsw-product-gallery-carousel--single .vsw-product-gallery-carousel__pagination {
  display: none !important;
}

.vsw-product-gallery-carousel__nav {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px;
}

.vsw-product-gallery-carousel__prev,
.vsw-product-gallery-carousel__next {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.vsw-product-gallery-carousel__prev:hover,
.vsw-product-gallery-carousel__next:hover {
  background: rgba(0, 0, 0, 0.65);
}

.vsw-product-gallery-carousel__prev span,
.vsw-product-gallery-carousel__next span {
  display: block;
  margin-top: -2px;
}

.vsw-product-gallery-carousel__pagination {
  position: relative;
  margin-top: 12px;
  text-align: center;
}

.vsw-product-gallery-carousel__pagination.swiper-pagination-bullets .swiper-pagination-bullet {
  background: currentColor;
  opacity: 0.35;
}

.vsw-product-gallery-carousel__pagination.swiper-pagination-bullets .swiper-pagination-bullet-active {
  opacity: 1;
}

/* Mobile: one full slide per swipe; widths set in JS (px) to avoid 1.25 peek. */
@media (max-width: 767px) {
  .vsw-product-gallery-carousel.vsw-pgc-mobile-full {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    overflow: hidden;
  }

  .vsw-product-gallery-carousel.vsw-pgc-mobile-full .vsw-product-gallery-carousel__swiper {
    width: 100%;
    overflow: hidden !important;
  }

  .vsw-product-gallery-carousel.vsw-pgc-mobile-full .swiper-wrapper {
    box-sizing: border-box;
  }

  .vsw-product-gallery-carousel.vsw-pgc-mobile-full .swiper-slide {
    max-height: none;
    box-sizing: border-box;
    overflow: hidden;
  }

  .vsw-product-gallery-carousel__slide-inner {
    width: 100%;
    min-height: min(56vw, 24rem);
    aspect-ratio: 1 / 1;
    border-radius: 0;
  }

  .vsw-product-gallery-carousel .product-gallery-item__wrap {
    border-radius: 0;
  }

  .vsw-product-gallery-carousel__nav {
    padding: 0 4px;
  }

  .vsw-product-gallery-carousel__prev,
  .vsw-product-gallery-carousel__next {
    width: 40px;
    height: 40px;
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vsw-product-gallery-carousel__slide-inner > img,
  .vsw-product-gallery-carousel .product-gallery-item__img.bg-cover {
    transition: none;
  }

  .vsw-product-gallery-carousel__slide-inner:not(.vsw-pgc-loaded),
  .vsw-product-gallery-carousel:not(.vsw-pgc-layout-ready) .vsw-product-gallery-carousel__slide-inner.vsw-pgc-loaded {
    animation: none;
  }
}
