/**
 * case_study_kit: the csk_* layouts of a case study (template-parts/layouts/csk_*.php).
 *
 * Loaded by inc/enqueue.php on single case studies, after case_study.css, and
 * linked by the admin section preview. Plain CSS on the theme's tokens
 * (assets/css/tokens.css), inside @layer components like sections.css, so
 * Tailwind utilities keep winning.
 *
 * Headings take their size from .rmd-s-title and .rmd-s-card-title in
 * sections.css (H1 48/40, H2 40/32, H3 24/20); nothing here sets one. The
 * mobile switch is 760px, the theme's. Band padding is the theme's .rmd-s
 * (100, 64 on mobile): only `flow` and the mid CTA change it.
 */
@layer components {

	/* ── band ─────────────────────────────────────────────────────────── */

	.rmd-ck {
		--ck-box: var(--color-surface-canvas-alt);
		font-family: var(--font-family-secondary);
		overflow-x: clip;
	}
	.rmd-ck--canvas { background: var(--color-surface-canvas); }
	.rmd-ck--alt {
		--ck-box: var(--color-surface-canvas);
		background: var(--color-surface-canvas-alt);
	}
	.rmd-ck--flow { padding-top: 0; }

	.rmd-ck .rmd-s-grad {
		background-image: var(--gradient-promotional-sunrise);
		-webkit-background-clip: text;
		background-clip: text;
		-webkit-text-fill-color: transparent;
		color: transparent;
	}

	.rmd-ck-head { max-width: 760px; gap: var(--space-lg); }
	.rmd-ck-head .rmd-s-head-main { display: grid; gap: var(--space-lg); }

	/* ── hero ─────────────────────────────────────────────────────────── */

	.rmd-ck-rail {
		display: grid;
		grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
		gap: var(--space-2xl);
		margin: 0 0 var(--spacing-48);
		padding-block: var(--space-xl);
		border-block: 1px solid var(--color-border-surface-divider);
	}
	.rmd-ck-rail__item { min-width: 0; display: grid; gap: var(--space-2xs); }
	.rmd-ck-rail dt,
	.rmd-ck-facts dt {
		font-size: var(--font-size-label-lg);
		font-weight: 500;
		color: var(--color-content-tertiary);
	}
	.rmd-ck-rail dd {
		margin: 0;
		font-family: var(--font-family-primary);
		font-size: var(--font-size-title-sm);
		font-weight: 500;
		color: var(--color-content-primary);
	}

	.rmd-ck-hero {
		display: grid;
		grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
		gap: var(--spacing-48);
		align-items: center;
	}
	.rmd-ck--solo .rmd-ck-hero { grid-template-columns: minmax(0, 800px); }
	.rmd-ck-hero__copy { display: grid; gap: var(--space-2xl); justify-items: start; min-width: 0; }
	.rmd-ck-hero__payoff {
		margin: 0;
		font-size: var(--font-size-body-lg);
		font-weight: 500;
		line-height: var(--line-height-body);
		color: var(--color-content-secondary);
	}
	.rmd-ck-hero__actions { align-items: center; gap: var(--space-2xl); }

	.rmd-ck-stage {
		display: grid;
		gap: var(--space-md);
		padding: var(--space-2xl);
		border-radius: var(--radius-16);
		background: var(--color-surface-accent-indigo);
	}
	.rmd-ck-stage__overline {
		margin: 0;
		font-size: var(--font-size-label-lg);
		font-weight: 600;
		color: var(--color-accent-on-indigo);
	}
	.rmd-ck-stage__title {
		margin: 0;
		font-family: var(--font-family-primary);
		font-size: var(--font-size-h5);
		font-weight: 500;
		line-height: var(--line-height-headline-sm);
		color: var(--color-content-primary);
	}
	.rmd-ck-stage__caption {
		margin: 0;
		font-size: var(--font-size-body-sm);
		line-height: var(--line-height-body);
		color: var(--color-content-tertiary);
	}
	.rmd-ck-stage__caption a { color: var(--color-intent-idle); text-underline-offset: 2px; }
	.rmd-ck-stage__img { overflow: hidden; border-radius: var(--radius-12); }
	.rmd-ck-stage__img img { display: block; width: 100%; height: auto; }

	.rmd-ck-route {
		display: flex;
		flex-wrap: wrap;
		gap: var(--space-md);
		margin-top: var(--spacing-48);
	}
	.rmd-ck-route a {
		display: inline-flex;
		align-items: center;
		gap: var(--space-sm);
		padding: var(--space-sm) var(--space-lg);
		border: 1px solid var(--color-border-control-default);
		border-radius: var(--radius-full);
		background: var(--color-surface-canvas);
		font-family: var(--font-family-primary);
		font-size: var(--font-size-label-xl);
		font-weight: 500;
		color: var(--color-content-primary);
		text-decoration: none;
		transition: background-color .15s ease, border-color .15s ease;
	}
	.rmd-ck-route a span { color: var(--color-accent-on-indigo); font-weight: 600; }
	.rmd-ck-route a:hover { background: var(--color-button-tertiary-hover); }
	.rmd-ck-route a:focus-visible { outline: 2px solid var(--color-border-control-focus); outline-offset: 2px; }

	/* ── figures ──────────────────────────────────────────────────────── */

	.rmd-ck-metrics {
		display: grid;
		grid-template-columns: repeat(var(--rmd-ck-n, 3), minmax(0, 1fr));
		gap: var(--space-2xl);
	}
	.rmd-ck-hero + .rmd-ck-metrics { margin-top: var(--spacing-48); }
	.rmd-ck-metric {
		display: grid;
		gap: var(--space-xs);
		align-content: start;
		min-width: 0;
		padding: var(--space-2xl);
		border: 1px solid var(--color-border-surface-modals);
		border-radius: var(--radius-12);
		background: var(--color-surface-canvas);
		box-shadow: var(--shadow-md);
	}
	.rmd-ck-metric__label {
		font-size: var(--font-size-label-xl);
		font-weight: 500;
		color: var(--color-content-tertiary);
	}
	.rmd-ck-metric__value {
		font-family: var(--font-family-primary);
		font-size: var(--font-size-h3);
		font-weight: 500;
		line-height: 1.15;
		color: var(--color-content-primary);
		overflow-wrap: anywhere;
	}
	.rmd-ck-metric__text {
		margin: 0;
		font-size: var(--font-size-body-sm);
		line-height: var(--line-height-body);
		color: var(--color-content-tertiary);
	}

	/* ── text, facts ──────────────────────────────────────────────────── */

	.rmd-ck-split { display: grid; gap: var(--spacing-48); }
	.rmd-ck--with-facts .rmd-ck-split {
		grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
		align-items: start;
	}
	.rmd-ck-prose {
		max-width: 760px;
		min-width: 0;
		font-size: var(--font-size-body-md);
		line-height: var(--line-height-body);
		color: var(--color-content-secondary);
	}
	.rmd-ck-prose > * + * { margin-top: var(--space-lg); }
	.rmd-ck-prose > :is(h3, h4) { margin-top: var(--space-3xl); }
	.rmd-ck-prose :is(h3, h4) + * { margin-top: var(--space-sm); }
	.rmd-ck-prose p,
	.rmd-ck-prose li { margin-bottom: 0; }
	.rmd-ck-prose ul { list-style: disc; padding-left: var(--space-xl); }
	.rmd-ck-prose ol { list-style: decimal; padding-left: var(--space-xl); }
	.rmd-ck-prose li + li { margin-top: var(--space-xs); }
	.rmd-ck-prose a,
	.rmd-s-card-text a { color: var(--color-intent-idle); text-underline-offset: 2px; }
	.rmd-ck-prose strong { color: var(--color-content-primary); font-weight: 600; }

	.rmd-ck--facts-only .rmd-ck-facts {
		grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
		gap: var(--space-2xl);
	}
	.rmd-ck-facts {
		display: grid;
		gap: var(--space-xl);
		margin: 0;
		padding: var(--space-2xl);
		border-radius: var(--radius-12);
		background: var(--ck-box);
		border: 1px solid var(--color-border-surface-modals);
	}
	.rmd-ck-facts__item { display: grid; gap: var(--space-2xs); }
	.rmd-ck-facts dd {
		margin: 0;
		font-family: var(--font-family-primary);
		font-size: var(--font-size-title-sm);
		font-weight: 500;
		line-height: 1.4;
		color: var(--color-content-primary);
	}

	/* ── cards, note ──────────────────────────────────────────────────── */

	.rmd-ck-cards,
	.rmd-ck-related,
	.rmd-ck-gallery {
		display: grid;
		gap: var(--space-2xl);
		margin: 0;
		padding: 0;
		list-style: none;
	}
	.rmd-ck-related { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.rmd-ck-cards--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.rmd-ck-cards--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.rmd-ck-cards--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
	.rmd-ck-card {
		display: grid;
		gap: var(--space-md);
		align-content: start;
		min-width: 0;
		padding: var(--space-2xl);
		border: 1px solid var(--color-border-surface-modals);
		border-radius: var(--radius-12);
		background: var(--ck-box);
	}
	.rmd-ck-card__media { overflow: hidden; border-radius: var(--radius-8); }
	.rmd-ck-card__media img { display: block; width: 100%; height: auto; }
	.rmd-ck-card__step {
		font-family: var(--font-family-primary);
		font-size: var(--font-size-label-xl);
		font-weight: 600;
		color: var(--color-accent-on-indigo);
	}

	.rmd-ck-note {
		display: grid;
		gap: var(--space-md);
		max-width: 880px;
		padding: var(--spacing-32);
		border-left: 4px solid var(--color-intent-idle);
		border-radius: var(--radius-12);
		background: var(--color-surface-accent-indigo);
	}

	/* ── table ────────────────────────────────────────────────────────── */

	.rmd-ck-tablebox {
		max-width: 100%;
		overflow-x: auto;
		border: 1px solid var(--color-border-surface-modals);
		border-radius: var(--radius-12);
		background: var(--color-surface-canvas);
	}
	.rmd-ck-tablebox:focus-visible { outline: 2px solid var(--color-border-control-focus); outline-offset: 2px; }
	.rmd-ck-table {
		width: 100%;
		min-width: 640px;
		border-collapse: collapse;
		font-size: var(--font-size-body-sm);
		line-height: 1.5;
		color: var(--color-content-secondary);
	}
	.rmd-ck-table th,
	.rmd-ck-table td {
		padding: var(--space-lg);
		text-align: left;
		vertical-align: top;
		border-bottom: 1px solid var(--color-border-surface-modals);
	}
	.rmd-ck-table thead th {
		background: var(--color-surface-canvas-alt);
		font-size: var(--font-size-label-lg);
		font-weight: 600;
		color: var(--color-content-tertiary);
	}
	.rmd-ck-table tbody th { font-weight: 500; color: var(--color-content-primary); }
	.rmd-ck-table tbody tr:last-child :is(th, td) { border-bottom: 0; }
	.rmd-ck-tablenote {
		margin: var(--space-lg) 0 0;
		font-size: var(--font-size-body-sm);
		line-height: var(--line-height-body);
		color: var(--color-content-tertiary);
	}
	.rmd-ck-tablenote p { margin: 0 0 var(--space-sm); }
	.rmd-ck-tablenote p:last-child { margin-bottom: 0; }
	.rmd-ck-tablenote strong { color: var(--color-content-primary); font-weight: 600; }

	/* ── gallery, zoom ────────────────────────────────────────────────── */

	.rmd-ck-gallery--1 { grid-template-columns: minmax(0, 1fr); }
	.rmd-ck-gallery--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.rmd-ck-gallery--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.rmd-ck-shot { display: grid; gap: var(--space-md); align-content: start; min-width: 0; margin: 0; }
	.rmd-ck-shot__media {
		position: relative;
		display: block;
		overflow: hidden;
		border: 1px solid var(--color-border-surface-modals);
		border-radius: var(--radius-12);
		background: var(--color-surface-canvas);
	}
	.rmd-ck-shot__media img,
	.rmd-ck-shot__media video { display: block; width: 100%; height: auto; }
	.rmd-ck-gallery--1 .rmd-ck-shot--tall { width: min(100%, max(320px, calc(1000px / var(--ck-r)))); justify-self: center; }
	.rmd-ck-gallery--1 .rmd-ck-shot--full { width: 100%; }
	.rmd-ck-shot--crop .rmd-ck-shot__media { max-height: 1100px; }
	.rmd-ck-shot--logo { max-width: 560px; justify-self: center; }
	.rmd-ck-shot--logo .rmd-ck-shot__media {
		padding: var(--spacing-48) var(--spacing-32);
		background: var(--color-rhillane-dark);
	}
	.rmd-ck-gallery--2 > .rmd-ck-shot:last-child:nth-child(odd) {
		grid-column: 1 / -1;
		justify-self: center;
		width: calc((100% - var(--space-2xl)) / 2);
	}
	.rmd-ck-gallery--3 > .rmd-ck-shot:last-child:nth-child(3n + 1) { grid-column: 2; }
	.rmd-ck-shot__zoom { display: grid; gap: var(--space-sm); color: inherit; text-decoration: none; cursor: zoom-in; }
	.rmd-ck-shot__zoom:focus-visible { outline: 2px solid var(--color-border-control-focus); outline-offset: 4px; border-radius: var(--radius-12); }
	.rmd-ck-shot__hint {
		font-size: var(--font-size-label-lg);
		font-weight: 500;
		color: var(--color-accent-on-indigo);
	}
	.rmd-ck-shot__zoom:hover .rmd-ck-shot__hint { text-decoration: underline; text-underline-offset: 3px; }
	.rmd-ck-shot figcaption { display: grid; gap: var(--space-2xs); }
	.rmd-ck-shot__title {
		font-family: var(--font-family-primary);
		font-size: var(--font-size-title-sm);
		font-weight: 500;
		line-height: 1.4;
		color: var(--color-content-primary);
	}
	.rmd-ck-shot__cap {
		font-size: var(--font-size-body-sm);
		line-height: var(--line-height-body);
		color: var(--color-content-tertiary);
	}
	.rmd-ck-shot__link {
		justify-self: start;
		font-size: var(--font-size-label-xl);
		font-weight: 500;
		color: var(--color-accent-on-indigo);
		text-underline-offset: 3px;
	}

	.rmd-ck-marks {
		position: absolute;
		inset: 0;
		width: 100%;
		height: 100%;
		pointer-events: none;
	}
	.rmd-ck-marks rect {
		fill: var(--color-orange-500);
		fill-opacity: .12;
		stroke: var(--color-orange-500);
		stroke-width: 2px;
		vector-effect: non-scaling-stroke;
	}

	.rmd-ck-dialog {
		width: fit-content;
		max-width: 96vw;
		max-height: 96vh;
		margin: auto;
		padding: 0;
		border: 0;
		background: transparent;
		overflow: visible;
		color: var(--color-content-static-white);
	}
	.rmd-ck-dialog::backdrop { background: var(--color-rhillane-dark); opacity: .9; }
	.rmd-ck-dialog__stage { position: relative; display: grid; width: fit-content; margin-inline: auto; }
	.rmd-ck-dialog__img {
		display: block;
		max-width: 96vw;
		max-height: 82vh;
		width: auto;
		height: auto;
		border-radius: var(--radius-8);
		background: var(--color-surface-canvas);
	}
	.rmd-ck-dialog__cap {
		margin: var(--space-md) 0 0;
		text-align: center;
		font-size: var(--font-size-body-sm);
		line-height: var(--line-height-body);
	}
	.rmd-ck-dialog__cap:empty { display: none; }
	.rmd-ck-dialog__close {
		position: absolute;
		top: var(--space-md);
		right: var(--space-md);
		z-index: 1;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: var(--scale-40);
		height: var(--scale-40);
		padding: 0;
		border: 0;
		border-radius: var(--radius-full);
		background: var(--color-surface-canvas);
		color: var(--color-content-primary);
		box-shadow: var(--shadow-lg);
		cursor: pointer;
	}
	.rmd-ck-dialog__close:focus-visible { outline: 2px solid var(--color-border-control-focus); outline-offset: 2px; }

	/* ── quote, faq ───────────────────────────────────────────────────── */

	.rmd-ck-quote {
		display: grid;
		gap: var(--space-xl);
		max-width: 880px;
		margin: 0;
		padding-left: var(--spacing-32);
		border-left: 4px solid var(--color-intent-idle);
	}
	.rmd-ck-quote blockquote { margin: 0; padding: 0; display: grid; gap: var(--space-lg); }
	.rmd-ck-quote blockquote p {
		margin: 0;
		font-family: var(--font-family-primary);
		font-size: var(--font-size-h5);
		font-weight: 500;
		line-height: var(--line-height-headline-sm);
		color: var(--color-content-primary);
	}
	.rmd-ck-quote figcaption { display: grid; gap: var(--space-2xs); font-size: var(--font-size-body-sm); color: var(--color-content-tertiary); }
	.rmd-ck-quote figcaption strong { font-size: var(--font-size-body-md); color: var(--color-content-primary); }

	.rmd-ck-faq { display: grid; max-width: 880px; border-top: 1px solid var(--color-border-surface-divider); }
	.rmd-ck-faq__item { padding-block: var(--space-xl); border-bottom: 1px solid var(--color-border-surface-divider); }
	.rmd-ck-faq__item summary {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: var(--space-lg);
		list-style: none;
		cursor: pointer;
	}
	.rmd-ck-faq__item summary::-webkit-details-marker { display: none; }
	.rmd-ck-faq__item summary::after {
		content: "";
		flex: none;
		width: 10px;
		height: 10px;
		border-right: 2px solid var(--color-content-tertiary);
		border-bottom: 2px solid var(--color-content-tertiary);
		transform: rotate(45deg);
		transition: transform .15s ease;
	}
	.rmd-ck-faq__item[open] summary::after { transform: rotate(-135deg); }
	.rmd-ck-faq__item summary:focus-visible { outline: 2px solid var(--color-border-control-focus); outline-offset: 4px; border-radius: var(--radius-4); }
	.rmd-ck-faq__item .rmd-s-card-text { margin-top: var(--space-md); max-width: 760px; }
	.rmd-ck-faq__item .rmd-s-card-text > * + * { margin-top: var(--space-sm); }

	/* ── calls to action ──────────────────────────────────────────────── */

	.rmd-ck--cta-mid { padding-bottom: var(--spacing-64); }
	.rmd-ck-cta {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		justify-content: space-between;
		gap: var(--space-2xl);
		padding: var(--spacing-32);
		border-radius: var(--radius-16);
		background: var(--color-surface-accent-indigo);
	}
	.rmd-ck-cta__copy { display: grid; gap: var(--space-sm); flex: 1 1 360px; min-width: 0; }
	.rmd-ck-cta .rmd-s-card-text { margin: 0; }

	.rmd-ck--cta-closing { background: var(--color-rhillane-dark); color: var(--color-content-static-white); }
	.rmd-ck-closing {
		display: grid;
		justify-items: center;
		gap: var(--space-2xl);
		max-width: 760px;
		margin-inline: auto;
		text-align: center;
	}
	.rmd-ck--cta-closing .rmd-s-title { color: var(--color-content-static-white); }
	.rmd-ck-closing__text {
		margin: 0;
		font-size: var(--font-size-body-lg);
		line-height: var(--line-height-body);
		color: var(--color-content-quaternary);
	}

	/* ── phones ───────────────────────────────────────────────────────── */

	@media (max-width: 1023px) {
		.rmd-ck-gallery--3 > .rmd-ck-shot:last-child:nth-child(3n + 1) { grid-column: auto; }
		.rmd-ck-gallery--3 > .rmd-ck-shot:last-child:nth-child(odd) {
			grid-column: 1 / -1;
			justify-self: center;
			width: calc((100% - var(--space-2xl)) / 2);
		}
		.rmd-ck-cards--3,
		.rmd-ck-cards--4,
		.rmd-ck-related,
		.rmd-ck-gallery--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
		.rmd-ck--with-facts .rmd-ck-split { grid-template-columns: minmax(0, 1fr); }
	}

	@media (max-width: 760px) {
		.rmd-ck-gallery > .rmd-ck-shot:last-child:nth-child(odd) { grid-column: auto; width: 100%; justify-self: stretch; }
		.rmd-ck-gallery > .rmd-ck-shot--tall.rmd-ck-shot:not(.rmd-ck-shot--full) { width: min(100%, max(320px, calc(1000px / var(--ck-r)))); justify-self: center; }
		.rmd-ck-hero,
		.rmd-ck-cards--2,
		.rmd-ck-cards--3,
		.rmd-ck-cards--4,
		.rmd-ck-related,
		.rmd-ck-gallery--2,
		.rmd-ck-gallery--3 { grid-template-columns: minmax(0, 1fr); }
		.rmd-ck-hero { gap: var(--spacing-32); }
		.rmd-ck-metrics { grid-template-columns: minmax(0, 1fr); }
		.rmd-ck-metric__value { font-size: var(--font-size-h4); }
		.rmd-ck-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-lg); }
		.rmd-ck-hero__actions { gap: var(--space-lg); }
		.rmd-ck-route a { font-size: var(--font-size-label-lg); }
		.rmd-ck-quote { padding-left: var(--space-xl); }
		.rmd-ck-quote blockquote p { font-size: var(--font-size-h6); }
		.rmd-ck-note { padding: var(--space-2xl); }
		.rmd-ck-cta { padding: var(--space-2xl); }
		.rmd-ck-dialog__img { max-height: 78vh; }
	}

	@media (prefers-reduced-motion: reduce) {
		.rmd-ck-route a,
		.rmd-ck-faq__item summary::after { transition: none; }
	}
}
