/**
 * Category Post Slider — front-end styles.
 *
 * Design intent: a calm, full-width banner that reads clearly on top of a photo
 * and blends with the host theme. All tunable values are CSS custom properties
 * declared on .cps-slider, so a site owner can restyle the slider from their own
 * theme without editing this file, e.g.:
 *
 *   .cps-slider { --cps-accent: #b02a37; --cps-radius: 0; }
 */

.cps-slider {
	/* Theme hooks — override these in your theme if needed. */
	--cps-radius: 10px;
	--cps-min-height: 340px;
	--cps-accent: #1a1a1a;          /* Button background. */
	--cps-accent-text: #ffffff;     /* Button text. */
	--cps-text: #ffffff;            /* Overlaid slide text. */
	--cps-scrim: rgba( 0, 0, 0, 0.45 ); /* Darkening over the image for legibility. */
	--cps-control-bg: rgba( 0, 0, 0, 0.4 );
	--cps-control-bg-hover: rgba( 0, 0, 0, 0.65 );

	position: relative;
	width: 100%;
	margin: 0 0 2rem;
	border-radius: var( --cps-radius );
	overflow: hidden;
	background: #f2f2f2; /* Fallback behind slides that have no image. */
}

/* The viewport clips the sliding track. */
.cps-slider__viewport {
	overflow: hidden;
	width: 100%;
}

/* The track holds all slides in a row and slides horizontally. */
.cps-slider__track {
	display: flex;
	width: 100%;
	transition-property: transform;
	transition-timing-function: ease;
	will-change: transform;
}

/* Each slide fills the whole viewport width, so only one shows at a time. */
.cps-slide {
	position: relative;
	flex: 0 0 100%;
	min-width: 100%;
	min-height: var( --cps-min-height );
	display: flex;
	align-items: flex-end; /* Text panel sits at the bottom. */
}

/* Featured image fills the slide as a backdrop. */
.cps-slide__image {
	position: absolute;
	inset: 0;
	display: block;
	z-index: 1;
}

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

/* A gradient scrim keeps overlaid text readable over any photo. */
.cps-slide::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 2;
	background: linear-gradient(
		to top,
		var( --cps-scrim ) 0%,
		rgba( 0, 0, 0, 0.1 ) 55%,
		rgba( 0, 0, 0, 0 ) 100%
	);
	pointer-events: none;
}

/* The text content sits above the scrim. */
.cps-slide__body {
	position: relative;
	z-index: 3;
	width: 100%;
	padding: 1.5rem 1.75rem 1.75rem;
	color: var( --cps-text );
	box-sizing: border-box;
}

.cps-slide__title {
	margin: 0 0 0.5rem;
	font-size: clamp( 1.25rem, 2.5vw, 1.9rem );
	line-height: 1.2;
}

.cps-slide__title a {
	color: inherit;
	text-decoration: none;
}

.cps-slide__title a:hover,
.cps-slide__title a:focus {
	text-decoration: underline;
}

.cps-slide__excerpt {
	margin: 0 0 1rem;
	max-width: 60ch;
	font-size: 1rem;
	line-height: 1.5;
	/* Keep the banner tidy: limit the excerpt to three lines. */
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* Call-to-action button. */
.cps-slide__button {
	display: inline-block;
	padding: 0.6rem 1.25rem;
	background: var( --cps-accent );
	color: var( --cps-accent-text );
	border-radius: calc( var( --cps-radius ) / 2 );
	text-decoration: none;
	font-weight: 600;
	line-height: 1.2;
	transition: opacity 0.15s ease;
}

.cps-slide__button:hover,
.cps-slide__button:focus {
	opacity: 0.9;
	color: var( --cps-accent-text );
}

/* When a slide has no image, show dark text on the neutral fallback and drop
   the scrim. The modifier class is added server-side, so this needs no :has(). */
.cps-slide--no-image {
	--cps-text: #1a1a1a;
	align-items: center;
}
.cps-slide--no-image::after {
	background: none;
}
.cps-slide--no-image .cps-slide__button {
	--cps-accent: #1a1a1a;
	--cps-accent-text: #ffffff;
}

/* --- Text alignment ----------------------------------------------------- *
 * The alignment class is set on the .cps-slider root. The extra specificity
 * (.cps-slider.cps-align-*) ensures it wins over most theme text styles. */
.cps-slider.cps-align-left .cps-slide__body {
	text-align: left;
}

.cps-slider.cps-align-center .cps-slide__body {
	text-align: center;
}
.cps-slider.cps-align-center .cps-slide__excerpt {
	margin-left: auto;
	margin-right: auto;
}

.cps-slider.cps-align-right .cps-slide__body {
	text-align: right;
}
.cps-slider.cps-align-right .cps-slide__excerpt {
	margin-left: auto;
	margin-right: 0;
}

/* --- Arrows ------------------------------------------------------------- */

/* The extra .cps-slider scope raises specificity so themes that style <button>
   (padding, min-width, etc.) cannot stretch our arrows back into ovals. */
.cps-slider .cps-slider__arrow {
	position: absolute;
	top: 50%;
	transform: translateY( -50% );
	z-index: 4;
	box-sizing: border-box;
	width: 44px;
	height: 44px;
	min-width: 44px;   /* Override theme button min-width. */
	max-width: 44px;
	padding: 0;        /* Override theme button padding. */
	margin: 0;
	border: 0;
	border-radius: 50%;
	aspect-ratio: 1 / 1;
	-webkit-appearance: none;
	appearance: none;
	background: var( --cps-control-bg );
	color: #fff;
	font-size: 1.6rem;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease;
}

.cps-slider__arrow:hover,
.cps-slider__arrow:focus {
	background: var( --cps-control-bg-hover );
}

.cps-slider__arrow:disabled {
	opacity: 0.35;
	cursor: default;
}

.cps-slider__arrow--prev {
	left: 12px;
}

.cps-slider__arrow--next {
	right: 12px;
}

/* --- Dots --------------------------------------------------------------- */

.cps-slider__dots {
	position: absolute;
	bottom: 10px;
	left: 0;
	right: 0;
	z-index: 4;
	display: flex;
	justify-content: center;
	gap: 8px;
}

.cps-slider__dot {
	width: 10px;
	height: 10px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba( 255, 255, 255, 0.55 );
	cursor: pointer;
	transition: background 0.15s ease, transform 0.15s ease;
}

.cps-slider__dot:hover,
.cps-slider__dot:focus {
	background: rgba( 255, 255, 255, 0.85 );
}

.cps-slider__dot.is-active {
	background: #fff;
	transform: scale( 1.2 );
}

/* --- Accessibility: honour reduced-motion by removing the slide animation. */
@media ( prefers-reduced-motion: reduce ) {
	.cps-slider__track {
		transition: none !important;
	}
}

/* --- Small screens ------------------------------------------------------ */
@media ( max-width: 600px ) {
	.cps-slider {
		--cps-min-height: 260px;
	}

	.cps-slide__body {
		padding: 1rem 1.15rem 1.35rem;
	}

	.cps-slider__arrow {
		width: 38px;
		height: 38px;
		font-size: 1.3rem;
	}
}
