/**
 * product-gallery: the store's Product Gallery block (large image, previous/next buttons, thumbnail strip).
 * Measured in new-woocommerce.sketch, Shop Product Detail: a 720×458 image (3:2 here, the store's preset), 25 below
 * it a strip of four 180×114 thumbnails without gaps, white 30×30 previous/next squares stacked in a corner (the next
 * one on top). The rules repeat the layout of the store's block styles so the reference (without them) matches;
 * those styles sit in :where(), so the root class wins.
 */
.rt-product-gallery {
	display: flex;
	flex-direction: column;
	gap: var(--rt-spacing-40);
}

/* Large image: every image sits in a horizontal scroll container; the store scrolls to the selected one. */
.rt-product-gallery .wc-block-product-gallery-large-image {
	position: relative;
	overflow: hidden;
	width: 100%;
	background: var(--rt-product-gallery-surface);
}

.rt-product-gallery .wc-block-product-gallery-large-image__container {
	display: flex;
	align-items: center;
	margin: 0;
	padding: 0;
	/* The store: a scroll-snap row (product-gallery.js scrolls it), its scrollbar hidden */
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	list-style: none;
}

.rt-product-gallery .wc-block-product-gallery-large-image__container::-webkit-scrollbar {
	display: none;
}

.rt-product-gallery .wc-block-product-gallery-large-image__wrapper {
	scroll-snap-align: start;
	display: flex;
	flex-shrink: 0;
	min-width: 100%;
	max-width: 100%;
	margin: 0;
	aspect-ratio: var(--wc-block-product-gallery-large-image-ratio-width, 3) / var(--wc-block-product-gallery-large-image-ratio-height, 2);
}

.rt-product-gallery .wc-block-product-gallery-large-image .wc-block-components-product-image {
	width: 100%;
	height: 100%;
	margin: 0;
}

.rt-product-gallery .wc-block-product-gallery-large-image img {
	display: block;
	width: 100%;
	height: 100%;
	mix-blend-mode: multiply;
}

/* Previous/next squares, flush with the large image's bottom right corner, the next one on top. */
.rt-product-gallery .wc-block-product-gallery-large-image__inner-blocks {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
}

.rt-product-gallery .wc-block-next-previous-buttons {
	display: flex;
	flex-direction: column-reverse;
	align-items: flex-end;
	justify-content: flex-start;
	gap: 0;
	width: 100%;
	height: 100%;
}

.rt-product-gallery .wc-block-next-previous-buttons__button {
	display: grid;
	place-items: center;
	position: relative;
	z-index: 2;
	width: 1.875rem;
	height: 1.875rem;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: var(--rt-product-gallery-arrow);
	color: var(--rt-product-gallery-arrow-icon);
	cursor: pointer;
	pointer-events: auto;
}

/* The store's chevrons have no viewBox, so they are scaled rather than resized (8×12 to 6×9). */
.rt-product-gallery .wc-block-next-previous-buttons__icon {
	padding: 0;
	scale: 0.75;
}

.rt-product-gallery .wc-block-next-previous-buttons__button[aria-disabled="true"] {
	cursor: not-allowed;
}

.rt-product-gallery .wc-block-next-previous-buttons__button[aria-disabled="true"] .wc-block-next-previous-buttons__icon {
	opacity: 0.3;
}

/*
 * Thumbnail strip: four 3:2 thumbnails fill the width (the strip's ratio follows the block's thumbnail size, 25% by
 * default); more images scroll.
 */
.rt-product-gallery .wc-block-product-gallery-thumbnails {
	position: relative;
	width: 100%;
	height: auto;
	min-height: 0;
	overflow: hidden;
	aspect-ratio: calc(150 / var(--wc-block-product-gallery-thumbnails-size, 25)) / 1;
}

.rt-product-gallery .wc-block-product-gallery-thumbnails__scrollable {
	display: flex;
	flex-direction: row;
	gap: 0;
	height: 100%;
	overflow: auto hidden;
	scrollbar-width: none;
}

.rt-product-gallery .wc-block-product-gallery-thumbnails__thumbnail {
	display: flex;
	flex: 0 0 auto;
	height: 100%;
	background: var(--rt-product-gallery-surface);
}

.rt-product-gallery .wc-block-product-gallery-thumbnails__thumbnail__image {
	display: block;
	width: auto;
	height: 100%;
	object-fit: cover;
	mix-blend-mode: multiply;
	cursor: pointer;
}

.rt-product-gallery .wc-block-product-gallery-thumbnails--active-overlay .wc-block-product-gallery-thumbnails__thumbnail__image--is-active {
	filter: brightness(0.8);
	cursor: default;
}

/* Phones: the store swipes between images, hides the arrows and makes the strip 5:1 (it scrolls). */
@media (width <= 37.5rem) {
	.rt-product-gallery .wc-block-next-previous-buttons {
		display: none;
	}

	.rt-product-gallery .wc-block-product-gallery-thumbnails {
		aspect-ratio: 5 / 1;
	}
}

/*
 * The store's full-screen view (product-gallery.js, a click on the large image): a white page over everything with
 * the close button at the top end and the images under each other, 8px apart; the page under it does not scroll.
 */
.rt-has-gallery-dialog body {
	overflow: hidden;
}

.rt-product-gallery .rt-product-gallery__dialog {
	position: fixed;
	inset: 0;
	box-sizing: border-box;
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 0;
	background: var(--rt-color-base);
	color: var(--rt-color-contrast);
}

.rt-product-gallery .rt-product-gallery__dialog:focus {
	outline: none;
}

.rt-product-gallery .rt-product-gallery__dialog[open] {
	display: flex;
	flex-direction: column;
}

.rt-product-gallery .rt-product-gallery__dialog .wc-block-product-gallery-dialog__header {
	display: flex;
	flex: 0 0 auto;
	justify-content: flex-end;
	padding: 14px;
}

.rt-product-gallery .rt-product-gallery__dialog .wc-block-product-gallery-dialog__close-button {
	display: flex;
	padding: 4px;
	border: 0;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.rt-product-gallery .rt-product-gallery__dialog .wc-block-product-gallery-dialog__close-button svg {
	fill: currentColor;
}

.rt-product-gallery .rt-product-gallery__dialog .wc-block-product-gallery-dialog__content {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	min-height: 0;
	padding: 0 8px;
	overflow-y: auto;
}

.rt-product-gallery .rt-product-gallery__dialog .wc-block-product-gallery-dialog__content img {
	display: block;
	width: 100%;
	height: auto;
}

.rt-product-gallery .wc-block-product-gallery-large-image__wrapper {
	cursor: pointer;
}

/* A variation's own image waits hidden until that variation is chosen (product-gallery.js) */
.rt-product-gallery li[hidden] {
	display: none;
}
