/* WC Video Gallery Diamond Brothers — frontend gallery styles. */

.wcvgdb-video-slide .wcvgdb-video-inner {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	background-color: #000;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	cursor: pointer;
	overflow: hidden;
}

.wcvgdb-video-slide .wcvgdb-video-inner video,
.wcvgdb-video-slide .wcvgdb-video-inner iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
	background: #000;
}

/* Letterbox the video inside the height-matched slide — never stretch it. */
.wcvgdb-video-slide .wcvgdb-video-inner video {
	object-fit: contain;
}

.wcvgdb-video-slide.wcvgdb-is-playing .wcvgdb-video-inner {
	cursor: default;
}

/* Play button overlay. */
.wcvgdb-video-slide .wcvgdb-play {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	display: flex;
	align-items: center;
	justify-content: center;
	width: 64px;
	height: 64px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.65);
	color: #fff;
	cursor: pointer;
	transition: background 0.2s ease, transform 0.2s ease;
}

.wcvgdb-video-slide .wcvgdb-play svg {
	margin-left: 4px; /* Optically center the triangle. */
}

.wcvgdb-video-slide .wcvgdb-video-inner:hover .wcvgdb-play,
.wcvgdb-video-slide .wcvgdb-play:focus-visible {
	background: rgba(0, 0, 0, 0.85);
	transform: translate(-50%, -50%) scale(1.08);
}

.wcvgdb-video-slide.wcvgdb-is-playing .wcvgdb-play {
	display: none;
}

/* Mute/unmute toggle (shown when native controls are hidden). */
.wcvgdb-mute {
	position: absolute;
	right: 10px;
	bottom: 10px;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	cursor: pointer;
	transition: background 0.2s ease;
}

.wcvgdb-mute:hover,
.wcvgdb-mute:focus-visible {
	background: rgba(0, 0, 0, 0.8);
}

.wcvgdb-mute .wcvgdb-icon-muted,
.wcvgdb-mute.is-muted .wcvgdb-icon-sound {
	display: none;
}

.wcvgdb-mute.is-muted .wcvgdb-icon-muted {
	display: block;
}

/* Paused indicator while native controls are hidden (tap to resume). */
.wcvgdb-video-slide.wcvgdb-is-playing.wcvgdb-paused .wcvgdb-video-inner::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 56px;
	height: 56px;
	border-radius: 50%;
	pointer-events: none;
	background: rgba(0, 0, 0, 0.55)
		url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5v14l11-7z' fill='%23fff'/%3E%3C/svg%3E")
		center / 26px 26px no-repeat;
}

/* Play badge on the flexslider thumbnail nav for video slides. */
.flex-control-thumbs li.wcvgdb-thumb-video {
	position: relative;
}

.flex-control-thumbs li.wcvgdb-thumb-video::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 26px;
	height: 26px;
	border-radius: 50%;
	pointer-events: none;
	background: rgba(0, 0, 0, 0.6)
		url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5v14l11-7z' fill='%23fff'/%3E%3C/svg%3E")
		center / 14px 14px no-repeat;
}

/* When the thumbnail shows a real preview (the video's own poster or a
   generated first frame), drop the play badge — the thumbnail is a clean
   image, not the dark placeholder. */
.flex-control-thumbs li.wcvgdb-thumb-video.wcvgdb-thumb-frame::after {
	content: none;
}

/* Zoom trigger is hidden while a video slide is active (not part of PhotoSwipe). */
.woocommerce-product-gallery__trigger.wcvgdb-hidden {
	display: none !important;
}

/* ------------------------------------------------------------------------- */
/* Featured video (no product image): the video occupies the placeholder slot */
/* while a hidden <img> stays behind it as WooCommerce's variation-swap target.*/
/* ------------------------------------------------------------------------- */

/* Default image is never shown — the video fills the featured area. The
   !important shields against themes that force gallery images visible with a
   higher-specificity rule (as several WooCommerce themes do). */
.wcvgdb-featured-video > .wp-post-image {
	display: none !important;
}

/* A variation with its own image was selected: reveal the (swapped) image and
   hide the video. */
