/**
 * Layali Gallery — vertical-thumb product gallery.
 * Token-bound (--ly-*). Falls back to literal values if the theme isn't active.
 */

/* =============================================================================
   Layout
   ============================================================================= */

.ly-gallery {
	display: flex;
	flex-direction: row;
	gap: 16px;
	align-items: center; /* vertically center the thumb column against the main image */
	width: 100%;
	font-family: var(--ly-text-body, 'DM Sans', sans-serif);
}

/* The WC magnifier-glass trigger is no longer injected (PhotoSwipe support
   is disabled in functions.php). No CSS guard needed. */

.ly-gallery--placeholder {
	padding: 24px;
	text-align: center;
	color: var(--ly-color-text-muted, #4a4a52);
	font-style: italic;
	background: var(--ly-color-surface, #fbf5ef);
	border-radius: 12px;
}

/* =============================================================================
   Thumb column
   ============================================================================= */

.ly-gallery__thumbs {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
	width: auto;
}

.ly-gallery__thumbs-track {
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-height: 480px;
	overflow-y: auto;
	overflow-x: hidden;
	scroll-snap-type: y mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none; /* Firefox */
	padding: 2px; /* space for the active border */
}

.ly-gallery__thumbs-track::-webkit-scrollbar {
	display: none;
}

.ly-gallery__thumb {
	width: 96px;
	height: 96px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 12px;
	background: var(--ly-color-surface, #fbf5ef);
	cursor: pointer;
	overflow: hidden;
	flex-shrink: 0;
	scroll-snap-align: start;
	transition: border-color 150ms ease, transform 150ms ease;
	/* Anchor the overlay <span> inside the button. */
	position: relative;
}

.ly-gallery__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	pointer-events: none;
}

.ly-gallery__thumb:hover {
	border-color: var(--ly-color-border, #e6e6e8);
}

.ly-gallery__thumb[aria-pressed="true"] {
	border-color: var(--ly-color-primary, #53225e);
}

.ly-gallery__thumb:focus-visible {
	outline: 2px solid var(--ly-color-focus-ring, #ff7477);
	outline-offset: 2px;
}

/* =============================================================================
   Arrows
   ============================================================================= */

.ly-gallery__arrow {
	width: 32px;
	height: 32px;
	border-radius: 999px;
	border: 0;
	background: var(--ly-color-bg, #ffffff);
	color: var(--ly-color-primary, #53225e);
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
	transition: opacity 150ms ease, transform 150ms ease;
}

.ly-gallery__arrow:hover:not(:disabled) {
	transform: scale(1.06);
}

.ly-gallery__arrow:disabled {
	opacity: 0.25;
	cursor: not-allowed;
}

/* Hide arrows entirely when JS has determined the track doesn't overflow. */
.ly-gallery__thumbs[data-ly-gallery-no-overflow="1"] .ly-gallery__arrow {
	display: none;
}

/* =============================================================================
   Main image
   ============================================================================= */

.ly-gallery__main {
	flex: 1;
	min-width: 0;
	aspect-ratio: 1 / 1;
	background: var(--ly-color-surface, #fbf5ef);
	border-radius: 16px;
	overflow: hidden;
	position: relative;
}

.ly-gallery__main a,
.ly-gallery__main > a.woocommerce-product-gallery__image {
	display: block;
	width: 100%;
	height: 100%;
	cursor: zoom-in;
}

.ly-gallery__main img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	transition: opacity 200ms ease;
}

.ly-gallery__main.is-switching img {
	opacity: 0;
}

/* Mobile peek carousel — hidden on desktop; revealed under the mobile
   breakpoint (slide styles live in the mobile media query). */
.ly-gallery__mobile {
	display: none;
}

/* =============================================================================
   Image overlay (color tint / blend mode — Elementor-style)
   --------------------------------------------------------------------------
   Sits above the image but below the prev/next nav arrows. pointer-events
   are disabled so clicks pass through to the lightbox link underneath.
   Defaults to transparent so it's invisible until the editor picks a color.
   ============================================================================= */

.ly-gallery__overlay {
	position: absolute;
	inset: 0;
	z-index: 1;
	pointer-events: none;
	background-color: transparent;
	opacity: 0;
	transition: opacity 200ms ease;
	border-radius: inherit;
}

/* =============================================================================
   Main image side arrows (prev / next)
   ============================================================================= */

.ly-gallery__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 44px;
	height: 44px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.92);
	color: var(--ly-color-primary, #53225e);
	border: 0;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
	z-index: 3;
	transition: transform 150ms ease, opacity 150ms ease, background-color 150ms ease;
}

.ly-gallery__nav:hover {
	background: #ffffff;
	transform: translateY(-50%) scale(1.06);
}

.ly-gallery__nav--prev {
	left: 16px;
}

.ly-gallery__nav--next {
	right: 16px;
}

.ly-gallery__nav:focus-visible {
	outline: 2px solid var(--ly-color-focus-ring, #ff7477);
	outline-offset: 2px;
}

/* =============================================================================
   Mobile — thumbs flip to horizontal row below main image
   ============================================================================= */

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

	/* Single-image galleries keep the main image; the lone thumb row is moot. */
	.ly-gallery__thumbs {
		flex-direction: row;
		width: 100%;
		order: 2;
	}

	.ly-gallery__thumbs-track {
		flex-direction: row;
		max-height: none;
		max-width: 100%;
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x mandatory;
		flex: 1;
	}

	.ly-gallery__arrow,
	.ly-gallery__nav {
		display: none;
	}

	.ly-gallery__main {
		order: 1;
		width: 100%;
	}

	/* Multi-image: replace the thumb strip + single main with a peek swipe
	   carousel — current image ~87% wide so the next peeks on the right edge
	   (Passage du Désir treatment). */
	.ly-gallery--carousel .ly-gallery__thumbs,
	.ly-gallery--carousel .ly-gallery__main {
		display: none;
	}

	.ly-gallery--carousel .ly-gallery__mobile {
		display: flex;
		gap: 12px;
		width: 100%;
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x mandatory;
		scroll-behavior: smooth;
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch;
	}

	.ly-gallery--carousel .ly-gallery__mobile::-webkit-scrollbar {
		display: none;
	}

	.ly-gallery__slide {
		flex: 0 0 87%;
		scroll-snap-align: start;
		aspect-ratio: 1 / 1;
		margin: 0;
		padding: 0;
		border: 0;
		background: var(--ly-color-surface, #fbf5ef);
		border-radius: 16px;
		overflow: hidden;
		position: relative;
		cursor: zoom-in;
	}

	.ly-gallery__slide img {
		display: block;
		width: 100%;
		height: 100%;
		object-fit: contain;
		pointer-events: none;
	}

	.ly-gallery__slide:focus-visible {
		outline: 2px solid var(--ly-color-focus-ring, #ff7477);
		outline-offset: -2px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ly-gallery__thumbs-track,
	.ly-gallery__mobile {
		scroll-behavior: auto;
	}
	.ly-gallery__main img,
	.ly-gallery__arrow,
	.ly-gallery__thumb {
		transition: none;
	}
}

/* =============================================================================
   Custom lightbox modal
   --------------------------------------------------------------------------
   Centered white card with the image; backdrop dims the page; circular close
   button on the card; circular prev/next arrows positioned at the viewport
   edges. Created lazily by gallery.js and shared across all gallery instances.
   ============================================================================= */

.ly-lightbox {
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	font-family: var(--ly-text-body, 'DM Sans', sans-serif);
}

.ly-lightbox[hidden] {
	display: none;
}

.ly-lightbox__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.55);
	cursor: pointer;
	animation: ly-lightbox-fade 200ms ease;
}

.ly-lightbox__card {
	position: relative;
	z-index: 1;
	background: #ffffff;
	border-radius: 16px;
	max-width: min(90vw, 880px);
	max-height: 90vh;
	overflow: hidden;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
	animation: ly-lightbox-pop 220ms cubic-bezier(0.2, 0, 0, 1);
}

.ly-lightbox__img {
	display: block;
	max-width: 100%;
	max-height: 90vh;
	object-fit: contain;
}

.ly-lightbox__close {
	position: absolute;
	top: 16px;
	right: 16px;
	width: 40px;
	height: 40px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.95);
	color: var(--ly-color-text, #1f1f23);
	border: 0;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
	z-index: 2;
	transition: transform 150ms ease, background-color 150ms ease;
}

.ly-lightbox__close:hover {
	background: #ffffff;
	transform: scale(1.06);
}

.ly-lightbox__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 52px;
	height: 52px;
	border-radius: 999px;
	background: #ffffff;
	color: var(--ly-color-primary, #53225e);
	border: 0;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
	z-index: 2;
	transition: transform 150ms ease, opacity 150ms ease;
}

.ly-lightbox__nav:hover {
	transform: translateY(-50%) scale(1.06);
}

.ly-lightbox__nav--prev {
	left: 24px;
}

.ly-lightbox__nav--next {
	right: 24px;
}

.ly-lightbox__close:focus-visible,
.ly-lightbox__nav:focus-visible {
	outline: 2px solid var(--ly-color-focus-ring, #ff7477);
	outline-offset: 2px;
}

/* Prevent body scroll behind the open lightbox. The class is toggled by
   gallery.js. */
body.ly-lightbox-open {
	overflow: hidden;
}

@keyframes ly-lightbox-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes ly-lightbox-pop {
	from { opacity: 0; transform: scale(0.94); }
	to   { opacity: 1; transform: scale(1); }
}

@media (max-width: 640px) {
	.ly-lightbox__nav {
		width: 40px;
		height: 40px;
	}
	.ly-lightbox__nav--prev {
		left: 8px;
	}
	.ly-lightbox__nav--next {
		right: 8px;
	}
	.ly-lightbox__card {
		max-width: 94vw;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ly-lightbox__backdrop,
	.ly-lightbox__card {
		animation: none;
	}
	.ly-lightbox__close,
	.ly-lightbox__nav {
		transition: none;
	}
}
