/*
 * rekos/case-studies. Featured: Figma 422:6235 desktop, 1162:5241 mobile. Carousel: 827:10842
 * desktop, 1162:9988 mobile. Tokens only. Literal values only for breakpoints, aspect ratios,
 * 0, 1px, percentages, opacities, unitless line heights and icon geometry (arrow and nav circles,
 * 4 px dots, 2 px progress bar).
 *
 * Desktop ≥1200 (1440 frame): padding 80; head row: heading, intro 24 below (≈500 wide), CTA
 *   bottom-right; 56 below the list.
 *   Featured card: 1296 wide, light surface, radius 30, padding 16; photo 636 × 348 (radius 18)
 *   | 48 | text column (24 top and right): logo 149 × 39 and 30 px arrow circle on top; at the
 *   bottom title 24/32, excerpt 14/20 12 below, gradient rule 16 below, stats 16 below
 *   (value 24/32 gradient, label 14/20, 32 apart).
 *   Carousel: cards 416 wide, 16 apart, the 4th peeks in from the right edge; card: logo row,
 *   48, title 20/28, excerpt, rule, stats, photo 384 × 210 at the bottom; under the track (32)
 *   prev / dots / next, 40 px outlined circles, 4 px dots.
 * Mobile ≤767 (375 frame): padding 72 / 16; heading H30, intro 14/20 16 below; cards 48 below:
 *   radius 20, padding 16, photo on top (radius 12), 48, logo row (32 high), 40, title 18/28,
 *   excerpt clamped to 3 lines, stats in two equal columns; carousel cards 310 wide, 12 apart,
 *   2 px progress bar 24 below; CTA full width 24 below.
 * Tablet (derived): head and CTA in one row from 768; featured card side by side from 1024;
 *   carousel shows 2 cards from 768 and 3 from 1200.
 */

.rk-case-studies {
	container-type: inline-size;
	overflow-x: clip;
	padding-block: var(--wp--preset--spacing--80);
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
}

.rk-case-studies__inner {
	display: flex;
	flex-direction: column;
}

/* ---------- Head and CTA ---------- */

.rk-case-studies__head {
	display: grid;
	gap: var(--wp--preset--spacing--40);
	margin-block-end: calc(var(--wp--preset--spacing--60) + var(--wp--preset--spacing--40));
}

.rk-case-studies .rk-case-studies__heading {
	margin: 0;
	overflow-wrap: break-word;
	text-wrap: balance;
}

.rk-case-studies .rk-case-studies__intro {
	margin: 0;
	font-size: var(--wp--preset--font-size--base);
	line-height: 1.43;
}

.rk-case-studies .rk-case-studies__notice {
	margin: 0 0 var(--wp--preset--spacing--50);
	padding: var(--wp--preset--spacing--30) var(--wp--preset--spacing--40);
	border: 1px dashed var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--input);
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--sm);
	line-height: 1.43;
}

.rk-case-studies__list {
	min-width: 0;
}

.rk-case-studies__cta-wrap {
	margin-block-start: var(--wp--preset--spacing--50);
}

/* Mobile: full-width CTA; the ring sits outside the pill, so the pill leaves room for it. */
.rk-case-studies__cta-wrap .rk-case-studies__cta {
	inline-size: calc(100% - 2 * (var(--wp--custom--button--ring-gap) + var(--wp--custom--button--ring-width)));
}

/* ---------- Card (mobile layout is the base) ---------- */

.rk-case-studies__card {
	--rk-cs-card-radius: var(--wp--custom--radius--media);
	position: relative;
	display: flex;
	flex-direction: column;
	gap: calc(var(--wp--preset--spacing--60) + var(--wp--preset--spacing--40));
	block-size: 100%;
	padding: var(--wp--preset--spacing--40);
	border-radius: var(--rk-cs-card-radius);
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--contrast);
}

.rk-case-studies__media {
	position: relative;
	flex: none;
	aspect-ratio: 636 / 348;
	overflow: hidden;
	border-radius: var(--wp--custom--radius--input);
	background: var(--wp--preset--color--contrast);
}

.rk-case-studies .rk-case-studies__img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	max-width: none;
	height: 100%;
	object-fit: cover;
}

