/*
 * Section: what we believe (the "jl-beliefs" group).
 *
 * The one section of the page on the sage tint (the services section's
 * ground on the home page). A large heading with a short lead beside it, then
 * numbered rows divided by hairlines: a title, a line of text and a
 * line-drawn icon. Every row is a Group holding a Heading, a Paragraph and a
 * Custom HTML block with an inline SVG; the numbers come from the stylesheet.
 *
 * The tint eases in from the page colour at the top and back out at the
 * bottom over a few hundred pixels with a curved gradient, so the section
 * meets its neighbours without an edge.
 *
 * Colours, fonts and edge spacing come from the theme. The reveal and the
 * line-drawing only run once the script is running (html.jl-js).
 */

.jl-beliefs.jl-beliefs {
	--bl-pad: 48px;
	--bl-gap: 24px;
	--bl-fade: 240px;
	--bl-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
	--bl-bg: color-mix(in srgb, var(--wp--preset--color--accent-1) 26%, var(--wp--preset--color--base));
	--bl-bg-hover: color-mix(in srgb, var(--wp--preset--color--accent-1) 42%, var(--wp--preset--color--base));
	margin-block: 0;
	padding: calc(var(--bl-fade) + 24px) var(--bl-pad) calc(var(--bl-fade) + 120px);
	background: linear-gradient(
		to bottom,
		var(--wp--preset--color--base) 0,
		color-mix(in srgb, var(--bl-bg) 10%, var(--wp--preset--color--base)) calc(var(--bl-fade) * 0.18),
		color-mix(in srgb, var(--bl-bg) 38%, var(--wp--preset--color--base)) calc(var(--bl-fade) * 0.42),
		color-mix(in srgb, var(--bl-bg) 74%, var(--wp--preset--color--base)) calc(var(--bl-fade) * 0.68),
		color-mix(in srgb, var(--bl-bg) 94%, var(--wp--preset--color--base)) calc(var(--bl-fade) * 0.88),
		var(--bl-bg) var(--bl-fade),
		var(--bl-bg) calc(100% - var(--bl-fade)),
		color-mix(in srgb, var(--bl-bg) 94%, var(--wp--preset--color--base)) calc(100% - var(--bl-fade) * 0.88),
		color-mix(in srgb, var(--bl-bg) 74%, var(--wp--preset--color--base)) calc(100% - var(--bl-fade) * 0.68),
		color-mix(in srgb, var(--bl-bg) 38%, var(--wp--preset--color--base)) calc(100% - var(--bl-fade) * 0.42),
		color-mix(in srgb, var(--bl-bg) 10%, var(--wp--preset--color--base)) calc(100% - var(--bl-fade) * 0.18),
		var(--wp--preset--color--base) 100%
	);
	color: var(--wp--preset--color--contrast);
	/* A link to this section lands where the tint is full, just below the header. */
	scroll-margin-top: calc(var(--jl-header-h) - var(--bl-fade));
}

/* WordPress spaces out a Group's children; every part here sets its own spacing. */
.jl-beliefs.jl-beliefs > *,
.jl-beliefs .jl-beliefs__head > *,
.jl-beliefs .jl-beliefs__main > *,
.jl-beliefs .jl-beliefs__list > *,
.jl-beliefs .jl-belief > * {
	margin-block: 0;
}

/* ---------- Heading and lead ---------- */

.jl-beliefs .jl-beliefs__head {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 40px var(--bl-gap);
	align-items: end;
}

.jl-beliefs .jl-beliefs__main {
	display: flex;
	flex-direction: column;
	gap: 24px;
}

.jl-beliefs .jl-beliefs__main h2 {
	font-size: clamp(2.75rem, 6.2vw, 5.5rem);
	letter-spacing: -0.03em;
	line-height: 1;
}

.jl-beliefs .jl-beliefs__lead {
	justify-self: end;
	max-width: 360px;
	margin-bottom: 8px;
	font-size: 1.1875rem;
	letter-spacing: -0.01em;
	line-height: 1.35;
}

/* ---------- Rows ---------- */

.jl-beliefs .jl-beliefs__list {
	margin-top: 96px;
	border-bottom: 1px solid var(--jl-line);
	counter-reset: jl-belief;
}

.jl-beliefs .jl-belief {
	display: grid;
	grid-template-columns: 64px minmax(0, 1.3fr) minmax(0, 1fr) 72px;
	gap: 16px var(--bl-gap);
	align-items: center;
	padding: 28px 0;
	border-top: 1px solid var(--jl-line);
	counter-increment: jl-belief;
	transition: background-color 0.4s;
}

.jl-beliefs .jl-belief::before {
	content: "0" counter(jl-belief, decimal-leading-zero);
	align-self: start;
	padding-top: 10px;
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.1em;
	line-height: 1.4;
}

.jl-beliefs .jl-belief h3 {
	font-size: clamp(1.5rem, 2.4vw, 2.25rem);
	letter-spacing: -0.02em;
	line-height: 1.1;
}

