/**
 * Case study (single-case_study.php; frame case-study-single).
 *
 * Header with the intro and share row, the orange stats bar and the facts
 * sidebar. Shared layout: singles.css.
 *
 * Logical properties only (RTL follows the active language). Tokens used
 * only here are local to this template.
 *
 * @package cartrack
 */

/*
 * Measured from design/subpages/case-study-single.png at 1920 (TODO: verify
 * in Figma): title in the .t-h1 style, a 556px 16:9 photo, no hairline under
 * the header, a full-width orange stats bar ~125px tall, then a ~788px body
 * and a ~248px facts sidebar at the row's end edge.
 */
.sp-single--case-study {
	--single-image-max: 34.75rem;         /* ~556px. */
	--single-image-share: 46%;
	--single-heading-gap: var(--space-lg);
	--single-rail-width: 15.5rem;         /* ~248px. */
	--single-main-max: 49.25rem;          /* ~788px. */
	--single-stats-bg: linear-gradient(90deg, var(--banner-orange) 0%, #f68244 100%); /* Frame #f55601 → #f68244. */
	--single-stats-text: var(--color-text-inverse);
	--single-stats-rule: var(--color-border-inverse);
	--single-stats-pad-x: var(--space-md);
	--single-stats-pad-y: var(--space-md);
	--single-stats-value-size: 1.75rem;   /* ~28px Montserrat 700. */
	--single-stats-gap: 0.5rem;           /* Value → label. */
	--single-stats-space: var(--space-xl);    /* Image → bar → body. */
	--single-lead-gap: var(--space-md);
	--facts-size: 1rem;                   /* ~16px labels and values. */
	--facts-rule: var(--color-border);
	--facts-row-pad: 1.125rem;            /* ~18px above and below each row. */
	--facts-value-gap: 0.5rem;
	--facts-logo-height: 3.25rem;         /* ~50px. */
}

@media (min-width: 64em) { /* --bp-lg */
	.sp-single--case-study {
		--single-header-pad-top: 5rem;    /* ~80px below the breadcrumb. */
		--single-header-pad-bottom: 0;
		--single-heading-gap: var(--space-xl);
		--single-lead-gap: var(--space-lg);   /* ~30px title → intro. */
		--single-stats-pad-x: 2.375rem;   /* ~38px. */
		--single-stats-pad-y: 1.625rem;   /* ~26px. */
		--single-stats-space: 3.5rem;     /* ~55px image → bar; the body adds ~64px. */
		--single-body-pad-top: var(--space-2xl);
	}
}

.sp-single--case-study .sp-single__header {
	border-block-end: 0;
}

.sp-single--case-study .sp-single__title {
	font-family: var(--t-h1-family);
	font-size: var(--t-h1-size);
	font-weight: var(--t-h1-weight);
	line-height: var(--t-h1-line-height);
	letter-spacing: var(--t-h1-tracking);
}

.sp-single__heading-text {
	display: flex;
	flex-direction: column;
	gap: var(--single-lead-gap);
	min-inline-size: 0;
}

.sp-single__lead {
	margin: 0;
	color: var(--color-text-muted);
	font-family: var(--t-body-family);
	font-size: var(--t-body-size);
	line-height: var(--t-body-line-height);
	overflow-wrap: anywhere;
}

/* An empty share row (no JS and no PDF) takes no space. */
.sp-single__actions.share-links:not(:has(.download-link, .share-links__group:not([hidden]))) {
	display: none;
}

/* Stats bar: orange, cells divided by a light line; one per row on phones. */
.sp-single__stats {
	max-inline-size: calc(var(--single-max) + 2 * var(--container-gutter));
	margin-inline: auto;
	padding-block-start: var(--single-stats-space);
	padding-inline: var(--container-gutter);
}

.sp-stats-bar {
	display: grid;
	margin: 0;
	padding: 0;
	list-style: none;
	background: var(--single-stats-bg);
	color: var(--single-stats-text);
}

.sp-stats-bar .stat {
	gap: var(--single-stats-gap);
	padding: var(--single-stats-pad-y) var(--single-stats-pad-x);
	min-inline-size: 0;
}

.sp-stats-bar .stat::before {
	display: none; /* No gradient hairline in the bar. */
}

.sp-stats-bar .stat + .stat {
	border-block-start: 1px solid var(--single-stats-rule);
}

.sp-stats-bar .stat__value,
.sp-stats-bar .stat__label {
	color: inherit;
	overflow-wrap: anywhere;
}

.sp-stats-bar .stat__value {
	font-family: var(--t-h1-family);
	font-size: var(--single-stats-value-size);
	font-weight: var(--t-h1-weight);
	line-height: 1.2;
}

.sp-stats-bar .stat__label {
	font-family: var(--t-body-bold-family);
	font-weight: var(--t-body-bold-weight);
}

@media (min-width: 48em) { /* --bp-md */
	/* Two per row: a line between the columns and above the second row. */
	.sp-stats-bar:not(.sp-stats-bar--1) {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.sp-stats-bar:not(.sp-stats-bar--1) .stat + .stat {
		border-block-start: 0;
	}

	.sp-stats-bar:not(.sp-stats-bar--1) .stat:nth-child(n + 3) {
		border-block-start: 1px solid var(--single-stats-rule);
	}

	.sp-stats-bar:not(.sp-stats-bar--1) .stat:nth-child(even) {
		border-inline-start: 1px solid var(--single-stats-rule);
	}
}

@media (min-width: 64em) { /* --bp-lg */
	/* Three or four in one row, a line between the cells. */
	.sp-stats-bar.sp-stats-bar--3 {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.sp-stats-bar.sp-stats-bar--4 {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.sp-stats-bar:is(.sp-stats-bar--3, .sp-stats-bar--4) .stat:nth-child(n) {
		border-block-start: 0;
		border-inline-start: 0;
	}

	.sp-stats-bar:is(.sp-stats-bar--3, .sp-stats-bar--4) .stat + .stat:nth-child(n) {
		border-inline-start: 1px solid var(--single-stats-rule);
	}
}

/* Body | facts sidebar. The facts come first in the markup (key facts first on phones). */
@media (min-width: 64em) { /* --bp-lg */
	.sp-single--case-study .sp-single__layout {
		grid-template-columns: minmax(0, var(--single-main-max)) var(--single-rail-width);
		justify-content: space-between;
	}

	.sp-single--case-study .sp-single__main {
		grid-row: 1;
		grid-column: 1;
	}

	.sp-single--case-study .sp-single__rail {
		grid-row: 1;
		grid-column: 2;
	}
}

/* Facts: logo, then rows split by hairlines. */
.sp-facts {
	font-family: var(--t-body-family);
	font-size: var(--facts-size);
	line-height: var(--t-body-line-height);
}

.sp-facts__logo {
	display: flex;
	justify-content: center;
	padding-block-end: var(--space-md);
	border-block-end: 1px solid var(--facts-rule);
}

.sp-facts__logo-image {
	display: block;
	inline-size: auto;
	max-inline-size: 100%;
	block-size: auto;
	max-block-size: var(--facts-logo-height);
	object-fit: contain;
}

.sp-facts__list {
	margin: 0;
}

.sp-facts__row {
	display: flex;
	flex-direction: column;
	gap: var(--facts-value-gap);
	padding-block: var(--facts-row-pad);
	border-block-end: 1px solid var(--facts-rule);
	min-inline-size: 0;
}

.sp-facts__label {
	color: var(--color-text);
	font-weight: var(--font-weight-medium);
}

.sp-facts__value {
	margin: 0;
	color: var(--color-text-muted);
	overflow-wrap: anywhere;
}

.sp-facts__value .tag-chip {
	overflow-wrap: anywhere;
}

/* Share row: label at the start, icons at the end; hidden until JS shows a button. */
.sp-facts__row--share:not(:has(.share-links__group:not([hidden]))) {
	display: none;
}

.sp-facts__share,
.sp-facts__share .share-links__group {
	inline-size: 100%;
}

.sp-facts__share .share-links__group {
	justify-content: space-between;
}

.sp-facts__share .share-links__label {
	color: var(--color-text);
	font-size: var(--facts-size);
	font-weight: var(--font-weight-medium);
}
