/**
 * Showcase effects, CSS only (no JavaScript): every effect is driven by the
 * scroll position (animation-timeline) and has a static fallback for
 * browsers without scroll-driven animations and for reduced motion.
 *
 * - Gallery style "Scroller" (is-style-scroller), or "scroller-row" as
 *   Additional CSS class of a Query Loop: one row of big images that
 *   scrolls sideways (touch, trackpad, scrollbar), with snap points.
 * - "pin-gallery" (Additional CSS class of a full-width Group that holds a
 *   Group with a heading and a Scroller gallery): on large screens the
 *   inner Group stays pinned while the page scrolls, and the row of images
 *   (gallery or Query Loop)
 *   slides sideways with the scroll.
 * - "ink-text" (Additional CSS class of a paragraph or heading): the text
 *   fills with ink as it scrolls into view.
 * - "sticky-story" (Additional CSS class of Columns): the first column stays
 *   in view on large screens while the steps in the other column scroll by.
 * - "lift-cards" (Additional CSS class of Columns or a Group): the children
 *   lift and tilt slightly on hover, and their images zoom.
 * - "zoom-in" (Additional CSS class of an Image or Cover): the picture
 *   settles from a slight zoom as it scrolls into view.
 */

/* Scroller: a sideways row of images. */
:is(.wp-block-gallery.is-style-scroller, .scroller-row > .wp-block-post-template) {
	--scroller-h: clamp(16rem, 52vh, 34rem);
	display: flex;
	flex-wrap: nowrap;
	gap: var(--wp--preset--spacing--50);
	overflow-x: auto;
	overscroll-behavior-x: contain;
	padding-block-end: var(--wp--preset--spacing--30);
	scroll-snap-type: x mandatory;
	scroll-padding-inline: var(--wp--preset--spacing--50);
	scrollbar-width: thin;
	list-style: none;
}

.scroller-row > .wp-block-post-template {
	--scroller-w: clamp(14rem, 24vw, 21rem);
	margin: 0;
	padding-inline: var(--wp--style--root--padding-left, var(--wp--preset--spacing--50));
}

.scroller-row:not(.alignfull) > .wp-block-post-template {
	padding-inline: 0;
}

.scroller-row > .wp-block-post-template > li {
	display: flex;
	flex: 0 0 var(--scroller-w);
	flex-direction: column;
	gap: var(--wp--preset--spacing--20);
	margin: 0;
	scroll-snap-align: start;
}

.scroller-row .wp-block-post-featured-image {
	overflow: hidden;
	margin: 0;
	border-radius: var(--wp--custom--radius--lg, 1rem);
	box-shadow: 0 1.25rem 2.5rem -1.5rem rgb(0 0 0 / 0.35);
}

.scroller-row .wp-block-post-featured-image img {
	aspect-ratio: 4 / 5;
	inline-size: 100%;
	object-fit: cover;
}

.wp-block-gallery.is-style-scroller > .wp-block-image {
	flex: 0 0 auto;
	inline-size: auto !important;
	margin: 0;
	scroll-snap-align: start;
}

.wp-block-gallery.is-style-scroller > .wp-block-image img {
	block-size: var(--scroller-h);
	inline-size: auto;
	max-inline-size: 80vw;
	border-radius: var(--wp--custom--radius--lg, 1rem);
	box-shadow: 0 1.25rem 2.5rem -1.5rem rgb(0 0 0 / 0.35);
	object-fit: cover;
}

.wp-block-gallery.is-style-scroller > .wp-block-image figcaption {
	border-radius: 0 0 var(--wp--custom--radius--lg, 1rem) var(--wp--custom--radius--lg, 1rem);
	font-family: var(--wp--preset--font-family--heading, inherit);
	font-size: var(--wp--preset--font-size--md, 1.1rem);
}

.wp-block-gallery.is-style-scroller > .wp-block-image a {
	display: block;
	overflow: hidden;
	border-radius: var(--wp--custom--radius--lg, 1rem);
}

/* Zoom in: the picture stays inside its box. */
.zoom-in:is(.wp-block-image, .wp-block-cover),
.zoom-in .wp-block-media-text__media {
	overflow: hidden;
}

/* Lift cards. */
.lift-cards > * {
	position: relative;
	overflow: hidden;
}

.lift-cards img {
	display: block;
}

@media (prefers-reduced-motion: no-preference) {

	.lift-cards > *,
	.lift-cards img,
	.wp-block-gallery.is-style-scroller img,
	.scroller-row img {
		transition:
			transform 0.5s cubic-bezier(0.2, 0, 0, 1),
			box-shadow 0.5s ease;
	}

	.lift-cards > :hover {
		box-shadow: 0 1.75rem 3rem -1.5rem rgb(0 0 0 / 0.3);
		transform: translateY(-0.5rem) rotate(-0.6deg);
	}

	.lift-cards > :nth-child(even):hover {
		transform: translateY(-0.5rem) rotate(0.6deg);
	}

	.lift-cards > :hover img,
	.wp-block-gallery.is-style-scroller > .wp-block-image a:is(:hover, :focus-visible) img,
	.scroller-row li:hover img {
		transform: scale(1.05);
	}
}