.rk-case-studies__content {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: calc(var(--wp--preset--spacing--60) + var(--wp--preset--spacing--20));
	min-width: 0;
}

.rk-case-studies__top {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: var(--wp--preset--spacing--40);
}

.rk-case-studies__logo {
	display: block;
	min-width: 0;
}

.rk-case-studies .rk-case-studies__logo-img {
	display: block;
	width: auto;
	max-width: 100%;
	height: var(--wp--preset--spacing--60);
	object-fit: contain;
	object-position: left center;
}

/* 30 px navy circle with an 18 px arrow (Figma 779:6816); decorative, the title is the link. */
.rk-case-studies__arrow {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	inline-size: 30px;
	block-size: 30px;
	margin-inline-start: auto;
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
	font-size: 18px;
	transition: background-color var(--wp--custom--motion--duration) var(--wp--custom--motion--ease);
}

.rk-case-studies__body {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--40);
}

.rk-case-studies__text {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--30);
}

.rk-case-studies .rk-case-studies__title {
	margin: 0;
	color: inherit;
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--lg);
	font-weight: 700;
	line-height: 1.556;
	text-transform: none;
	overflow-wrap: break-word;
}

.rk-case-studies .rk-case-studies__link {
	color: inherit;
	text-decoration: none;
	transition: color var(--wp--custom--motion--duration) var(--wp--custom--motion--ease);
}

/* The whole card is clickable through the title link. */
.rk-case-studies__link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	border-radius: var(--rk-cs-card-radius);
}

.rk-case-studies .rk-case-studies__link:focus-visible {
	outline: none;
}

.rk-case-studies__link:focus-visible::after {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: -2px;
}

/* Hover (derived, not in Figma): arrow and title turn indigo. */
.rk-case-studies__card:hover .rk-case-studies__arrow {
	background: var(--wp--preset--color--primary);
}

.rk-case-studies .rk-case-studies__card:hover .rk-case-studies__link {
	color: var(--wp--preset--color--primary);
}

.rk-case-studies .rk-case-studies__excerpt {
	margin: 0;
	font-size: var(--wp--preset--font-size--sm);
	line-height: 1.43;
}

/* Stats under a 1 px gradient rule at 40 % (Figma 815:9640). */
.rk-case-studies__stats {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--40) var(--wp--preset--spacing--60);
	margin: 0;
	padding: 0;
	list-style: none;
}

.rk-case-studies__stats::before {
	content: "";
	flex: 0 0 100%;
	block-size: 1px;
	background: var(--wp--preset--gradient--edrana);
	opacity: 0.4;
}

.rk-case-studies__stat {
	display: flex;
	flex: 1 1 0;
	flex-direction: column;
	min-width: 0;
}

.rk-case-studies__stat-value {
	align-self: flex-start;
	background: var(--wp--preset--gradient--edrana);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	font-size: var(--wp--preset--font-size--2-xl);
	font-weight: 700;
	line-height: 1.333;
}

.rk-case-studies__stat-label {
	font-size: var(--wp--preset--font-size--sm);
	line-height: 1.43;
	overflow-wrap: break-word;
}

@media (forced-colors: active) {
	.rk-case-studies__stat-value {
		background: none;
		color: CanvasText;
	}
}

/* ---------- Carousel (scroll-snap; view.js adds arrows, dots and the progress bar) ---------- */

/*
 * The track runs to both edges of the section: negative margins of one side gutter (the space
 * between .rk-inner and the section edge, measured in the section's container units), the same
 * padding and scroll padding, so the first card lines up with the content and later cards peek in.
 */
.rk-case-studies__track {
	--rk-cs-bleed: max(var(--wp--style--root--padding-left), calc((100cqw - var(--wp--style--global--content-size)) / 2));
	--rk-cs-gap: var(--wp--preset--spacing--30);
	position: relative;
	display: flex;
	gap: var(--rk-cs-gap);
	margin: 0 calc(-1 * var(--rk-cs-bleed));
	padding: 0 var(--rk-cs-bleed);
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-padding-inline: var(--rk-cs-bleed);
	list-style: none;
}

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

/*
 * Once view.js has set up the carousel (data-rk-ready), the arrows, dots and progress bar
 * replace the scrollbar; without JS, or if view.js fails to load, the scrollbar stays.
 */