.wcvgdb-featured-video.wcvgdb-variation-active .wcvgdb-video-inner {
	display: none !important;
}

.wcvgdb-featured-video.wcvgdb-variation-active > .wp-post-image {
	display: block !important;
	width: 100%;
	height: auto;
}

/* Video-as-featured gallery (no product image): every slide is forced to the
   featured video's aspect ratio (set inline by applyVideoAspect) so the gallery
   height never jumps when switching between videos and the variation image. A
   mismatched video letterboxes on the page background — never on black. */
.wcvgdb-video-featured .wcvgdb-video-slide .wcvgdb-video-inner {
	background-color: transparent;
}

.wcvgdb-video-featured .wcvgdb-video-slide .wcvgdb-video-inner video {
	background: transparent;
}

/* ------------------------------------------------------------------------- */
/* "Slider" gallery type — thumbnail slider with Previous/Next arrows.       */
/* ------------------------------------------------------------------------- */

.wcvgdb-gallery--slider .wcvgdb-thumbs {
	position: relative;
	margin-top: 10px;
}

.wcvgdb-gallery--slider .wcvgdb-thumbs-viewport {
	overflow: hidden;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
}

/* Horizontal strip (bottom position, and the small-screen fallback).
   Heavy !important shielding: WooCommerce core and themes (e.g. Astra) style
   `.flex-control-thumbs` with high-specificity selectors — most critically
   `overflow: hidden` on the <ol>, which clips the extra thumbnails inside the
   list itself and leaves our scroll viewport with nothing to scroll. The
   viewport must be the ONLY clipping element. */
.wcvgdb-gallery--slider .wcvgdb-thumbs-viewport .flex-control-thumbs {
	display: flex !important;
	flex-wrap: nowrap !important;
	overflow: visible !important;
	gap: 8px;
	width: 100%;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
	float: none !important;
}

.wcvgdb-gallery--slider .wcvgdb-thumbs-viewport .flex-control-thumbs li {
	float: none !important;
	clear: none !important;
	flex: 0 0 calc( (100% - (var(--wcvgdb-tpv, 4) - 1) * 8px) / var(--wcvgdb-tpv, 4) ) !important;
	width: auto !important;
	margin: 0 !important;
	padding: 0 !important;
}

/* Uniform thumbnail size: images and video posters have different intrinsic
   ratios (portrait photos, 16:9 posters…), which makes the strip ragged.
   Lock every thumb to the same aspect ratio and crop to fill — the image is
   never stretched, so quality is untouched. */
.wcvgdb-gallery--slider .wcvgdb-thumbs-viewport .flex-control-thumbs li img {
	width: 100% !important;
	aspect-ratio: 4 / 3;
	height: auto !important;
	object-fit: cover;
	display: block;
	margin: 0 !important;
}

/* Previous / Next arrows. */
.wcvgdb-thumb-nav {
	position: absolute;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	cursor: pointer;
	opacity: 0.9;
	transition: opacity 0.2s ease, background 0.2s ease;
}

.wcvgdb-thumb-nav:hover:not(:disabled),
.wcvgdb-thumb-nav:focus-visible {
	background: rgba(0, 0, 0, 0.8);
	opacity: 1;
}

.wcvgdb-thumb-nav:disabled {
	opacity: 0.25;
	cursor: default;
}

/* Arrows only make sense when there is something to scroll. */
.wcvgdb-thumbs:not(.wcvgdb-thumbs-scrollable) .wcvgdb-thumb-nav {
	display: none;
}

/* Shield our buttons from theme button styling (blue hover backgrounds,
   borders, link colors etc.) — they must stay neutral dark/white. */
.wcvgdb-thumbs .wcvgdb-thumb-nav,
.wcvgdb-thumbs .wcvgdb-thumb-nav:hover,
.wcvgdb-thumbs .wcvgdb-thumb-nav:focus,
.wcvgdb-thumbs .wcvgdb-thumb-nav:active,
.wcvgdb-video-slide .wcvgdb-play,
.wcvgdb-video-slide .wcvgdb-play:hover,
.wcvgdb-video-slide .wcvgdb-play:focus,
.wcvgdb-video-slide .wcvgdb-play:active,
.wcvgdb-video-slide .wcvgdb-mute,
.wcvgdb-video-slide .wcvgdb-mute:hover,
.wcvgdb-video-slide .wcvgdb-mute:focus,
.wcvgdb-video-slide .wcvgdb-mute:active {
	background: rgba(0, 0, 0, 0.55) !important;
	color: #fff !important;
	border: 0 !important;
	box-shadow: none !important;
	text-shadow: none !important;
	text-decoration: none !important;
	outline: none;
}

