/*
 * Section: how we work together (the "jl-steps" group).
 *
 * A small label and a heading, then numbered steps side by side along a
 * thin line. Every step is a Group holding a Heading and a Paragraph; the
 * dot and the number above each title come from the stylesheet, so steps
 * can be added or removed. Any number of steps share the row; three or four
 * fit best. Below 700px the line turns vertical and the steps stack.
 *
 * The line is drawn on the "Steps" group itself (::before for the track,
 * ::after for the darker part already travelled). The script sets
 * --jl-progress from 0 to 1 as the section scrolls past, and marks the
 * steps the line has not reached yet ("is-pending", an open dot). Without
 * the script the line is complete and every dot is filled.
 *
 * Colours, fonts and edge spacing come from the theme.
 */

.jl-steps.jl-steps {
	--sp-pad: 48px;
	--sp-gap: 24px;
	--sp-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
	margin-block: 0;
	padding: 24px var(--sp-pad) 120px;
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	scroll-margin-top: var(--jl-header-h);
}

/* WordPress spaces out a Group's children; every part here sets its own spacing. */
.jl-steps.jl-steps > *,
.jl-steps .jl-steps__head > *,
.jl-steps .jl-steps__list > *,
.jl-steps .jl-step > * {
	margin-block: 0;
}

/* ---------- Label and heading ---------- */

.jl-steps .jl-steps__head {
	display: flex;
	flex-direction: column;
	gap: 24px;
	max-width: 520px;
}

.jl-steps .jl-steps__head h2 {
	font-size: clamp(2.5rem, 4.6vw, 4.25rem);
	letter-spacing: -0.03em;
	line-height: 1;
}

/* ---------- Steps and their line ---------- */

.jl-steps .jl-steps__list {
	position: relative;
	display: grid;
	grid-auto-columns: minmax(0, 1fr);
	grid-auto-flow: column;
	gap: 48px var(--sp-gap);
	margin-top: 96px;
	counter-reset: jl-step;
}

.jl-steps .jl-steps__list::before,
.jl-steps .jl-steps__list::after {
	content: "";
	position: absolute;
	top: 3px;
	right: 0;
	left: 0;
	height: 1px;
	background: var(--jl-line);
}

.jl-steps .jl-steps__list::after {
	background: var(--wp--preset--color--contrast);
	transform: scaleX(var(--jl-progress, 1));
	transform-origin: 0 50%;
}

.jl-steps .jl-step {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	counter-increment: jl-step;
}

/* The dot on the line. */
.jl-steps .jl-step::before {
	content: "";
	order: -2;
	box-sizing: border-box;
	width: 7px;
	height: 7px;
	border: 1px solid var(--wp--preset--color--contrast);
	border-radius: 50%;
	background: var(--wp--preset--color--contrast);
	transition: background-color 0.5s;
}

.jl-steps .jl-step.is-pending::before {
	background: var(--wp--preset--color--base);
}

/* The number under the dot. */
.jl-steps .jl-step::after {
	content: counter(jl-step, decimal-leading-zero);
	order: -1;
	margin-top: 40px;
	color: var(--wp--preset--color--accent-4);
	font-family: var(--wp--preset--font-family--fraunces);
	font-size: 2.75rem;
	letter-spacing: -0.03em;
	line-height: 1;
}

.jl-steps .jl-step h3 {
	max-width: 340px;
	margin: 28px 0 12px;
	font-size: 1.75rem;
	letter-spacing: -0.02em;
	line-height: 1.12;
	text-wrap: balance;
}

.jl-steps .jl-step p {
	max-width: 340px;
	color: var(--wp--preset--color--accent-4);
	font-size: 1rem;
	line-height: 1.6;
}

/* ---------- Motion (front only, once the script is running) ---------- */

.jl-js .jl-steps .jl-steps__head h2:not(.is-split):not(.is-done) {
	opacity: 0;
}

.jl-steps .jl-steps__head h2 .jl-word {
	display: inline-block;
	opacity: 0;
	transform: translateY(0.45em);
	transition: opacity 0.9s ease var(--d, 0ms), transform 1s var(--sp-ease) var(--d, 0ms);
}

.jl-steps .jl-steps__head h2.is-in .jl-word {
	opacity: 1;
	transform: none;
}

.jl-js .jl-steps .jl-steps__head > .jl-tag,
.jl-js .jl-steps .jl-step {
	opacity: 0;
	transform: translateY(24px);
	transition: opacity 0.9s var(--sp-ease) var(--d, 0ms), transform 0.9s var(--sp-ease) var(--d, 0ms);
}

.jl-js .jl-steps .jl-steps__head.is-in > .jl-tag,
.jl-js .jl-steps .jl-step.is-in {
	opacity: 1;
	transform: none;
}

/* The line follows the scroll closely; a short ease keeps it smooth. */
.jl-js .jl-steps .jl-steps__list::after {
	transition: transform 0.25s linear;
}

/* ---------- Tablet ---------- */
@media (max-width: 1099px) {
	.jl-steps.jl-steps {
		--sp-pad: 40px;
		--sp-gap: 20px;
	}

	.jl-steps .jl-steps__list {
		margin-top: 72px;
	}

	.jl-steps .jl-step::after {
		margin-top: 32px;
		font-size: 2.25rem;
	}

	.jl-steps .jl-step h3 {
		margin-top: 20px;
		font-size: 1.375rem;
	}
}

/* ---------- Mobile: a vertical line, steps one under another ---------- */
@media (max-width: 699px) {
	.jl-steps.jl-steps {
		--sp-pad: 24px;
		--sp-gap: 12px;
		padding-bottom: 88px;
	}

	.jl-steps .jl-steps__list {
		grid-auto-flow: row;
		gap: 40px;
		margin-top: 48px;
	}

	.jl-steps .jl-steps__list::before,
	.jl-steps .jl-steps__list::after {
		top: 4px;
		right: auto;
		bottom: 0;
		left: 3px;
		width: 1px;
		height: auto;
	}

	.jl-steps .jl-steps__list::after {
		transform: scaleY(var(--jl-progress, 1));
		transform-origin: 50% 0;
	}

	.jl-steps .jl-step {
		padding-left: 32px;
	}

	.jl-steps .jl-step::before {
		position: absolute;
		top: 4px;
		left: 0;
	}

	.jl-steps .jl-step::after {
		margin-top: 0;
		font-size: 2rem;
	}

	.jl-steps .jl-step h3 {
		margin-top: 14px;
		font-size: 1.5rem;
	}
}

/* Set by the script if it could not prepare the section: everything shows at rest. */
.jl-steps.is-plain h2,
.jl-steps.is-plain .jl-word,
.jl-steps.is-plain .jl-tag,
.jl-steps.is-plain .jl-step {
	opacity: 1 !important;
	transform: none !important;
}

.jl-steps.is-plain .jl-steps__list::after {
	transform: none !important;
}

.jl-steps.is-plain .jl-step::before {
	background: var(--wp--preset--color--contrast);
}

@media (prefers-reduced-motion: reduce) {
	.jl-js .jl-steps h2,
	.jl-js .jl-steps .jl-tag,
	.jl-js .jl-steps .jl-step {
		opacity: 1;
		transform: none;
	}

	.jl-steps.jl-steps *,
	.jl-steps.jl-steps *::before,
	.jl-steps .jl-steps__list::after {
		transition: none !important;
	}
}