.rk-case-studies[data-rk-ready] .rk-case-studies__track {
	scrollbar-width: none;
}

.rk-case-studies[data-rk-ready] .rk-case-studies__track::-webkit-scrollbar {
	display: none;
}

.rk-case-studies__slide {
	flex: 0 0 calc(100% - var(--wp--preset--spacing--60));
	min-width: 0;
	scroll-snap-align: start;
}

.rk-case-studies__controls,
.rk-case-studies__progress {
	display: none;
}

.rk-case-studies__progress-bar {
	position: absolute;
	inset-block: 0;
	inset-inline-start: var(--rk-cs-progress-start, 0%);
	inline-size: var(--rk-cs-progress-size, 100%);
	border-radius: inherit;
	background: var(--wp--preset--color--contrast);
}

/* 40 px outlined circles with an 18 px chevron (Figma 827:11025, 827:11035). */
.rk-case-studies .rk-case-studies__nav {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	inline-size: 40px;
	block-size: 40px;
	margin: 0;
	padding: 0;
	border: 1px solid var(--wp--preset--color--contrast);
	border-radius: var(--wp--custom--radius--pill);
	background: transparent;
	color: var(--wp--preset--color--contrast);
	font-size: 18px;
	cursor: pointer;
	transition:
		background-color var(--wp--custom--motion--duration) var(--wp--custom--motion--ease),
		color var(--wp--custom--motion--duration) var(--wp--custom--motion--ease);
}

.rk-case-studies .rk-case-studies__nav:hover:not(:disabled) {
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

.rk-case-studies .rk-case-studies__nav:disabled {
	opacity: 0.4;
	cursor: default;
}

.rk-case-studies__nav--next .rk-icon {
	transform: rotate(180deg);
}

.rk-case-studies__dots {
	display: flex;
	align-items: center;
	gap: var(--wp--preset--spacing--10);
}

.rk-case-studies__dot {
	display: block;
	inline-size: 4px;
	block-size: 4px;
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--contrast);
	opacity: 0.4;
	transition: opacity var(--wp--custom--motion--duration) var(--wp--custom--motion--ease);
}

.rk-case-studies__dot.is-active {
	opacity: 1;
}

@media (max-width: 767px) {
	/* Excerpt clamped to 3 lines with an ellipsis, as in Figma (1162:9415, 1162:10032, 1162:9733). */
	.rk-case-studies .rk-case-studies__excerpt {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 3;
		line-clamp: 3;
		overflow: hidden;
	}

	.rk-case-studies__progress:not([hidden]) {
		position: relative;
		display: block;
		block-size: 2px;
		margin-block-start: var(--wp--preset--spacing--50);
		overflow: hidden;
		border-radius: 2px;
		background: color-mix(in srgb, var(--wp--preset--color--contrast) 20%, transparent);
	}
}

/* ---------- Tablet and desktop ---------- */

