/**
 * Single product gallery (WoodMart child).
 * Scoped to .single-product .woocommerce-product-gallery — uses WoodMart classes/CSS variables.
 * Mobile breakpoint: WoodMart max-width 1024px / min-width 1025px.
 */

.single-product .woocommerce-product-gallery {
	--nxm-surface: var(--wd-main-bgcolor);
	--nxm-border: var(--wd-form-brd-color);
	--nxm-border-strong: var(--wd-form-brd-color);
	--nxm-accent: var(--btn-accented-bgcolor);
	--nxm-accent-hover: var(--btn-accented-bgcolor-hover);
	--nxm-accent-soft: color-mix(in srgb, var(--wd-primary-color) 12%, var(--wd-main-bgcolor));
	--nxm-text-soft: var(--wd-text-color);
	--nxm-text-muted: var(--wd-text-muted-color);
	--nxm-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
	--nxm-radius: var(--wd-brd-radius);
	--nxm-thumb-gap: var(--wd-gallery-gap, var(--wd-gap, 10px));
	--nxm-thumb-inset: 6px;
}

/* -------------------------------------------------------------------------
 * Desktop: keep left thumbs beside the main image after Swiper init
 * ------------------------------------------------------------------------- */
@media (min-width: 1025px) {
	.single-product .woocommerce-product-gallery.thumbs-position-left.wd-has-thumb {
		flex-wrap: nowrap;
		align-items: stretch;
	}

	.single-product .woocommerce-product-gallery.thumbs-position-left.wd-has-thumb .wd-gallery-images {
		flex: 1 1 auto;
		width: auto;
		min-width: 0;
		max-width: calc(100% - var(--wd-thumbs-width, 132px));
		align-self: stretch;
	}

	.single-product .woocommerce-product-gallery.thumbs-position-left .wd-gallery-thumb {
		flex: 0 0 var(--wd-thumbs-width, 132px);
		width: var(--wd-thumbs-width, 132px);
		max-width: var(--wd-thumbs-width, 132px);
		align-self: stretch;
	}

	.single-product .woocommerce-product-gallery.thumbs-position-left .wd-thumb-nav {
		--wd-arrow-bg: var(--nxm-surface);
		--wd-arrow-bg-hover: var(--nxm-accent-soft);
		--wd-arrow-bg-dis: var(--nxm-surface);
		--wd-arrow-color: var(--nxm-text-soft);
		--wd-arrow-color-hover: var(--nxm-accent);
		--wd-arrow-color-dis: var(--nxm-text-muted);
		--wd-arrow-brd: 1px solid;
		--wd-arrow-brd-color: var(--nxm-border);
		--wd-arrow-brd-color-hover: var(--nxm-accent);
		--wd-arrow-radius: 8px;
		--wd-arrow-shadow: var(--nxm-shadow);
	}
}

/* -------------------------------------------------------------------------
 * Main image card — desktop 1:1; mobile 4:3 (WoodMart ≤1024)
 * ------------------------------------------------------------------------- */
.single-product .woocommerce-product-gallery .wd-gallery-images {
	position: relative;
	background: var(--nxm-surface);
	border: 1px solid var(--nxm-border);
	border-radius: var(--nxm-radius);
	box-shadow: var(--nxm-shadow);
	overflow: hidden;
	aspect-ratio: 1 / 1;
}

@media (max-width: 1024px) {
	.single-product .woocommerce-product-gallery .wd-gallery-images {
		aspect-ratio: 4 / 3;
	}
}

.single-product .woocommerce-product-gallery .wd-gallery-images .wd-carousel-inner,
.single-product .woocommerce-product-gallery .wd-gallery-images .wd-carousel,
.single-product .woocommerce-product-gallery .wd-gallery-images .wd-carousel-item {
	height: 100%;
}

.single-product .woocommerce-product-gallery .wd-gallery-images .woocommerce-product-gallery__image {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	background: var(--nxm-surface);
	overflow: hidden;
	border-radius: 0;
}

.single-product .woocommerce-product-gallery .wd-gallery-images .woocommerce-product-gallery__image a {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	padding: 0;
	box-sizing: border-box;
}

.single-product .woocommerce-product-gallery .wd-gallery-images .woocommerce-product-gallery__image img,
.single-product .woocommerce-product-gallery .wd-gallery-images .woocommerce-product-gallery__image .wp-post-image {
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	object-position: center;
	margin: 0;
	border-radius: 0;
}

.single-product .woocommerce-product-gallery .zoomImg {
	background-color: var(--nxm-surface);
}

