/**
 * Ken Burns hero media — pure CSS crossfade + slow zoom.
 *
 * Usage (no code needed):
 *   [sbc_kenburns images="url,url" interval="8" height="72vh"]
 *   Or as classes: give a section `sbc-kenburns sbc-kb--3` (slide count 2-4)
 *   and its images `sbc-kenburns__slide`, with --sbc-kb-interval set.
 *
 * Turning it off: remove the shortcode/class, or set interval=0 — the
 * shortcode then renders a still first image (sbc-kenburns--static).
 * Reduced-motion users get the still image too.
 *
 * Keyframe percentages are concrete (custom properties are NOT allowed in
 * keyframe selectors), so 2/3/4-slide sets ship pre-styled below; the
 * shortcode emits an exact scoped copy for other slide counts.
 */

.sbc-kenburns {
	position: relative;
	isolation: isolate;
	overflow: hidden;
	border-radius: var(--sbc-radius-lg);
	min-height: var(--sbc-kb-height, min(72vh, 40rem));
	background: var(--sbc-ink);
}

.sbc-kenburns__slide {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transform: scale(1.02);
	will-change: opacity, transform;
}

/* Pre-styled cycles: 2, 3 and 4 slides ------------------------------------ */

.sbc-kb--2 .sbc-kenburns__slide,
.sbc-kb--3 .sbc-kenburns__slide,
.sbc-kb--4 .sbc-kenburns__slide {
	animation-name: var(--sbc-kb-name);
	animation-duration: calc(var(--sbc-kb-interval, 8s) * var(--sbc-kb-count));
	animation-timing-function: linear;
	animation-iteration-count: infinite;
	animation-fill-mode: both;
}

.sbc-kb--2 {
	--sbc-kb-name: sbc-kb-cycle-2;
}

.sbc-kb--3 {
	--sbc-kb-name: sbc-kb-cycle-3;
}

.sbc-kb--4 {
	--sbc-kb-name: sbc-kb-cycle-4;
}

/* Each slide owns one full cycle; the inline delay staggers the crossfade. */

@keyframes sbc-kb-cycle-2 {
	0% {
		opacity: 0;
		transform: scale(1.02);
	}
	3% {
		opacity: 1;
	}
	47% {
		opacity: 1;
		transform: scale(1.13);
	}
	50% {
		opacity: 0;
	}
	100% {
		opacity: 0;
		transform: scale(1.02);
	}
}

@keyframes sbc-kb-cycle-3 {
	0% {
		opacity: 0;
		transform: scale(1.02);
	}
	2% {
		opacity: 1;
	}
	31% {
		opacity: 1;
		transform: scale(1.13);
	}
	34% {
		opacity: 0;
	}
	100% {
		opacity: 0;
		transform: scale(1.02);
	}
}

@keyframes sbc-kb-cycle-4 {
	0% {
		opacity: 0;
		transform: scale(1.02);
	}
	1.5% {
		opacity: 1;
	}
	23.5% {
		opacity: 1;
		transform: scale(1.13);
	}
	26% {
		opacity: 0;
	}
	100% {
		opacity: 0;
		transform: scale(1.02);
	}
}

/* Static mode: interval=0 — first image only, no animation. */

.sbc-kenburns--static .sbc-kenburns__slide {
	position: relative;
	inset: auto;
	opacity: 1;
	transform: none;
}

@media (prefers-reduced-motion: reduce) {
	/* Three classes, not one: the cycle rules above (and the PHP-injected
	   `.sbc-kb--custom` style block, which is printed in the BODY and so
	   wins on equal specificity) are (0,2,0); a bare `.sbc-kenburns__slide`
	   override loses the cascade and the slideshow keeps running. Worse,
	   base.css's global reduced-motion kill sets animation-duration to
	   0.01ms, so every slide runs once and LANDS on the cycle keyframes'
	   100% state (opacity: 0) — the hero photo disappears entirely. Removing
	   the animation is the only way the static first-slide rule below can
	   take the opacity back. */
	.sbc-kenburns.sbc-kb--2 .sbc-kenburns__slide,
	.sbc-kenburns.sbc-kb--3 .sbc-kenburns__slide,
	.sbc-kenburns.sbc-kb--4 .sbc-kenburns__slide,
	.sbc-kenburns.sbc-kb--custom .sbc-kenburns__slide {
		animation: none;
	}

	.sbc-kenburns__slide {
		opacity: 0;
	}

	.sbc-kenburns__slide:first-child {
		opacity: 1;
		transform: none;
	}
}