.wcvgdb-thumbs .wcvgdb-thumb-nav:hover:not(:disabled),
.wcvgdb-thumbs .wcvgdb-thumb-nav:focus-visible,
.wcvgdb-video-slide .wcvgdb-video-inner:hover .wcvgdb-play,
.wcvgdb-video-slide .wcvgdb-play:focus-visible,
.wcvgdb-video-slide .wcvgdb-mute:hover,
.wcvgdb-video-slide .wcvgdb-mute:focus-visible {
	background: rgba(0, 0, 0, 0.8) !important;
	color: #fff !important;
}

/* Horizontal arrow placement. */
.wcvgdb-thumb-prev {
	left: 2px;
	top: 50%;
	transform: translateY(-50%);
}

.wcvgdb-thumb-next {
	right: 2px;
	top: 50%;
	transform: translateY(-50%);
}

/* Left / right positions: vertical thumbnail column beside the main image
   (desktop only — on small screens the strip drops below the image). */
@media ( min-width: 769px ) {
	.wcvgdb-gallery--slider.wcvgdb-thumbs--left,
	.wcvgdb-gallery--slider.wcvgdb-thumbs--right {
		display: flex;
		gap: 12px;
		align-items: flex-start;
	}

	.wcvgdb-thumbs--left .wcvgdb-thumbs,
	.wcvgdb-thumbs--right .wcvgdb-thumbs {
		flex: 0 0 18%;
		max-width: 18%;
		margin-top: 0;
	}

	.wcvgdb-thumbs--left .wcvgdb-thumbs {
		order: -1;
	}

	.wcvgdb-thumbs--left .flex-viewport,
	.wcvgdb-thumbs--right .flex-viewport,
	.wcvgdb-thumbs--left > .woocommerce-product-gallery__wrapper,
	.wcvgdb-thumbs--right > .woocommerce-product-gallery__wrapper {
		flex: 1 1 auto;
		min-width: 0;
	}

	/* Vertical list inside the viewport. */
	.wcvgdb-thumbs--left .wcvgdb-thumbs-viewport .flex-control-thumbs,
	.wcvgdb-thumbs--right .wcvgdb-thumbs-viewport .flex-control-thumbs {
		flex-direction: column !important;
	}

	.wcvgdb-thumbs--left .wcvgdb-thumbs-viewport .flex-control-thumbs li,
	.wcvgdb-thumbs--right .wcvgdb-thumbs-viewport .flex-control-thumbs li {
		flex: 0 0 auto !important;
		width: 100% !important;
	}

	/* Vertical arrow placement (rotated chevrons point up/down). */
	.wcvgdb-thumbs--left .wcvgdb-thumb-prev,
	.wcvgdb-thumbs--right .wcvgdb-thumb-prev {
		top: 2px;
		left: 50%;
		right: auto;
		transform: translateX(-50%) rotate(90deg);
	}

	.wcvgdb-thumbs--left .wcvgdb-thumb-next,
	.wcvgdb-thumbs--right .wcvgdb-thumb-next {
		top: auto;
		bottom: 2px;
		left: 50%;
		right: auto;
		transform: translateX(-50%) rotate(90deg);
	}

	/* Keep the zoom trigger clear of a right-hand thumbnail column. */
	.wcvgdb-thumbs--right .woocommerce-product-gallery__trigger {
		right: calc( 18% + 24px );
	}
}

/* Stacked (non-slider) fallback: give video slides some breathing room. */
.woocommerce-product-gallery__wrapper > .wcvgdb-video-slide {
	margin-top: 1em;
}

.woocommerce-product-gallery .flex-viewport .wcvgdb-video-slide {
	margin-top: 0;
}
