/* ==========================================================================
   Product Video Gallery - frontend styles
   ========================================================================== */

.pvg-video-slide {
	position: relative;
}

.pvg-video-preview {
	position: relative;
	width: 100%;
	overflow: hidden;
	background: #0b0b0c;
}

.pvg-video-poster {
	display: block;
	width: 100%;
	height: auto;
}

/* Gradient scrim for depth and play-button contrast. */
.pvg-video-scrim {
	position: absolute;
	inset: 0;
	z-index: 1;
	pointer-events: none;
	background: linear-gradient( to top, rgba( 0, 0, 0, 0.4 ) 0%, rgba( 0, 0, 0, 0 ) 45% );
	opacity: 0.85;
	transition: opacity 0.25s ease;
}

/* ---- Play button ---- */
.pvg-play-button {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate( -50%, -50% );
	display: flex;
	align-items: center;
	justify-content: center;
	width: 68px;
	height: 68px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: rgba( 0, 0, 0, 0.65 );
	color: #fff;
	cursor: pointer;
	z-index: 2;
	box-shadow: 0 6px 24px rgba( 0, 0, 0, 0.35 );
	transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease, box-shadow 0.2s ease;
	border: 2.5px solid rgba( 255, 255, 255, 0.35 );
}

.pvg-play-button:hover {
	background: rgba( 0, 0, 0, 0.8 );
	transform: translate( -50%, -50% ) scale( 1.12 );
	box-shadow: 0 10px 32px rgba( 0, 0, 0, 0.45 );
	border-color: rgba( 255, 255, 255, 0.7 );
}

.pvg-play-button:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 3px;
}

.pvg-play-icon {
	display: block;
	margin-left: 4px;
	width: 28px;
	height: 28px;
}

/* ---- Source badge ---- */
.pvg-video-badge {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	padding: 0.28em 0.6em;
	border-radius: 999px;
	font-size: 0.72rem;
	font-weight: 600;
	line-height: 1;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: #fff;
	background: rgba( 0, 0, 0, 0.6 );
	-webkit-backdrop-filter: blur( 4px );
	backdrop-filter: blur( 4px );
}

.pvg-video-badge--youtube {
	background: rgba( 229, 9, 20, 0.9 );
}

.pvg-video-badge--vimeo {
	background: rgba( 26, 183, 234, 0.92 );
}

/* ---- Player ---- */
.pvg-video-player {
	position: absolute;
	inset: 0;
	z-index: 3;
}

.pvg-video-player video,
.pvg-video-player iframe {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	background: #000;
}

/* ---- Playing state ---- */
.pvg-video-slide.is-playing .pvg-play-button,
.pvg-video-slide.is-playing .pvg-video-poster,
.pvg-video-slide.is-playing .pvg-video-scrim,
.pvg-video-slide.is-playing .pvg-video-badge {
	opacity: 0;
	pointer-events: none;
}

.pvg-video-slide.is-playing .pvg-video-player {
	display: block !important;
}

/* ==========================================================================
   Dedicated section above the description
   ========================================================================== */

.pvg-video-section {
	margin: clamp( 2rem, 4vw, 3.5rem ) 0;
	clear: both;
}

.pvg-video-section-header {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 0.5rem 0.75rem;
	margin-bottom: clamp( 1rem, 2vw, 1.5rem );
}

.pvg-video-section-title {
	margin: 0;
	font-size: clamp( 1.25rem, 2.2vw, 1.6rem );
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: -0.01em;
}

.pvg-video-section-count {
	font-size: 0.85rem;
	font-weight: 500;
	opacity: 0.55;
}

.pvg-video-grid {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 300px, 1fr ) );
	gap: clamp( 16px, 2vw, 24px );
}

.pvg-video-grid.pvg-video-count-1 {
	grid-template-columns: minmax( 0, 760px );
}

.pvg-video-grid.pvg-video-count-2 {
	grid-template-columns: repeat( 2, minmax( 0, 1fr ) );
}

.pvg-video-item {
	margin: 0;
	min-width: 0;
}

