/**
 * Shoptrangsuc - Flatsome Stacked mixed-media product video.
 * Loaded only on supported Stacked products with a valid Flatsome Product Video.
 */

body.single-product.st-has-product-video .st-product-video-slide {
  position: relative;
  overflow: hidden;
}

body.single-product.st-has-product-video .st-product-video-trigger,
body.single-product.st-has-product-video .st-product-video-poster {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--st-bg-soft, #F8F8F8);
}

body.single-product.st-has-product-video .st-product-video-poster {
  min-height: 220px;
  aspect-ratio: 1 / 1;
}

body.single-product.st-has-product-video .st-product-video-slide__image {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: cover;
  opacity: .94;
}

body.single-product.st-has-product-video .st-product-video-inline-media {
  position: absolute;
  z-index: 2;
  inset: 0;
  overflow: hidden;
  background: #F8F8F8;
  opacity: 0;
  pointer-events: none;
}

body.single-product.st-has-product-video .st-product-video-slide.is-player-ready .st-product-video-inline-media {
  opacity: 1;
  pointer-events: auto;
}

body.single-product.st-has-product-video .st-product-video-inline-player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/*
 * Inline gallery uses a square media tile. Give YouTube an iframe viewport
 * that matches the source aspect ratio, then crop it inside the 1:1 tile.
 * This prevents YouTube from drawing black pillar/letterbox bars itself.
 */
body.single-product.st-has-product-video .st-product-video-inline-media iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--st-product-video-cover-width, 100%) !important;
  height: var(--st-product-video-cover-height, 100%) !important;
  max-width: none !important;
  max-height: none !important;
  transform: translate(-50%, -50%);
  border: 0;
}

/* Product Image Lightbox preserves the source aspect ratio; no crop here. */
.st-product-video-pswp-player,
.st-product-video-pswp-frame iframe {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  border: 0;
}

/*
 * YouTube is cross-origin. Direct iframe interaction is never exposed:
 * the iframe ignores pointer input and a Shoptrangsuc-owned shield covers it.
 */
.st-product-video-iframe,
body.single-product.st-has-product-video .st-product-video-inline-media iframe,
.st-product-video-pswp-frame iframe {
  pointer-events: none !important;
}

.st-product-video-interaction-shield {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: block;
  background: transparent;
  pointer-events: auto;
  touch-action: pan-y pinch-zoom;
}

/*
 * Desktop: clicking anywhere except Play/Pause opens the mixed Product Image
 * Lightbox. Touch layouts deliberately disable this surface so normal Flickity
 * swipe remains the primary interaction, matching the Swarovski-style UX.
 */
body.single-product.st-has-product-video .st-product-video-open-surface {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  cursor: zoom-in;
  outline: 0;
  -webkit-tap-highlight-color: transparent;
}

body.single-product.st-has-product-video .st-product-video-open-surface:focus-visible {
  outline: 2px solid var(--st-secondary, #806744);
  outline-offset: -3px;
}

/* First-party Play/Pause control used inline and in PhotoSwipe. */
.st-product-video-toggle {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  z-index: 6;
  right: 14px;
  bottom: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  min-height: 46px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .68) !important;
  border-radius: 999px;
  background: rgba(28, 28, 26, .48) !important;
  box-shadow: 0 5px 18px rgba(28, 28, 26, .16) !important;
  color: #FFFFFF !important;
  line-height: 1 !important;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.st-product-video-toggle:hover,
.st-product-video-toggle:focus-visible {
  background: rgba(28, 28, 26, .64) !important;
  border-color: rgba(255, 255, 255, .88) !important;
  color: #FFFFFF !important;
}

.st-product-video-toggle:focus-visible {
  outline: 2px solid #FFFFFF;
  outline-offset: 2px;
}

.st-product-video-toggle__icon {
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  pointer-events: none;
}

.st-product-video-toggle__icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.st-product-video-toggle[data-state="play"] .st-product-video-toggle__icon--play,
.st-product-video-toggle[data-state="pause"] .st-product-video-toggle__icon--pause {
  display: inline-flex;
}

.st-product-video-toggle[data-state="play"] .st-product-video-toggle__icon--play svg {
  transform: translateX(1px);
}

/*
 * Keep Flatsome's native thumbnail geometry. Only position the play marker;
 * width, spacing, opacity, border and selected state remain theme-owned.
 */
body.single-product.st-has-product-video .st-product-video-thumb > a {
  position: relative;
  display: block;
  overflow: hidden;
}

body.single-product.st-has-product-video .st-product-video-thumb__play {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  color: var(--st-primary, #1C1C1A);
  box-shadow: 0 3px 10px rgba(28, 28, 26, .15);
  pointer-events: none;
}

body.single-product.st-has-product-video .st-product-video-thumb__play svg {
  display: block;
  width: 14px;
  height: 14px;
  margin-left: 1px;
}

/* Mixed WooCommerce PhotoSwipe video slide. */
.st-product-video-pswp-stage {
  --st-product-video-space-x: 96px;
  --st-product-video-space-y: 120px;

  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 60px 48px;
  pointer-events: auto;
}

.st-product-video-pswp-frame {
  position: relative;
  width: min(
    var(--st-product-video-max-width, 900px),
    calc(100vw - var(--st-product-video-space-x)),
    calc((100vh - var(--st-product-video-space-y)) * var(--st-product-video-ratio, 1))
  );
  max-width: 100%;
  max-height: calc(100vh - var(--st-product-video-space-y));
  aspect-ratio: var(--st-product-video-aspect, 1 / 1);
  overflow: hidden;
  background: #F8F8F8;
}

.st-product-video-toggle--lightbox {
  right: 14px;
  bottom: 14px;
}

.st-product-video-pswp-status {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: min(320px, calc(100% - 40px));
  transform: translate(-50%, -50%);
  color: var(--st-text, #3A3936);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  pointer-events: none;
}

/* Zoom is image-only; keep native counter, fullscreen, arrows and close. */
.pswp.st-product-video-pswp-active .pswp__button--zoom {
  display: none !important;
}

@supports (height: 100dvh) {
  .st-product-video-pswp-frame {
    width: min(
      var(--st-product-video-max-width, 900px),
      calc(100vw - var(--st-product-video-space-x)),
      calc((100dvh - var(--st-product-video-space-y)) * var(--st-product-video-ratio, 1))
    );
    max-height: calc(100dvh - var(--st-product-video-space-y));
  }
}

@media (max-width: 849px) {
  body.single-product.st-has-product-video .st-product-video-open-surface {
    display: none;
  }

  body.single-product.st-has-product-video .st-product-video-toggle,
  .st-product-video-toggle--lightbox {
    right: 10px;
    bottom: 10px;
    width: 42px;
    height: 42px;
    min-height: 42px;
  }

  .st-product-video-toggle__icon {
    width: 20px;
    height: 20px;
  }

  .st-product-video-pswp-stage {
    --st-product-video-space-x: 32px;
    --st-product-video-space-y: 108px;
    padding: 54px 16px;
  }
}

@media (max-width: 549px) {
  body.single-product.st-has-product-video .st-product-video-thumb__play {
    width: 28px;
    height: 28px;
  }

  .st-product-video-pswp-stage {
    --st-product-video-space-x: 16px;
    padding-right: 8px;
    padding-left: 8px;
  }
}
