/*
 * Sections: legal text (the "jl-legal" group) and its closing line (the
 * "jl-ask" group). Used by the Privacy Policy and Terms pages.
 *
 * "jl-legal" is split five to seven. On the left, a contents list stays in
 * place while the text scrolls, and the section being read is marked with a
 * thin underline. On the right, the text in a 645px column: each Heading
 * (H2) starts a numbered part with a hairline above it, followed by ordinary
 * Paragraphs, Lists (drawn as hairline rows) and Tables (hairlines only).
 *
 * The contents list is not typed: inc/legal.php builds it from the headings
 * when the page is shown, and the numbers come from this stylesheet, so
 * parts can be added, removed or renamed freely. On tablets and phones the
 * list folds into a "Contents" pill that stays at the top of the screen.
 *
 * Colours, fonts and edge spacing come from the theme. The reveal and the
 * folding pill only run once the script is running (html.jl-js), so the
 * editor and visitors without JavaScript see everything at rest, with the
 * full list.
 */

.jl-legal.jl-legal {
	--lg-pad: 48px;
	--lg-gap: 24px;
	--lg-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
	--lg-top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--jl-header-h) + 24px);
	display: grid;
	grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
	gap: 32px var(--lg-gap);
	align-items: start;
	margin-block: 0;
	padding: 24px var(--lg-pad) 0;
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	counter-reset: jl-legal;
}

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

/* The contents links glide down the page unless the visitor prefers stillness. */
@media (prefers-reduced-motion: no-preference) {
	html:has(.jl-legal) {
		scroll-behavior: smooth;
	}
}

/* ---------- Contents (left) ---------- */

.jl-legal .jl-legal__aside {
	position: sticky;
	top: var(--lg-top);
	display: flex;
	flex-direction: column;
	align-items: flex-start;
}

.jl-legal .jl-legal__toc {
	width: 100%;
	margin-top: 28px;
}

