/* ==========================================================================
   Work: projects archive + single project
   Figma archive: desktop 4089:964 / 4101:4955, tablet 4016:635 / 4101:2876,
   mobile 4004:511 / 4101:3732.
   Figma single:  desktop 2:693 / 4101:4574, tablet 4021:525 / 4101:3224,
   mobile 4007:968 / 4101:4089.
   Desktop values are 1440px artboard pixels (var(--u)); tablet = 768px
   artboard in px; mobile = 390px artboard in px (status bar of 60 removed).
   ========================================================================== */

/* --------------------------------------------------------------------------
   Archive grid
   First card at y=200; two 645u columns with a 30u gap; rows top-aligned
   with 80u between the tallest card and the next row; last card bottom to
   "Back to top" = 80u.
   -------------------------------------------------------------------------- */
.projects-archive {
	padding: calc(200 * var(--u)) var(--gutter) calc(80 * var(--u));
}
.projects-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	column-gap: calc(30 * var(--u));
	row-gap: calc(80 * var(--u));
	align-items: start;
}
.projects-empty {
	font-size: calc(26 * var(--u));
	line-height: calc(32 * var(--u));
}

.project-card {
	min-width: 0;
}
.project-card__link {
	display: block;
	color: inherit;
}
/* 645 x 400. Only an empty slot is grey (the .placeholder-img element): a
   fill on the box itself showed as a hairline around images at some sizes. */
.project-card__media {
	position: relative;
	aspect-ratio: 645 / 400;
	overflow: hidden;
}
.project-card__media img,
.project-card__media video,
.project-card__media .placeholder-img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: opacity 0.3s var(--ease);
}
/* Title top 37u below the image: 26/32 bold. */
.project-card__title {
	margin-top: calc(37 * var(--u));
	font-weight: 700;
	font-size: calc(26 * var(--u));
	line-height: calc(32 * var(--u));
	letter-spacing: -0.02em;
	color: var(--fg);
	transition: opacity 0.2s var(--ease);
}
.project-card__link:hover .project-card__title,
.project-card__link:focus-visible .project-card__title {
	opacity: 0.5;
}
.project-card__link:hover img,
.project-card__link:hover video,
.project-card__link:hover .placeholder-img {
	opacity: 0.65;
}

/* Pills: 30u tall, 1u outline, 18/28 text, 10u gaps; top 16u below the title. */
.project-card .pills {
	display: flex;
	flex-wrap: wrap;
	gap: calc(10 * var(--u));
	margin-top: calc(16 * var(--u));
	color: var(--fg);
}
.project-card .pill {
	display: block;
	height: calc(30 * var(--u));
	padding: 0 calc(15 * var(--u));
	border: calc(1 * var(--u)) solid currentColor;
	font-size: calc(18 * var(--u));
	line-height: calc(28 * var(--u));
	letter-spacing: -0.01em;
	text-align: center;
	white-space: nowrap;
}
/* Highlighted projects use red pills in both colour schemes. */
.project-card--accent .pills {
	color: var(--red);
}

/* Tablet 768: 309 x 192 images in two columns, 18/21 title, 12.92px pills, 60px row gap. */
@media (min-width: 768px) and (max-width: 1023px) {
	.projects-archive {
		padding: 200px 60px 80px;
	}
	.projects-grid {
		column-gap: 30px;
		row-gap: 60px;
	}
	.project-card__title {
		margin-top: 20px;
		font-size: 18px;
		line-height: 21px;
	}
	.project-card .pills {
		gap: 7px;
		margin-top: 11px;
	}
	.project-card .pill {
		height: 21.5px;
		padding: 0 10.75px;
		border-width: 1px;
		font-size: 12.92px;
		line-height: 19.5px;
	}
}

