/**
 * upcomer/article-card-carousel — horizontal carousel of dark article cards
 * on the theme's established dark-hero canvas. No new colors: every value
 * here maps to a token already in use elsewhere in the project.
 *
 *   - Canvas: #0a0a0a  — matches --hero-bg / --page-hero-bg
 *   - Card surface: rgba(255,255,255,0.04)  — matches --hero-card-bg
 *   - Card surface on hover: rgba(255,255,255,0.08)  — matches --hero-card-bg-hover
 *   - White text + rgba(255,255,255,0.72) muted  — matches hero-block fg tokens
 *   - Accent (eyebrow + MER link): #ffd84d  — matches --hero-accent
 *   - Outlined CTA: white border + currentColor fill, no new fill values
 *
 * The "brand purple" the spec mentioned doesn't exist in the project palette;
 * see README → Visual decisions.
 *
 * Card count per slide flows from the cards_per_slide field via the inline
 * `--carousel-cards` CSS custom property on the <section>.
 */

.upcomer-block--article-card-carousel {
	/* Dark theme defaults (the dark-hero family). The "light" and "custom"
	   themes override the canvas + card + text tokens below via attribute
	   selectors — same approach featured-news-hero uses for its
	   background_theme switcher. */
	--carousel-bg: #0a0a0a;
	--carousel-fg: #ffffff;
	--carousel-fg-muted: rgba(255, 255, 255, 0.72);
	--carousel-rule: rgba(255, 255, 255, 0.18);
	--carousel-accent: #ffd84d;

	--card-bg: rgba(255, 255, 255, 0.04);
	--card-bg-hover: rgba(255, 255, 255, 0.08);
	--card-radius: 12px;
	--card-fg: #ffffff;
	--card-fg-muted: rgba(255, 255, 255, 0.72);

	--carousel-cards: 4;
	--carousel-gap: clamp(0.75rem, 1.4vw, 1.125rem);
	--carousel-arrow-size: clamp(2rem, 3.4vw, 2.75rem);

	background: var(--carousel-bg);
	color: var(--carousel-fg);
	padding-inline: clamp(1rem, 3vw, 1.5rem);
	box-sizing: border-box;
}

/* ---- Light theme ---------------------------------------------------- */
/* Inverts canvas + card + text tokens. Cards become a subtle gray-tinted
   surface against a white-ish canvas, with theme-aligned dark text. */
.upcomer-block--article-card-carousel[data-theme="light"] {
	--carousel-bg: #FEFEFE;             /* theme.json general-color-bg.minimal */
	--carousel-fg: #171717;             /* theme.json general-color.h1 */
	--carousel-fg-muted: #5D5D5D;       /* theme.json general-color.caption */
	--carousel-rule: rgba(15, 15, 15, 0.22);
	--carousel-accent: #171717;         /* keep the "MER" link in the same dark voice */

	--card-bg: rgba(15, 15, 15, 0.04);
	--card-bg-hover: rgba(15, 15, 15, 0.08);
	--card-fg: #171717;
	--card-fg-muted: #5D5D5D;
}

/* ---- Custom theme --------------------------------------------------- */
/* Canvas color comes from the inline --carousel-bg set on the <section>.
   Text defaults to light (white) unless the editor opted into dark text
   via data-text-color="dark", which swaps to the same dark tokens the
   light theme uses. Cards stay translucent so they tint with the canvas. */
.upcomer-block--article-card-carousel[data-theme="custom"] {
	--carousel-fg: #ffffff;
	--carousel-fg-muted: rgba(255, 255, 255, 0.78);
	--carousel-rule: rgba(255, 255, 255, 0.22);
	--carousel-accent: #ffd84d;

	--card-bg: rgba(255, 255, 255, 0.08);
	--card-bg-hover: rgba(255, 255, 255, 0.14);
	--card-fg: #ffffff;
	--card-fg-muted: rgba(255, 255, 255, 0.78);
}

.upcomer-block--article-card-carousel[data-theme="custom"][data-text-color="dark"] {
	--carousel-fg: #171717;
	--carousel-fg-muted: #5D5D5D;
	--carousel-rule: rgba(15, 15, 15, 0.22);
	--carousel-accent: #171717;

	--card-bg: rgba(15, 15, 15, 0.06);
	--card-bg-hover: rgba(15, 15, 15, 0.12);
	--card-fg: #171717;
	--card-fg-muted: #5D5D5D;
}

.upcomer-block--article-card-carousel *,
.upcomer-block--article-card-carousel *::before,
.upcomer-block--article-card-carousel *::after {
	box-sizing: border-box;
}

.upcomer-block--article-card-carousel .upcomer-block__inner {
	max-width: calc(1px * var(--wp--custom--top-nav--primary-container-spacing--desktop--max-width, 1200));
	margin-inline: auto;
}

@media (max-width: 1247px) {
	.upcomer-block--article-card-carousel .upcomer-block__inner {
		max-width: calc(1px * var(--wp--custom--top-nav--primary-container-spacing--laptop--max-width, 1200));
	}
}

