/* Project Content — the art-directed project body.
   Seven layouts, one section shell, one media grid. Nothing here is reachable
   from any other template: the selectors are all new, and the page, landing and
   homepage systems keep their own classes.

   Every value is a token. There are no pixel margins, font sizes, gaps or
   colours an editor can reach — the ACF field group offers compositions
   (widths, alignment, ground, spacing steps) and this file decides what each
   one looks like. */

/* ---- Section shell ----
   Shared by all seven layouts. Ground, container width, vertical rhythm and
   the anchor target, in one place, so a new layout inherits all four by
   emitting the same two elements. */
.project-block {
	--section-max: var(--content-max);
	--media-gap: var(--space-md);
	/* The ground a creative sits on. Named rather than set per frame: the
	   HTML5 component writes `--ad-bg: var(--ad-ground)` and the section
	   decides what that resolves to, so there is no colour picker anywhere in
	   the chain. */
	--ad-ground: var(--color-bg-elevated);
	padding-block: var(--space-xl);
}

.project-block--space-top-reduced {
	padding-block-start: var(--space-lg);
}

.project-block--space-top-none {
	padding-block-start: 0;
}

.project-block--space-bottom-reduced {
	padding-block-end: var(--space-lg);
}

.project-block--space-bottom-none {
	padding-block-end: 0;
}

/* Dark is one step up from the page, which on a black page is a small step —
   --color-bg-elevated is 4% lighter than --color-bg and that is the whole
   range the palette has. So the band is drawn as well as filled: a hairline
   marks where it starts and ends, and the section reads as a panel rather than
   as more page.

   A run of adjacent dark sections is one panel, not several, so the rule
   between two of them is made transparent rather than removed — keeping the
   1px means no section shifts by a pixel depending on its neighbour. */
.project-block--bg-dark {
	background: var(--color-bg-elevated);
	border-block: 1px solid var(--color-line);
}

.project-block--bg-dark + .project-block--bg-dark {
	border-block-start-color: transparent;
}

.project-block--bg-dark:not(:last-child) {
	border-block-end-color: transparent;
}

/* Kept in its own rule, not folded into the one below. A selector list is not
   forgiving — one selector a browser does not understand drops the whole rule
   — and this half needs no :has(). */
.project-block--bg-dark:last-child {
	border-block-end-color: var(--color-line);
}

/* Where the run of dark sections ends. In a browser without :has() the panel
   simply keeps its opening hairline and loses its closing one, which is a
   softer edge rather than a broken layout. */
.project-block--bg-dark:has(+ :not(.project-block--bg-dark)) {
	border-block-end-color: var(--color-line);
}

/* Light is a real inversion, not a lighter black: the foreground ramp flips
   with the ground, so body copy, captions, labels and hairlines all stay at
   the same relative contrast they have on dark. Anything that reads a
   --color-fg-* token inside a light section gets the light-ground value. */
.project-block--bg-light {
	background: var(--color-surface-light);
	--color-fg: var(--color-fg-on-light);
	--color-fg-soft: var(--color-fg-on-light);
	--color-fg-dim: var(--color-fg-on-light-dim);
	--color-fg-faint: var(--color-fg-on-light-dim);
	--color-line: var(--color-line-on-light);
	--ad-ground: var(--color-surface-light-raised);
	color: var(--color-fg-on-light);
}

/* Same geometry as .flex-block: the container is expressed as padding rather
   than a max-width wrapper, so a full-bleed section is the absence of padding
   instead of an extra element. --section-max is what the three container
   settings change. */
.project-block__inner {
	padding-inline: max(
		var(--gutter),
		(100% - (var(--section-max) - 2 * var(--gutter))) / 2
	);
}

.project-block__inner--wide {
	--section-max: var(--content-max-wide);
}

.project-block__inner--full {
	padding-inline: 0;
}

/* ---- Media grid ----
   Twelve columns, expressed as proportional flex widths rather than
   grid-template-columns. The reason is wrapping: flex lines form from the
   items' own widths, so a block of any number of items fills each row and
   overflows onto the next by itself — 25+25+50 ends a row exactly, 25+75 ends
   a row exactly, and six 25s make one-and-a-half rows without the block
   knowing how many rows it has. A 12-track grid would need every item placed.

   The width formula is the standard n-of-12-with-gaps one:
     span/12 × (100% + gap) − gap
   which is why a 6 and two 3s land on the same edges as a real 12-track grid. */
.media-grid {
	display: flex;
	flex-wrap: wrap;
	gap: var(--media-gap);
	/* So the HTML5 step-down below can ask how wide the *grid* is rather than
	   how wide the window is. The answer differs by container setting, and the
	   window cannot tell them apart. */
	container-type: inline-size;
	container-name: media;
}

