.bbpmg-gallery-item--video,
.bbpmg-flexy-item--video {
  width: 100%;
}

.bbpmg-video-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #f5f5f5;
}

.bbpmg-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.woocommerce-product-gallery__wrapper .bbpmg-gallery-item--video video {
  cursor: default;
}

.woocommerce-product-gallery .flex-control-thumbs li.bbpmg-thumb-video,
.woocommerce-product-gallery ol.flex-control-nav li.bbpmg-thumb-video,
.ct-product-gallery-container .bbpmg-flexy-pill {
  position: relative !important;
  cursor: pointer;
  overflow: hidden;
  background: #111;
}

.woocommerce-product-gallery .flex-control-thumbs li.bbpmg-thumb-video > img.bbpmg-thumb-fallback-image,
.woocommerce-product-gallery ol.flex-control-nav li.bbpmg-thumb-video > img.bbpmg-thumb-fallback-image {
  opacity: 0 !important;
}

.bbpmg-video-thumb-wrap,
.bbpmg-pill-media {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: #111;
}

.woocommerce-product-gallery .flex-control-thumbs li.bbpmg-thumb-video .bbpmg-video-thumb-wrap,
.woocommerce-product-gallery ol.flex-control-nav li.bbpmg-thumb-video .bbpmg-video-thumb-wrap {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.bbpmg-video-thumb-media,
.bbpmg-pill-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bbpmg-video-thumb-media {
  opacity: 0;
}

.bbpmg-video-thumb-media.bbpmg-video-thumb-media--loaded {
  opacity: 1;
}

.bbpmg-play-badge {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
  z-index: 3;
}

.ct-product-gallery-container .bbpmg-flexy-item .bbpmg-video-wrap,
.ct-product-gallery-container .bbpmg-flexy-item .bbpmg-image-wrap {
  border-radius: inherit;
}

.ct-product-gallery-container .bbpmg-image-wrap img {
  width: 100%;
  height: auto;
  display: block;
}

.bbpmg-featured-product-media {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #f5f5f5;
}

.bbpmg-featured-product-media video,
.bbpmg-featured-product-video,
.bbpmg-featured-product-image {
  display: block;
  width: 100%;
  height: 100%;
}

.bbpmg-featured-product-video {
  object-fit: cover;
}

.bbpmg-featured-product-image {
  object-fit: cover;
}

/* Keep common WooCommerce/Blocksy product cards from reserving space for the old placeholder image. */
.product .bbpmg-featured-product-media + img,
.product .bbpmg-featured-product-media + .woocommerce-placeholder {
  display: none !important;
}

.bbpmg-gallery-item--static-frame .bbpmg-video,
.bbpmg-flexy-item--static-frame .bbpmg-video,
.bbpmg-featured-product-media--static-frame video {
  cursor: default;
}

.bbpmg-featured-product-media--static-frame video::-webkit-media-controls,
.bbpmg-gallery-item--static-frame video::-webkit-media-controls,
.bbpmg-flexy-item--static-frame video::-webkit-media-controls {
  display: none !important;
}

.bbpmg-image-wrap {
  display: block;
  width: 100%;
}

.bbpmg-image-wrap img {
  display: block;
  width: 100%;
  height: auto;
}

.woocommerce-product-gallery__wrapper .bbpmg-variation-override .bbpmg-image-wrap,
.woocommerce-product-gallery__wrapper .bbpmg-variation-override .bbpmg-video-wrap {
  width: 100%;
}


.bbpmg-featured-product-media[data-bbpmg-product-url] {
  cursor: pointer;
}

.bbpmg-featured-product-media[data-bbpmg-product-url]:focus {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}


/* Keep video previews visible in WooCommerce thumbnail nav, but do not steal
   the click from FlexSlider/WooCommerce's own thumbnail switching. */
.woocommerce-product-gallery .flex-control-thumbs li.bbpmg-thumb-video .bbpmg-video-thumb-wrap,
.woocommerce-product-gallery ol.flex-control-nav li.bbpmg-thumb-video .bbpmg-video-thumb-wrap,
.woocommerce-product-gallery .flex-control-thumbs li.bbpmg-thumb-video .bbpmg-video-thumb-media,
.woocommerce-product-gallery ol.flex-control-nav li.bbpmg-thumb-video .bbpmg-video-thumb-media,
.woocommerce-product-gallery .flex-control-thumbs li.bbpmg-thumb-video .bbpmg-play-badge,
.woocommerce-product-gallery ol.flex-control-nav li.bbpmg-thumb-video .bbpmg-play-badge {
  pointer-events: none;
}


.woocommerce-product-gallery .bbpmg-placeholder-image-wrap {
  display: block;
  width: 100%;
  background: #f5f5f5;
}

.woocommerce-product-gallery .bbpmg-placeholder-image-wrap img {
  display: block;
  width: 100%;
  height: auto;
}

.woocommerce-product-gallery:not(.bbpmg-gallery-showing-placeholder) .bbpmg-gallery-item--video.bbpmg-variation-override,
.woocommerce-product-gallery:not(.bbpmg-gallery-showing-placeholder) .bbpmg-gallery-item--video.bbpmg-variation-override .bbpmg-video-wrap,
.woocommerce-product-gallery:not(.bbpmg-gallery-showing-placeholder) .bbpmg-gallery-item--video.bbpmg-variation-override video {
  opacity: 1 !important;
  filter: none !important;
}

.woocommerce-product-gallery .bbpmg-gallery-item--video.bbpmg-variation-override::before,
.woocommerce-product-gallery .bbpmg-gallery-item--video.bbpmg-variation-override::after,
.woocommerce-product-gallery .bbpmg-gallery-item--video.bbpmg-variation-override .bbpmg-video-wrap::before,
.woocommerce-product-gallery .bbpmg-gallery-item--video.bbpmg-variation-override .bbpmg-video-wrap::after {
  display: none !important;
}


.bbpmg-block-product-media-link,
.bbpmg-product-card-media-link {
  display: block;
  width: 100%;
  text-decoration: none;
  color: inherit;
}

.bbpmg-block-product-media-link .bbpmg-featured-product-media,
.bbpmg-product-card-media-link .bbpmg-featured-product-media,
.bbpmg-product-image-block .bbpmg-featured-product-media {
  width: 100%;
}

.wc-block-grid__product-image .bbpmg-featured-product-media,
.wc-block-components-product-image .bbpmg-featured-product-media,
.wp-block-woocommerce-product-image .bbpmg-featured-product-media,
.bbpmg-product-image-block .bbpmg-featured-product-media {
  margin: 0;
}