.pvg-video-item .pvg-video-preview {
	aspect-ratio: 16 / 9;
	border-radius: 14px;
	box-shadow: 0 1px 2px rgba( 0, 0, 0, 0.06 ), 0 10px 26px -14px rgba( 0, 0, 0, 0.3 );
	transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.pvg-video-item .pvg-video-poster {
	height: 100%;
	object-fit: cover;
	transition: transform 0.5s ease;
}

.pvg-video-item:hover .pvg-video-preview {
	transform: translateY( -4px );
	box-shadow: 0 8px 20px rgba( 0, 0, 0, 0.12 ), 0 22px 44px -18px rgba( 0, 0, 0, 0.4 );
}

.pvg-video-item:hover .pvg-video-poster {
	transform: scale( 1.05 );
}

.pvg-video-item:hover .pvg-video-scrim {
	opacity: 1;
}

.pvg-video-caption {
	margin-top: 0.7rem;
	font-size: 0.95rem;
	font-weight: 500;
	line-height: 1.35;
}

/* ==========================================================================
   Woostify gallery slides (match native product photo sizing)
   ========================================================================== */

.product-gallery .pvg-gallery-slide {
	width: 100%;
}

.product-gallery .pvg-gallery-slide > a {
	display: block;
	position: relative;
	line-height: 0;
}

.product-gallery .pvg-gallery-slide img.pvg-video-poster {
	width: 100%;
	height: auto;
	display: block;
}

.product-gallery .pvg-gallery-slide .pvg-woostify-play {
	z-index: 5;
	line-height: 0;
}

.product-gallery .pvg-gallery-slide.playing-video .pvg-woostify-play,
.product-gallery .pvg-gallery-slide.is-playing .pvg-woostify-play {
	opacity: 0;
	pointer-events: none;
}

.product-gallery .pvg-gallery-slide.playing-video > a,
.product-gallery .pvg-gallery-slide.is-playing > a {
	display: none;
}

.product-gallery .pvg-gallery-slide .woostify-product-video-container,
.product-gallery .pvg-gallery-slide .pvg-video-player {
	position: relative;
	width: 100%;
	aspect-ratio: var(--pvg-ar, 1 / 1);
	background: #000;
}

.product-gallery .pvg-gallery-slide .woostify-product-video-container iframe,
.product-gallery .pvg-gallery-slide .woostify-product-video-container video,
.product-gallery .pvg-gallery-slide .pvg-video-player iframe,
.product-gallery .pvg-gallery-slide .pvg-video-player video {
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
}

.product-gallery .pvg-video-thumb {
	position: relative;
}

.product-gallery .pvg-video-thumb img {
	display: block;
	width: 100%;
	height: auto;
}

.product-gallery .pvg-video-thumb .pvg-thumb-play {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.65);
	color: #fff;
	pointer-events: none;
	z-index: 2;
	box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
	transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
	border: 1.5px solid rgba(255, 255, 255, 0.35);
	line-height: 0;
}

.product-gallery .pvg-video-thumb .pvg-thumb-play svg {
	display: block;
	margin-left: 2px;
	width: 14px;
	height: 14px;
}

.product-gallery .pvg-video-thumb:hover .pvg-thumb-play {
	background: rgba(0, 0, 0, 0.8);
	transform: translate(-50%, -50%) scale(1.15);
	box-shadow: 0 5px 16px rgba(0, 0, 0, 0.4);
	border-color: rgba(255, 255, 255, 0.7);
}

/* When Flickity has not initialized yet, still show all video slides. */
.product-gallery.pvg-has-videos .product-images-container .pvg-gallery-slide {
	display: block;
}

/* ==========================================================================
   Default WooCommerce gallery slides
   ========================================================================== */

.pvg-gallery-slide {
	position: relative;
	width: 100%;
	margin: 0;
}

.pvg-gallery-slide .pvg-video-preview {
	width: 100%;
	aspect-ratio: var( --pvg-ar, 1 / 1 );
	background: #0b0b0c;
	cursor: pointer;
}

.pvg-gallery-slide .pvg-video-poster {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.pvg-gallery-slide .pvg-video-player {
	position: absolute;
	inset: 0;
}

/* Neutralize the theme's lightbox link wrapping the cell, if present. */
.pvg-gallery-slide > a {
	pointer-events: none;
}

/* ==========================================================================
   Woostify thumbnail navigation items
   ========================================================================== */

.pvg-video-thumb {
	position: relative;
}

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

.pvg-thumb-badge {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate( -50%, -50% );
	width: 0;
	height: 0;
	border-top: 7px solid transparent;
	border-bottom: 7px solid transparent;
	border-left: 12px solid #fff;
	filter: drop-shadow( 0 0 2px rgba( 0, 0, 0, 0.6 ) );
	pointer-events: none;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media ( max-width: 782px ) {
	.pvg-video-grid,
	.pvg-video-grid.pvg-video-count-2,
	.pvg-video-grid.pvg-video-count-3 {
		grid-template-columns: 1fr;
	}

	.pvg-play-button {
		width: 54px;
		height: 54px;
	}

	.pvg-play-icon {
		width: 22px;
		height: 22px;
	}
}

/* ==========================================================================
   Motion preferences
   ========================================================================== */

@media ( prefers-reduced-motion: reduce ) {
	.pvg-video-item .pvg-video-preview,
	.pvg-video-item .pvg-video-poster,
	.pvg-play-button,
	.pvg-video-scrim {
		transition: none;
	}

	.pvg-video-item:hover .pvg-video-preview,
	.pvg-video-item:hover .pvg-video-poster {
		transform: none;
	}
}
