/*
 * Section: page opener (the "jl-opener" group).
 *
 * The top of an inner page, on the page colour, with room for the floating
 * header above it: a small label, the page title (the page's only H1), and
 * a row with a lead paragraph on the left and an "On this page" list of
 * links in the right-hand third. Built from ordinary blocks; the list is a
 * List block, numbered by the stylesheet so items can be added or removed.
 *
 * A second arrangement (the Services page): the title with the lead beside
 * it ("jl-opener__head"), then a row of links that jump down the page
 * ("jl-opener__jump", a List block too): equal columns on wide screens, a
 * row to swipe on tablets and phones.
 *
 * Colours, fonts and edge spacing come from the theme. The reveal only runs
 * once the script is running (html.jl-js), so the editor and visitors
 * without JavaScript see the opener at rest.
 */

.jl-opener.jl-opener {
	--op-pad: 48px;
	--op-gap: 24px;
	--op-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
	margin-block: 0;
	padding: 120px var(--op-pad) 96px;
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
}

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

/* The links below jump down the page; let them glide unless the visitor prefers stillness. */
@media (prefers-reduced-motion: no-preference) {
	html:has(.jl-opener__toc),
	html:has(.jl-opener__jump) {
		scroll-behavior: smooth;
	}
}

.jl-opener .jl-opener__title {
	max-width: 83%;
	margin-top: 32px;
	font-size: clamp(3rem, 7vw, 6.5rem);
	letter-spacing: -0.03em;
	line-height: 1;
	text-wrap: balance;
}

/* ---------- A quieter opener (Privacy Policy, Terms) ---------- */

/* The title at section-heading size, and one muted line under it. */
.jl-opener.jl-opener--legal {
	padding-bottom: 96px;
}

.jl-opener.jl-opener--legal .jl-opener__title {
	font-size: clamp(2.5rem, 4.6vw, 4.25rem);
}

.jl-opener .jl-opener__updated {
	margin-top: 28px;
	color: var(--wp--preset--color--accent-4);
	font-size: 1rem;
	line-height: 1.5;
}

/* ---------- Title with the lead beside it ---------- */

.jl-opener .jl-opener__head {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 360px;
	gap: 28px 120px;
	align-items: start;
	margin-top: 32px;
}

.jl-opener .jl-opener__head > * {
	margin-block: 0;
}

.jl-opener .jl-opener__head .jl-opener__title {
	max-width: 900px;
	margin-top: 0;
}

.jl-opener .jl-opener__head .jl-opener__lead {
	max-width: 360px;
	padding-top: 14px;
}

/* ---------- A search box in place of the lead (the Search page) ---------- */

.jl-opener .wp-block-search.jl-opener__lead,
.jl-opener .jl-search {
	width: 100%;
	max-width: 360px;
	padding-top: 14px;
}

.jl-opener .jl-search .wp-block-search__inside-wrapper {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 0;
	border: 0;
	border-bottom: 1px solid var(--jl-line);
}

.jl-opener .jl-search .wp-block-search__input {
	flex: 1;
	min-width: 0;
	padding: 12px 0 14px;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: var(--wp--preset--color--contrast);
	font-family: inherit;
	font-size: 1.125rem;
}

.jl-opener .jl-search .wp-block-search__button {
	margin: 0;
	padding: 6px 0;
	border: 0;
	background: none;
	color: var(--wp--preset--color--contrast);
	font-size: 1rem;
	cursor: pointer;
}

.jl-opener .jl-search .wp-block-search__button:hover {
	color: var(--wp--preset--color--accent-3);
}

/* ---------- Links that jump down the page ---------- */

.jl-opener .jl-opener__jump {
	margin-top: 120px;
}

.jl-opener .jl-opener__jump ul,
.jl-opener .jl-opener__jump ol {
	display: grid;
	grid-auto-columns: minmax(0, 1fr);
	grid-auto-flow: column;
	column-gap: var(--op-gap);
	margin: 0;
	padding: 0;
	border-top: 1px solid var(--jl-line);
	list-style: none;
	counter-reset: jl-jump;
}

.jl-opener .jl-opener__jump li {
	margin: 0;
	counter-increment: jl-jump;
}

.jl-opener .jl-opener__jump li a {
	display: flex;
	align-items: baseline;
	gap: 12px;
	padding: 22px 0 20px;
	color: inherit;
	font-size: 1rem;
	line-height: 1.35;
	text-decoration: none;
	transition: color 0.4s var(--op-ease);
}

