/**
 * Shanelle Product Gallery Component — SHEIN-style vertical thumbs
 */

.product-gallery {
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
}

.product-gallery__layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--space-3);
}

.product-gallery__panel {
	min-width: 0;
}

.product-gallery__stage {
	position: relative;
}

.product-gallery__position {
	position: absolute;
	bottom: var(--space-3);
	left: 50%;
	z-index: var(--z-raised);
	margin: 0;
	padding: var(--space-1) var(--space-2);
	border-radius: var(--radius-sm);
	background: rgb(255 255 255 / 72%);
	backdrop-filter: blur(4px);
	box-shadow: none;
	color: var(--color-text-secondary);
	font-size: var(--font-size-2xs);
	font-weight: var(--font-weight-regular);
	letter-spacing: 0.04em;
	line-height: 1.2;
	pointer-events: none;
	transform: translateX(-50%);
	white-space: nowrap;
}

.product-gallery__position-sep {
	opacity: 0.55;
}

.product-gallery__main {
	position: relative;
	margin: 0;
	overflow: hidden;
	border-radius: var(--radius-sm);
	aspect-ratio: 3 / 4;
	background: var(--color-surface-sunken);
	cursor: zoom-in;
}

.product-gallery__image-stack {
	position: relative;
	width: 100%;
	height: 100%;
}

.product-gallery__image {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transform: scale(1.03);
	transition:
		opacity var(--duration-slow) var(--ease-out),
		transform var(--duration-slow) var(--ease-out);
}

.product-gallery__image.is-active,
.product-gallery__image.is-entering {
	opacity: 1;
	transform: scale(1);
}

.product-gallery__image.is-leaving {
	opacity: 0;
	transform: scale(0.98);
}

.product-gallery__zoom-lens {
	position: absolute;
	z-index: var(--z-raised);
	border: 2px solid rgb(255 255 255 / 90%);
	border-radius: var(--radius-full);
	pointer-events: none;
	box-shadow: var(--shadow-md);
	opacity: 0;
	background: rgb(255 255 255 / 12%);
	transition: opacity var(--duration-fast) var(--ease-out);
}

.product-gallery.is-zoom-active .product-gallery__zoom-lens {
	opacity: 1;
}

.product-gallery__zoom-lens[hidden] {
	display: none;
}

.product-gallery__zoom-pane {
	position: absolute;
	inset: 0;
	z-index: calc(var(--z-raised) - 1);
	background-color: var(--color-surface-sunken);
	background-repeat: no-repeat;
	pointer-events: none;
}

.product-gallery.is-zoom-active .product-gallery__main {
	cursor: crosshair;
}

.product-gallery.is-zoom-active .product-gallery__image-stack {
	opacity: 0;
}

.product-gallery__action.is-active {
	background: var(--color-brand-100);
	color: var(--color-brand-700);
	border-color: var(--color-brand-300);
}

.product-gallery__nav {
	position: absolute;
	inset: 0;
	z-index: var(--z-raised);
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding-inline: var(--space-2);
	pointer-events: none;
}

.product-gallery__nav-btn {
	pointer-events: auto;
	background: var(--color-surface-overlay);
	backdrop-filter: blur(6px);
	box-shadow: var(--shadow-sm);
}

.product-gallery__nav-btn:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

.product-gallery__actions {
	position: absolute;
	top: var(--space-3);
	right: var(--space-3);
	z-index: var(--z-raised);
	display: flex;
	gap: var(--space-2);
}

.product-gallery__action {
	background: var(--color-surface-overlay);
	backdrop-filter: blur(6px);
	box-shadow: var(--shadow-sm);
}