/* Mobile 390: one 330 x 205 column, 16px title, 10px pills, 30px row gap. */
@media (max-width: 767px) {
	.projects-archive {
		padding: 110px 30px 24px;
	}
	.projects-grid {
		grid-template-columns: minmax(0, 1fr);
		row-gap: 30px;
	}
	.project-card__title {
		margin-top: 21px;
		font-size: 16px;
		line-height: 20px;
	}
	.project-card .pills {
		gap: 5px;
		margin-top: 4px;
	}
	/* The half-pixel outline is drawn as a 1px outline at double size, scaled
	   down by half. A true 0.5px border can lose an edge on iPhones when the
	   pill does not sit on a whole pixel; this always draws all four sides.
	   The pill's size and the text position are unchanged. */
	.project-card .pill {
		position: relative;
		height: 18px;
		padding: 0 10px;
		border: 0;
		font-size: 10px;
		line-height: 18px;
	}
	.project-card .pill::before {
		content: "";
		position: absolute;
		top: 0;
		left: 0;
		width: 200%;
		height: 200%;
		border: 1px solid currentColor;
		transform: scale(0.5);
		transform-origin: 0 0;
		pointer-events: none;
	}
	/* The card image is a whole number of pixels tall, so the title and
	   pills below it sit on whole pixels on every phone width. */
	@supports (height: round(down, 1.5px, 1px)) {
		.project-card__media {
			aspect-ratio: auto;
			height: round(down, calc((100vw - 60px) * 205 / 330), 1px);
		}
	}
}

/* --------------------------------------------------------------------------
   Single project
   -------------------------------------------------------------------------- */
/* Intro row at y=193; last module bottom to "Back to top" = 140u. */
.project-single {
	padding: calc(193 * var(--u)) var(--gutter) calc(140 * var(--u));
}

/* Intro: standfirst in the left half (533u wide), client name in column 3,
   services in column 4. */
.project-intro {
	display: grid;
	grid-template-columns: minmax(0, 645fr) minmax(0, 308fr) minmax(0, 307fr);
	column-gap: calc(30 * var(--u));
	align-items: start;
}
.project-intro__text {
	max-width: calc(533 * var(--u));
	font-size: calc(36 * var(--u));
	line-height: calc(40 * var(--u));
	letter-spacing: -0.01em;
}
.project-intro__client {
	font-weight: 700;
	font-size: calc(20 * var(--u));
	line-height: calc(26 * var(--u));
	letter-spacing: -0.02em;
}
.project-intro__services {
	font-size: calc(20 * var(--u));
	line-height: calc(26 * var(--u));
	letter-spacing: -0.01em;
}

/* Every module sits 140u below the previous element. */
.project-module {
	margin-top: calc(140 * var(--u));
}
/* Hero and bleed modules run edge to edge. */
.project-module--hero,
.project-module--bleed {
	margin-left: calc(-1 * var(--gutter));
	margin-right: calc(-1 * var(--gutter));
}

/* Media boxes keep the design ratios; only an empty slot is grey. */
.project-media {
	position: relative;
	margin: 0;
	overflow: hidden;
}
.project-media img,
.project-media video,
.project-media .placeholder-img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.project-media--hero  { aspect-ratio: 1440 / 848; }  /* Module 1 */
.project-media--half  { aspect-ratio: 645 / 627; }   /* Modules 2, 3, 5, 10, 11 */
.project-media--full  { aspect-ratio: 1320 / 742; }  /* Module 4 */
.project-media--stat  { aspect-ratio: 870 / 681; }   /* Modules 6, 7 */
.project-media--bleed { aspect-ratio: 16 / 9; }      /* Module 8 */
.project-media--grid  { aspect-ratio: 645 / 546; }   /* Module 9 */

/* Modules 2 and 3: half-width image with copy centred beside it. The copy
   column (421u) is inset 112u from the gutter on its outer side. */
