/*
 * Carousel style (core Group / Query with the "Carousel" style).
 * The first child is the track; its children are the slides.
 */

/* Without JavaScript: a horizontal scroll-snap strip. */
.is-style-carousel {
	position: relative;
}

.is-style-carousel > :first-child {
	display: flex;
	flex-wrap: nowrap;
	gap: 0;
	margin: 0;
	padding: 0;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	list-style: none;
}

.is-style-carousel > :first-child > * {
	flex: 0 0 100%;
	min-width: 0;
	margin: 0 !important;
	scroll-snap-align: start;
}

/* With Embla: the block becomes the viewport and the track stops scrolling natively. */
.is-style-carousel.is-carousel-ready {
	overflow: hidden;
}

.is-style-carousel.is-carousel-ready > :first-child {
	overflow: visible;
	scroll-snap-type: none;
}

.snathp-carousel__arrow {
	position: absolute;
	top: calc(var(--snathp-carousel-track-height, 100%) / 2);
	z-index: 2;
	display: grid;
	place-items: center;
	width: 3rem;
	height: 3rem;
	margin: 0; /* The block gap of the group's flow layout would push them down. */
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--wp--preset--color--base);
	cursor: pointer;
	transform: translateY(-50%);
}

/* A soft shadow keeps the white chevrons visible over a light photo (sky, sand). */
.snathp-carousel__arrow svg {
	filter: drop-shadow(0 1px 2px rgb(0 0 0 / 70%));
}

.snathp-carousel__arrow--previous {
	left: var(--wp--preset--spacing--30);
}

.snathp-carousel__arrow--next {
	right: var(--wp--preset--spacing--30);
}

.snathp-carousel__controls {
	display: flex;
	gap: var(--wp--preset--spacing--20);
	align-items: center;
	margin-top: var(--wp--preset--spacing--30);
}

.snathp-carousel__dots {
	display: flex;
	gap: 0.5rem;
}

.snathp-carousel__dot {
	width: 1rem;
	height: 0.5rem;
	padding: 0;
	border: 0;
	background: var(--wp--preset--color--muted);
	cursor: pointer;
}

.snathp-carousel__dot[aria-current="true"] {
	background: var(--wp--preset--color--primary);
}

.snathp-carousel__toggle {
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--wp--preset--color--primary);
	opacity: 0.5;
	cursor: pointer;
	transition: color 0.2s, background-color 0.2s, opacity 0.2s;
}

.snathp-carousel__toggle:hover,
.snathp-carousel__toggle:focus-visible {
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.snathp-carousel__toggle {
		transition: none;
	}
}

/* Photo carousels: a readable caption, and the counter and pause button over the top
   right corner of the photo, on a dark pill. */
.snathp-photo-carousel .wp-block-image figcaption {
	font-size: var(--wp--preset--font-size--large);
}

.snathp-photo-carousel .snathp-carousel__controls {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 2;
	gap: 2px;
	margin: 0;
	padding: 2px 2px 2px 12px;
	border-radius: 99px;
	background: rgb(0 0 0 / 40%);
}

.snathp-photo-carousel .snathp-carousel__counter,
.snathp-photo-carousel .snathp-carousel__toggle {
	color: var(--wp--preset--color--base);
}

.snathp-photo-carousel .snathp-carousel__counter {
	margin: 0;
}

.snathp-photo-carousel .snathp-carousel__toggle {
	opacity: 0.85;
}

/* Without a counter, the pill holds the pause button alone. */
.snathp-photo-carousel .snathp-carousel__controls:not(:has(.snathp-carousel__counter)) {
	padding-left: 2px;
}

/* Thumbnail strip (has-carousel-thumbnails): six thumbnails across, four on phones. */
.snathp-carousel__thumbs {
	position: relative;
	display: flex;
	gap: 10px;
	margin-top: 10px;
	overflow-x: auto;
	scrollbar-width: none;
}

.snathp-carousel__thumb {
	flex: 0 0 calc((100% - 50px) / 6);
	aspect-ratio: 3 / 2;
	padding: 0;
	border: 0;
	background: var(--wp--preset--color--surface);
	opacity: 0.6;
	cursor: pointer;
	transition: opacity 0.2s;
}

.snathp-carousel__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.snathp-carousel__thumb:hover,
.snathp-carousel__thumb[aria-current="true"] {
	opacity: 1;
}

.snathp-carousel__thumb[aria-current="true"] {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: -2px;
}

@media (max-width: 781px) {
	.snathp-carousel__thumb {
		flex-basis: calc((100% - 30px) / 4);
	}
}

/* Position counter (has-carousel-counter), at the right end of the controls row. */
.snathp-carousel__counter {
	margin: 0 0 0 auto;
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--small);
}

@media (prefers-reduced-motion: reduce) {
	.snathp-carousel__thumb {
		transition: none;
	}
}

.snathp-carousel__thumb:focus-visible,
.snathp-carousel__arrow:focus-visible,
.snathp-carousel__dot:focus-visible,
.snathp-carousel__toggle:focus-visible {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}
