/**
 * WC YouTube Gallery Slide — front end styles.
 *
 * Deliberately minimal. The slide sits inside the theme's own gallery, so the
 * only thing this file draws is the play affordance; everything else inherits
 * from Astra (or whichever theme is running).
 *
 * To crop the video poster to match square product images, set the ratio in
 * your child theme:
 *
 *   .wcyg-slide { --wcyg-ratio: 1; }
 */

.wcyg-slide {
	--wcyg-ratio: auto;
	--wcyg-play-bg: rgba( 17, 17, 17, 0.72 );
	--wcyg-play-bg-hover: #e62117;
	position: relative;
	overflow: hidden;
}

.wcyg-facade {
	display: block;
	position: relative;
	width: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	line-height: 0;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.wcyg-poster {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: var( --wcyg-ratio );
	object-fit: cover;
}

.wcyg-play {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 68px;
	height: 48px;
	border-radius: 14px;
	background: var( --wcyg-play-bg );
	transform: translate( -50%, -50% );
	transition: background 180ms ease, transform 180ms ease;
	pointer-events: none;
}

.wcyg-play::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate( -35%, -50% );
	border-style: solid;
	border-width: 9px 0 9px 16px;
	border-color: transparent transparent transparent #fff;
}

.wcyg-facade:hover .wcyg-play,
.wcyg-facade:focus-visible .wcyg-play {
	background: var( --wcyg-play-bg-hover );
	transform: translate( -50%, -50% ) scale( 1.06 );
}

.wcyg-facade:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -4px;
}

.wcyg-iframe {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	border: 0;
}

.wcyg-slide.is-playing {
	display: flex;
	align-items: center;
	background: #000;
}

.wcyg-slide.is-playing .wcyg-facade {
	display: none;
}

/* The gallery thumbnail for the video slide, marked so it can be styled. */
.woocommerce-product-gallery .flex-control-thumbs li img[ src*="i.ytimg.com" ] {
	object-fit: cover;
}

/* Astra Pro renders its own thumbnail rail; this is the item injected into it. */
.wcyg-thumb {
	position: relative;
	cursor: pointer;
}

.wcyg-thumb img {
	display: block;
	width: 100%;
	height: 100%;
	aspect-ratio: 1;
	object-fit: cover;
}

.wcyg-thumb::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate( -50%, -50% );
	border: 7px solid transparent;
	border-left: 12px solid #fff;
	filter: drop-shadow( 0 0 3px rgba( 0, 0, 0, 0.6 ) );
	pointer-events: none;
}

/* A poster that fails to load would otherwise collapse the slide to zero
   height and make the video unreachable. */
.wcyg-slide.has-broken-poster .wcyg-poster {
	aspect-ratio: 16 / 9;
	background: #1a1a1a;
}

@media ( prefers-reduced-motion: reduce ) {
	.wcyg-play {
		transition: background 180ms ease;
	}

	.wcyg-facade:hover .wcyg-play,
	.wcyg-facade:focus-visible .wcyg-play {
		transform: translate( -50%, -50% );
	}
}