@media (min-width: 768px) {
	/* Head left, CTA bottom-right, cards below. Margins instead of row gaps, so empty rows add nothing. */
	.rk-case-studies__inner {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
		grid-template-areas:
			"head cta"
			"notice notice"
			"list list";
		column-gap: var(--wp--preset--spacing--70);
		align-items: end;
	}

	.rk-case-studies__head {
		grid-area: head;
		gap: var(--wp--preset--spacing--50);
		margin-block-end: var(--wp--preset--spacing--70);
	}

	.rk-case-studies .rk-case-studies__intro {
		max-inline-size: calc(var(--wp--style--global--content-size) * 0.42);
		line-height: 1.5;
	}

	.rk-case-studies .rk-case-studies__notice {
		grid-area: notice;
	}

	.rk-case-studies__list {
		grid-area: list;
		align-self: start;
	}

	.rk-case-studies__cta-wrap {
		grid-area: cta;
		margin-block: 0 var(--wp--preset--spacing--70);
	}

	/*
	 * The heading runs over the CTA column (the CTA sits beside the intro, bottom-aligned), so a
	 * short heading is not wrapped by the button's column (768: 444 → 695 px, 1024: 672 → 924).
	 * Head = a subgrid over the "title" and "head" rows; without subgrid the layout above stays.
	 */
	@supports (grid-template-rows: subgrid) {
		.rk-case-studies__inner {
			grid-template-areas:
				"title title"
				"head cta"
				"notice notice"
				"list list";
		}

		.rk-case-studies__head {
			display: grid;
			grid-area: title-start / title-start / head-end / title-end;
			grid-template-columns: subgrid;
			grid-template-rows: subgrid;
			align-items: end;
		}

		.rk-case-studies .rk-case-studies__heading {
			grid-area: 1 / 1 / 2 / -1;
		}

		.rk-case-studies .rk-case-studies__intro {
			grid-area: 2 / 1 / 3 / 2;
		}
	}

	/* Pill 200 wide as in Figma (nav button width + 32). */
	.rk-case-studies__cta-wrap .rk-case-studies__cta {
		inline-size: auto;
		min-inline-size: calc(var(--wp--custom--button--nav-width) + var(--wp--preset--spacing--60));
	}

	.rk-case-studies .rk-case-studies__title {
		line-height: 1.4;
	}

	.rk-case-studies__stat {
		flex: 0 1 auto;
	}

	.rk-case-studies__stat-value {
		font-size: var(--wp--preset--font-size--xl);
	}

	.rk-case-studies--featured .rk-case-studies__card {
		--rk-cs-card-radius: var(--wp--custom--radius--card);
	}

	.rk-case-studies--featured .rk-case-studies__media {
		border-radius: var(--wp--custom--radius--media);
	}

	.rk-case-studies--featured .rk-case-studies__title {
		font-size: var(--wp--preset--font-size--xl);
		line-height: 1.333;
	}

	/* Carousel: 2 cards per view; logo row, text, photo at the bottom (Figma 827:10852). */
	.rk-case-studies__track {
		--rk-cs-gap: var(--wp--preset--spacing--40);
	}

	.rk-case-studies__slide {
		flex-basis: calc((100% - var(--rk-cs-gap)) / 2);
	}

	.rk-case-studies--carousel .rk-case-studies__card {
		--rk-cs-card-radius: var(--wp--custom--radius--card);
		gap: 0;
	}

	.rk-case-studies--carousel .rk-case-studies__media {
		order: 1;
		margin-block-start: var(--wp--preset--spacing--40);
		aspect-ratio: 384 / 210;
		border-radius: var(--wp--custom--radius--media);
	}

	.rk-case-studies--carousel .rk-case-studies__content {
		gap: calc(var(--wp--preset--spacing--60) + var(--wp--preset--spacing--40));
	}

	.rk-case-studies--carousel .rk-case-studies__logo-img {
		height: calc(var(--wp--preset--spacing--60) + var(--wp--preset--spacing--10));
	}

	.rk-case-studies__controls:not([hidden]) {
		display: flex;
		align-items: center;
		justify-content: center;
		gap: var(--wp--preset--spacing--20);
		margin-block-start: var(--wp--preset--spacing--60);
	}
}

@media (min-width: 1024px) {
	/* Featured: photo left (636), text right (580), equal height; text pinned top and bottom. */
	.rk-case-studies--featured .rk-case-studies__card {
		display: grid;
		grid-template-columns: minmax(0, 636fr) minmax(0, 580fr);
		gap: calc(var(--wp--preset--spacing--60) + var(--wp--preset--spacing--40));
	}

	.rk-case-studies--featured .rk-case-studies__card--no-media {
		grid-template-columns: minmax(0, 1fr);
	}

	/* width 100%: with a stretched height, aspect-ratio would otherwise size the width from the
	   height and push the photo over the text between 1024 and ~1250 px (QA 2026-10-08). */
	.rk-case-studies--featured .rk-case-studies__media {
		align-self: stretch;
		width: 100%;
	}

	.rk-case-studies--featured .rk-case-studies__content {
		justify-content: space-between;
		padding: var(--wp--preset--spacing--50) var(--wp--preset--spacing--50) 0 0;
	}

	.rk-case-studies--featured .rk-case-studies__logo-img {
		height: calc(var(--wp--preset--spacing--60) + var(--wp--preset--spacing--20));
	}
}

@media (min-width: 1200px) {
	/* 3 cards of 416 plus 3 gaps fill the 1296 content: the 4th starts at its edge (827:10842). */
	.rk-case-studies__slide {
		flex-basis: calc((100% - 3 * var(--rk-cs-gap)) / 3);
	}
}
