/* EduMagnet TpT-style WooCommerce product gallery */
body.single-product .woocommerce-product-gallery {
	--em-gallery-gap: 18px;
	--em-thumb-size: 88px;
	min-width: 0;
}

/* Make the product preview area more prominent without rebuilding the theme. */
@media (min-width: 1024px) {
	body.single-product .woocommerce div.product div.images.woocommerce-product-gallery {
		width: 58%;
	}

	body.single-product .woocommerce div.product div.summary {
		width: 38%;
	}
}

/* FlexSlider adds .flex-viewport dynamically. Turn the gallery itself into a 2-column preview. */
@media (min-width: 769px) {
	body.single-product .woocommerce-product-gallery.em-tpt-gallery-ready,
	body.single-product .woocommerce-product-gallery:has(.flex-control-thumbs) {
		display: grid;
		grid-template-columns: var(--em-thumb-size) minmax(0, 1fr);
		grid-template-rows: auto;
		column-gap: var(--em-gallery-gap);
		align-items: start;
	}

	body.single-product .woocommerce-product-gallery.em-tpt-gallery-ready > .flex-viewport,
	body.single-product .woocommerce-product-gallery:has(.flex-control-thumbs) > .flex-viewport {
		grid-column: 2;
		grid-row: 1;
		width: 100% !important;
		min-width: 0;
		border: 1px solid #e7e3ea;
		border-radius: 18px;
		background: #fff;
		overflow: hidden;
		box-sizing: border-box;
	}

	body.single-product .woocommerce-product-gallery.em-tpt-gallery-ready > .flex-control-thumbs,
	body.single-product .woocommerce-product-gallery:has(.flex-control-thumbs) > .flex-control-thumbs {
		grid-column: 1;
		grid-row: 1;
		display: flex !important;
		flex-direction: column;
		gap: 12px;
		margin: 0 !important;
		padding: 0 !important;
		list-style: none !important;
		width: var(--em-thumb-size) !important;
		max-height: 720px;
		overflow-y: auto;
		overflow-x: hidden;
		scrollbar-width: thin;
	}

	body.single-product .woocommerce-product-gallery.em-tpt-gallery-ready > .flex-control-thumbs li,
	body.single-product .woocommerce-product-gallery:has(.flex-control-thumbs) > .flex-control-thumbs li {
		float: none !important;
		width: var(--em-thumb-size) !important;
		margin: 0 !important;
		padding: 0 !important;
		flex: 0 0 auto;
	}
}

/* Thumbnail cards */
body.single-product .woocommerce-product-gallery .flex-control-thumbs li {
	box-sizing: border-box;
}

body.single-product .woocommerce-product-gallery .flex-control-thumbs img {
	display: block;
	width: 100% !important;
	aspect-ratio: 1 / 1;
	height: auto !important;
	object-fit: contain !important;
	object-position: center;
	background: #fff;
	border: 2px solid #e6e0ea;
	border-radius: 12px;
	padding: 5px;
	box-sizing: border-box;
	opacity: 1 !important;
	cursor: pointer;
	transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

body.single-product .woocommerce-product-gallery .flex-control-thumbs img.flex-active,
body.single-product .woocommerce-product-gallery .flex-control-thumbs img:hover,
body.single-product .woocommerce-product-gallery .flex-control-thumbs img:focus {
	border-color: #f1c232;
	box-shadow: 0 0 0 2px rgba(83, 24, 105, .16);
	outline: none;
}

@media (hover: hover) and (pointer: fine) {
	body.single-product .woocommerce-product-gallery .flex-control-thumbs img:hover {
		transform: translateY(-1px);
	}
}

/* Keep every resource page fully visible instead of cropping. */
body.single-product .woocommerce-product-gallery .woocommerce-product-gallery__image,
body.single-product .woocommerce-product-gallery .woocommerce-product-gallery__image a {
	background: #fff;
}

body.single-product .woocommerce-product-gallery .woocommerce-product-gallery__image img {
	display: block;
	width: 100% !important;
	height: auto !important;
	max-height: 760px;
	object-fit: contain !important;
	object-position: center;
	margin: 0 auto;
	background: #fff;
}

/* Keep the zoom control clear of the thumbnail rail. */
body.single-product .woocommerce-product-gallery .woocommerce-product-gallery__trigger {
	z-index: 20;
	top: 14px !important;
	right: 14px !important;
	left: auto !important;
}

/* Cleaner product summary spacing to complement the larger gallery. */
body.single-product .woocommerce div.product div.summary {
	min-width: 0;
}

body.single-product .woocommerce div.product .product_title {
	line-height: 1.18;
	margin-bottom: 18px;
}

/* Mobile/tablet: main image first, thumbnails as a horizontal swipe strip underneath. */
@media (max-width: 768px) {
	body.single-product .woocommerce div.product div.images.woocommerce-product-gallery,
	body.single-product .woocommerce div.product div.summary {
		width: 100% !important;
		float: none !important;
	}

	body.single-product .woocommerce-product-gallery > .flex-viewport {
		border: 1px solid #e7e3ea;
		border-radius: 16px;
		background: #fff;
		overflow: hidden;
	}

	body.single-product .woocommerce-product-gallery .flex-control-thumbs {
		display: flex !important;
		flex-wrap: nowrap !important;
		gap: 10px;
		overflow-x: auto;
		overflow-y: hidden;
		margin: 12px 0 0 !important;
		padding: 2px 2px 8px !important;
		list-style: none !important;
		-webkit-overflow-scrolling: touch;
		scroll-snap-type: x proximity;
	}

	body.single-product .woocommerce-product-gallery .flex-control-thumbs li {
		float: none !important;
		width: 72px !important;
		min-width: 72px !important;
		margin: 0 !important;
		scroll-snap-align: start;
	}

	body.single-product .woocommerce-product-gallery .woocommerce-product-gallery__image img {
		max-height: none;
	}
}