.project-module--image-left,
.project-module--image-right {
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.project-module--image-left .project-media,
.project-module--image-right .project-media {
	flex: none;
	width: calc(645 * var(--u));
}
.project-copy {
	width: calc(421 * var(--u));
	font-size: calc(28 * var(--u));
	line-height: calc(34 * var(--u));
	letter-spacing: -0.01em;
}
.project-module--image-left .project-copy {
	margin-right: calc(112 * var(--u));
}
.project-module--image-right .project-copy {
	order: -1;
	margin-left: calc(113 * var(--u));
}

/* Modules 5 and 9: 645u images with 30u gaps. */
.project-module--pair,
.project-module--grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: calc(30 * var(--u));
}

/* Modules 6 and 7: one stat in an outer column (308u) with an 870u image. */
.project-module--stat-left,
.project-module--stat-right {
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.project-module--stat-left .project-media,
.project-module--stat-right .project-media {
	flex: none;
	width: calc(870 * var(--u));
}
.project-module--stat-left .project-stat {
	order: -1;
}
.project-stat {
	width: calc(308 * var(--u));
}
/* The number's line box (30u) is shorter than its glyphs, so the spacing is
   set baseline to baseline: 40u from the number to the text below it (as the
   design renders) and 72u from the text above it down to the number. */
.project-stat__number {
	margin-bottom: calc(16.75 * var(--u));
	font-weight: 700;
	font-size: calc(64 * var(--u));
	line-height: calc(30 * var(--u));
	letter-spacing: -0.02em;
}
.project-stat__number:last-child {
	margin-bottom: 0;
}
.project-stat__lead,
.project-stat__caption {
	font-size: calc(28 * var(--u));
	line-height: calc(34 * var(--u));
	letter-spacing: -0.01em;
}
.project-stat__lead {
	margin-bottom: calc(31.25 * var(--u));
}

/* Modules 10 and 11: two stacked stats (307u, 68u apart) beside a 645u image,
   inset 113u from the gutter on the outer side. */
.project-module--stats-left,
.project-module--stats-right {
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.project-module--stats-left .project-media,
.project-module--stats-right .project-media {
	flex: none;
	width: calc(645 * var(--u));
}
.project-stats {
	width: calc(307 * var(--u));
}
.project-stats .project-stat {
	width: 100%;
}
.project-stats .project-stat + .project-stat {
	margin-top: calc(68 * var(--u));
}
.project-module--stats-left .project-stats {
	order: -1;
	margin-left: calc(113 * var(--u));
}
.project-module--stats-right .project-stats {
	margin-right: calc(113 * var(--u));
}

/* Between the tablet and desktop artboards the page keeps its 60px gutters
   and the desktop layout scales down to fit between them, so the images,
   copy and stats keep their proportions and the space between them. */
@media (min-width: 1024px) and (max-width: 1439px) {
	.project-single {
		--u: calc((100vw - 120px) / 1320);
		padding: 193px 60px 140px;
	}
}

/* Tablet 768 */
@media (min-width: 768px) and (max-width: 1023px) {
	.project-single {
		padding: 193px 60px 80px;
	}
	/* Intro spans the row (535 wide); client name and services sit in the
	   two 309px columns 39px below it. */
	.project-intro {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		column-gap: 30px;
		row-gap: 39px;
	}
	.project-intro__text {
		grid-column: 1 / -1;
		max-width: 535px;
		font-size: 36px;
		line-height: 40px;
	}
	.project-intro__client {
		max-width: 196px;
		font-size: 18px;
		line-height: 22px;
	}
	.project-intro__services {
		font-size: 18px;
		line-height: 22px;
	}
	.project-module {
		margin-top: 80px;
	}
	.project-module--image-left .project-media,
	.project-module--image-right .project-media {
		width: 310px;
	}
	.project-copy {
		width: 252px;
		font-size: 18px;
		line-height: 22px;
	}
	.project-module--image-left .project-copy,
	.project-module--image-right .project-copy {
		margin: 0;
	}
	.project-module--pair,
	.project-module--grid {
		gap: 30px;
	}
	.project-module--stat-left .project-media,
	.project-module--stat-right .project-media {
		width: 422px;
	}
	.project-stat {
		width: 196px;
	}
	.project-stat__number {
		margin-bottom: 11.75px;
		font-size: 55px;
		line-height: 30px;
	}
	.project-stat__lead,
	.project-stat__caption {
		font-size: 18px;
		line-height: 22px;
	}
	.project-stat__lead {
		margin-bottom: 21.25px;
	}
	.project-module--stats-left .project-media,
	.project-module--stats-right .project-media {
		width: 309px;
	}
	.project-stats {
		width: 253px;
	}
	.project-stats .project-stat + .project-stat {
		margin-top: 44px;
	}
	.project-module--stats-left .project-stats,
	.project-module--stats-right .project-stats {
		margin: 0;
	}
}

/* Mobile 390: everything stacks in one 330px column. */
@media (max-width: 767px) {
	.project-single {
		padding: 115px 30px 80px;
	}
	.project-intro {
		display: block;
	}
	.project-intro__text {
		max-width: 331px;
		font-size: 23px;
		line-height: 27px;
	}
	.project-intro__client {
		margin-top: 35px;
		font-size: 16px;
		line-height: 19px;
	}
	.project-intro__services {
		margin-top: 19px;
		font-size: 16px;
		line-height: 19px;
	}
	.project-module {
		margin-top: 50px;
	}
	.project-intro + .project-modules > .project-module:first-child {
		margin-top: 40px;
	}
	/* Stack in a column; the desktop "order" rules keep stat/copy first
	   where the design puts them above the image. */
	.project-module--image-left,
	.project-module--image-right,
	.project-module--stat-left,
	.project-module--stat-right,
	.project-module--stats-left,
	.project-module--stats-right {
		flex-direction: column;
		align-items: stretch;
		justify-content: flex-start;
	}
	.project-module--image-left .project-media,
	.project-module--image-right .project-media,
	.project-module--stat-left .project-media,
	.project-module--stat-right .project-media,
	.project-module--stats-left .project-media,
	.project-module--stats-right .project-media {
		width: 100%;
	}
	/* Module 2: copy 50px below the image; module 3: copy 50px above it. */
	.project-copy {
		width: 100%;
		max-width: 328px;
		font-size: 16px;
		line-height: 19px;
	}
	.project-module--image-left .project-copy {
		margin: 50px 0 0;
	}
	.project-module--image-right .project-copy {
		margin: 0 0 50px;
	}
	.project-module--pair,
	.project-module--grid {
		grid-template-columns: minmax(0, 1fr);
		gap: 30px;
	}
	/* Stats: the 55px numerals overflow their 30px line box, so the design
	   leaves 55px (not 50px) above every stat block. */
	.project-stat {
		width: 240px;
		max-width: 100%;
		padding-top: 5px;
	}
	/* 20px below the number keeps the text clear of letters that hang below
	   the line ("Top 3"), in the same proportion as the desktop design. */
	.project-stat__number {
		margin-bottom: 20px;
		font-size: 55px;
		line-height: 30px;
	}
	.project-stat__lead,
	.project-stat__caption {
		font-size: 16px;
		line-height: 20px;
	}
	.project-stat__lead {
		margin-bottom: 19px;
	}
	.project-module--stat-left .project-media {
		margin-top: 50px;
	}
	.project-module--stat-right .project-stat {
		margin-top: 50px;
	}
	.project-stats {
		width: 100%;
	}
	.project-stats .project-stat {
		width: 100%;
		padding-top: 0;
	}
	.project-stats .project-stat:first-child {
		padding-top: 5px;
	}
	.project-stats .project-stat + .project-stat {
		margin-top: 35px;
	}
	.project-module--stats-left .project-stats,
	.project-module--stats-right .project-stats {
		margin: 0;
	}
	.project-module--stats-left .project-media {
		margin-top: 50px;
	}
	.project-module--stats-right .project-stats {
		margin-top: 50px;
	}
}
