.steps {
	--height: 100vh;
	--height: 100lvh;
	/* scroll-snap-align: start; */
	counter-reset: step;
	background-color: hsl(var(--hsl-black));
	color: hsl(var(--hsl-white));
}

/* .steps > h2 {
	position: sticky;
	top: var(--header);
} */

.steps__wrapper {
	display: grid;
	gap: var(--margin-double);
	grid-template-columns: 1fr 1fr;
	height: var(--height);
	position: sticky;
	top: 0;
}

.steps__steps {
	display: grid;
	align-items: start;
	gap: var(--margin-double);
	grid-template-columns: repeat(4, 1fr);
	height: var(--height);
	padding: var(--margin-double);
	position: absolute;
	inset: 0;
	z-index: 1;
	font-family: "Suisse Intl Mono";
	text-transform: uppercase;
	pointer-events: none;
}

.steps__steps > div {
	height: 100%;
}

/* .steps__steps > div:nth-child(3) {
	padding-left: 0.18em;
} */

.steps__steps > div > .animate {
	position: sticky;
	top: var(--header);
}

.steps__steps .animate > span {
	animation-name: none !important;
}

.steps--reveal .steps__steps .animate > span {
	animation-name: in !important;
}

.steps__coffees {
	grid-column: 1;
	display: flex;
	flex-direction: column;
	height: calc(var(--height) - var(--header) - 2 * var(--margin-double) - var(--fontsize));
	margin: calc(var(--header) + var(--margin-double) + var(--fontsize)) 0 var(--margin-double);
	padding: 0 var(--margin-double);
	overflow-x: hidden;
	overflow-y: hidden; /* desktop: scrollable while the recipes fill the screen (.steps--list-scrolls) */
	position: relative;
	opacity: 0;
	mask: linear-gradient(
		to bottom,
		transparent,
		black calc(2 * var(--margin-double)),
		black calc(100% - 2 * var(--margin-double)),
		transparent 100%
	);
}

.steps__coffees::before,
.steps__coffees::after {
	content: "";
	display: block;
	flex: 0 0 calc(50% - 1.5 * 1.8vw - var(--margin-double)); /* centres the first and last coffee */
}

.steps--reveal .steps__coffees {
	animation: in 1s var(--delay) forwards;
}

.steps__coffee {
	-webkit-tap-highlight-color: transparent;
	--offsetY: 0;
	scroll-snap-align: center;
	display: flex;
	justify-content: space-between;
	margin-bottom: calc(2 * var(--margin-double) + 0.75em); /* same distance between coffees as before the font got 20% smaller, so more room between them */
	position: relative;
	transform: none; /* all coffees the same size, the selected one is white (was scaled down when not selected) */
	transform-origin: left center;
	font-size: 1.8vw; /* 28% smaller than the original 2.5vw (10%, then another 20%) */
	line-height: 1;
	letter-spacing: -0.03em;
	white-space: nowrap;
	cursor: pointer;
	pointer-events: none;
	transition: transform 0.3s ease;
}

.steps__coffee--active {
	transform: none;
	cursor: default;
}

.steps__coffee > div:not(.qr) {
	margin-left: -0.09em;
	color: hsl(var(--hsl-dark-grey));
	pointer-events: all;
	transition: color 0.5s;
}

.steps__coffee--active > div:not(.qr) {
	color: hsl(var(--hsl-white));
}

@media (hover: hover) {
	.steps__coffee:hover > div:not(.qr) {
		color: hsl(var(--hsl-white));
	}
}

.steps__flavors {
	display: none;
	gap: var(--margin-double);
	margin-top: var(--margin);
	position: absolute;
	top: 100%;
	left: 0;
}

.steps__coffee--active .steps__flavors {
	display: flex;
}

.steps__flavor[style*='--color'] {
	display: flex;
	align-items: baseline;
	position: relative;
	font-family: "Suisse Intl Mono";
	font-size: var(--fontsize);
	letter-spacing: 0.04em;
	line-height: 1.2;
	text-transform: uppercase;
}