@media (max-width: 943px) {
	.upcomer-block--article-card-carousel .upcomer-block__inner {
		max-width: unset;
	}
}

/* ---- Header (section label + "MER" link) --------------------------- */

.upcomer-block--article-card-carousel .carousel-header {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	column-gap: clamp(1rem, 2.5vw, 1.75rem);
	align-items: end;
	min-height: 2.5rem;
	padding-bottom: clamp(0.75rem, 1.4vw, 1rem);
	margin-bottom: clamp(1rem, 2vw, 1.5rem);
	border-bottom: 1px solid var(--carousel-rule);
}

.upcomer-block--article-card-carousel .section-eyebrow {
	margin: 0;
	font-family: "Barlow Condensed", "Barlow", sans-serif;
	font-weight: 800;
	font-size: clamp(0.9375rem, 1.4vw, 1.0625rem);
	line-height: 1.2;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--carousel-fg);
}

.upcomer-block--article-card-carousel .carousel-see-more,
.upcomer-block--article-card-carousel .carousel-see-more:link,
.upcomer-block--article-card-carousel .carousel-see-more:visited,
.upcomer-block--article-card-carousel .carousel-see-more:hover,
.upcomer-block--article-card-carousel .carousel-see-more:focus,
.upcomer-block--article-card-carousel .carousel-see-more:focus-visible,
.upcomer-block--article-card-carousel .carousel-see-more:active {
	color: var(--carousel-accent);
	text-decoration: none;
}

.upcomer-block--article-card-carousel .carousel-see-more {
	font-family: "Barlow Condensed", "Barlow", sans-serif;
	font-weight: 800;
	font-size: clamp(0.8125rem, 1.2vw, 0.9375rem);
	letter-spacing: 0.1em;
	text-transform: uppercase;
	white-space: nowrap;
	transition: opacity 150ms ease;
}

.upcomer-block--article-card-carousel .carousel-see-more:hover {
	opacity: 0.78;
}

/* ---- Carousel chassis (arrows + viewport) -------------------------- */

.upcomer-block--article-card-carousel .carousel {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	column-gap: clamp(0.5rem, 1.5vw, 1rem);
	align-items: center;
}

/* When there's no slider (everything fits in one slide), the arrows aren't
   rendered and the viewport takes the full inner width. */
.upcomer-block--article-card-carousel:not(.has-slider) .carousel {
	grid-template-columns: minmax(0, 1fr);
}

.upcomer-block--article-card-carousel .carousel__viewport {
	overflow: hidden;
	min-width: 0;
	/* Establishes a container for the carousel track so translate calcs are
	   relative to the viewport width, not the section. */
	container-type: inline-size;
}

.upcomer-block--article-card-carousel .carousel__track {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: calc(
		(100cqw - (var(--carousel-cards) - 1) * var(--carousel-gap))
		/ var(--carousel-cards)
	);
	gap: var(--carousel-gap);
	transition: transform 360ms cubic-bezier(0.2, 0.65, 0.2, 1);
	transform: translateX(calc(
		var(--strip-offset, 0) * (-100cqw - var(--carousel-gap))
	));
	touch-action: pan-y; /* allow vertical page scroll, capture horizontal for swipe */
}

.upcomer-block--article-card-carousel .carousel__track.is-dragging {
	transition: none;
}

@media (prefers-reduced-motion: reduce) {
	.upcomer-block--article-card-carousel .carousel__track {
		transition: none;
	}
}

.upcomer-block--article-card-carousel .carousel__item {
	min-width: 0;
	display: flex;
}

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

.upcomer-block--article-card-carousel .carousel__arrow {
	width: var(--carousel-arrow-size);
	height: var(--carousel-arrow-size);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	color: var(--carousel-fg);
	border: 1px solid var(--carousel-rule);
	border-radius: 999px;
	cursor: pointer;
	font-family: "Barlow Condensed", "Barlow", sans-serif;
	font-size: clamp(1.25rem, 2vw, 1.5rem);
	line-height: 1;
	padding: 0;
	transition: background 150ms ease, border-color 150ms ease, transform 120ms ease;
}

.upcomer-block--article-card-carousel .carousel__arrow:hover,
.upcomer-block--article-card-carousel .carousel__arrow:focus-visible {
	background: var(--card-bg-hover);
	border-color: var(--carousel-fg);
}

.upcomer-block--article-card-carousel .carousel__arrow:focus-visible {
	outline: 2px solid var(--carousel-accent);
	outline-offset: 3px;
}

.upcomer-block--article-card-carousel .carousel__arrow:active {
	transform: scale(0.94);
}

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

.upcomer-block--article-card-carousel .carousel__dots {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 0.5rem;
	margin-top: clamp(1rem, 2.4vw, 1.5rem);
}