/* -------------------------------------------------------------------------
 * Main gallery arrows — style only; WoodMart hover opacity/transform untouched
 * Card overflow:hidden. WoodMart pos-sep: inset = 100% + offset → negative
 * offset pulls arrows inside. Gallery default is calc(size / -1).
 * ------------------------------------------------------------------------- */
.single-product .woocommerce-product-gallery .wd-gallery-images .wd-nav-arrows {
	--wd-arrow-size: 36px;
	--wd-arrow-icon-size: 16px;
	--wd-arrow-bg: var(--nxm-surface);
	--wd-arrow-bg-hover: var(--nxm-accent-soft);
	--wd-arrow-bg-dis: var(--nxm-surface);
	--wd-arrow-color: var(--nxm-text-soft);
	--wd-arrow-color-hover: var(--nxm-accent);
	--wd-arrow-color-dis: var(--nxm-text-muted);
	--wd-arrow-brd: 1px solid;
	--wd-arrow-brd-color: var(--nxm-border);
	--wd-arrow-brd-color-hover: var(--nxm-accent);
	--wd-arrow-radius: 999px;
	--wd-arrow-shadow: var(--nxm-shadow);
}

/* 12px inset from card edge (size + gap), still inside overflow:hidden. */
.single-product .woocommerce-product-gallery .wd-gallery-images .wd-nav-arrows.wd-pos-sep {
	--wd-arrow-offset-h: calc((var(--wd-arrow-size, 36px) + 12px) * -1);
}

/* -------------------------------------------------------------------------
 * Zoom button
 * ------------------------------------------------------------------------- */
.single-product .woocommerce-product-gallery .product-additional-galleries {
	inset-inline-start: auto;
	inset-inline-end: 16px;
	bottom: 16px;
	padding: 0;
	align-items: flex-end;
}

.single-product .woocommerce-product-gallery .wd-gallery-btn.wd-action-btn.wd-style-icon-bg-text {
	--wd-action-icon-size: 16px;
	--wd-action-h: 36px;
	--wd-action-w: 36px;
	--wd-action-color: var(--nxm-text-soft);
	--wd-action-color-hover: var(--nxm-accent);
}

.single-product .woocommerce-product-gallery .wd-gallery-btn.wd-action-btn.wd-style-icon-bg-text > a {
	min-width: var(--wd-action-w);
	height: var(--wd-action-h);
	border: 1px solid var(--nxm-border);
	border-radius: 999px;
	background-color: var(--nxm-surface);
	box-shadow: var(--nxm-shadow);
	color: var(--nxm-text-soft);
}

.single-product .woocommerce-product-gallery .wd-gallery-btn.wd-action-btn.wd-style-icon-bg-text > a:hover {
	border-color: var(--nxm-accent);
	background-color: var(--nxm-surface);
	color: var(--nxm-accent);
}

.single-product .woocommerce-product-gallery .wd-gallery-btn.wd-action-btn.wd-style-icon-bg-text .wd-action-text {
	max-width: 160px;
	padding-inline-end: 14px;
	font-size: 13px;
	font-weight: 500;
	letter-spacing: 0;
}

.single-product .woocommerce-product-gallery .wd-gallery-btn.wd-action-btn.wd-style-icon-bg-text > a:hover .wd-action-text {
	padding-inline-end: 14px;
	max-width: 160px;
}

/* -------------------------------------------------------------------------
 * Thumbnails — fixed square cells, object-fit: contain, centered
 * Beats WoodMart left-thumbs object-fit:cover and col-*:auto height:auto.
 * Img is absolutely filled so intrinsic portrait size cannot stretch the cell.
 * ------------------------------------------------------------------------- */
.single-product .woocommerce-product-gallery .wd-gallery-thumb .wd-carousel-item {
	position: relative;
	box-sizing: border-box;
	aspect-ratio: 1 / 1;
	min-width: 0;
	min-height: 0;
	background: transparent;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	overflow: hidden;
	opacity: 1;
	cursor: pointer;
}

.single-product .woocommerce-product-gallery .wd-gallery-thumb :is(.wd-carousel-item:hover, .wd-thumb-active, .wd-carousel:not(.wd-initialized) .wd-carousel-item:first-child) {
	opacity: 1;
}

.single-product .woocommerce-product-gallery .wd-gallery-thumb .wd-carousel-item img {
	position: absolute;
	inset: 0;
	box-sizing: border-box;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: var(--nxm-thumb-inset);
	object-fit: contain;
	object-position: center;
	background: var(--nxm-surface);
	border: 1px solid var(--nxm-border);
	border-radius: 10px;
	box-shadow: none;
	transition: border-color 0.2s ease;
}

