/*
 * Case study: the numbers band, then the story beside «بصمة بداية نمو في
 * المشروع» (pages/case-study/metrics.php, story.php).
 */

/* ---------- «بالأرقام»: a row of watch faces (components/metric/) ---------- */

.gb-case-metrics {
	padding-block: var(--gb-space-2xl);
	background-color: var(--gb-surface);
	background-image: radial-gradient(60% 70% at 50% 0%, var(--gb-color-turquoise-a10), transparent 70%);
	color: var(--gb-text);
}

.gb-case-metrics__title {
	margin-block-end: var(--gb-space-xl);
	font-size: var(--gb-step-4);
	text-align: center;
	color: var(--gb-color-navy);
}

.gb-case-metrics__list {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: var(--gb-space-xl) var(--gb-space-l);
	margin: 0;
	padding: 0;
	list-style: none;
}

.gb-case-metrics__list > li {
	flex: 0 1 15rem;
}

/* Six numbers: two calm rows of three. Four: one row of four on wide screens, two by two below. */
@media (min-width: 48rem) {
	.gb-case-metrics__list[data-count="6"] > li {
		flex-basis: calc((100% - 2 * var(--gb-space-l)) / 3);
		max-inline-size: 20rem;
	}
}

@media (min-width: 48rem) and (max-width: 74.99rem) {
	.gb-case-metrics__list[data-count="4"] > li {
		flex-basis: calc((100% - var(--gb-space-l)) / 2);
		max-inline-size: 20rem;
	}
}

/* Phones: two faces side by side (they are small enough), one when a single number. */
@media (max-width: 47.99rem) {
	.gb-case-metrics__list > li {
		flex-basis: calc((100% - var(--gb-space-l)) / 2);
	}

	.gb-case-metrics__list[data-count="1"] > li {
		flex-basis: 100%;
	}

	.gb-case-metrics__list .gb-metric__dial {
		inline-size: min(100%, 10rem);
	}
}

/* ---------- The story: the opening beside «بصمة بداية نمو» ---------- */

.gb-case-story {
	padding-block: var(--gb-space-2xl) var(--gb-space-3xl);
	background-color: var(--gb-bg);
	color: var(--gb-text);
}

.gb-case-story__top {
	display: grid;
	gap: var(--gb-space-xl);
	align-items: start;
}

@media (min-width: 64rem) {
	.gb-case-story__top--with-roles {
		grid-template-columns: minmax(0, 1fr) minmax(18rem, 25rem);
		column-gap: var(--gb-space-2xl);
	}
}

/*
 * The opening: the first paragraph large and navy, under a turquoise line
 * that starts where the reading starts; the rest in the body size. Lines
 * are balanced (D-38): no stub of one or two words on a last line.
 */
.gb-case-story__intro {
	position: relative;
	display: grid;
	gap: var(--gb-space-s);
	max-inline-size: 46rem;
	padding-block-start: var(--gb-space-m);
}

.gb-case-story__intro::before {
	content: "";
	position: absolute;
	inset-block-start: 0;
	inset-inline-start: 0;
	inline-size: 4.5rem;
	block-size: 4px;
	border-radius: var(--gb-radius-pill);
	background: linear-gradient(var(--gb-dir-deg, 270deg), var(--gb-primary), var(--gb-seed));
}

[dir="ltr"] .gb-case-story__intro::before {
	--gb-dir-deg: 90deg;
}

.gb-case-story__intro p {
	margin: 0;
	font-size: var(--gb-step-1);
	line-height: 1.9;
	color: var(--gb-text-muted);
	text-wrap: balance;
}

.gb-case-story__intro > p:first-child {
	font-size: var(--gb-step-3);
	line-height: 1.65;
	font-weight: var(--gb-weight-medium);
	color: var(--gb-color-navy);
}

/* ---------- «بصمة بداية نمو في المشروع» ---------- */

.gb-case-roles {
	--gb-focus: var(--gb-focus-inverse);

	padding: var(--gb-space-m);
	border-radius: var(--gb-radius-l);
	background-color: var(--gb-scene-bg);
	background-image: radial-gradient(80% 50% at 50% 0%, var(--gb-color-turquoise-a20), transparent 70%);
	color: var(--gb-scene-text);
	box-shadow: 0 1.5rem 3rem -2rem rgb(12 35 66 / 0.5);
}