.media-grid--align-left {
	justify-content: flex-start;
}

.media-grid--align-centre {
	justify-content: center;
}

.media-grid--align-right {
	justify-content: flex-end;
}

.media-grid--valign-top {
	align-items: flex-start;
}

.media-grid--valign-centre {
	align-items: center;
}

.media-grid--valign-bottom {
	align-items: flex-end;
}

.media-grid__item {
	--span: 12;
	flex: 0 1 auto;
	width: calc(var(--span) / 12 * (100% + var(--media-gap)) - var(--media-gap));
	max-width: 100%;
	min-width: 0;
}

.media-grid__item--span-3 {
	--span: 3;
}

.media-grid__item--span-6 {
	--span: 6;
}

.media-grid__item--span-9 {
	--span: 9;
}

.media-grid__item--span-12 {
	--span: 12;
}

/* Tablet and small desktop: 25 → 50, 75 → 100. The two breakpoints are the
   theme's existing ones (1200 from the case-study format wall, 640 from every
   other mobile rule); no new breakpoint is introduced for this component. */
@media (max-width: 1199px) {
	.media-grid__item--span-3 {
		--span: 6;
	}

	.media-grid__item--span-9 {
		--span: 12;
	}
}

@media (max-width: 640px) {
	.media-grid__item--span-3,
	.media-grid__item--span-6,
	.media-grid__item--span-9,
	.media-grid__item--span-12 {
		--span: 12;
	}
}

/* HTML5 creatives are the one case where the column width is not the whole
   story, because the creative inside has a real size that the layout must
   respect rather than override.

   Four 160×600s fit across a standard container at true size. Four 300×600s
   need 1320px of grid (see --content-max-wide) and do not, so below that a
   wide creative takes half a row instead of a quarter — two deliberate columns
   rather than four squeezed ones. The measurement is of the grid, so the same
   rule gives the right answer in a standard, wide or full container.

   The lower bound matters: under ~600px of grid every item is full width
   anyway, and without it this rule's higher specificity would beat the mobile
   rule above and leave a creative at half width on a phone. */
@container media (min-width: 601px) and (max-width: 1319px) {
	.media-grid__item--span-3.has-wide-creative {
		--span: 6;
	}
}

/* ---- Media items ----
   One presentation for all three media types, in all three layouts that use
   them. */
.media-item {
	margin: 0;
}

.media-item__media {
	position: relative;
}

.media-item__image,
.media-item__video {
	display: block;
	width: 100%;
	height: auto;
}

/* Natural is the default and needs no rule — the file's own proportions are
   kept. Crop offers five shapes and nothing else; there is no way to type a
   ratio, and no arbitrary dimensions are exposed. */
.media-item__media--ratio-16x9,
.media-item__media--ratio-4x3,
.media-item__media--ratio-1x1,
.media-item__media--ratio-3x4,
.media-item__media--ratio-9x16 {
	overflow: hidden;
}

.media-item__media--ratio-16x9 {
	aspect-ratio: 16 / 9;
}

.media-item__media--ratio-4x3 {
	aspect-ratio: 4 / 3;
}

.media-item__media--ratio-1x1 {
	aspect-ratio: 1 / 1;
}

.media-item__media--ratio-3x4 {
	aspect-ratio: 3 / 4;
}

.media-item__media--ratio-9x16 {
	aspect-ratio: 9 / 16;
}

.media-item__media[class*="ratio-"] > .media-item__image,
.media-item__media[class*="ratio-"] > .media-item__video {
	height: 100%;
	object-fit: cover;
}

/* A creative is never stretched to its column. It renders at its real size and
   is centred in whatever space the column gives it — .ad-frame's own
   `width: var(--ad-w); max-width: 100%` does the sizing, and this only decides
   where the leftover space goes. */
.media-item--html5 .media-item__media {
	display: flex;
	justify-content: center;
}

.media-item--html5 .media-item__caption {
	text-align: center;
}

.media-item__label {
	margin-bottom: var(--space-2xs);
	font-size: var(--size-label);
	font-weight: 700;
	text-transform: none; /* Direction C: no capitals */
	letter-spacing: 0;
	color: var(--color-fg-dim);
}

.media-item__caption {
	margin-top: var(--space-xs);
	font-size: var(--size-small);
	color: var(--color-fg-dim);
}

/* ---- Text ---- */
.project-text--width-50 {
	max-width: 50%;
}

.project-text--width-75 {
	max-width: 75%;
}

.project-text--centre {
	margin-inline: auto;
	text-align: center;
}

@media (max-width: 899px) {
	.project-text--width-50,
	.project-text--width-75 {
		max-width: none;
	}
}

