/*
 * Section: where we meet (the "jl-places" group).
 *
 * A heading with a short note beside it, then photos with captions: the
 * first set large across two thirds, the next two stacked in the last third
 * (the third one smaller and set to the right). A fourth photo and any after
 * it start a new row of thirds. Every photo is an Image block with a caption.
 *
 * On tablets the large photo takes the full width with the next two side by
 * side under it; on phones the photos become a row to swipe through.
 *
 * Square photos, no boxes. Colours, fonts and edge spacing come from the
 * theme. The reveal only runs once the script is running (html.jl-js).
 */

.jl-places.jl-places {
	--pl-pad: 48px;
	--pl-gap: 24px;
	--pl-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
	--pl-photo: color-mix(in srgb, var(--wp--preset--color--accent-1) 30%, var(--wp--preset--color--accent-5));
	margin-block: 0;
	padding: 24px var(--pl-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-places.jl-places > *,
.jl-places .jl-places__head > *,
.jl-places .jl-places__main > *,
.jl-places .jl-places__grid > * {
	margin-block: 0;
}

/* ---------- Heading and note ---------- */

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

.jl-places .jl-places__main {
	display: flex;
	flex-direction: column;
	gap: 24px;
}

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

.jl-places .jl-places__note {
	justify-self: end;
	max-width: 360px;
	margin-bottom: 8px;
	color: var(--wp--preset--color--accent-4);
	font-size: 1rem;
	line-height: 1.6;
}

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

.jl-places .jl-places__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: var(--pl-gap);
	align-items: start;
	margin-top: 72px;
}

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

.jl-places .jl-places__grid img {
	display: block;
	width: 100%;
	height: auto;
	max-width: none;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	background: var(--pl-photo);
}

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

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

/* The first photo: two thirds wide, beside the next two. */
.jl-places .jl-places__grid > figure:first-child {
	grid-row: span 2;
	grid-column: span 2;
}

.jl-places .jl-places__grid > figure:first-child img {
	aspect-ratio: 16 / 10;
}

/* The third: a small square, set to the right under the second. */
.jl-places .jl-places__grid > figure:nth-child(3) {
	justify-self: end;
	width: 70%;
}

.jl-places .jl-places__grid > figure:nth-child(3) img {
	aspect-ratio: 1;
}

.jl-places figcaption {
	display: flex;
	justify-content: space-between;
	gap: 16px;
	margin: 14px 0 0;
	color: inherit;
	font-size: 1rem;
	line-height: 1.4;
	text-align: left;
}

.jl-places figcaption::after {
	content: "+";
	flex: none;
	color: var(--wp--preset--color--accent-4);
}

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

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

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

.jl-places .jl-places__main h2.is-in .jl-word {
	opacity: 1;
	transform: none;
}

.jl-js .jl-places .jl-places__main > .jl-tag,
.jl-js .jl-places .jl-places__note,
.jl-js .jl-places .jl-places__grid > figure {
	opacity: 0;
	transform: translateY(24px);
	transition: opacity 0.9s var(--pl-ease) var(--d, 0ms), transform 0.9s var(--pl-ease) var(--d, 0ms);
}

.jl-js .jl-places .jl-places__head.is-in .jl-places__main > .jl-tag,
.jl-js .jl-places .jl-places__head.is-in .jl-places__note,
.jl-js .jl-places .jl-places__grid > figure.is-in {
	opacity: 1;
	transform: none;
}

.jl-js .jl-places .jl-places__note {
	--d: 100ms;
}

/* ---------- Tablet: the large photo across, the next two side by side ---------- */
@media (max-width: 1099px) {
	.jl-places.jl-places {
		--pl-pad: 40px;
		--pl-gap: 20px;
	}

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

	.jl-places .jl-places__note {
		justify-self: start;
	}

	.jl-places .jl-places__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		row-gap: 32px;
		margin-top: 56px;
	}

	.jl-places .jl-places__grid > figure:first-child {
		grid-row: auto;
	}

	.jl-places .jl-places__grid > figure:nth-child(3) {
		justify-self: stretch;
		width: auto;
	}

	.jl-places .jl-places__grid > figure:nth-child(3) img {
		aspect-ratio: 4 / 3;
	}
}

/* ---------- Mobile: a row to swipe, the next photo peeking in ---------- */
@media (max-width: 699px) {
	.jl-places.jl-places {
		--pl-pad: 24px;
		--pl-gap: 12px;
		padding-bottom: 88px;
	}

	.jl-places .jl-places__head {
		gap: 20px;
	}

	.jl-places .jl-places__grid {
		display: flex;
		align-items: flex-start;
		margin: 40px calc(-1 * var(--pl-pad)) 0;
		padding: 0 var(--pl-pad);
		overflow-x: auto;
		scroll-padding: 0 var(--pl-pad);
		scroll-snap-type: x mandatory;
		scrollbar-width: none;
	}

	.jl-places .jl-places__grid::-webkit-scrollbar {
		display: none;
	}

	.jl-places .jl-places__grid > figure,
	.jl-places .jl-places__grid > figure:nth-child(3) {
		flex: 0 0 80%;
		width: auto;
		scroll-snap-align: start;
	}

	.jl-places .jl-places__grid > figure:only-child {
		flex-basis: 100%;
	}

	.jl-places .jl-places__grid img,
	.jl-places .jl-places__grid > figure:first-child img,
	.jl-places .jl-places__grid > figure:nth-child(3) img {
		aspect-ratio: 4 / 5;
	}

	.jl-places figcaption {
		font-size: 0.9375rem;
	}
}

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

@media (prefers-reduced-motion: reduce) {
	.jl-js .jl-places h2,
	.jl-js .jl-places .jl-tag,
	.jl-js .jl-places .jl-places__note,
	.jl-js .jl-places .jl-places__grid > figure {
		opacity: 1;
		transform: none;
	}

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