/* 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;
}

/* ------------------------------------------------------------------------- */
/* "Grid" gallery type — every image/video shown at once in two columns.     */
/*                                                                           */
/* WooCommerce's flexslider is disabled server side for this layout (see      */
/* WCVGDB_Frontend::grid_disable_feature), so the gallery wrapper holds every */
/* `.woocommerce-product-gallery__image` (and our video slides) as plain      */
/* siblings — exactly what a CSS grid needs. WooCommerce's own PhotoSwipe     */
/* lightbox stays enabled and is bound to each image link.                    */
/* ------------------------------------------------------------------------- */

/* The gallery template ships `style="opacity:0"`, cleared by WooCommerce's
   gallery script. Guarantee the grid is visible even if that script is absent
   (theme without gallery support, JS error…). */
.wcvgdb-gallery--grid {
	opacity: 1 !important;
}

.wcvgdb-gallery--grid .woocommerce-product-gallery__wrapper {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
	width: 100%;
	max-width: none;
	margin: 0;
	padding: 0;
	float: none;
	/* Neutralise any flexslider transform left over from a previous layout. */
	transform: none;
}

/* Equal-width columns, equal-height rows: one shared box per cell.
   Shielded with !important against WooCommerce core's non-slider fallback
   (`div.images .woocommerce-product-gallery__image:nth-child(n+2){width:25%}`)
   and against themes that float or margin gallery images. */
.wcvgdb-gallery--grid .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image,
.wcvgdb-gallery--grid .woocommerce-product-gallery__wrapper > .wcvgdb-video-slide {
	position: relative;
	display: block;
	width: auto !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
	float: none !important;
	aspect-ratio: 1 / 1;
	overflow: hidden;
}

/* A lone item spans both columns rather than sitting in a half-width square.
   A single image keeps its natural shape; a lone video slide needs a definite
   box (its player is height-matched to the cell), so it falls back to 16:9. */
.wcvgdb-gallery--grid .woocommerce-product-gallery__wrapper > :only-child {
	grid-column: 1 / -1;
}

.wcvgdb-gallery--grid .woocommerce-product-gallery__wrapper > :only-child:not(.wcvgdb-video-slide) {
	aspect-ratio: auto;
}

.wcvgdb-gallery--grid .woocommerce-product-gallery__wrapper > .wcvgdb-video-slide:only-child {
	aspect-ratio: 16 / 9;
}

/* Fill the cell consistently: the whole product stays visible inside the shared
   box — never stretched, never cropped. Product photography that already ships
   its own white margin (the usual studio shot) therefore looks identical in
   every tile, whatever its source ratio. Swap `contain` for `cover` here if
   edge-to-edge, cropped tiles are wanted instead. */
.wcvgdb-gallery--grid .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image > a {
	display: block;
	width: 100%;
	height: 100%;
}

.wcvgdb-gallery--grid .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image img {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	object-fit: contain;
}

.wcvgdb-gallery--grid .woocommerce-product-gallery__wrapper > :only-child:not(.wcvgdb-video-slide) img {
	height: auto;
	object-fit: contain;
}

/* Video cells match the image cells exactly: the whole frame is fitted inside
   the shared box (never cropped), and the cell's own background shows around
   it — the same treatment the images get, so the Background color setting
   applies to image and video cells alike. */
.wcvgdb-gallery--grid .wcvgdb-video-slide .wcvgdb-video-inner {
	height: 100% !important;
	aspect-ratio: auto !important;
	background-color: transparent;
	background-size: contain;
}

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

/* Keep the on-video mute button clear of the lightbox icon in the corner. */
.wcvgdb-gallery--grid .wcvgdb-video-slide .wcvgdb-mute {
	right: 48px;
}

/* Zoom is turned off for the grid, so the magnifier trigger is never rendered;
   hide it defensively in case a theme adds one of its own. */
.wcvgdb-gallery--grid .woocommerce-product-gallery__trigger {
	display: none;
}

/* Smaller gap and play button on phones — the two columns are kept. */
@media ( max-width: 480px ) {
	.wcvgdb-gallery--grid .woocommerce-product-gallery__wrapper {
		gap: 6px;
	}

	.wcvgdb-gallery--grid .wcvgdb-video-slide .wcvgdb-play {
		width: 48px;
		height: 48px;
	}
}

/* ------------------------------------------------------------------------- */
/* Grid gallery — video slides inside WooCommerce's PhotoSwipe lightbox.     */
/*                                                                           */
/* The lightbox copy is a real `.wcvgdb-video-slide`, so it inherits the      */
/* player, play button and mute button styles above; only its box needs to    */
/* change, from a square grid cell to a centred stage inside the overlay.     */
/* Nothing here can reach the gallery itself — every rule is scoped to .pswp. */
/* ------------------------------------------------------------------------- */

.pswp .wcvgdb-pswp-video {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	/* Clear of PhotoSwipe's top bar and caption strip. */
	padding: 50px 10px 60px;
	box-sizing: border-box;
}