.project-text__eyebrow {
	margin-bottom: var(--space-sm);
	font-size: var(--size-label);
	font-weight: 700;
	text-transform: none; /* Direction C: no capitals */
	letter-spacing: 0;
	color: var(--color-fg-dim);
}

.project-text__heading {
	font-size: var(--size-h2);
	font-weight: 800;
	line-height: 1.1;
	max-width: 20ch;
}

.project-text--centre .project-text__heading {
	margin-inline: auto;
}

/* The measure, not the column, decides where a line breaks. A 100%-width Text
   block still sets its body at a readable length; the width setting controls
   the block's share of the page, and 68ch is the same measure .flex-block__body
   has used since the case studies were built. */
.project-text__body {
	max-width: 68ch;
	font-size: var(--size-body-lg);
	color: var(--color-fg-dim);
}

.project-text__heading + .project-text__body {
	margin-top: var(--space-sm);
}

.project-text--centre .project-text__body {
	margin-inline: auto;
}

.project-text__body p + p {
	margin-top: var(--space-xs);
}

.project-text__body a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

/* ---- Text + Media ----
   Composition is the text's share against the media's: even, or 40/60 either
   way. The shares are named rather than written as a column list because the
   columns follow the *visual* order, and media-left reverses it — so the same
   two values are simply laid out the other way round. Project rows have no
   composition setting and stay even. */
.project-text-media {
	--text-share: 1fr;
	--media-share: 1fr;
	display: grid;
	grid-template-columns: var(--text-share) var(--media-share);
	gap: var(--space-lg);
	align-items: center;
}

.project-text-media--split-40-60 {
	--text-share: 2fr;
	--media-share: 3fr;
}

.project-text-media--split-60-40 {
	--text-share: 3fr;
	--media-share: 2fr;
}

.project-text-media--media-left {
	grid-template-columns: var(--media-share) var(--text-share);
}

.project-text-media--media-left .project-text-media__text {
	order: 2;
}

.project-text-media--media-left .project-text-media__media {
	order: 1;
}

/* Stacked, text first, whichever side the media was on. The explanation is
   the reason this block exists rather than a Media Layout, so it should not be
   the half that scrolls past. */
@media (max-width: 899px) {
	.project-text-media {
		grid-template-columns: 1fr;
	}

	.project-text-media--media-left .project-text-media__text,
	.project-text-media--media-left .project-text-media__media {
		order: 0;
	}
}

/* ---- Before / After ---- */
.project-before-after {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--space-lg);
	align-items: start;
}

@media (max-width: 899px) {
	.project-before-after {
		grid-template-columns: 1fr;
	}
}

/* ---- Quote ---- */
.project-quote {
	margin: 0;
	text-align: center;
}

.project-quote__text {
	margin: 0;
	font-size: var(--size-h2);
	font-weight: 600;
	line-height: 1.25;
	max-width: 32ch;
	margin-inline: auto;
}

.project-quote__attribution {
	margin-top: var(--space-sm);
	font-size: var(--size-small);
	text-transform: none; /* Direction C: no capitals */
	letter-spacing: 0;
	color: var(--color-fg-dim);
}

/* ---- Production Stats ---- */
.project-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: var(--space-lg);
	margin: 0;
}

.project-stats__item {
	min-width: 0;
}

.project-stats__value {
	font-size: var(--size-hero);
	font-weight: 800;
	line-height: 1;
}

.project-stats__label {
	margin: var(--space-xs) 0 0;
	font-size: var(--size-small);
	text-transform: none; /* Direction C: no capitals */
	letter-spacing: 0;
	color: var(--color-fg-dim);
}

/* ---- Delivery / Credits ----
   Compact on purpose: this is the closing summary, not a section of its own
   weight, so the heading sits at label scale beside the list rather than above
   it at heading scale. */
.project-credits {
	display: grid;
	grid-template-columns: minmax(0, 18ch) 1fr;
	gap: var(--space-sm) var(--space-lg);
	align-items: start;
	border-top: 1px solid var(--color-line);
	padding-top: var(--space-md);
}

.project-credits__heading {
	margin: 0;
	font-size: var(--size-label);
	font-weight: 700;
	text-transform: none; /* Direction C: no capitals */
	letter-spacing: 0;
	color: var(--color-fg-dim);
}

.project-credits__list {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-2xs);
	margin: 0;
	padding: 0;
	list-style: none;
}

.project-credits__item {
	font-size: var(--size-body);
	color: var(--color-fg-soft);
}

/* A dot between items rather than a bullet before each: the list reads as one
   delivery line.

   It trails its own item rather than leading the next one, which is what keeps
   it from ever opening a wrapped row — a leading separator is the first thing
   on the new line, and reads as a bullet for an item it does not belong to. */