.jl-beliefs .jl-belief p {
	max-width: 300px;
	font-size: 0.9375rem;
	line-height: 1.5;
}

/* The icon: an SVG on the site, the Custom HTML block's preview in the editor. */
.jl-beliefs .jl-belief > svg,
.jl-beliefs .jl-belief > .wp-block-html {
	justify-self: end;
	width: 64px;
	height: 56px;
	color: inherit;
}

@media (hover: hover) {
	.jl-beliefs .jl-belief:hover {
		background-color: var(--bl-bg-hover);
	}
}

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

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

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

.jl-beliefs .jl-beliefs__main h2.is-in .jl-word {
	opacity: 1;
	transform: none;
}

.jl-js .jl-beliefs .jl-beliefs__main > .jl-tag,
.jl-js .jl-beliefs .jl-beliefs__lead,
.jl-js .jl-beliefs .jl-belief {
	opacity: 0;
	transform: translateY(24px);
	transition: opacity 0.9s var(--bl-ease) var(--d, 0ms), transform 0.9s var(--bl-ease) var(--d, 0ms), background-color 0.4s;
}

.jl-js .jl-beliefs .jl-beliefs__head.is-in .jl-beliefs__main > .jl-tag,
.jl-js .jl-beliefs .jl-beliefs__head.is-in .jl-beliefs__lead,
.jl-js .jl-beliefs .jl-belief.is-in {
	opacity: 1;
	transform: none;
}

.jl-js .jl-beliefs .jl-beliefs__lead {
	--d: 100ms;
}

/* The script marks each stroked shape with "dr" so the icon can draw itself in. */
@keyframes jl-belief-draw {
	from {
		stroke-dashoffset: 1;
	}
	to {
		stroke-dashoffset: 0;
	}
}

.jl-js .jl-beliefs .dr {
	stroke-dasharray: 1;
	stroke-dashoffset: 1;
}

.jl-js .jl-beliefs .jl-belief.is-in .dr {
	animation: jl-belief-draw 1.6s cubic-bezier(0.6, 0, 0.2, 1) forwards;
	animation-delay: calc(var(--d, 0ms) + 350ms + var(--n, 0) * 120ms);
}

/* ---------- Tablet: the head stacks; the text sits under each title ---------- */
@media (max-width: 1099px) {
	.jl-beliefs.jl-beliefs {
		--bl-pad: 40px;
		--bl-gap: 20px;
	}

	.jl-beliefs .jl-beliefs__head {
		grid-template-columns: minmax(0, 1fr);
	}

	.jl-beliefs .jl-beliefs__lead {
		justify-self: start;
	}

	.jl-beliefs .jl-beliefs__list {
		margin-top: 72px;
	}

	.jl-beliefs .jl-belief {
		grid-template-columns: 56px minmax(0, 1fr) 64px;
		gap: 10px var(--bl-gap);
	}

	.jl-beliefs .jl-belief::before {
		grid-column: 1;
		grid-row: 1;
	}

	.jl-beliefs .jl-belief h3 {
		grid-column: 2;
		grid-row: 1;
	}

	.jl-beliefs .jl-belief p {
		grid-column: 2;
		grid-row: 2;
		max-width: 440px;
	}

	.jl-beliefs .jl-belief > svg,
	.jl-beliefs .jl-belief > .wp-block-html {
		grid-column: 3;
		grid-row: 1 / 3;
		align-self: start;
		width: 56px;
		height: 49px;
	}
}

/* ---------- Mobile: number and icon on one line, then the title and text ---------- */
@media (max-width: 699px) {
	.jl-beliefs.jl-beliefs {
		--bl-pad: 24px;
		--bl-gap: 12px;
		--bl-fade: 140px;
		padding-bottom: calc(var(--bl-fade) + 88px);
	}

	.jl-beliefs .jl-beliefs__head {
		gap: 20px;
	}

	.jl-beliefs .jl-beliefs__list {
		margin-top: 48px;
	}

	.jl-beliefs .jl-belief {
		grid-template-columns: minmax(0, 1fr) auto;
		gap: 12px;
		padding: 24px 0;
	}

	.jl-beliefs .jl-belief::before {
		grid-column: 1;
		grid-row: 1;
		padding-top: 0;
	}

	.jl-beliefs .jl-belief > svg,
	.jl-beliefs .jl-belief > .wp-block-html {
		grid-column: 2;
		grid-row: 1;
		width: 44px;
		height: 38px;
	}

	.jl-beliefs .jl-belief h3 {
		grid-column: 1 / -1;
		grid-row: 2;
	}

	.jl-beliefs .jl-belief p {
		grid-column: 1 / -1;
		grid-row: 3;
	}
}

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

.jl-beliefs.is-plain .dr {
	stroke-dashoffset: 0 !important;
}

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

	.jl-js .jl-beliefs .dr {
		stroke-dashoffset: 0;
		animation: none;
	}

	.jl-beliefs.jl-beliefs * {
		transition: none !important;
	}
}