/* steps.js briefly sets this to restart the colour blocks' animation (see replayFlavors) */
.steps__flavors--restart .steps__flavor[style*='--color']::before {
	animation: none;
}

.steps__flavor[style*='--color']::before {
	content: "";
	display: inline-block;
	width: 0.725em;
	height: 0.725em;
	margin-right: 1ch;
	animation: color 0s 0.5s forwards;
}

@keyframes color {
	from {
		background-color: transparent;
	}
	to {
		background-color: var(--color);
	}
}

.steps__coffee > .qr {
	display: none;
	width: auto;
	height: 100%;
	position: absolute;
	top: 0;
	right: 0;
	opacity: 0;
}

.steps__coffee--active > .qr {
	display: block;
	opacity: 1;
	transition: display 1s, opacity 0.5s 1s;
	transition-behavior: allow-discrete;
}

@starting-style {
	.steps__coffee--active > .qr {
		opacity: 0;
	}
}

.steps__coffee > .qr > svg {
	width: auto;
	height: 100%;
}

.steps__coffee > .qr > svg rect[fill="#ffffff"] {
	fill: currentColor;
}

.steps__flare {
	grid-column: 2;
	width: calc(100% + var(--margin-double));
	height: var(--height);
	margin-left: calc(-1 * var(--margin-double));
	overflow: hidden;
	position: relative;
	opacity: 0;
}

.steps--reveal .steps__flare {
	animation: in 0.8s var(--delay) forwards;
}

.steps__flare > canvas,
.steps__flare > noscript > video {
	display: block;
	width: 100%;
	height: 100%;
	position: absolute;
	top: 0;
	left: 0;
	object-fit: cover;
}

@media (orientation: portrait) {
	.steps__wrapper {
		gap: 0;
		grid-template-columns: 1fr;
		grid-template-rows: 33% 1fr;
	}

	.steps__steps {
		grid-template-columns: 1fr;
		grid-template-rows: 33% 1fr 1fr 1fr;
		gap: 0;
		padding: 0;
	}

	.steps__steps > div {
		padding: var(--margin-double);
	}

	.steps__coffees {
		--height: 33vh;
		--height: 33svh;
		align-items: center;
		flex-direction: row;
		height: auto;
		margin-bottom: 0;
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x mandatory;
		mask: linear-gradient(
			to right,
			transparent,
			black var(--margin-double),
			black calc(100% - 2 * var(--margin-double)),
			transparent 100%
		);
	}

	.steps__coffees::before,
	.steps__coffees::after {
		display: none;
	}

	.steps__coffee {
		scroll-snap-align: start;
		scroll-margin-left: var(--margin-double);
		flex: 0 0 calc(100% - 2 * var(--margin-double));
		margin-bottom: 0;
		transform-origin: top left;
		transform: translateY(calc(-1 * var(--margin-double)));
		/* font-size: calc((var(--height) - var(--header) - 3 * var(--margin-double) - var(--fontsize)) / 3) !important; */
	}

	.steps__coffee:last-of-type {
		flex-basis: 100%;
	}

	.steps__coffee:not(.steps__coffee--active) {
		transform: translateY(calc(-1 * var(--margin-double)));
	}

	.steps__flare {
		grid-column: 1;
		grid-row: 2;
		height: auto;
	}
}

@media (max-width: 1024px) {
	.steps__coffee {
		font-size: 2.592vw; /* 28% smaller (was 3.6vw) */
	}
}

@media (max-width: 600px) {
	.steps__coffee {
		font-size: 4.32vw; /* 28% smaller (was 6vw) */
	}
}

@media (max-width: 480px) {
	.steps__coffee {
		font-size: 1.44em; /* 28% smaller (was 2em) */
	}
}

/* "The platform" heading and description at the top of the recipe section.
   They scroll up together with the recipes; the recipes (step labels, coffee list, flare) stop
   once they fill the screen, stay while the list is scrolled through, then move on. */