.project-credits__item:not(:last-child)::after {
	content: "·";
	margin-inline: var(--space-2xs);
	color: var(--color-fg-faint);
}

@media (max-width: 640px) {
	.project-credits {
		grid-template-columns: 1fr;
	}
}

/* ---- Background Video ----
   The full-bleed cinematic moment. `.project-block` outside still owns spacing
   and the anchor; everything below is the film's own box, which is why the
   section takes no container — it has no inner padding to give. */
.project-bgvideo {
	position: relative;
	display: flex;
	overflow: hidden;
	background: var(--color-bg);
}

/* Cropped heights. The film is absolutely positioned and cover-cropped, so the
   section's height is the composition's and never the file's. */
.project-bgvideo--h-viewport,
.project-bgvideo--h-tall {
	min-height: 72dvh;
}

.project-bgvideo--h-viewport {
	min-height: 100dvh;
}

.project-bgvideo--h-viewport .project-bgvideo__media,
.project-bgvideo--h-tall .project-bgvideo__media {
	position: absolute;
	inset: 0;
}

.project-bgvideo--h-viewport .project-bgvideo__video,
.project-bgvideo--h-tall .project-bgvideo__video {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Natural keeps the file's own proportions and crops nothing, so the film sits
   in flow and the section is exactly as tall as it is. Nothing reserves the
   ratio in advance — the element's own intrinsic size does, the moment its
   metadata arrives, which is why this height is the one that can shift if a
   poster is not set. */
.project-bgvideo--h-natural .project-bgvideo__media {
	width: 100%;
}

.project-bgvideo--h-natural .project-bgvideo__video {
	display: block;
	width: 100%;
	height: auto;
}

.project-bgvideo--h-natural .project-bgvideo__content {
	position: absolute;
	inset: 0;
}

/* A cinematic crop on a landscape source needs a wide, short viewport to read.
   On a phone the same crop keeps a sliver of the frame's width and routinely
   loses whatever was off-centre — the reason project.css already eases its
   other full-bleed moments to 62vh below this breakpoint. The legacy component
   was written with inline styles that outranked that rule and never got it;
   this one does. */
@media (max-width: 640px) {
	.project-bgvideo--h-viewport {
		min-height: 62dvh;
	}

	.project-bgvideo--h-tall {
		min-height: 52dvh;
	}
}

.project-bgvideo__content {
	position: relative;
	z-index: 2;
	width: 100%;
	display: flex;
}

/* Centre — the cinematic statement, and what the legacy component rendered. */
.project-bgvideo--pos-centre .project-bgvideo__content {
	align-items: center;
	justify-content: center;
	text-align: center;
}

/* Bottom — the composition the project hero already uses: the block sits on
   the foot of the frame, inside the standard gutters. */
.project-bgvideo--pos-bottom-left .project-bgvideo__content,
.project-bgvideo--pos-bottom-centre .project-bgvideo__content {
	align-items: flex-end;
	padding-block-end: var(--space-xl);
}

.project-bgvideo--pos-bottom-centre .project-bgvideo__content {
	text-align: center;
}

/* A centred radial vignette is the right shape behind centred text and the
   wrong one behind text on the foot of the frame, where the weight belongs at
   the bottom — the same linear treatment .project-hero__scrim uses. The
   strength modifier still applies, because both read --scrim-core. */
.project-bgvideo--pos-bottom-left .bg-video-scrim,
.project-bgvideo--pos-bottom-centre .bg-video-scrim {
	background: linear-gradient(
		to top,
		rgba(0, 0, 0, var(--scrim-core)) 0%,
		rgba(0, 0, 0, var(--scrim-mid)) 55%,
		transparent 100%
	);
}

.project-bgvideo__eyebrow {
	margin: 0 0 var(--space-sm);
	font-size: var(--size-label);
	font-weight: 700;
	letter-spacing: 0;
	text-transform: none; /* Direction C: no capitals */
	/* Matches .project-hero__eyebrow: 0.72 is the value that clears 4.5:1 over
	   this theme's hero media while still reading as secondary. */
	opacity: 0.72;
}

.project-bgvideo__heading {
	margin: 0;
	font-size: var(--size-hero);
	font-weight: 800;
	line-height: 1.02;
	max-width: 20ch;
}

.project-bgvideo--pos-centre .project-bgvideo__heading,
.project-bgvideo--pos-bottom-centre .project-bgvideo__heading {
	margin-inline: auto;
}

.project-bgvideo__body {
	margin: var(--space-sm) 0 0;
	font-size: var(--size-body-lg);
	color: var(--color-fg-soft);
	max-width: 46ch;
}

.project-bgvideo--pos-centre .project-bgvideo__body,
.project-bgvideo--pos-bottom-centre .project-bgvideo__body {
	margin-inline: auto;
}