.upcomer-block--article-card-carousel .carousel__dot {
	width: 0.625rem;
	height: 0.625rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--carousel-rule);
	cursor: pointer;
	transition: background 150ms ease, transform 150ms ease;
}

.upcomer-block--article-card-carousel .carousel__dot span {
	/* Visually-hidden label, kept in DOM for screen readers + a11y testing */
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.upcomer-block--article-card-carousel .carousel__dot[aria-current="true"] {
	background: var(--carousel-fg);
	transform: scale(1.15);
}

.upcomer-block--article-card-carousel .carousel__dot:hover,
.upcomer-block--article-card-carousel .carousel__dot:focus-visible {
	background: var(--carousel-fg-muted);
}

.upcomer-block--article-card-carousel .carousel__dot:focus-visible {
	outline: 2px solid var(--carousel-accent);
	outline-offset: 3px;
}

/* ---- The carousel-item variant of the shared article-card partial -- */

.upcomer-block--article-card-carousel .article-card--carousel-item {
	width: 100%;
}

.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__link,
.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__link:link,
.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__link:visited,
.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__link:hover,
.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__link:focus,
.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__link:focus-visible,
.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__link:active {
	color: var(--card-fg);
	text-decoration: none;
}

.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__link {
	display: flex;
	flex-direction: column;
	width: 100%;
	background: var(--card-bg);
	border-radius: var(--card-radius);
	overflow: hidden;
	transition: background 200ms ease, transform 200ms ease;
}

.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__link:hover {
	background: var(--card-bg-hover);
	transform: translateY(-2px);
}

@media (prefers-reduced-motion: reduce) {
	.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__link,
	.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__link:hover {
		transition: none;
		transform: none;
	}
}

.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__media {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 10;
	background: var(--card-bg);
	overflow: hidden;
	position: relative;
}

.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__media .article-card__image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* Inline-SVG placeholder shown when the post has no featured image. The
   SVG uses currentColor so it picks up the muted body token automatically
   across all three themes (dark/light/custom + light-text/dark-text). */
.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__placeholder {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	color: var(--card-fg-muted);
	opacity: 0.5;
	pointer-events: none;
}

.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__placeholder svg {
	width: clamp(2.25rem, 5vw, 3rem);
	height: clamp(2.25rem, 5vw, 3rem);
}

.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__body {
	display: flex;
	flex-direction: column;
	gap: clamp(0.5rem, 1vw, 0.75rem);
	padding: clamp(0.875rem, 1.6vw, 1.25rem);
	flex: 1;
}

.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__title {
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin: 0;
	font-family: "Barlow Condensed", "Barlow", sans-serif;
	font-weight: 700;
	font-size: clamp(0.9375rem, 1.4vw, 1.125rem);
	line-height: 1.2;
	letter-spacing: -0.005em;
	color: var(--card-fg);
}

.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.25rem 0.5rem;
	margin: 0;
	font-family: "Barlow", sans-serif;
	font-weight: 600;
	font-size: clamp(0.625rem, 0.85vw, 0.6875rem);
	line-height: 1.2;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--card-fg-muted);
}

.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__meta-sep {
	color: var(--carousel-rule);
	font-weight: 400;
}

/* Outlined pseudo-button CTA. aria-hidden because the whole card is a link;
   this is purely decorative — same affordance, no extra interactive element. */
.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__cta {
	display: inline-flex;
	align-self: flex-start;
	align-items: center;
	gap: 0.375rem;
	margin-top: auto;
	padding: 0.5rem 1rem;
	border: 1px solid var(--carousel-fg);
	border-radius: 999px;
	font-family: "Barlow", sans-serif;
	font-weight: 700;
	font-size: clamp(0.6875rem, 1vw, 0.8125rem);
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--card-fg);
	transition: background 150ms ease, color 150ms ease;
}

.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__link:hover .article-card__cta {
	background: var(--carousel-fg);
	color: var(--carousel-bg);
}

/* ---- Breakpoints --------------------------------------------------- */

/* Mid: 2 cards per slide regardless of editor choice. */
@media (max-width: 900px) {
	.upcomer-block--article-card-carousel .carousel__track {
		grid-auto-columns: calc((100cqw - var(--carousel-gap)) / 2);
		transform: translateX(calc(
			var(--strip-offset, 0) * (-200cqw - 2 * var(--carousel-gap))
		));
	}
}

/* Mobile: single-card touch rail. Arrows remain visible but smaller; the
   primary interaction is horizontal swipe on the track. */
@media (max-width: 640px) {
	.upcomer-block--article-card-carousel .carousel {
		grid-template-columns: auto minmax(0, 1fr) auto;
		column-gap: 0.375rem;
	}
	.upcomer-block--article-card-carousel .carousel__track {
		grid-auto-columns: 100cqw;
		transform: translateX(calc(
			var(--strip-offset, 0) * (-100cqw - var(--carousel-gap))
		));
	}
	.upcomer-block--article-card-carousel .article-card--carousel-item .article-card__media {
		aspect-ratio: 16 / 9;
	}
}
