/*
 * Coinable single-product image correction.
 * The selectors intentionally cover standard WooCommerce, FlexSlider, and
 * common theme wrappers without changing the product form or YITH options.
 */
body.single-product.coinable-product-image-fit-active div.product .woocommerce-product-gallery,
body.single-product.coinable-product-image-fit-active div.product .woocommerce-product-gallery__wrapper,
body.single-product.coinable-product-image-fit-active div.product .flex-viewport {
	max-width: 100% !important;
}

body.single-product.coinable-product-image-fit-active div.product .woocommerce-product-gallery__image,
body.single-product.coinable-product-image-fit-active div.product .woocommerce-product-gallery__image > a {
	box-sizing: border-box !important;
	width: 100% !important;
	max-width: 100% !important;
}

body.single-product.coinable-product-image-fit-active div.product .woocommerce-product-gallery__image > a {
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	overflow: hidden !important;
	background: transparent !important;
}

body.single-product.coinable-product-image-fit-active div.product .woocommerce-product-gallery__image img:not(.zoomImg),
body.single-product.coinable-product-image-fit-active div.product .woocommerce-product-gallery img.wp-post-image,
body.single-product.coinable-product-image-fit-active div.product .flex-viewport img:not(.zoomImg) {
	display: block !important;
	width: auto !important;
	max-width: 100% !important;
	height: auto !important;
	max-height: min(72vh, 760px) !important;
	margin: 0 auto !important;
	object-fit: contain !important;
	object-position: center center !important;
	transform: none !important;
	transform-origin: center center !important;
}

/* WooCommerce's zoom plugin injects a second, oversized image. A stale or
 * theme-conflicted copy is the usual cause of the permanently zoomed view. */
body.single-product.coinable-product-image-fit-active div.product .woocommerce-product-gallery img.zoomImg,
body.single-product.coinable-product-image-fit-active div.product .woocommerce-product-gallery .zoomImg {
	display: none !important;
	opacity: 0 !important;
	visibility: hidden !important;
	pointer-events: none !important;
}

/* Keep gallery thumbnails proportional too, but do not enlarge small files. */
body.single-product.coinable-product-image-fit-active div.product .flex-control-thumbs img {
	width: 100% !important;
	height: auto !important;
	aspect-ratio: 1 / 1;
	object-fit: contain !important;
	object-position: center !important;
}

@media (max-width: 782px) {
	body.single-product.coinable-product-image-fit-active div.product .woocommerce-product-gallery__image img:not(.zoomImg),
	body.single-product.coinable-product-image-fit-active div.product .woocommerce-product-gallery img.wp-post-image,
	body.single-product.coinable-product-image-fit-active div.product .flex-viewport img:not(.zoomImg) {
		max-height: 64vh !important;
	}
}