.pswp .wcvgdb-pswp-video .wcvgdb-video-inner {
	width: 100%;
	height: 100%;
	max-width: 1400px;
	/* The stage is the available area; the poster and the player both fit
	   inside it (contain), so nothing is cropped whatever the video's ratio. */
	aspect-ratio: auto;
	background-color: transparent;
	background-size: contain;
	cursor: pointer;
}

.pswp .wcvgdb-pswp-video .wcvgdb-video-inner video,
.pswp .wcvgdb-pswp-video .wcvgdb-video-inner iframe {
	background: transparent;
}

/* Placeholder for a gallery slide with no image of its own — only ever hit by
   malformed markup, and present so the item list stays 1:1 with the slides. */
.pswp .wcvgdb-pswp-blank {
	display: none;
}

/* ------------------------------------------------------------------------- */
/* Grid gallery — hover zoom and the per-cell lightbox icon.                  */
/* ------------------------------------------------------------------------- */

/* Hover zoom on image cells: the zoom follows the pointer rather than growing
   the picture from the middle. `.wcvgdb-zoom-lens` paints the full-size image,
   scaled and offset by the JS so whatever is under the cursor stays under it,
   and the cell clips (overflow: hidden) so the layout never moves. The lens is
   only revealed once that image has decoded, so the cell never flashes empty. */
.wcvgdb-gallery--grid .wcvgdb-zoom-lens {
	position: absolute;
	inset: 0;
	z-index: 2;
	opacity: 0;
	pointer-events: none;
	background-repeat: no-repeat;
	transition: opacity 0.15s ease;
}

.wcvgdb-gallery--grid .wcvgdb-zoom-active .wcvgdb-zoom-lens {
	opacity: 1;
}

/* The gallery image is hidden behind the lens while zooming, so an image that
   does not fill its cell cannot show an unzoomed strip beside the zoomed one.
   Visibility only — the element itself, which WooCommerce and the theme read,
   is left completely alone. */
.wcvgdb-gallery--grid .wcvgdb-zoom-active img {
	visibility: hidden;
}

/* The pointer is replaced by a large crosshair over the zoomed area. */
.wcvgdb-gallery--grid .wcvgdb-zoom-active,
.wcvgdb-gallery--grid .wcvgdb-zoom-active a,
.wcvgdb-gallery--grid .wcvgdb-zoom-active img,
.wcvgdb-gallery--grid .wcvgdb-zoom-active .wcvgdb-grid-zoom {
	cursor: none !important;
}

.wcvgdb-gallery--grid .wcvgdb-zoom-plus {
	position: absolute;
	top: 0;
	left: 0;
	z-index: 4;
	display: block;
	color: #1d2327;
	opacity: 0;
	pointer-events: none;
	/* The crosshair carries its own light halo (see the SVG); this only lifts
	   it off busy detail. */
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}

.wcvgdb-gallery--grid .wcvgdb-zoom-active .wcvgdb-zoom-plus {
	opacity: 1;
}

.wcvgdb-gallery--grid .wcvgdb-zoom-plus svg {
	display: block;
}

@media ( prefers-reduced-motion: reduce ) {
	.wcvgdb-gallery--grid .wcvgdb-zoom-lens {
		transition: none;
	}
}

/* "Open in lightbox" icon, bottom-right of every cell. It sits on top of a
   control that already opens the lightbox (the gallery link on an image cell,
   the cell itself on a video cell), so it needs no behaviour of its own. */
.wcvgdb-gallery--grid .wcvgdb-grid-zoom {
	position: absolute;
	/* 6px of padding around an 18px glyph: the icon still sits 12px in from
	   the cell's corner, but is a 30px target to aim at — it is the only way
	   to open the lightbox with a mouse. */
	right: 6px;
	bottom: 6px;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: content-box;
	width: 18px;
	height: 18px;
	padding: 6px;
	margin: 0;
	border: 0;
	background: none;
	color: #1d2327;
	cursor: pointer;
	opacity: 0.75;
	/* Readable over a busy photo without needing a chip behind it. */
	filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.9));
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.wcvgdb-gallery--grid .wcvgdb-grid-zoom svg {
	display: block;
	/* Clicks always report the icon itself, never a path inside it. */
	pointer-events: none;
}

.wcvgdb-gallery--grid .woocommerce-product-gallery__image:hover .wcvgdb-grid-zoom,
.wcvgdb-gallery--grid .wcvgdb-grid-zoom:hover,
.wcvgdb-gallery--grid .wcvgdb-grid-zoom:focus-visible {
	opacity: 1;
	transform: scale(1.12);
}

/* Shield the icon from theme button/link styling, the way the play and mute
   buttons above are shielded. */
.wcvgdb-gallery--grid .wcvgdb-grid-zoom,
.wcvgdb-gallery--grid .wcvgdb-grid-zoom:hover,
.wcvgdb-gallery--grid .wcvgdb-grid-zoom:focus,
.wcvgdb-gallery--grid .wcvgdb-grid-zoom:active {
	background: none !important;
	border: 0 !important;
	box-shadow: none !important;
	text-decoration: none !important;
	outline: none;
}
