/**
 * Product gallery:
 * - Tablet + desktop (min-width: 768px): tight-gap grid, custom left nav (JS), vertical scroll in .nwcs-product-images-scroll.
 * - Mobile (max-width: 767px): horizontal swipe + dot pagination (no infinite loop).
 * Touch: tablet + mobile use touch-action: manipulation (+ overscroll hints) so gestures don’t trap page scroll.
 */

.product-template-default.single-product .site-content {
	max-width: 1400px;
	width: 90%;
}

.wishsuite-btn,
.htcompare-button-area {
	display: none !important;
}

.single-product .nwcs-product-top {
	display: grid;
	grid-template-columns: 55% 45%;
	gap: 100px;
	align-items: start;
	max-width: 1600px;
	margin: 0 auto;
	padding: 0px 60px;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

@media (max-width: 1200px) {
	.single-product .nwcs-product-top {
		gap: 60px;
		padding: 20px 40px;
	}
}

@media (max-width: 991px) {
	.single-product .nwcs-product-top {
		grid-template-columns: 1fr;
		gap: 40px;
		padding: 20px 20px;
	}
}

@media (max-width: 576px) {
	.single-product .nwcs-product-top {
		padding: 20px;
	}
}

.nwcs-product-top .summary.entry-summary {
	max-width: 100% !important;
}

/* ----- Tablet + desktop: tight grid + floating left nav (breakpoint matches JS 768px) -----
   Two-up tiles (1,2,4,5,…): 3:4. Full rows (3,6,…): square 1:1. Images use object-fit: cover. ----- */

@media (min-width: 768px) {
	/*
	 * Gallery column must not stretch to match the summary column (default grid align-items: stretch),
	 * or the bordered box grows tall and leaves empty space below the images.
	 */
	.single-product .nwcs-product-gallery.product-images {
		position: relative;
		width: 100%;
		height: fit-content;
		max-height: none;
		overflow: visible;
		border: 1px solid #e5e5e5;
		box-sizing: border-box;
		background: #fff;
		align-self: start;
	}

	/* Tall galleries scroll inside this cap; short galleries shrink to content (no forced min height). */
	.single-product .nwcs-product-gallery .nwcs-product-images-scroll {
		max-height: 685px;
		height: auto;
		min-height: 0;
		overflow-x: hidden;
		overflow-y: auto;
		scrollbar-width: none;
		-ms-overflow-style: none;
		position: relative;
		z-index: 1;
		box-sizing: border-box;
		-webkit-overflow-scrolling: touch;
		/* Same intent as mobile .product-images-wrapper: vertical gallery scroll + page scroll both usable */
		touch-action: manipulation;
		overscroll-behavior-x: contain;
		overscroll-behavior-y: auto;
	}

	.single-product .nwcs-product-gallery .nwcs-product-images-scroll::-webkit-scrollbar {
		display: none;
	}

	.single-product .nwcs-product-gallery .product-images-wrapper {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 4px;
		padding: 4px;
		height: auto;
		width: 100%;
		min-width: 0;
		box-sizing: border-box;
	}

	.single-product .nwcs-product-gallery .product-image-item {
		width: 100%;
		min-width: 0;
		overflow: hidden;
		background: #f5f5f5;
	}

	/* Two-up cells (1,2,4,5,7,8,…): same width × height in each row */
	.single-product .nwcs-product-gallery .product-image-item:not(:nth-child(3n)) {
		aspect-ratio: 4 / 5;
	}

	/* Full-width rows (3,6,9,…): square (1:1) on desktop/tablet */
	.single-product .nwcs-product-gallery .product-image-item:nth-child(3n) {
		grid-column: 1 / -1;
		justify-self: stretch;
		width: 100%;
		max-width: 100%;
		aspect-ratio: 4 / 5;
		position: relative;
	}

	.single-product .nwcs-product-gallery .product-images-wrapper img {
		width: 100%;
		height: 100%;
		max-width: none;
		max-height: none;
		display: block;
		object-fit: cover;
		object-position: center;
	}

	.single-product .nwcs-product-gallery .product-image-item:nth-child(3n) img {
		position: absolute;
		left: 0;
		top: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		height: 100%;
		object-fit: cover;
		object-position: center;
	}

	/* Left: up / track+thumb / down — hidden when no overflow (JS) */
	.nwcs-desktop-gallery-nav {
		position: absolute;
		left: 10px;
		top: 50%;
		transform: translateY(-50%);
		z-index: 6;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		gap: 6px;
		pointer-events: none;
	}

	.nwcs-desktop-gallery-nav.is-hidden {
		display: none !important;
	}

	.nwcs-desktop-gallery-nav--no-scroll {
		opacity: 0.35;
		pointer-events: none;
	}

	.nwcs-desktop-gallery-nav__btn {
		pointer-events: auto;
		width: 32px;
		height: 32px;
		padding: 0;
		border: none;
		border-radius: 50%;
		background: rgba(255, 255, 255, 0.95);
		box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
		color: #333;
		cursor: pointer;
		display: flex;
		align-items: center;
		justify-content: center;
		transition: background 0.15s ease, color 0.15s ease;
	}

	.nwcs-desktop-gallery-nav__btn:hover {
		background: #fff;
		color: #000;
	}

	.nwcs-desktop-gallery-nav__btn svg {
		display: block;
	}

	.nwcs-desktop-gallery-nav__track {
		position: relative;
		width: 10px;
		height: 132px;
		border-radius: 999px;
		background: rgba(255, 255, 255, 0.95);
		box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
		pointer-events: none;
		flex-shrink: 0;
	}

	.nwcs-desktop-gallery-nav__thumb {
		position: absolute;
		left: 2px;
		right: 2px;
		width: auto;
		min-height: 28px;
		border-radius: 999px;
		background: #4a4a4a;
		top: 0;
	}
}

@media (max-width: 767px) {
	.nwcs-desktop-gallery-nav {
		display: none !important;
	}
}

.nwcs-gallery-pagination {
	display: none;
}

/* ----- Mobile only: horizontal gallery (JS breakpoint max 767px) ----- */

@media (max-width: 767px) {
	.single-product .nwcs-product-gallery.product-images {
		position: relative;
		overflow: visible;
		border: none;
		padding-bottom: 0;
		--nwcs-gallery-vh-offset: 11rem;
	}

	/* Inner scroll wrapper is desktop-only; reset so horizontal carousel uses the wrapper. */
	.single-product .nwcs-product-gallery .nwcs-product-images-scroll {
		height: auto !important;
		min-height: 0;
		max-height: none;
		overflow: visible !important;
	}

	.single-product .nwcs-product-gallery .product-images-wrapper {
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-items: stretch;
		gap: 0;
		padding: 0;
		width: 100%;
		height: calc(100vh - var(--nwcs-gallery-vh-offset));
		height: calc(100dvh - var(--nwcs-gallery-vh-offset));
		min-height: 280px;
		max-height: calc(70dvh - 4rem);
		overflow-x: auto;
		overflow-y: hidden;
		-webkit-overflow-scrolling: touch;
		scroll-snap-type: x mandatory;
		scroll-behavior: auto;
		/* pan-x alone blocks vertical page scroll when the gesture starts on the gallery */
		touch-action: manipulation;
		overscroll-behavior-x: contain;
		overscroll-behavior-y: auto;
		scrollbar-width: none;
	}

	.single-product .nwcs-product-gallery .product-images-wrapper::-webkit-scrollbar {
		display: none;
	}

	.single-product .nwcs-product-gallery .product-image-item {
		flex: 0 0 100%;
		width: 100%;
		min-width: 100%;
		max-width: 100%;
		height: 100%;
		min-height: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		scroll-snap-align: start;
		scroll-snap-stop: always;
		box-sizing: border-box;
		background: #f5f5f5;
		overflow: hidden;
	}

	.single-product .nwcs-product-gallery .product-image-item:nth-child(3n) {
		grid-column: auto;
	}

	/* Same frame for every slide; crop with cover so all tiles match visually */
	.single-product .nwcs-product-gallery .product-images-wrapper img {
		width: 100%;
		height: 100%;
		max-width: 100%;
		max-height: 100%;
		display: block;
		object-fit: cover;
		object-position: center;
		background: #f5f5f5;
	}

	.nwcs-gallery-pagination {
		display: flex;
		justify-content: center;
		align-items: center;
		position: absolute;
		left: 0;
		right: 0;
		bottom: 14px;
		z-index: 2;
		pointer-events: none;
	}

	.nwcs-gallery-pagination.is-hidden {
		display: none !important;
	}

	.nwcs-gallery-pagination__inner {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		gap: 7px;
		padding: 9px 14px;
		background: rgba(255, 255, 255, 0.96);
		border-radius: 999px;
		box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
		pointer-events: auto;
	}

	.nwcs-gallery-pagination__dot {
		display: block;
		border: none;
		margin: 0;
		padding: 0;
		cursor: pointer;
		flex-shrink: 0;
		transition: background 0.08s ease-out, width 0.08s ease-out, height 0.08s ease-out, border-radius 0.08s ease-out;
		-webkit-tap-highlight-color: transparent;
	}

	.nwcs-gallery-pagination__dot:not(.nwcs-gallery-pagination__dot--active) {
		width: 6px;
		height: 6px;
		border-radius: 50%;
		background: #c8c8c8;
	}

	.nwcs-gallery-pagination__dot.nwcs-gallery-pagination__dot--active {
		width: 26px;
		height: 8px;
		border-radius: 999px;
		background: #3a3a3a;
	}
}

/* Mobile only: inset spacing (not edge-to-edge) */
@media (max-width: 767px) {
	.single-product .nwcs-product-top .nwcs-product-gallery.product-images {
		width: 100%;
		max-width: 100%;
		margin-left: 0;
		margin-right: 0;
		padding-left: max(12px, env(safe-area-inset-left));
		padding-right: max(12px, env(safe-area-inset-right));
		box-sizing: border-box;
		--nwcs-gallery-vh-offset: 10rem;
	}
}