.jl-legal .jl-legal__list {
	display: flex;
	flex-direction: column;
	gap: 14px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.jl-legal .jl-legal__list li {
	margin: 0;
}

.jl-legal .jl-legal__list a {
	color: inherit;
	font-size: 1rem;
	line-height: 1.4;
	text-decoration-line: underline;
	text-decoration-color: transparent;
	text-decoration-thickness: 1px;
	text-underline-offset: 6px;
	transition: text-decoration-color 0.3s ease, color 0.2s ease;
}

.jl-legal .jl-legal__list a:hover {
	color: var(--wp--preset--color--accent-3);
}

.jl-legal .jl-legal__list a[aria-current] {
	text-decoration-color: currentColor;
}

/* The link to the other legal page, under the list. */
.jl-legal .jl-legal__aside > .jl-arrow {
	margin-top: 56px;
	color: var(--wp--preset--color--accent-4);
	font-size: 0.875rem;
	line-height: 1.4;
}

/* The pill only appears on tablets and phones, once the script is running. */
.jl-legal .jl-legal__pill,
.jl-legal .jl-legal__scrim {
	display: none;
}

/* In the editor the list is not there yet: say where it comes from. */
.editor-styles-wrapper .jl-legal .jl-legal__aside::after {
	content: "The contents list is made from the headings on the right.";
	margin-top: 28px;
	color: var(--wp--preset--color--accent-4);
	font-size: 0.875rem;
	line-height: 1.4;
	order: 1;
}

.editor-styles-wrapper .jl-legal .jl-legal__aside > .jl-arrow {
	order: 2;
}

/* ---------- Text (right) ---------- */

.jl-legal .jl-legal__text {
	min-width: 0;
	max-width: 645px;
	font-size: 1.0625rem;
	line-height: 1.6;
	text-wrap: pretty;
}

/* Each heading opens a numbered part, with a hairline above it. */
.jl-legal.jl-legal .jl-legal__text > h2 {
	margin-top: 88px;
	padding-top: 28px;
	border-top: 1px solid var(--jl-line);
	font-size: 1.75rem;
	letter-spacing: -0.02em;
	line-height: 1.15;
	scroll-margin-top: var(--lg-top);
	counter-increment: jl-legal;
}

.jl-legal.jl-legal .jl-legal__text > h2:first-child {
	margin-top: 0;
}

.jl-legal .jl-legal__text > h2::before {
	content: counter(jl-legal, decimal-leading-zero);
	display: block;
	margin-bottom: 20px;
	font-family: var(--wp--preset--font-family--dm-sans);
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.1em;
	line-height: 1.4;
}

.jl-legal .jl-legal__text > h2:focus {
	outline: none;
}

/* :where keeps this below the heading's own margin. */
.jl-legal.jl-legal .jl-legal__text > :where(* + *) {
	margin-top: 16px;
}

.jl-legal.jl-legal .jl-legal__text > h2 + * {
	margin-top: 24px;
}

.jl-legal .jl-legal__text a {
	color: inherit;
	text-decoration-thickness: 1px;
	text-underline-offset: 4px;
}

.jl-legal .jl-legal__text a:hover {
	color: var(--wp--preset--color--accent-3);
}

/* A Paragraph in the "Note" style: small and muted. */
.jl-legal .jl-legal__text > .is-style-note {
	color: var(--wp--preset--color--accent-4);
	font-size: 0.875rem;
	line-height: 1.5;
}

/* Lists: hairline rows. */
.jl-legal.jl-legal .jl-legal__text > ul,
.jl-legal.jl-legal .jl-legal__text > ol {
	margin-top: 20px;
	padding: 0;
	border-bottom: 1px solid var(--jl-line);
	list-style: none;
	line-height: 1.5;
}

.jl-legal .jl-legal__text > ul li,
.jl-legal .jl-legal__text > ol li {
	margin: 0;
	padding: 13px 0;
	border-top: 1px solid var(--jl-line);
}

.jl-legal.jl-legal .jl-legal__text > :is(ul, ol) + p {
	margin-top: 24px;
}

/* Tables: hairlines only, scrolling sideways on narrow screens. */
.jl-legal.jl-legal .jl-legal__text > .wp-block-table {
	margin-top: 40px;
	margin-inline: 0;
	overflow-x: auto;
}

.jl-legal.jl-legal .jl-legal__text > .wp-block-table + p {
	margin-top: 32px;
}

.jl-legal .wp-block-table table {
	width: 100%;
	min-width: 520px;
	border-collapse: collapse;
	font-size: 0.9375rem;
	line-height: 1.5;
	text-align: left;
}

.jl-legal .wp-block-table thead {
	border: 0;
}

.jl-legal .wp-block-table th,
.jl-legal .wp-block-table td {
	padding: 16px 20px 18px 0;
	border: 0;
	border-top: 1px solid var(--jl-line);
	vertical-align: top;
}

.jl-legal .wp-block-table th {
	padding-top: 0;
	padding-bottom: 14px;
	border-top: 0;
	color: var(--wp--preset--color--accent-4);
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.1em;
	line-height: 1.4;
	text-transform: uppercase;
	vertical-align: bottom;
}

.jl-legal .wp-block-table :is(th, td):last-child {
	padding-right: 0;
}

.jl-legal .wp-block-table tbody tr:last-child td {
	border-bottom: 1px solid var(--jl-line);
}

.jl-legal .wp-block-table figcaption {
	margin-top: 12px;
	color: var(--wp--preset--color--accent-4);
	font-size: 0.875rem;
	text-align: left;
}

/* ---------- Questions (the "jl-ask" group) ---------- */

.jl-ask.jl-ask {
	--lg-pad: 48px;
	margin-block: 0;
	padding: 150px var(--lg-pad);
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
}

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

.jl-ask .jl-ask__line {
	max-width: 900px;
	margin-top: 28px;
	font-family: var(--wp--preset--font-family--fraunces);
	font-size: clamp(1.75rem, 2.6vw, 2.25rem);
	letter-spacing: -0.02em;
	line-height: 1.12;
	text-wrap: pretty;
}

/* The email on its own line, under the question (connected to Business details). */
.jl-ask .jl-ask__line.jl-ask__email {
	margin-top: 4px;
	overflow-wrap: anywhere;
}

.jl-ask .jl-ask__line a {
	color: inherit;
	text-decoration-thickness: 1px;
	text-underline-offset: 8px;
}

.jl-ask .jl-ask__line a:hover {
	color: var(--wp--preset--color--accent-3);
}

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

.jl-js .jl-legal .jl-legal__aside,
.jl-js .jl-legal .jl-legal__text > *,
.jl-js .jl-ask > * {
	opacity: 0;
	transform: translateY(24px);
	transition: opacity 0.9s var(--lg-ease) var(--d, 0ms), transform 0.9s var(--lg-ease) var(--d, 0ms);
}

.jl-js .jl-legal .jl-legal__aside.is-in,
.jl-js .jl-legal .jl-legal__text > .is-in,
.jl-js .jl-ask > .is-in {
	opacity: 1;
	transform: none;
}

/* ---------- Tablet: one column, the contents fold into a pill ---------- */
@media (max-width: 1099px) {
	.jl-legal.jl-legal,
	.jl-ask.jl-ask {
		--lg-pad: 40px;
		--lg-gap: 20px;
	}

	.jl-legal.jl-legal {
		--lg-top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--jl-header-h) + 12px);
		grid-template-columns: minmax(0, 1fr);
		gap: 48px;
	}

	.jl-legal .jl-legal__aside {
		position: static;
	}

	.jl-legal .jl-legal__aside > .jl-arrow {
		margin-top: 32px;
	}

	.jl-ask.jl-ask {
		padding-block: 96px;
	}

	/* Once the script has set up the pill ("is-folding"): only the pill shows, and it stays at the top of the screen. */
	.jl-legal.is-folding .jl-legal__aside {
		position: sticky;
		z-index: 5;
	}

	.jl-legal.is-folding .jl-legal__aside > :not(.jl-legal__toc) {
		display: none;
	}

	.jl-legal.is-folding .jl-legal__toc {
		position: relative;
		margin-top: 0;
	}

	.jl-legal.is-folding .jl-legal__pill {
		display: flex;
		align-items: center;
		gap: 12px;
		max-width: 100%;
		height: 44px;
		padding: 0 18px 0 20px;
		border: 1px solid var(--jl-line);
		border-radius: 999px;
		background: var(--wp--preset--color--base);
		color: var(--wp--preset--color--contrast);
		font-family: inherit;
		font-size: 0.875rem;
		font-weight: 500;
		line-height: 1;
		cursor: pointer;
	}

	.jl-legal .jl-legal__current {
		overflow: hidden;
		color: var(--wp--preset--color--accent-4);
		font-weight: 400;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.jl-legal .jl-legal__pill::after {
		content: "";
		flex: none;
		width: 10px;
		height: 6px;
		background: currentColor;
		-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6' fill='none' stroke='%23000' stroke-width='1.2'%3E%3Cpath d='M1 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 10 6' fill='none' stroke='%23000' stroke-width='1.2'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E") center / contain no-repeat;
		transition: transform 0.3s ease;
	}

	.jl-legal .jl-legal__pill[aria-expanded="true"]::after {
		transform: rotate(180deg);
	}

	/*
	 * The page behind the open list is veiled in the page colour. The template
	 * blurred it instead; a plain veil is used because a full-screen
	 * backdrop-filter is heavy to draw while scrolling.
	 */
	.jl-legal.is-folding .jl-legal__scrim {
		display: block;
		position: fixed;
		inset: 0;
		z-index: -1;
		background: color-mix(in srgb, var(--wp--preset--color--base) 88%, transparent);
		opacity: 0;
		pointer-events: none;
		transition: opacity 0.4s var(--lg-ease);
	}

	.jl-legal.is-folding .jl-legal__toc.is-open .jl-legal__scrim {
		opacity: 1;
		pointer-events: auto;
	}

	.jl-legal.is-folding .jl-legal__list {
		position: absolute;
		top: 100%;
		right: 0;
		left: 0;
		gap: 0;
		max-height: calc(100vh - var(--lg-top) - 72px);
		margin-top: 8px;
		overflow-y: auto;
		border-bottom: 1px solid var(--jl-line);
		background: var(--wp--preset--color--base);
	}

	.jl-legal.is-folding .jl-legal__list[hidden] {
		display: none;
	}

	.jl-legal.is-folding .jl-legal__list li {
		border-top: 1px solid var(--jl-line);
	}

	.jl-legal.is-folding .jl-legal__list a {
		display: block;
		padding: 12px 0;
	}
}

/* ---------- Mobile ---------- */
@media (max-width: 699px) {
	.jl-legal.jl-legal,
	.jl-ask.jl-ask {
		--lg-pad: 24px;
		--lg-gap: 12px;
	}

	.jl-legal.jl-legal {
		gap: 40px;
	}

	.jl-legal.jl-legal .jl-legal__text > h2 {
		margin-top: 72px;
	}
}

/* Set by the script if it could not prepare the section: everything shows at rest. */
.jl-legal.is-plain .jl-legal__aside,
.jl-legal.is-plain .jl-legal__text > *,
.jl-ask.is-plain > * {
	opacity: 1 !important;
	transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
	.jl-js .jl-legal .jl-legal__aside,
	.jl-js .jl-legal .jl-legal__text > *,
	.jl-js .jl-ask > * {
		opacity: 1;
		transform: none;
	}

	.jl-legal.jl-legal *,
	.jl-ask.jl-ask * {
		transition: none !important;
	}
}