.gb-case-roles__title {
	margin-block-end: var(--gb-space-s);
	font-size: var(--gb-step-1);
	color: var(--gb-primary);
}

/* The roles hang on a fine line, a seed at each — the Growth Line again. */
.gb-case-roles__list {
	position: relative;
	display: grid;
	gap: var(--gb-space-s);
	margin: 0;
	padding: 0;
	list-style: none;
}

.gb-case-roles__list::before {
	content: "";
	position: absolute;
	inset-block: 0.6em 0.6em;
	inset-inline-start: calc(0.35rem - 0.5px);
	inline-size: 1px;
	background-color: var(--gb-color-turquoise-a35);
}

.gb-case-roles__item {
	position: relative;
	display: grid;
	grid-template-columns: 0.7rem 1fr;
	gap: var(--gb-space-xs);
	align-items: start;
}

.gb-case-roles__seed {
	inline-size: 0.7rem;
	aspect-ratio: 1;
	margin-block-start: 0.45em;
	border-radius: 50%;
	background-color: var(--gb-seed);
	box-shadow: 0 0 0 3px var(--gb-scene-bg), 0 0 0.6rem var(--gb-seed-glow);
}

.gb-case-roles__text {
	display: grid;
	gap: 0.2em;
	line-height: 1.6;
}

.gb-case-roles__text strong {
	font-weight: var(--gb-weight-bold);
	text-wrap: balance;
}

.gb-case-roles__text span {
	font-size: var(--gb-step--1);
	color: var(--gb-scene-text-muted);
	text-wrap: balance;
}

/* ---------- The chapters, along the Growth Line ---------- */

/*
 * Wide screens: a line down the middle; each chapter is a row with its text
 * on one side and its picture on the other, the sides alternating; a seed on
 * the line at every chapter. The line's light part grows as the story is read
 * (--gb-story-progress, set by story.js; 1 = drawn, the default).
 * Phones / tablets: the line runs along the reading start, the picture under
 * the text.
 */
.gb-case-chapters {
	--gb-line-x: 0.55rem;

	position: relative;
	display: grid;
	gap: var(--gb-space-2xl);
	margin: var(--gb-space-2xl) 0 0;
	padding: 0;
	padding-inline-start: 2.5rem;
	list-style: none;
}

.gb-case-chapters::before,
.gb-case-chapters::after {
	content: "";
	position: absolute;
	inset-block: 0;
	inset-inline-start: var(--gb-line-x);
	inline-size: 2px;
	margin-inline-start: -1px;
	border-radius: var(--gb-radius-pill);
}

/* The track… */
.gb-case-chapters::before {
	background-color: var(--gb-color-turquoise-a20);
}

/* …and the light that grows along it. */
.gb-case-chapters::after {
	background: linear-gradient(to bottom, var(--gb-primary), var(--gb-seed));
	transform-origin: top;
	scale: 1 var(--gb-story-progress, 1);
}

.gb-case-chapter {
	position: relative;
	display: grid;
	gap: var(--gb-space-m);
	align-items: center;
}

.gb-case-chapter__node {
	position: absolute;
	z-index: 1;
	inset-block-start: 0.55em;
	inset-inline-start: calc(var(--gb-line-x) - 2.5rem);
	inline-size: 1.1rem;
	aspect-ratio: 1;
	margin-inline-start: -0.55rem;
	border: 2px solid var(--gb-primary);
	border-radius: 50%;
	background-color: var(--gb-bg);
	transition:
		background-color var(--gb-duration-base) linear,
		box-shadow var(--gb-duration-slow) var(--gb-ease-out);
}

/* Reached (or no script): the seed is lit, with its soft glow. */
.gb-case-chapter:not([data-gb-pending]) .gb-case-chapter__node {
	border-color: var(--gb-seed);
	background-color: var(--gb-seed);
	box-shadow: 0 0 0 5px var(--gb-color-seed-a35), 0 0 1.2rem var(--gb-seed-glow);
}

