.gallery-carousel {
	--gallery-carousel-thumb-height: 68px;
	width: 100%;
	margin-block: clamp(28px, 3vw, 52px);
	color: #000;
	background: #fff;
}

.gallery-carousel__stage {
	position: relative;
	display: grid;
	width: 100%;
	min-height: 0;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	isolation: isolate;
	place-items: center;
	background: #fff;
	touch-action: pan-y;
}

.gallery-carousel__stage:focus-visible {
	outline: 1px solid #000;
	outline-offset: 3px;
}

.gallery-carousel__slide {
	position: absolute;
	inset: 0;
	display: grid;
	width: 100%;
	height: 100%;
	min-width: 0;
	min-height: 0;
	margin: 0;
	overflow: hidden;
	place-items: center;
	background: #fff;
}

.gallery-carousel__slide > a {
	display: grid;
	width: 100%;
	height: 100%;
	min-width: 0;
	min-height: 0;
	overflow: hidden;
	place-items: center;
}

.gallery-carousel__slide img {
	display: block;
	width: 100%;
	max-width: 100%;
	height: 100%;
	max-height: 100%;
	object-fit: contain;
	object-position: center;
	background: #f4f4f4;
}

.gallery-carousel__slide figcaption {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	margin: 0;
	padding: 28px 16px 12px;
	color: #fff;
	background: linear-gradient(transparent, rgb(0 0 0 / 70%));
	font-size: calc(15px * var(--a11y-text-scale, 1));
	line-height: 1.25;
	text-align: left;
}

.gallery-carousel__thumbnails {
	width: 100%;
	margin-top: 12px;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-behavior: smooth;
	scrollbar-width: none;
	scroll-snap-type: x proximity;
	background: #fff;
}

.gallery-carousel__thumbnails::-webkit-scrollbar {
	display: none;
}

.gallery-carousel__track {
	display: flex;
	align-items: stretch;
	gap: 2px;
	width: max-content;
	min-width: 100%;
	background: #fff;
}

.gallery-carousel__thumbnail {
	position: relative;
	display: block;
	flex: 0 0 112px;
	height: var(--gallery-carousel-thumb-height);
	padding: 0;
	overflow: hidden;
	border: 1px solid transparent;
	border-radius: 0;
	color: inherit;
	background: #fff;
	cursor: pointer;
	opacity: 0.58;
	scroll-snap-align: start;
	transition: opacity 200ms ease, border-color 200ms ease;
}

.gallery-carousel__thumbnail img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
}

.gallery-carousel__thumbnail:hover,
.gallery-carousel__thumbnail:focus-visible,
.gallery-carousel__thumbnail.is-active {
	border-color: #000;
	opacity: 1;
}

.gallery-carousel__thumbnail:focus-visible {
	outline: 1px solid #000;
	outline-offset: -4px;
}

/* Keep the Gallery block compact and easy to manage in Gutenberg. */
.editor-styles-wrapper .wp-block-gallery.has-nested-images {
	display: grid !important;
	grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)) !important;
	gap: 8px !important;
	width: 100%;
	max-width: 680px;
	margin-right: auto;
	margin-left: auto;
}

/*
 * The empty Gallery placeholder is also a direct grid item. Make it span the
 * complete block instead of squeezing it into the first thumbnail column.
 */
.editor-styles-wrapper
	.wp-block-gallery.has-nested-images
	> .block-editor-media-placeholder {
	box-sizing: border-box;
	grid-column: 1 / -1;
	width: 100%;
	min-width: 0;
}

.editor-styles-wrapper
	.wp-block-gallery.has-nested-images
	> .block-editor-media-placeholder:not(.is-appender) {
	min-height: 180px;
	padding: 24px;
}

.editor-styles-wrapper
	.wp-block-gallery.has-nested-images
	> .block-editor-media-placeholder
	.components-placeholder__fieldset {
	width: 100%;
	min-width: 0;
}

.editor-styles-wrapper
	.wp-block-gallery.has-nested-images
	> figure.wp-block-image {
	width: 100% !important;
	margin: 0 !important;
}

.editor-styles-wrapper
	.wp-block-gallery.has-nested-images
	> figure.wp-block-image
	img {
	display: block;
	width: 100% !important;
	height: 88px !important;
	object-fit: cover;
	object-position: center;
}

.editor-styles-wrapper
	.wp-block-gallery.has-nested-images
	> figure.wp-block-image
	figcaption {
	padding: 16px 5px 4px;
	font-size: calc(10px * var(--a11y-text-scale, 1));
	line-height: 1.1;
}

@media (max-width: 767px) {
	.gallery-carousel {
		--gallery-carousel-thumb-height: 56px;
	}

	.gallery-carousel__thumbnail {
		flex-basis: 88px;
	}

	.editor-styles-wrapper .wp-block-gallery.has-nested-images {
		grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)) !important;
	}

	.editor-styles-wrapper
		.wp-block-gallery.has-nested-images
		> figure.wp-block-image
		img {
		height: 72px !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.gallery-carousel__thumbnails {
		scroll-behavior: auto;
	}

	.gallery-carousel__thumbnail {
		transition: none;
	}
}