.product-gallery__thumbs-wrap {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

.product-gallery__thumbs-wrap::-webkit-scrollbar {
	display: none;
}

.product-gallery__thumbs {
	display: flex;
	flex-direction: row;
	gap: var(--space-2);
	margin: 0;
	padding: 0;
	list-style: none;
}

.product-gallery__thumb {
	display: block;
	padding: 0;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	overflow: hidden;
	background: transparent;
	cursor: pointer;
	transition:
		border-color var(--duration-base) var(--ease-in-out),
		opacity var(--duration-fast) var(--ease-out);
}

.product-gallery__thumb img {
	display: block;
	width: 4rem;
	height: auto;
	aspect-ratio: 3 / 4;
	object-fit: cover;
	transition: opacity var(--duration-base) var(--ease-out);
}

.product-gallery__thumb:hover,
.product-gallery__thumb:focus-visible {
	border-color: var(--color-neutral-400);
	transform: none;
	box-shadow: none;
	outline: none;
}

.product-gallery__thumb:hover img,
.product-gallery__thumb:focus-visible img {
	transform: none;
	opacity: 0.92;
}

.product-gallery__thumb.is-active {
	border-color: var(--color-neutral-800);
	box-shadow: none;
}

.product-gallery__modal {
	position: fixed;
	inset: 0;
	z-index: var(--z-modal);
	display: flex;
	align-items: center;
	justify-content: center;
}

.product-gallery__modal[hidden] {
	display: none;
}

.product-gallery__modal-overlay {
	position: absolute;
	inset: 0;
	background: rgb(17 17 17 / 94%);
}

.product-gallery__modal-dialog {
	position: relative;
	z-index: var(--z-raised);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	max-width: 100vw;
	margin: 0 auto;
	padding: var(--space-6);
	box-sizing: border-box;
}

.product-gallery__modal-close {
	position: absolute;
	top: max(var(--space-4), env(safe-area-inset-top, 0px));
	right: max(var(--space-4), env(safe-area-inset-right, 0px));
	z-index: calc(var(--z-raised) + 1);
	background: rgb(255 255 255 / 18%);
	border: 1px solid rgb(255 255 255 / 45%);
	color: #fff;
	box-shadow: var(--shadow-sm);
}

.product-gallery__modal-close:hover,
.product-gallery__modal-close:focus-visible {
	background: rgb(255 255 255 / 28%);
	border-color: rgb(255 255 255 / 70%);
	color: #fff;
	outline: none;
	box-shadow: 0 0 0 2px rgb(255 255 255 / 35%);
}

.product-gallery__modal-close svg {
	display: block;
	stroke: currentColor;
}

.product-gallery__modal-figure {
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0 auto;
	width: 100%;
	max-width: min(100%, 42rem);
	max-height: calc(100vh - 8rem);
}

.product-gallery__modal-image {
	display: block;
	width: auto;
	max-width: 100%;
	height: auto;
	max-height: calc(100vh - 8rem);
	margin-inline: auto;
	object-fit: contain;
}

.product-gallery__modal-nav {
	display: flex;
	justify-content: center;
	gap: var(--space-3);
	margin-top: var(--space-4);
}

.product-gallery__modal-nav .btn {
	background: rgb(255 255 255 / 14%);
	border: 1px solid rgb(255 255 255 / 35%);
	color: #fff;
}

.product-gallery__modal-nav .btn:hover,
.product-gallery__modal-nav .btn:focus-visible {
	background: rgb(255 255 255 / 24%);
	color: #fff;
	outline: none;
}

.product-gallery.is-swiping .product-gallery__image {
	transition: none;
}

@media (min-width: 48rem) {
	.product-gallery__layout {
		grid-template-columns: 4.75rem minmax(0, 1fr);
		gap: var(--space-3);
		align-items: start;
	}

	/* DOM is panel-then-thumbs (a11y / mobile image-first); restore thumbs-left on desktop. */
	.product-gallery__thumbs-wrap {
		grid-column: 1;
		grid-row: 1;
		overflow: visible;
	}

	.product-gallery__panel {
		grid-column: 2;
		grid-row: 1;
	}

	.product-gallery__position {
		display: none;
	}

	.product-gallery__thumbs {
		flex-direction: column;
		max-height: clamp(20rem, 52vh, 36rem);
		overflow-y: auto;
		scrollbar-width: none;
	}

	.product-gallery__thumbs::-webkit-scrollbar {
		display: none;
	}

	.product-gallery__thumb img {
		width: 100%;
	}
}

.product-gallery.is-touch-gallery [data-shanelle-gallery-zoom-toggle] {
	display: none !important;
}

@media (hover: none), (pointer: coarse) {
	.product-gallery [data-shanelle-gallery-zoom-toggle] {
		display: none !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.product-gallery__image,
	.product-gallery__zoom-lens,
	.product-gallery__thumb,
	.product-gallery__thumb img {
		transition: none;
	}
}