/* Sticky story. */
@media (min-width: 782px) {

	.sticky-story {
		--sticky-top: calc(var(--wp-admin--admin-bar--height, 0px) + 6rem);
	}

	.sticky-story > .wp-block-column:first-child {
		position: sticky;
		inset-block-start: var(--sticky-top);
		align-self: flex-start;
	}

	/* The picture always fits under the header. */
	.sticky-story > .wp-block-column:first-child img {
		display: block;
		inline-size: auto;
		max-block-size: calc(100svh - var(--sticky-top) - var(--wp--preset--spacing--50));
		margin-inline: auto;
		object-fit: contain;
	}
}

.sticky-story .wp-block-column:last-child > * + * {
	margin-block-start: var(--wp--preset--spacing--60);
}

.sticky-story .is-style-stat {
	color: var(--wp--preset--color--primary);
}

@media (prefers-reduced-motion: no-preference) {

	@supports (animation-timeline: view()) {

		/* Ink: the colour fills from the top left while scrolling in. */
		.ink-text {
			background-image:
				linear-gradient(
					160deg,
					var(--wp--preset--color--contrast) 45%,
					color-mix(in oklab, var(--wp--preset--color--contrast) 18%, transparent) 55%
				);
			background-clip: text;
			background-position: 100% 100%;
			background-size: 250% 250%;
			color: transparent;
			animation: showcase-ink linear both;
			animation-timeline: view();
			animation-range: entry 40% cover 55%;
		}

		.zoom-in img,
		.zoom-in .wp-block-cover__image-background {
			animation: showcase-zoom linear both;
			animation-timeline: view();
			animation-range: entry 0% cover 50%;
		}

		.sticky-story .wp-block-column:last-child > * {
			animation: showcase-step linear both;
			animation-timeline: view();
			animation-range: entry 10% cover 40%;
		}
	}
}

/* Pinned gallery: large screens with scroll-driven animations only. */
@media (min-width: 782px) and (prefers-reduced-motion: no-preference) {

	@supports (animation-timeline: view()) {

		/* Pinned only with six images or more: fewer fit on the screen. */
		.pin-gallery:has(.wp-block-gallery.is-style-scroller > :nth-child(6), .scroller-row > .wp-block-post-template > :nth-child(6)) {

			/* Room of the sticky header (and of the admin bar when logged in). */
			--pin-top: calc(var(--wp-admin--admin-bar--height, 0px) + 4.5rem);
			block-size: 280vh;
			view-timeline: --showcase-pin block;
		}

		.pin-gallery:has(.wp-block-gallery.is-style-scroller > :nth-child(6), .scroller-row > .wp-block-post-template > :nth-child(6)) > .wp-block-group {
			position: sticky;
			inset-block-start: var(--pin-top);
			display: flex;
			overflow: hidden;
			box-sizing: border-box;
			flex-direction: column;
			justify-content: center;
			block-size: calc(100vh - var(--pin-top));
			block-size: calc(100svh - var(--pin-top));
			padding-block: var(--wp--preset--spacing--40) !important;
			max-inline-size: none;
			container-type: inline-size;
		}

		.pin-gallery:has(.wp-block-gallery.is-style-scroller > :nth-child(6), .scroller-row > .wp-block-post-template > :nth-child(6)) :is(.wp-block-gallery.is-style-scroller, .scroller-row > .wp-block-post-template) {
			overflow: visible;
			inline-size: max-content;
			max-inline-size: none;
			margin-inline: 0;
			padding-inline: max(var(--wp--preset--spacing--50), calc((100cqi - var(--wp--style--global--wide-size, 1200px)) / 2));
			scroll-snap-type: none;
			animation: showcase-slide linear both;
			animation-timeline: --showcase-pin;
			animation-range: contain 8% contain 92%;
		}

		/* Cards as tall as the screen allows, so the button below always shows. */
		.pin-gallery:has(.wp-block-gallery.is-style-scroller > :nth-child(6), .scroller-row > .wp-block-post-template > :nth-child(6)) .scroller-row > .wp-block-post-template {
			--scroller-w: clamp(10rem, min(24vw, (100svh - var(--pin-top) - 22rem) * 0.8), 21rem);
		}

		.pin-gallery:has(.wp-block-gallery.is-style-scroller > :nth-child(6), .scroller-row > .wp-block-post-template > :nth-child(6)) .scroller-row {
			max-inline-size: none;
		}

		[dir="rtl"] .pin-gallery:has(.wp-block-gallery.is-style-scroller > :nth-child(6), .scroller-row > .wp-block-post-template > :nth-child(6)) :is(.wp-block-gallery.is-style-scroller, .scroller-row > .wp-block-post-template) {
			animation-name: showcase-slide-rtl;
		}
	}
}

@keyframes showcase-ink {

	to {
		background-position: 0 0;
	}
}

@keyframes showcase-zoom {

	from {
		transform: scale(1.15);
	}

	to {
		transform: scale(1);
	}
}

@keyframes showcase-step {

	from {
		opacity: 0.15;
		transform: translateY(2rem);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes showcase-slide {

	to {
		transform: translateX(calc(-100% + 100cqi));
	}
}

@keyframes showcase-slide-rtl {

	to {
		transform: translateX(calc(100% - 100cqi));
	}
}

/* Pictures in a sticky story and in lift cards: rounded corners. */
.sticky-story .wp-block-image img,
.lift-cards .wp-block-post-featured-image img {
	border-radius: var(--wp--custom--radius--lg, 1rem);
}
