/**
 * Custom Mobile Product Gallery - structural styles.
 * Visibility is toggled via an inline media query (breakpoint from Customizer).
 */

.klyna-mobile-gallery {
	display: none;
	margin-bottom: 20px;
}

.klyna-mobile-gallery__main {
	position: relative;
	width: 100%;
	height: var( --klyna-mobile-gallery-main-height, 380px );
	overflow: hidden;
	touch-action: pan-y;
	background: #f5f5f5;
}

.klyna-mobile-gallery__track {
	display: flex;
	width: 100%;
	height: 100%;
	will-change: transform;
	transition: transform 0.3s ease;
}

.klyna-mobile-gallery__slide {
	flex: 0 0 100%;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.klyna-mobile-gallery__slide img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	pointer-events: none;
	user-select: none;
	-webkit-user-drag: none;
}

/* On mobile, use a 1:1 aspect-ratio square container instead of a fixed pixel
   height, so the product image is always fully visible (no crop) and the
   gallery stays compact regardless of the source image's orientation. */
@media ( max-width: 767px ) {
	.klyna-mobile-gallery__main {
		height: auto;
		aspect-ratio: 1 / 1;
		box-sizing: border-box;
		padding: 20px;
	}

	.klyna-mobile-gallery__slide {
		box-sizing: border-box;
	}
}

.klyna-mobile-gallery__zoom-btn {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 5;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 1px solid rgba( 0, 0, 0, 0.08 );
	border-radius: 50%;
	background: #ffffff;
	box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.25 );
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: #000000;
}

.klyna-mobile-gallery__zoom-btn svg {
	width: 18px;
	height: 18px;
	stroke: currentColor;
	fill: none;
}

.klyna-mobile-gallery__thumbs {
	display: flex;
	gap: 8px;
	margin-top: 10px;
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	touch-action: pan-x;
	scrollbar-width: none;
}

.klyna-mobile-gallery__thumbs::-webkit-scrollbar {
	display: none;
}

.klyna-mobile-gallery__thumb {
	flex: 0 0 auto;
	width: var( --klyna-mobile-gallery-thumb-size, 64px );
	height: var( --klyna-mobile-gallery-thumb-size, 64px );
	padding: 0;
	border: 2px solid transparent;
	border-radius: 4px;
	overflow: hidden;
	background: #f5f5f5;
	cursor: pointer;
}

.klyna-mobile-gallery__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	pointer-events: none;
}

.klyna-mobile-gallery__thumb.is-active {
	border-color: #333;
}

/* Lightbox */

.klyna-mobile-gallery-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	background: #000;
	display: none;
}

.klyna-mobile-gallery-lightbox.is-open {
	display: block;
}

.klyna-mobile-gallery-lightbox__track {
	display: flex;
	width: 100%;
	height: 100%;
}

.klyna-mobile-gallery-lightbox__slide {
	flex: 0 0 100%;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	touch-action: none;
}

.klyna-mobile-gallery-lightbox__slide img {
	max-width: 100%;
	max-height: 100%;
	touch-action: none;
	will-change: transform;
	user-select: none;
	-webkit-user-drag: none;
}

.klyna-mobile-gallery-lightbox__close {
	position: absolute;
	top: 14px;
	right: 14px;
	z-index: 2;
	width: 40px;
	height: 40px;
	border: none;
	border-radius: 50%;
	background: rgba( 255, 255, 255, 0.15 );
	color: #fff;
	font-size: 22px;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

body.klyna-mobile-gallery-lock {
	position: fixed;
	left: 0;
	right: 0;
	overflow: hidden;
}