.jl-opener .jl-opener__jump li a::before {
	content: "0" counter(jl-jump, decimal-leading-zero);
	flex: none;
	color: var(--wp--preset--color--accent-4);
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.1em;
}

/* A thin arrow pointing down, after the name. */
.jl-opener .jl-opener__jump li a::after {
	content: "";
	flex: none;
	align-self: center;
	width: 10px;
	height: 12px;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 12' fill='none' stroke='%23000' stroke-width='1.2'%3E%3Cpath d='M5 0v11M1 7l4 4 4-4'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 12' fill='none' stroke='%23000' stroke-width='1.2'%3E%3Cpath d='M5 0v11M1 7l4 4 4-4'/%3E%3C/svg%3E") center / contain no-repeat;
	transition: transform 0.4s var(--op-ease);
}

.jl-opener .jl-opener__jump li a:hover,
.jl-opener .jl-opener__jump li a:focus-visible {
	color: var(--wp--preset--color--accent-3);
}

.jl-opener .jl-opener__jump li a:hover::after,
.jl-opener .jl-opener__jump li a:focus-visible::after {
	transform: translateY(4px);
}

.jl-opener .jl-opener__jump li a:focus-visible {
	outline-offset: -2px;
}

/* ---------- Lead and contents ---------- */

.jl-opener .jl-opener__row {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 40px var(--op-gap);
	align-items: start;
	margin-top: 88px;
}

.jl-opener .jl-opener__lead {
	max-width: 400px;
	font-size: 1.1875rem;
	letter-spacing: -0.01em;
	line-height: 1.35;
}

.jl-opener .jl-opener__toc {
	grid-column: 3;
}

.jl-opener .jl-opener__toc > .jl-tag {
	margin-bottom: 14px;
	color: var(--wp--preset--color--accent-4);
}

.jl-opener .jl-opener__toc ul,
.jl-opener .jl-opener__toc ol {
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: jl-toc;
}

.jl-opener .jl-opener__toc li {
	margin: 0;
	border-top: 1px solid var(--jl-line);
	counter-increment: jl-toc;
	font-size: 0.9375rem;
	line-height: 1.4;
}

/* Number, words and arrow on one line; the whole line is the link. */
.jl-opener .jl-opener__toc li a {
	display: grid;
	grid-template-columns: 40px minmax(0, 1fr) auto;
	align-items: center;
	gap: 12px;
	padding: 11px 0;
	color: inherit;
	text-decoration: none;
	transition: color 0.4s var(--op-ease);
}

.jl-opener .jl-opener__toc li a::before {
	content: counter(jl-toc, decimal-leading-zero);
	color: var(--wp--preset--color--accent-4);
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.1em;
}

.jl-opener .jl-opener__toc li a::after {
	content: "";
	width: 14px;
	height: 10px;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 10' fill='none' stroke='%23000' stroke-width='1.2'%3E%3Cpath d='M0 5h12M8 1l4 4-4 4'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 10' fill='none' stroke='%23000' stroke-width='1.2'%3E%3Cpath d='M0 5h12M8 1l4 4-4 4'/%3E%3C/svg%3E") center / contain no-repeat;
	transition: transform 0.4s var(--op-ease);
}

.jl-opener .jl-opener__toc li a:hover,
.jl-opener .jl-opener__toc li a:focus-visible {
	color: var(--wp--preset--color--accent-3);
}

.jl-opener .jl-opener__toc li a:hover::after,
.jl-opener .jl-opener__toc li a:focus-visible::after {
	transform: translateX(6px);
}

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

/* The title waits out of sight until the script has split it into words. */
.jl-js .jl-opener .jl-opener__title:not(.is-split):not(.is-done) {
	opacity: 0;
}

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

.jl-opener .jl-opener__title.is-in .jl-word {
	opacity: 1;
	transform: none;
}

/* The label, the lead and the contents fade and rise in, one after another. */
.jl-js .jl-opener > .jl-tag,
.jl-js .jl-opener > .jl-opener__updated,
.jl-js .jl-opener .jl-opener__row > *,
.jl-js .jl-opener .jl-opener__head > .jl-opener__lead,
.jl-js .jl-opener .jl-opener__jump {
	opacity: 0;
	transform: translateY(24px);
	transition: opacity 0.9s var(--op-ease) var(--d, 0ms), transform 0.9s var(--op-ease) var(--d, 0ms);
}

