/**
 * Caramba Moreno Slideshow — front-end styles.
 *
 * Every rule is scoped to `[data-cms-effect]`, which is only stamped on the
 * RENDERED site by render_block — so the block editor canvas is untouched and
 * each slide stays individually editable.
 *
 * Slides are stacked with CSS grid (all in cell 1/1) instead of absolute
 * positioning: the wrapper auto-sizes to the tallest slide, so it works for
 * images, text groups, columns — anything — without a hard-coded aspect ratio.
 * The minimal arrow/dot styling is the only "own" CSS (irreducible UI layout);
 * everything else inherits from the theme.
 */

.cms-slideshow[data-cms-effect] {
	position: relative;
	display: grid;
}

/* Stack every slide (direct child) into the same grid cell; exclude injected UI. */
.cms-slideshow[data-cms-effect] > *:not(.cms-slideshow__ui) {
	grid-area: 1 / 1 / 2 / 2;
	min-width: 0;
	z-index: 0;
}

.cms-slideshow[data-cms-effect] > .cms-is-active {
	z-index: 1;
}

/* The leaving slide sits on top while it animates out → clean cross-fade
   regardless of DOM order (e.g. last slide looping back to the first). */
.cms-slideshow[data-cms-effect] > .cms-is-prev {
	z-index: 2;
}

/* ---- Fade ---- */
.cms-slideshow[data-cms-effect="fade"] > *:not(.cms-slideshow__ui) {
	opacity: 0;
	transition: opacity var(--cms-transition, 1500ms) ease-in-out;
}

.cms-slideshow[data-cms-effect="fade"] > .cms-is-active {
	opacity: 1;
}

/* ---- Slide ----
   Pure horizontal translate (no opacity fade): the outgoing slide exits left
   while the incoming enters from the right, edges meeting — a real carousel
   slide with no blank gap. Resting slides wait off-screen right (clipped). */
.cms-slideshow[data-cms-effect="slide"] {
	overflow: hidden;
}

.cms-slideshow[data-cms-effect="slide"] > *:not(.cms-slideshow__ui) {
	opacity: 1;
	transform: translateX(100%);
	transition: transform var(--cms-transition, 1500ms) ease;
}

.cms-slideshow[data-cms-effect="slide"] > .cms-is-active {
	transform: translateX(0);
}

.cms-slideshow[data-cms-effect="slide"] > .cms-is-prev {
	transform: translateX(-100%);
}

/* ---- Pre-JS fallback: show the first slide before the engine flags --init,
        so there is no flash of a blank (fade) or off-screen (slide) wrapper. ---- */
.cms-slideshow[data-cms-effect]:not(.cms-slideshow--init) > *:not(.cms-slideshow__ui):first-child {
	opacity: 1;
	transform: none;
}

/* ============================================================
   Controls (arrows + dots) — minimal, neutral, inherit theme colour.
   Only present when the wrapper opts in; positioned over the slides.
   ============================================================ */
.cms-slideshow__ui {
	position: absolute;
	z-index: 5;
}

.cms-slideshow__arrow {
	top: 50%;
	transform: translateY(-50%);
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	height: 2.5rem;
	padding: 0;
	font-size: 1.75rem;
	line-height: 1;
	color: inherit;
	background: rgba(255, 255, 255, 0.6);
	border: 0;
	border-radius: 50%;
	cursor: pointer;
}

.cms-slideshow__arrow:hover {
	background: rgba(255, 255, 255, 0.85);
}

.cms-slideshow__arrow--prev {
	left: 0.75rem;
}

.cms-slideshow__arrow--next {
	right: 0.75rem;
}

.cms-slideshow__dots {
	left: 50%;
	bottom: 0.75rem;
	transform: translateX(-50%);
	display: flex;
	gap: 0.5rem;
}

.cms-slideshow__dot {
	width: 0.7rem;
	height: 0.7rem;
	padding: 0;
	background: rgba(255, 255, 255, 0.5);
	border: 1px solid rgba(0, 0, 0, 0.25);
	border-radius: 50%;
	cursor: pointer;
}

.cms-slideshow__dot.cms-is-active {
	background: currentColor;
}

@media (prefers-reduced-motion: reduce) {
	.cms-slideshow[data-cms-effect] > *:not(.cms-slideshow__ui) {
		transition: none;
	}
}