.gb-case-chapter__text {
	display: grid;
	gap: var(--gb-space-xs);
	max-inline-size: 38rem;
}

.gb-case-chapter__text h2,
.gb-case-chapter__text h3 {
	margin: 0;
	font-family: var(--gb-font-display);
	font-size: var(--gb-step-3);
	line-height: 1.35;
	color: var(--gb-color-navy);
	text-wrap: balance;
}

.gb-case-chapter__text p {
	margin: 0;
	font-size: var(--gb-step-1);
	line-height: 1.9;
	text-wrap: balance;
}

.gb-case-chapter__text ul,
.gb-case-chapter__text ol {
	margin: 0;
	padding-inline-start: 1.2em;
	font-size: var(--gb-step-1);
	line-height: 1.9;
}

/* ---------- The chapter's picture ---------- */

.gb-case-chapter__picture {
	position: relative;
	margin: 0;
}

.gb-case-chapter__image {
	display: block;
	inline-size: 100%;
	block-size: auto;
	aspect-ratio: 16 / 10;
	object-fit: cover;
	border-radius: var(--gb-radius-l);
	background-color: var(--gb-color-navy);
	box-shadow: 0 1.75rem 3rem -2rem rgb(12 35 66 / 0.55);
}

.gb-case-chapter--portrait .gb-case-chapter__picture {
	inline-size: min(100%, 21rem);
}

.gb-case-chapter--portrait .gb-case-chapter__image {
	aspect-ratio: 4 / 5;
	object-position: 50% 42%;
}

/* The brand's signature on the photo: a fine turquoise edge and the seed in the corner. */
.gb-case-chapter__picture::after {
	content: "";
	position: absolute;
	inset: 0 0 auto;
	aspect-ratio: 16 / 10;
	border: 1px solid var(--gb-color-turquoise-a35);
	border-radius: var(--gb-radius-l);
	background: radial-gradient(circle at calc(100% - 1.2rem) 1.2rem, var(--gb-seed) 0 0.34rem, transparent 0.38rem);
	pointer-events: none;
}

.gb-case-chapter--portrait .gb-case-chapter__picture::after {
	aspect-ratio: 4 / 5;
}

[dir="ltr"] .gb-case-chapter__picture::after {
	background: radial-gradient(circle at 1.2rem 1.2rem, var(--gb-seed) 0 0.34rem, transparent 0.38rem);
}

.gb-case-chapter__caption {
	display: flex;
	align-items: center;
	gap: 0.5em;
	margin-block-start: var(--gb-space-2xs);
	font-size: var(--gb-step--1);
	color: var(--gb-text-muted);
}

.gb-case-chapter__caption::before {
	content: "";
	flex: none;
	inline-size: 1.4rem;
	block-size: 1px;
	background-color: var(--gb-primary);
}

/* ---------- Wide screens: the line in the middle, sides alternating ---------- */

@media (min-width: 56rem) {
	.gb-case-chapters {
		--gb-line-x: 50%;

		padding-inline-start: 0;
		gap: var(--gb-space-3xl);
	}

	.gb-case-chapter {
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
		column-gap: calc(2 * var(--gb-space-xl));
	}

	/* On the line, level with the middle of the chapter. */
	.gb-case-chapter__node {
		inset-block-start: 50%;
		inset-inline-start: var(--gb-line-x);
		margin-block-start: -0.55rem;
	}

	/* Odd chapters: text on the reading-start side, picture after the line. */
	.gb-case-chapter__text {
		grid-column: 1;
		grid-row: 1;
		justify-self: end;
	}

	.gb-case-chapter__picture {
		grid-column: 2;
		grid-row: 1;
		justify-self: start;
	}

	/* Even chapters: the other way round. */
	.gb-case-chapter:nth-child(even) .gb-case-chapter__text {
		grid-column: 2;
		justify-self: start;
	}

	.gb-case-chapter:nth-child(even) .gb-case-chapter__picture {
		grid-column: 1;
		justify-self: end;
	}

	/* A chapter without a picture keeps its side; the other side stays open. */
	.gb-case-chapter--text .gb-case-chapter__text {
		max-inline-size: 34rem;
	}
}
