/**
 * Lewenstein Product Gallery — base layout.
 *
 * Colors, gaps and opacities that are also exposed as Divi module settings
 * only appear here as sensible fallbacks; the builder's generated CSS
 * (higher specificity via the module's own `.et_pb_module` class) overrides
 * them once a value differs from the default.
 */

.lw-gallery {
	display: flex;
	align-items: flex-start;
	gap: 20px;
	width: 100%;
}

.lw-gallery--thumbs-left {
	flex-direction: row;
}

.lw-gallery--thumbs-right {
	flex-direction: row-reverse;
}

.lw-gallery--thumbs-bottom {
	flex-direction: column;
}

.lw-gallery__main {
	flex: 1 1 0%;
	min-width: 0;
	width: 100%;
}

/*
 * WooCommerce's own `woocommerce-layout.css` still ships the pre-flexbox
 * default theme rule `.woocommerce div.product div.images { float: left;
 * width: 48%; }`. Our gallery wrapper keeps the `images` class (for anything
 * else that targets it), so that legacy rule can still match here and would
 * otherwise leave the main image squeezed into less than half its column
 * with dead space beside it. `!important` is used deliberately to guarantee
 * this wins regardless of stylesheet print order.
 */
.lw-gallery__main .lw-gallery__source {
	margin: 0;
	width: 100% !important;
	max-width: 100% !important;
	float: none !important;
}

.lw-gallery__main .lw-gallery__source img.wp-post-image {
	width: 100%;
	height: auto;
}

/* Thumbnail column/row ------------------------------------------------- */

.lw-gallery__thumbs {
	position: relative;
	display: flex;
	flex: 0 0 auto;
}

.lw-gallery--thumbs-left .lw-gallery__thumbs,
.lw-gallery--thumbs-right .lw-gallery__thumbs {
	flex-direction: column;
	width: 96px;
}

.lw-gallery--thumbs-bottom .lw-gallery__thumbs {
	flex-direction: row;
	width: 100%;
}

.lw-gallery__track {
	overflow: hidden;
	scroll-behavior: smooth;
	scrollbar-width: thin;
	width: 100%;
}

.lw-gallery--thumbs-left .lw-gallery__track,
.lw-gallery--thumbs-right .lw-gallery__track {
	overflow-y: auto;
	overflow-x: hidden;
	scroll-snap-type: y mandatory;
}

.lw-gallery--thumbs-bottom .lw-gallery__track {
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
}

.lw-gallery__track .flex-control-nav {
	display: flex;
	list-style: none;
	margin: 0;
	padding: 0;
	gap: 10px;
}

.lw-gallery--thumbs-left .lw-gallery__track .flex-control-nav,
.lw-gallery--thumbs-right .lw-gallery__track .flex-control-nav {
	flex-direction: column;
}

.lw-gallery--thumbs-bottom .lw-gallery__track .flex-control-nav {
	flex-direction: row;
}

.lw-gallery__track .flex-control-nav li {
	flex: 0 0 auto;
	scroll-snap-align: start;
}

.lw-gallery--thumbs-left .lw-gallery__track li,
.lw-gallery--thumbs-right .lw-gallery__track li {
	width: 100%;
}

.lw-gallery--thumbs-bottom .lw-gallery__track li {
	width: 72px;
}

.lw-gallery__track img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	cursor: pointer;
	border: 2px solid transparent;
	border-radius: 4px;
	opacity: 0.6;
	transition: opacity 0.2s ease, border-color 0.2s ease;
}

.lw-gallery__track img.flex-active {
	opacity: 1;
	border-color: #123e7d;
}

/* Prev/Next arrows ------------------------------------------------------ */

.lw-gallery__nav {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 100%;
	height: 28px;
	border: 0;
	background: transparent;
	color: rgba(0, 0, 0, 0.6);
	cursor: pointer;
	padding: 0;
}

.lw-gallery--thumbs-bottom .lw-gallery__nav {
	width: 28px;
	height: auto;
}

/*
 * A plain CSS triangle (drawn with borders, `currentColor` so the "Arrow
 * Color" module setting applies) pointing right by default, then rotated
 * per layout so "prev"/"next" always point the correct way — including the
 * mobile breakpoint, which forces horizontal thumbnails regardless of the
 * desktop position setting below.
 */
.lw-gallery__nav-icon {
	display: block;
	width: 0;
	height: 0;
	border-top: 6px solid transparent;
	border-bottom: 6px solid transparent;
	border-left: 8px solid currentColor;
	transition: transform 0.2s ease;
}

/* Vertical thumbnails (left/right of the main image): up / down. */
.lw-gallery__nav--prev .lw-gallery__nav-icon {
	transform: rotate(-90deg);
}

.lw-gallery__nav--next .lw-gallery__nav-icon {
	transform: rotate(90deg);
}

/* Horizontal thumbnails (below the main image): left / right. */
.lw-gallery--thumbs-bottom .lw-gallery__nav--prev .lw-gallery__nav-icon {
	transform: rotate(180deg);
}

.lw-gallery--thumbs-bottom .lw-gallery__nav--next .lw-gallery__nav-icon {
	transform: none;
}

.lw-gallery__nav:disabled {
	visibility: hidden;
}

.lw-gallery__thumbs--no-overflow .lw-gallery__nav {
	display: none;
}

/* Lightbox disabled: keep the cursor honest ----------------------------- */

.lw-gallery[data-lightbox="0"] .lw-gallery__source .woocommerce-product-gallery__image a {
	cursor: default;
}

/* Mobile: always show thumbnails below the main image ------------------- */

@media (max-width: 767px) {
	.lw-gallery {
		flex-direction: column !important;
	}

	.lw-gallery__thumbs {
		flex-direction: row !important;
		width: 100% !important;
	}

	.lw-gallery__track .flex-control-nav {
		flex-direction: row !important;
	}

	.lw-gallery__track {
		overflow-x: auto !important;
		overflow-y: hidden !important;
		scroll-snap-type: x mandatory !important;
	}

	.lw-gallery__track li {
		width: 72px !important;
	}

	.lw-gallery__nav {
		width: 28px !important;
		height: auto !important;
	}

	/* Thumbnails are always horizontal here, regardless of the desktop
	 * position setting, so the arrows must always point left / right too. */
	.lw-gallery__nav--prev .lw-gallery__nav-icon {
		transform: rotate(180deg) !important;
	}

	.lw-gallery__nav--next .lw-gallery__nav-icon {
		transform: none !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.lw-gallery__track {
		scroll-behavior: auto;
	}
}
