/*
 * Section: our story (the "jl-story" group).
 *
 * Two halves: on the left a tall portrait with a caption, which stays in
 * place below the floating header while the right half scrolls past; on the
 * right a small label, a one-sentence statement, two paragraphs, a line with
 * a name and a link, and a second, smaller photo set to the right.
 *
 * Square photos, hairlines, no boxes. 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 it at rest.
 *
 * The section must not clip its overflow, or the portrait would stop
 * staying in place.
 */

.jl-story.jl-story {
	--st-pad: 48px;
	--st-gap: 24px;
	--st-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
	--st-photo: color-mix(in srgb, var(--wp--preset--color--accent-1) 30%, var(--wp--preset--color--accent-5));
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 56px var(--st-gap);
	align-items: start;
	margin-block: 0;
	padding: 48px var(--st-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-story.jl-story > *,
.jl-story .jl-story__text > *,
.jl-story .jl-story__paras > *,
.jl-story .jl-story__sign > * {
	margin-block: 0;
}

/* ---------- Photos ---------- */

.jl-story figure {
	min-width: 0;
	margin: 0;
}

.jl-story figure img {
	display: block;
	width: 100%;
	height: auto;
	max-width: none;
	aspect-ratio: 4 / 5;
	object-fit: cover;
	background: var(--st-photo);
}

/* While editing, WordPress wraps each image in a box that would otherwise shrink to the image's own size. */
.jl-story figure > div {
	display: block !important;
	width: 100% !important;
	height: auto !important;
	max-width: none !important;
}

.jl-story figure > a {
	display: block;
}

/* The portrait stays in place just below the floating header. */
.jl-story .jl-story__portrait {
	position: sticky;
	top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--jl-header-h) + 24px);
}

/* A caption reads as one quiet line, with a small "+" at its right end. */
.jl-story figcaption {
	display: flex;
	justify-content: space-between;
	gap: 16px;
	margin: 14px 0 0;
	color: var(--wp--preset--color--accent-4);
	font-size: 0.875rem;
	line-height: 1.4;
	text-align: left;
}

.jl-story figcaption::after {
	content: "+";
	flex: none;
}

/* ---------- Text ---------- */

.jl-story .jl-story__text {
	display: flex;
	flex-direction: column;
	min-width: 0;
	padding-top: clamp(0px, 12vw, 180px);
}

.jl-story .jl-story__title {
	max-width: 560px;
	margin-top: 24px;
	font-size: clamp(1.75rem, 2.8vw, 2.5rem);
	letter-spacing: -0.025em;
	line-height: 1.1;
}

.jl-story .jl-story__paras {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--st-gap);
	max-width: 645px;
	margin-top: 56px;
}

.jl-story .jl-story__paras p {
	color: var(--wp--preset--color--accent-4);
	font-size: 1rem;
	line-height: 1.6;
}

/* The name and the link sit on one hairline. */
.jl-story .jl-story__sign {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	max-width: 645px;
	margin-top: 56px;
	padding-top: 16px;
	border-top: 1px solid var(--jl-line);
}

.jl-story .jl-story__sign .jl-tag {
	color: var(--wp--preset--color--accent-4);
}

.jl-story .jl-story__sign .jl-arrow {
	font-size: 1rem;
	line-height: 1.4;
}

.jl-story .jl-story__second {
	align-self: flex-end;
	width: min(100%, 360px);
	margin-top: 96px;
}

.jl-story .jl-story__second img {
	aspect-ratio: 3 / 4;
}

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

.jl-js .jl-story .jl-story__title:not(.is-split):not(.is-done) {
	opacity: 0;
}

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

.jl-story .jl-story__title.is-in .jl-word {
	opacity: 1;
	transform: none;
}

/* Photos and blocks of text fade and rise in as each one comes into view. */
.jl-js .jl-story figure,
.jl-js .jl-story .jl-story__text > .jl-tag,
.jl-js .jl-story .jl-story__paras,
.jl-js .jl-story .jl-story__sign {
	opacity: 0;
	transform: translateY(24px);
	transition: opacity 0.9s var(--st-ease) var(--d, 0ms), transform 0.9s var(--st-ease) var(--d, 0ms);
}

.jl-js .jl-story .is-in {
	opacity: 1;
	transform: none;
}

/* ---------- Tablet: a narrower portrait, one paragraph above the other ---------- */
@media (max-width: 1099px) {
	.jl-story.jl-story {
		--st-pad: 40px;
		--st-gap: 20px;
		grid-template-columns: 5fr 7fr;
		gap: 40px var(--st-gap);
	}

	.jl-story .jl-story__text {
		padding-top: 40px;
	}

	.jl-story .jl-story__paras {
		grid-template-columns: minmax(0, 1fr);
		margin-top: 40px;
	}

	/* The second photo is left out; the portrait already fills the left half. */
	.jl-story .jl-story__second {
		display: none;
	}
}

/* ---------- Mobile: one column, the portrait scrolls with the page ---------- */
@media (max-width: 699px) {
	.jl-story.jl-story {
		--st-pad: 24px;
		--st-gap: 12px;
		grid-template-columns: minmax(0, 1fr);
		gap: 32px;
		padding-bottom: 88px;
	}

	.jl-story .jl-story__portrait {
		position: static;
	}

	.jl-story .jl-story__text {
		padding-top: 0;
	}

	.jl-story .jl-story__paras {
		gap: 16px;
		margin-top: 28px;
	}

	.jl-story .jl-story__sign {
		margin-top: 32px;
	}
}

/* Set by the script if it could not prepare the section: everything shows at rest. */
.jl-story.is-plain .jl-story__title,
.jl-story.is-plain .jl-word,
.jl-story.is-plain figure,
.jl-story.is-plain .jl-story__text > * {
	opacity: 1 !important;
	transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
	.jl-js .jl-story .jl-story__title,
	.jl-js .jl-story figure,
	.jl-js .jl-story .jl-story__text > * {
		opacity: 1;
		transform: none;
	}

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