/**
 * Build Break Automate: Solutions carousel
 *
 * Applied to a Group block with the class "brk-carousel" (see patterns/solutions-carousel.php).
 * The Query Loop's post list becomes a horizontal, scroll-snapping track. It works with no
 * JavaScript (swipe or scroll); assets/js/carousel.js adds arrows, dots, keyboard and autoplay.
 *
 * Modifier classes (add them in the block's Advanced panel, next to brk-carousel):
 *   brk-carousel--2up       two cards per view on desktop instead of three
 *   brk-carousel--1up       one card per view everywhere (large screenshots)
 *   brk-carousel--autoplay  advance every 6 seconds (off when the visitor prefers reduced motion)
 *   brk-carousel--loop      arrows wrap around at the ends
 */

.brk-carousel {
	--brk-carousel-gap: 1.5rem;
	--brk-carousel-per-view: 3;
	position: relative;
}

.brk-carousel--2up { --brk-carousel-per-view: 2; }
.brk-carousel--1up { --brk-carousel-per-view: 1; }

/* Track ------------------------------------------------------------------ */

.brk-carousel .wp-block-post-template {
	display: flex !important;
	flex-wrap: nowrap;
	gap: var(--brk-carousel-gap);
	margin: 0;
	padding: 0 0 0.5rem;
	list-style: none;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

.brk-carousel .wp-block-post-template::-webkit-scrollbar {
	display: none;
}

.brk-carousel .wp-block-post-template > .wp-block-post {
	flex: 0 0 calc((100% - (var(--brk-carousel-per-view) - 1) * var(--brk-carousel-gap)) / var(--brk-carousel-per-view));
	margin: 0;
	scroll-snap-align: start;
}

@media (max-width: 1024px) {
	.brk-carousel:not(.brk-carousel--1up) { --brk-carousel-per-view: 2; }
}

@media (max-width: 640px) {
	.brk-carousel { --brk-carousel-per-view: 1; }
}

@media (prefers-reduced-motion: reduce) {
	.brk-carousel .wp-block-post-template { scroll-behavior: auto; }
}

/* Cards ------------------------------------------------------------------ */

.brk-solution-card {
	height: 100%;
	padding: 0 !important; /* the inner text group carries the padding; the screenshot runs edge to edge */
	overflow: hidden;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.brk-solution-card:hover {
	box-shadow: var(--wp--preset--shadow--lg);
	transform: translateY(-2px);
}

.brk-solution-card .wp-block-post-featured-image {
	margin: 0;
	background: var(--wp--preset--color--surface-alt);
}

.brk-solution-card .wp-block-post-featured-image img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.brk-solution-card .wp-block-post-title a {
	text-decoration: none;
	color: var(--wp--preset--color--primary);
}

.brk-solution-card .wp-block-post-title a:hover {
	color: var(--wp--preset--color--accent);
}

.brk-solution-card .wp-block-post-terms a {
	text-decoration: none;
}

.brk-solution-card .wp-block-post-excerpt p {
	margin: 0.5rem 0 0;
}

/* Controls (injected by carousel.js) ------------------------------------- */

.brk-carousel__nav {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	margin-top: 1.25rem;
}

.brk-carousel__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	height: 2.5rem;
	padding: 0;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 999px;
	background: var(--wp--preset--color--white);
	color: var(--wp--preset--color--primary);
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.brk-carousel__btn:hover,
.brk-carousel__btn:focus-visible {
	background: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--primary);
	outline: none;
}

.brk-carousel__btn[disabled] {
	opacity: 0.35;
	cursor: default;
}

.brk-carousel__btn svg {
	width: 1.125rem;
	height: 1.125rem;
}

.brk-carousel__dots {
	display: flex;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.brk-carousel__dot {
	width: 0.625rem;
	height: 0.625rem;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: var(--wp--preset--color--border);
	cursor: pointer;
	transition: background-color 0.15s ease, transform 0.15s ease;
}

.brk-carousel__dot[aria-current="true"] {
	background: var(--wp--preset--color--accent);
	transform: scale(1.2);
}

.brk-carousel__dot:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 2px;
}

.brk-carousel__status {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}
