/* WooCommerce core CSS hides .woocommerce-product-gallery (opacity:0) until
   its own gallery JS runs. We replace that JS, so force this back to visible. */
.woocommerce-product-gallery.wpmg-gallery-root {
	opacity: 1 !important;
}

.wpmg-gallery {
	display: flex;
	gap: 12px;
	position: relative;
	width: 100%;
}

.wpmg-gallery.wpmg-thumbs-left { flex-direction: row; }
.wpmg-gallery.wpmg-thumbs-right { flex-direction: row-reverse; }
.wpmg-gallery.wpmg-thumbs-top { flex-direction: column-reverse; }
.wpmg-gallery.wpmg-thumbs-bottom { flex-direction: column; }

.wpmg-stage {
	position: relative;
	flex: 1 1 0%;
	min-width: 0;
	min-height: 280px;
	overflow: hidden;
	border-radius: 6px;
	background: #f6f7f7;
	aspect-ratio: 1 / 1;
}

.wpmg-slide {
	position: absolute;
	inset: 0;
	opacity: 0;
	visibility: hidden;
	transition: opacity .25s ease;
}

.wpmg-slide.is-active {
	opacity: 1;
	visibility: visible;
	position: relative;
}

.wpmg-slide-img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
	cursor: zoom-in;
	transition: transform .2s ease;
}

.wpmg-video-poster {
	width: 100%;
	height: 100%;
	background-size: cover;
	background-position: center;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	position: relative;
}

.wpmg-play-btn img {
	width: 56px;
	height: 56px;
	filter: drop-shadow(0 2px 6px rgba(0,0,0,.4));
}

.wpmg-inline-video {
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
}

/* Thumbnails */
.wpmg-thumbs {
	display: flex;
	align-items: center;
	gap: 6px;
}

.wpmg-gallery.wpmg-orientation-vertical .wpmg-thumbs {
	flex-direction: column;
	max-height: 500px;
}
.wpmg-gallery.wpmg-orientation-vertical .wpmg-thumb-track {
	flex-direction: column;
	overflow-y: auto;
	max-height: 500px;
}
.wpmg-gallery.wpmg-orientation-horizontal .wpmg-thumb-track {
	flex-direction: row;
	overflow-x: auto;
}

.wpmg-thumb-track {
	display: flex;
	gap: 8px;
	scroll-behavior: smooth;
}

.wpmg-thumb {
	position: relative;
	width: 64px;
	height: 64px;
	flex: 0 0 auto;
	border-radius: 4px;
	overflow: hidden;
	border: 2px solid transparent;
	cursor: pointer;
	opacity: .7;
	transition: border-color .15s ease, opacity .15s ease;
}
.wpmg-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.wpmg-thumb.is-active,
.wpmg-thumb:hover {
	border-color: var(--wpmg-active-border, #2c6ecb);
	opacity: 1;
}
.wpmg-thumb-video-badge {
	position: absolute;
	bottom: 3px;
	right: 3px;
	width: 14px;
	height: 14px;
	background: var(--wpmg-primary, #2c6ecb);
	border-radius: 50%;
}
.wpmg-thumb-video-badge::after {
	content: '';
	position: absolute;
	left: 5px;
	top: 3px;
	border-left: 6px solid var(--wpmg-icon-color, #fff);
	border-top: 4px solid transparent;
	border-bottom: 4px solid transparent;
}

.wpmg-thumb-nav {
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 50%;
	width: 26px;
	height: 26px;
	cursor: pointer;
	flex: 0 0 auto;
}

/* Carousel layout tweak: thumbs become the primary slider row */
.wpmg-gallery.wpmg-layout-carousel {
	flex-direction: column;
}
.wpmg-gallery.wpmg-layout-carousel .wpmg-thumb {
	width: 90px;
	height: 90px;
}

/* Modern grid layout */
.wpmg-gallery.wpmg-layout-grid_modern {
	flex-direction: column;
}
.wpmg-gallery.wpmg-layout-grid_modern .wpmg-stage {
	aspect-ratio: 4 / 5;
}
.wpmg-gallery.wpmg-layout-grid_modern .wpmg-thumb-track {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	overflow: visible;
}
.wpmg-gallery.wpmg-layout-grid_modern .wpmg-thumb {
	width: auto;
	height: 60px;
}

/* Zoom lens */
.wpmg-zoom-lens {
	position: absolute;
	width: 120px;
	height: 120px;
	border: 1px solid var(--wpmg-active-border, #2c6ecb);
	border-radius: 50%;
	pointer-events: none;
	background-repeat: no-repeat;
	box-shadow: 0 0 0 2000px rgba(255,255,255,.05);
	z-index: 5;
}

/* Lightbox */
.wpmg-lightbox {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,.9);
	display: none;
	align-items: center;
	justify-content: center;
	z-index: 100000;
}
.wpmg-lightbox.is-open { display: flex; }
.wpmg-lightbox-content {
	max-width: 90vw;
	max-height: 85vh;
}
.wpmg-lightbox-content img,
.wpmg-lightbox-content video,
.wpmg-lightbox-content iframe {
	max-width: 90vw;
	max-height: 85vh;
	width: 80vw;
	height: 70vh;
	border: 0;
}
.wpmg-lightbox-close,
.wpmg-lightbox-prev,
.wpmg-lightbox-next {
	position: absolute;
	background: rgba(255,255,255,.15);
	color: #fff;
	border: none;
	cursor: pointer;
	font-size: 22px;
	border-radius: 50%;
}
.wpmg-lightbox-close { top: 20px; right: 20px; width: 40px; height: 40px; }
.wpmg-lightbox-prev { left: 20px; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; }
.wpmg-lightbox-next { right: 20px; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; }

/* Shop loop overlays */
.wpmg-loop-video-badge {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 28px;
	height: 28px;
	background: rgba(0,0,0,.55);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 3;
}
.wpmg-loop-video-badge img { width: 14px; height: 14px; }

.wpmg-loop-hover-preview {
	position: absolute;
	inset: 0;
	z-index: 2;
	overflow: hidden;
}
.wpmg-loop-video {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border: 0;
}

ul.products li.product {
	position: relative;
}
