/**
 * IPIS – kwadratowa galeria WooCommerce
 */

body.single-product .elementor-widget-woocommerce-product-images .woocommerce-product-gallery {
	--ipis-gallery-gap: 10px;
	--ipis-gallery-columns: 4;
	--ipis-gallery-arrow-size: 40px;
	--ipis-gallery-arrow-color: #1f94d2;
	--ipis-gallery-arrow-color-hover: #187cad;
	--ipis-gallery-focus-color: #111827;
	width: 100% !important;
	max-width: none !important;
}

/* Zdjęcie główne zawsze ma proporcje 1:1. */
body.single-product .elementor-widget-woocommerce-product-images .woocommerce-product-gallery .flex-viewport {
	width: 100%;
	height: auto !important;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	background: #f5f5f5;
}

body.single-product .elementor-widget-woocommerce-product-images .woocommerce-product-gallery .flex-viewport .woocommerce-product-gallery__wrapper,
body.single-product .elementor-widget-woocommerce-product-images .woocommerce-product-gallery .flex-viewport .woocommerce-product-gallery__image,
body.single-product .elementor-widget-woocommerce-product-images .woocommerce-product-gallery .flex-viewport .woocommerce-product-gallery__image > a {
	height: 100% !important;
}

body.single-product .elementor-widget-woocommerce-product-images .woocommerce-product-gallery .flex-viewport .woocommerce-product-gallery__image > a {
	display: block;
	width: 100%;
}

body.single-product .elementor-widget-woocommerce-product-images .woocommerce-product-gallery .flex-viewport .woocommerce-product-gallery__image img:not(.zoomImg) {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	margin: 0 !important;
	object-fit: cover;
	object-position: center;
}

/* Pasek miniaturek ze strzałkami. */
body.single-product .elementor-widget-woocommerce-product-images .ipis-gallery-navigation {
	display: flex;
	flex-direction: column;
	width: 100%;
	margin-top: 10px;
}

body.single-product .elementor-widget-woocommerce-product-images .ipis-gallery-actions {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 7px;
	width: 100%;
	margin: 0 0 8px;
}

body.single-product .elementor-widget-woocommerce-product-images .ipis-gallery-thumbs-viewport {
	width: 100%;
	min-width: 0;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-behavior: smooth;
	scrollbar-width: none;
	overscroll-behavior-inline: contain;
	-webkit-overflow-scrolling: touch;
}

body.single-product .elementor-widget-woocommerce-product-images .ipis-gallery-thumbs-viewport::-webkit-scrollbar {
	display: none;
}

body.single-product .elementor-widget-woocommerce-product-images ol.flex-control-thumbs {
	display: flex !important;
	flex-flow: row nowrap !important;
	gap: var(--ipis-gallery-gap);
	width: 100%;
	margin: 0 !important;
	padding: 0 !important;
	list-style: none !important;
	transform: none !important;
}

body.single-product .elementor-widget-woocommerce-product-images ol.flex-control-thumbs li {
	flex: 0 0 calc(25% - 7.5px) !important;
	float: none !important;
	width: auto !important;
	margin: 0 !important;
	padding: 0 !important;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	background: #f5f5f5;
	cursor: pointer;
}

body.single-product .elementor-widget-woocommerce-product-images ol.flex-control-thumbs li img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	margin: 0 !important;
	object-fit: cover;
	object-position: center;
	opacity: 0.66;
	transition: opacity 180ms ease, box-shadow 180ms ease;
}

body.single-product .elementor-widget-woocommerce-product-images ol.flex-control-thumbs li img:hover,
body.single-product .elementor-widget-woocommerce-product-images ol.flex-control-thumbs li img.flex-active {
	opacity: 1;
}

body.single-product .elementor-widget-woocommerce-product-images ol.flex-control-thumbs li img.flex-active {
	box-shadow: inset 0 0 0 2px var(--ipis-gallery-focus-color);
}

body.single-product .elementor-widget-woocommerce-product-images .ipis-gallery-arrow {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--ipis-gallery-arrow-size);
	min-width: 0;
	height: var(--ipis-gallery-arrow-size);
	min-height: var(--ipis-gallery-arrow-size);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: var(--ipis-gallery-arrow-color);
	color: #fff;
	font: inherit;
	cursor: pointer;
	transition: background-color 180ms ease, opacity 180ms ease;
	-webkit-tap-highlight-color: transparent;
}

body.single-product .elementor-widget-woocommerce-product-images .ipis-gallery-arrow:hover,
body.single-product .elementor-widget-woocommerce-product-images .ipis-gallery-arrow:focus-visible {
	background: var(--ipis-gallery-arrow-color-hover);
	color: #fff;
}

body.single-product .elementor-widget-woocommerce-product-images .ipis-gallery-arrow:focus-visible {
	outline: 2px solid var(--ipis-gallery-focus-color);
	outline-offset: 2px;
}

body.single-product .elementor-widget-woocommerce-product-images .ipis-gallery-arrow:disabled {
	opacity: 0.3;
	cursor: default;
}

body.single-product .elementor-widget-woocommerce-product-images .ipis-gallery-navigation.ipis-gallery-no-overflow {
	margin-top: 10px;
}

body.single-product .elementor-widget-woocommerce-product-images .ipis-gallery-navigation.ipis-gallery-no-overflow .ipis-gallery-actions {
	display: none;
}

body.single-product .elementor-widget-woocommerce-product-images .ipis-gallery-arrow svg {
	display: block;
	width: 18px;
	height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

@media (max-width: 1024px) {
	body.single-product .elementor-widget-woocommerce-product-images .woocommerce-product-gallery {
		--ipis-gallery-gap: 8px;
		--ipis-gallery-arrow-size: 38px;
	}

	body.single-product .elementor-widget-woocommerce-product-images ol.flex-control-thumbs li {
		flex-basis: calc(25% - 6px) !important;
	}
}

@media (max-width: 767px) {
	body.single-product .elementor-widget-woocommerce-product-images .woocommerce-product-gallery {
		--ipis-gallery-columns: 3;
		--ipis-gallery-gap: 7px;
		--ipis-gallery-arrow-size: 36px;
	}

	body.single-product .elementor-widget-woocommerce-product-images ol.flex-control-thumbs li {
		flex-basis: calc(33.333333% - 4.666667px) !important;
	}

	body.single-product .elementor-widget-woocommerce-product-images .ipis-gallery-navigation {
		margin-top: 8px;
	}

	body.single-product .elementor-widget-woocommerce-product-images .ipis-gallery-actions {
		gap: 6px;
		margin-bottom: 7px;
	}
}

@media (prefers-reduced-motion: reduce) {
	body.single-product .elementor-widget-woocommerce-product-images .ipis-gallery-thumbs-viewport {
		scroll-behavior: auto;
	}

	body.single-product .elementor-widget-woocommerce-product-images ol.flex-control-thumbs li img,
	body.single-product .elementor-widget-woocommerce-product-images .ipis-gallery-arrow {
		transition: none;
	}
}