:not(.hero, .invert, .machine, .steps) + .steps {
	margin-top: 33vh; /* same space as before the other dark sections */
	margin-top: 33svh;
}

.steps {
	height: auto;
}

.steps::after {
	content: "";
	display: block;
	height: var(--height); /* the scroll distance while the recipes stay on screen */
}

.steps__intro {
	display: grid;
	align-items: baseline;
	gap: 0 var(--margin-double);
	grid-template-columns: 1fr 1fr;
	padding: var(--header) var(--margin-double) 0;
	position: relative;
	z-index: 2; /* above the flare, which reaches up behind the description */
	pointer-events: none;
}

.steps__intro > .reveal {
	grid-column: 2;
}

@media not (orientation: portrait) {
	/* desktop: heading top left, description top right over the flare; below them the recipes,
	   which stop at the top of the screen with the step labels just below the header */
	.steps__wrapper {
		--top: var(--header);
	}

	.steps__steps {
		padding-top: var(--top);
	}

	.steps__steps > div > .animate {
		position: static; /* move with the panel, so they don't linger over "The system" */
	}

	/* The page scrolls past the recipes normally (no extra pinned scrolling); the coffee list scrolls
	   on its own with the mouse over it, once the recipes (nearly) fill the screen (see steps.js) */
	.steps::after {
		display: none;
	}

	.steps--list-scrolls .steps__coffees {
		overflow-y: auto;
		scrollbar-width: none;
	}

	.steps--list-scrolls .steps__coffees::-webkit-scrollbar {
		display: none;
	}

	.steps__coffees {
		height: calc(var(--height) - var(--top) - 2 * var(--margin-double) - var(--fontsize));
		margin-top: calc(var(--top) + var(--margin-double) + var(--fontsize));
	}

	/* The flare panel reaches up behind the description (--intro-h is its height, set by steps.js);
	   the flare itself stays one screen high and stays at the top of the screen while scrolling */
	.steps__flare {
		height: calc(var(--height) + var(--intro-h, 0px));
		margin-top: calc(-1 * var(--intro-h, 0px));
		overflow: clip; /* not "hidden": that would stop the flare from staying at the top */
	}

	.steps__flare > canvas,
	.steps__flare > noscript > video {
		height: var(--height);
		position: sticky;
		top: 0;
	}
}

@media (orientation: portrait) {
	/* phones: heading and description above the coffee list and the flare */
	.steps__intro {
		grid-template-columns: 1fr;
		padding-bottom: 12vh; /* more space below the platform description */
		padding-bottom: 12svh;
	}

	.steps__intro > .reveal {
		grid-column: 1;
		margin-top: var(--margin-double);
	}
}

/* Endless carousel on phones: copies of the list before and after the real one (see steps.js) */
.steps__coffee--copy {
	display: none;
}

/* A coffee that took over the selection from its copy: shown at once, without animations */
.steps__coffee--instant,
.steps__coffee--instant > div {
	transition: none;
}

.steps__coffee--instant .animate > span {
	animation: none;
	opacity: 1;
}

.steps__coffee--instant .steps__flavor[style*='--color']::before {
	animation: none;
	background-color: var(--color);
}

@media (orientation: portrait) {
	.steps__coffee--copy {
		display: flex;
	}
}

/* Phones: the four step labels evenly spaced. "01" sits at the header height, the others at the top
   of their rows (plus the page margin), so the first row is a quarter of the screen plus three quarters
   of that difference. The coffee information sits directly below "01" (top-aligned, no longer centred). */
@media (orientation: portrait) {
	.steps__wrapper {
		--first-row: calc(25% + 0.75 * (var(--header) - var(--margin-double)));
		grid-template-rows: var(--first-row) 1fr;
	}

	.steps__steps {
		grid-template-rows: var(--first-row) repeat(3, 1fr);
	}

	.steps__coffees {
		align-items: flex-start;
	}

	.steps__coffee {
		transform: none;
	}

	.steps__coffee:not(.steps__coffee--active) {
		transform: none; /* all coffees the same size */
	}
}