.jl-js .jl-opener.is-in > .jl-tag,
.jl-js .jl-opener.is-in > .jl-opener__updated,
.jl-js .jl-opener.is-in .jl-opener__row > *,
.jl-js .jl-opener.is-in .jl-opener__head > .jl-opener__lead,
.jl-js .jl-opener.is-in .jl-opener__jump {
	opacity: 1;
	transform: none;
}

.jl-opener .jl-opener__row > :nth-child(1),
.jl-opener > .jl-opener__updated,
.jl-opener .jl-opener__head > .jl-opener__lead {
	--d: 200ms;
}

.jl-opener .jl-opener__row > :nth-child(n + 2),
.jl-opener .jl-opener__jump {
	--d: 300ms;
}

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

	.jl-opener .jl-opener__title {
		max-width: none;
	}

	.jl-opener .jl-opener__row {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		margin-top: 64px;
	}

	.jl-opener .jl-opener__toc {
		grid-column: 2;
	}

	.jl-opener .jl-opener__head {
		grid-template-columns: minmax(0, 1fr);
		margin-top: 24px;
	}

	.jl-opener .jl-opener__head .jl-opener__lead {
		max-width: 440px;
		padding-top: 0;
	}

	/* The jump links become a row to swipe, reaching both screen edges. */
	.jl-opener .jl-opener__jump {
		margin: 80px calc(-1 * var(--op-pad)) 0;
	}

	.jl-opener .jl-opener__jump ul,
	.jl-opener .jl-opener__jump ol {
		display: flex;
		gap: 36px;
		padding: 0 var(--op-pad);
		overflow-x: auto;
		border-bottom: 1px solid var(--jl-line);
		scroll-padding-inline: var(--op-pad);
		scroll-snap-type: x proximity;
		scrollbar-width: none;
	}

	.jl-opener .jl-opener__jump ul::-webkit-scrollbar,
	.jl-opener .jl-opener__jump ol::-webkit-scrollbar {
		display: none;
	}

	/* Keeps the last link clear of the right edge once scrolled to the end. */
	.jl-opener .jl-opener__jump ul::after,
	.jl-opener .jl-opener__jump ol::after {
		content: "";
		flex: 0 0 1px;
	}

	.jl-opener .jl-opener__jump li {
		flex: none;
		scroll-snap-align: start;
	}

	.jl-opener .jl-opener__jump li a {
		gap: 10px;
		padding: 18px 0 17px;
		font-size: 0.9375rem;
		white-space: nowrap;
	}

	.jl-opener .jl-opener__jump li a::after {
		display: none;
	}
}

/* ---------- Mobile: the contents list is left out ---------- */
@media (max-width: 699px) {
	.jl-opener.jl-opener {
		--op-pad: 24px;
		--op-gap: 12px;
		padding-top: 88px;
		padding-bottom: 56px;
	}

	.jl-opener .jl-opener__title {
		margin-top: 24px;
	}

	.jl-opener .jl-opener__row {
		grid-template-columns: minmax(0, 1fr);
		margin-top: 32px;
	}

	.jl-opener .jl-opener__toc {
		display: none;
	}

	.jl-opener .jl-opener__head {
		gap: 20px;
	}

	.jl-opener .jl-opener__head .jl-opener__lead {
		font-size: 1.0625rem;
		line-height: 1.4;
	}

	.jl-opener .jl-opener__jump {
		margin-top: 56px;
	}

	.jl-opener .jl-opener__jump ul,
	.jl-opener .jl-opener__jump ol {
		gap: 28px;
	}
}

/* Set by the script if it could not prepare the section: everything shows at rest. */
.jl-opener.is-plain .jl-opener__title,
.jl-opener.is-plain .jl-word,
.jl-opener.is-plain > .jl-tag,
.jl-opener.is-plain > .jl-opener__updated,
.jl-opener.is-plain .jl-opener__row > *,
.jl-opener.is-plain .jl-opener__head > *,
.jl-opener.is-plain .jl-opener__jump {
	opacity: 1 !important;
	transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
	.jl-js .jl-opener .jl-opener__title,
	.jl-js .jl-opener > .jl-tag,
	.jl-js .jl-opener > .jl-opener__updated,
	.jl-js .jl-opener .jl-opener__row > *,
	.jl-js .jl-opener .jl-opener__head > *,
	.jl-js .jl-opener .jl-opener__jump {
		opacity: 1;
		transform: none;
	}

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