.shop-gallery {
	display: grid;
	grid-template-columns: 72px minmax(0, 1fr);
	gap: 16px;
	align-items: start;
}

.shop-gallery-single {
	grid-template-columns: minmax(0, 1fr);
}

.shop-gallery-main {
	grid-column: 2;
	grid-row: 1;
	min-width: 0;
	width: 100%;
	max-width: 70dvh;
	justify-self: center;
	aspect-ratio: 1;
	background: var(--site-palette-ink-100);
	border: 1px solid var(--sw-border-color);
}

.shop-gallery-single .shop-gallery-main {
	grid-column: 1;
}

.shop-gallery-image {
	display: flex;
	width: 100%;
	height: 100%;
	padding: 16px;
	cursor: zoom-in;
}

.shop-gallery-image[hidden] {
	display: none;
}

.shop-gallery-image img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.shop-gallery-placeholder {
	padding: 25%;
	aspect-ratio: 1;
}

.shop-gallery-rail {
	grid-column: 1;
	grid-row: 1;
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-height: 392px;
	overflow: auto;
	padding: 3px;
	scrollbar-width: thin;
}

.shop-gallery-thumbnail {
	flex: 0 0 64px;
	width: 64px;
	height: 64px;
	padding: 3px;
	background: white;
	border: 2px solid var(--sw-border-color);
	border-radius: 0;
}

.shop-gallery-thumbnail img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.shop-gallery-thumbnail[aria-pressed="true"] {
	border-color: var(--sw-color-brand-primary);
}

.shop-gallery :focus-visible {
	outline: 2px solid var(--sw-color-brand-primary);
	outline-offset: 3px;
}

@media (width <= 767px) {
	.shop-gallery {
		grid-template-columns: minmax(0, 1fr);
		gap: 0.75rem;
	}

	.shop-gallery-main {
		grid-column: 1;
	}

	.shop-gallery-rail {
		grid-column: 1;
		grid-row: 2;
		flex-direction: row;
		max-width: 348px;
		width: 100%;
		justify-self: center;
	}

	.shop-gallery-thumbnail {
		width: 56px;
		height: 56px;
		flex-basis: 56px;
	}
}

.shop-gallery-main {
	position: relative;
}

.shop-gallery-main > .product-badges {
	position: absolute;
	top: 12px;
	left: 12px;
	right: 12px;
	z-index: 2;
	pointer-events: none;
}

.shop-gallery-track {
	width: 100%;
	height: 100%;
}

@media (width <= 767px) {
	.shop-gallery {
		position: relative;
		gap: 0;
	}

	.shop-gallery-main {
		max-width: none;
		border: 0;
	}

	.shop-gallery-track {
		display: flex;
		overflow-x: auto;
		scroll-snap-type: x mandatory;
		scrollbar-width: none;
		overscroll-behavior-x: contain;
	}

	.shop-gallery-track::-webkit-scrollbar {
		display: none;
	}

	.shop-gallery-image {
		flex: 0 0 100%;
		min-width: 0;
		scroll-snap-align: start;
		cursor: default;
	}

	.shop-gallery-rail {
		display: none;
	}

	.shop-gallery .shop-gallery-controls {
		position: absolute;
		right: 16px;
		bottom: 12px;
		z-index: 3;
		gap: 0;
		font-size: 0.8125rem;
		background: var(--site-palette-white);
		border-radius: 20px;
		box-shadow: 0 1px 4px rgb(3 32 24 / 12%);
	}

	.shop-gallery [data-gallery-position] {
		padding: 6px 10px;
	}

	.shop-gallery .shop-gallery-direction {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
	}

	.shop-gallery .shop-gallery-direction:focus-visible {
		position: static;
		width: 44px;
		height: 44px;
		clip-path: none;
	}
}

/* Only overflowing desktop thumbnail lists expose rail controls. */
.shop-gallery-track {
	position: absolute;
	inset: 0;
}

.shop-gallery-thumbnails {
	grid-column: 1;
	grid-row: 1;
	display: flex;
	flex-direction: column;
	max-height: var(--gallery-rail-height, 70dvh);
	min-height: 0;
	width: 72px;
}

.shop-gallery-thumbnails .shop-gallery-rail {
	flex: 0 1 auto;
	min-height: 0;
	max-height: none;
	width: 100%;
	overflow: hidden auto;
	scrollbar-width: none;
}

.shop-gallery-rail::-webkit-scrollbar {
	display: none;
}

.shop-gallery-rail[data-overflow="true"] {
	cursor: grab;
	overscroll-behavior-y: contain;
	user-select: none;
}

.shop-gallery-rail[data-overflow="true"] .shop-gallery-thumbnail {
	cursor: inherit;
}

.shop-gallery-rail[data-dragging="true"] {
	cursor: grabbing;
}

.shop-gallery-rail-direction {
	display: flex;
	flex: 0 0 44px;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	width: 100%;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--sw-color-brand-primary);
	cursor: pointer;
}

.shop-gallery-rail-direction[hidden] {
	display: none;
}

.shop-gallery-rail-direction:disabled {
	color: var(--site-palette-ink-500);
	cursor: default;
}

.shop-gallery-rail-direction .icon {
	width: 20px;
	height: 20px;
	color: inherit;
}

.shop-gallery-rail-direction .icon > svg {
	top: 0;
}

@media (width <= 767px) {
	.shop-gallery-thumbnails {
		display: none;
	}
}