.single-product .woocommerce-product-gallery .wd-gallery-thumb .wd-carousel-item:hover img {
	border-color: var(--nxm-border-strong);
}

.single-product .woocommerce-product-gallery .wd-gallery-thumb .wd-carousel-item.wd-thumb-active img,
.single-product .woocommerce-product-gallery .wd-gallery-thumb .wd-carousel:not(.wd-initialized) .wd-carousel-item:first-child img {
	border-color: var(--nxm-accent);
}

/* Desktop left column: square stack.
 * !important on height: WoodMart carousel JS writes inline height on slides;
 * without it aspect-ratio cannot produce 1:1 cells.
 * Carousel shortens by --nxm-thumb-gap so last square never flushes into nav. */
@media (min-width: 1025px) {
	.single-product .woocommerce-product-gallery.thumbs-position-left .wd-gallery-thumb .wd-carousel {
		height: calc(var(--wd-thumbs-height, 100%) - 30px - var(--nxm-thumb-gap));
		margin-bottom: var(--nxm-thumb-gap);
	}

	.single-product .woocommerce-product-gallery.thumbs-position-left .wd-gallery-thumb .wd-carousel-item,
	.single-product .woocommerce-product-gallery.thumbs-position-left [style*="col-lg:auto"] .wd-carousel-item {
		flex: 0 0 auto;
		width: 100%;
		max-width: none;
		height: auto !important;
		padding-inline: 0;
		margin-bottom: var(--nxm-thumb-gap);
	}

	.single-product .woocommerce-product-gallery.thumbs-position-left .wd-gallery-thumb .wd-carousel-item img,
	.single-product .woocommerce-product-gallery.thumbs-position-left [style*="col-lg:auto"] .wd-carousel-item img {
		margin: 0;
		object-fit: contain;
	}
}

/* -------------------------------------------------------------------------
 * Mobile / tablet (WoodMart ≤1024): square strip flush with main card
 * Replace WoodMart padding + negative-margin gap trick with explicit
 * flex-basis + margin-inline-end so cell edges meet the card edges.
 * ------------------------------------------------------------------------- */
@media (max-width: 1024px) {
	.single-product .woocommerce-product-gallery .wd-gallery-thumb .wd-carousel {
		margin-inline: 0;
		max-width: 100%;
	}

	.single-product .woocommerce-product-gallery .wd-gallery-thumb .wd-carousel-item,
	.single-product .woocommerce-product-gallery.thumbs-position-left [style*="col-sm:auto"] .wd-carousel-item,
	.single-product .woocommerce-product-gallery.thumbs-position-left [style*="col-md:auto"] .wd-carousel-item {
		--nxm-thumb-cell: calc((100% - (var(--wd-col) - 1) * var(--wd-gap)) / var(--wd-col));
		flex: 0 0 var(--nxm-thumb-cell);
		width: var(--nxm-thumb-cell);
		max-width: var(--nxm-thumb-cell);
		/* Same reason as desktop: Swiper may write inline height. */
		height: auto !important;
		padding-inline: 0;
		margin-inline-end: var(--wd-gap);
		margin-bottom: 0;
	}

	.single-product .woocommerce-product-gallery .wd-gallery-thumb .wd-carousel-item img,
	.single-product .woocommerce-product-gallery.thumbs-position-left [style*="col-sm:auto"] .wd-carousel-item img,
	.single-product .woocommerce-product-gallery.thumbs-position-left [style*="col-md:auto"] .wd-carousel-item img {
		width: 100%;
		height: 100%;
		margin: 0;
		object-fit: contain;
	}

	.single-product .woocommerce-product-gallery .wd-gallery-btn.wd-action-btn.wd-style-icon-bg-text .wd-action-text {
		max-width: 0;
		padding-inline-end: 0;
	}

	.single-product .woocommerce-product-gallery .wd-gallery-btn.wd-action-btn.wd-style-icon-bg-text > a:hover .wd-action-text {
		max-width: 0;
		padding-inline-end: 0;
	}

	/* Strip arrows: sit on the strip edge (readable over cells if needed). */
	.single-product .woocommerce-product-gallery .wd-gallery-thumb .wd-nav-arrows.wd-pos-sep {
		--wd-arrow-offset-h: calc(var(--wd-arrow-size, 36px) * -1);
	}
}
