/* Four square thumbnails, horizontally scrollable. */
.woocommerce-product-gallery.cwspg-gallery .flex-control-thumbs {
	display: flex !important;
	flex-wrap: nowrap !important;
	gap: 10px;
	width: 100% !important;
	margin: 12px 0 0 !important;
	padding: 0 !important;
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	scroll-behavior: smooth;
	scrollbar-width: none;
	cursor: grab;
}

.woocommerce-product-gallery.cwspg-gallery .flex-control-thumbs::-webkit-scrollbar {
	display: none;
}

.woocommerce-product-gallery.cwspg-gallery .flex-control-thumbs:active,
.woocommerce-product-gallery.cwspg-gallery.cwspg-dragging-thumbs .flex-control-thumbs {
	cursor: grabbing;
}

.woocommerce-product-gallery.cwspg-gallery .flex-control-thumbs li {
	float: none !important;
	width: calc((100% - 30px) / 4) !important;
	max-width: none !important;
	flex: 0 0 calc((100% - 30px) / 4) !important;
	height: auto;
	margin: 0 !important;
	padding: 0 !important;
	aspect-ratio: 1 / 1;
	overflow: hidden;
}

.woocommerce-product-gallery.cwspg-gallery .flex-control-thumbs li img {
	display: block !important;
	width: 100% !important;
	height: 100% !important;
	margin: 0 !important;
	object-fit: cover;
	user-select: none;
	-webkit-user-drag: none;
	transition: opacity 180ms ease, outline-color 180ms ease;
}

.woocommerce-product-gallery.cwspg-gallery .flex-control-thumbs li img:not(.flex-active) {
	opacity: 0.62;
}

.woocommerce-product-gallery.cwspg-gallery .flex-control-thumbs li img.flex-active {
	opacity: 1;
	outline: 1px solid rgba(0, 0, 0, 0.35);
	outline-offset: -1px;
}

/* The native WooCommerce gallery handles touch swipes; this adds a mouse cursor
 * and a desktop swipe gesture without replacing FlexSlider. */
.woocommerce-product-gallery.cwspg-gallery .flex-viewport {
	cursor: grab;
}

.woocommerce-product-gallery.cwspg-gallery.cwspg-dragging-main .flex-viewport {
	cursor: grabbing;
}

.woocommerce-product-gallery.cwspg-gallery .flex-viewport img {
	user-select: none;
	-webkit-user-drag: none;
}

@media (max-width: 767px) {
	.woocommerce-product-gallery.cwspg-gallery .flex-control-thumbs {
		gap: 8px;
	}

	.woocommerce-product-gallery.cwspg-gallery .flex-control-thumbs li {
		width: calc((100% - 24px) / 4) !important;
		flex-basis: calc((100% - 24px) / 4) !important;
	}
}
