/*
 * Slothturtle Paper Forest
 * Everything is prefixed stpf- / --stpf- so nothing collides with the theme.
 *
 * Custom properties
 *   --stpf-h-lg / --stpf-h-sm  scene height on wide and narrow screens (set by the shortcode)
 *   --stpf-k                   parallax strength (set by the shortcode)
 *   --stpf-sky                 sky colour (set by the shortcode)
 *   --stpf-s                   px scrolled past the scene (written by the script)
 *   --stpf-p                   page progress 0..1 (written by the script)
 *   --stpf-vy                  vine offset in px (written by the script)
 */

/* ---------- 1. Scene ---------- */

.stpf-scene {
	--stpf-h: var(--stpf-h-lg, 700px);
	position: relative;
	display: flow-root;
	box-sizing: border-box;
	min-height: var(--stpf-h);
	overflow: hidden;
	background: var(--stpf-sky, transparent);
}

.stpf-scene .stpf-layer {
	position: absolute;
	display: block;
	max-width: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	object-fit: contain;
	pointer-events: none;
	user-select: none;
	will-change: transform;
}

.stpf-scene .stpf-layer--sun {
	top: calc(var(--stpf-h) * 0.1);
	right: 17%;
	width: 120px;
	height: 120px;
	filter: drop-shadow(0 4px 3px rgba(60, 40, 20, 0.2));
	transform: translateY(calc(var(--stpf-s, 0) * var(--stpf-k, 1) * 0.35px));
}

.stpf-scene .stpf-layer--cloud-a {
	top: calc(var(--stpf-h) * 0.214);
	left: 7%;
	width: 220px;
	height: 88px;
	filter: drop-shadow(0 5px 3px rgba(40, 60, 60, 0.2));
	transform: translateX(calc(var(--stpf-s, 0) * var(--stpf-k, 1) * 0.3px));
}

.stpf-scene .stpf-layer--cloud-b {
	top: calc(var(--stpf-h) * 0.357);
	right: 30%;
	width: 150px;
	height: 60px;
	filter: drop-shadow(0 4px 3px rgba(40, 60, 60, 0.18));
	transform: translateX(calc(var(--stpf-s, 0) * var(--stpf-k, 1) * -0.2px));
}

/*
 * Wide layers: the art keeps its own size and is pinned to the bottom centre.
 * Narrow screens crop it evenly from both sides; screens wider than the art
 * repeat it sideways. It is never stretched, so tree tops are never cut off.
 */
.stpf-scene .stpf-layer--wide {
	left: 0;
	width: 100%;
	background-repeat: repeat-x;
	background-position: 50% 100%;
	background-size: auto 100%;
}

/* Bottom-pinned strips: trim 2px off the top, where a scaled repeating image
   can show a hairline of its own bottom row. */
.stpf-scene .stpf-layer--far,
.stpf-scene .stpf-layer--mid,
.stpf-scene .stpf-layer--hills,
.stpf-scene .stpf-layer--near {
	bottom: 0;
	clip-path: inset(2px 0 0 0);
}

.stpf-scene .stpf-layer--far {
	height: calc(var(--stpf-h) * 0.5714);
	filter: drop-shadow(0 -3px 3px rgba(30, 60, 50, 0.14));
	transform: translateY(calc(var(--stpf-s, 0) * var(--stpf-k, 1) * 0.32px));
}

.stpf-scene .stpf-layer--mid {
	height: calc(var(--stpf-h) * 0.4857);
	filter: drop-shadow(0 -4px 4px rgba(20, 50, 35, 0.2));
	transform: translateY(calc(var(--stpf-s, 0) * var(--stpf-k, 1) * 0.16px));
}

.stpf-scene .stpf-layer--near {
	height: calc(var(--stpf-h) * 0.3714);
	filter: drop-shadow(0 -5px 5px rgba(10, 40, 25, 0.26));
	will-change: auto;
}

.stpf-scene .stpf-layer--leaves-left,
.stpf-scene .stpf-layer--leaves-right {
	top: -40px;
	z-index: 3;
	width: 320px;
	height: 220px;
	filter: drop-shadow(0 6px 5px rgba(10, 40, 25, 0.3));
	transform: translateY(calc(var(--stpf-s, 0) * var(--stpf-k, 1) * -0.25px));
}

.stpf-scene .stpf-layer--leaves-left {
	left: -30px;
	object-position: 0 0;
}

.stpf-scene .stpf-layer--leaves-right {
	right: -30px;
	object-position: 100% 0;
}

/*
 * Torn bottom edge. The art file only supplies the shape; the colour comes
 * from --stpf-edge so it can match the page below. The shadow sits on the
 * outer box because a mask would cut it off.
 */
.stpf-edge {
	position: absolute;
	bottom: -1px;
	left: 0;
	z-index: 4;
	width: 100%;
	height: 28px;
	pointer-events: none;
	filter: drop-shadow(0 -3px 2px rgba(10, 40, 25, 0.22));
}

.stpf-edge::before {
	position: absolute;
	inset: 0;
	content: "";
	background-color: var(--stpf-edge, transparent);
	/* One copy of the shape, never repeated: repeated copies leave a hairline
	   seam where they meet. Wider screens stretch it; narrower ones crop it
	   evenly from both sides so the tears keep their size. */
	-webkit-mask: var(--stpf-edge-img) no-repeat 50% 100% / 100% 100%;
	mask: var(--stpf-edge-img) no-repeat 50% 100% / 100% 100%;
}

@media (max-width: 1439px) {
	.stpf-edge::before {
		-webkit-mask-size: 1440px 100%;
		mask-size: 1440px 100%;
	}
}

/*
 * Soft focus. One see-through sheet laid over the background pieces: it blurs
 * what is behind it and can tint towards the sky colour. Characters, leaves
 * and the content come later in the page, so they stay sharp.
 *
 *   --stpf-blur         blur at rest, px
 *   --stpf-blur-scroll  extra blur by the time 400px have scrolled, px
 *   --stpf-fade         tint by the time 400px have scrolled, percent
 */
.stpf-veil {
	--stpf-veil-p: min(1, var(--stpf-s, 0) / 400);
	position: absolute;
	inset: 0;
	z-index: 1;
	pointer-events: none;
	background-color: color-mix(in srgb, var(--stpf-sky, #fff) calc(var(--stpf-veil-p) * var(--stpf-fade, 0) * 1%), transparent);
	-webkit-backdrop-filter: blur(calc((var(--stpf-blur, 0) + var(--stpf-veil-p) * var(--stpf-blur-scroll, 0)) * 1px));
	backdrop-filter: blur(calc((var(--stpf-blur, 0) + var(--stpf-veil-p) * var(--stpf-blur-scroll, 0)) * 1px));
}

/* Torn top edge: the same shape flipped, sitting under the content and leaves. */
.stpf-edge--top {
	top: -1px;
	bottom: auto;
	z-index: 1;
	transform: scaleY(-1);
}

.stpf-edge--top::before {
	background-color: var(--stpf-edge-top, transparent);
}

/*
 * Characters and hanging pieces share one size rule, so they keep their real
 * sizes next to each other (Dangler is a kid). Set on each piece:
 *   --stpf-art-h  the art's own height in art pixels (Dreamy is 398)
 *   --stpf-scale  the piece's size setting, 1 by default
 *   --stpf-y      % of the scene height: lifted off the ground, or lowered from the top
 *   --stpf-flip   -1 to face the other way
 *   --stpf-char-x how far across the scene, the middle of the piece
 * --stpf-u turns art pixels into screen pixels and follows the scene's height,
 * so everything grows and shrinks with the scene and on phones.
 */
.stpf-scene {
	--stpf-u: max(0.3px, var(--stpf-h) * 0.0008);
}

.stpf-scene .stpf-layer--character,
.stpf-hang {
	--stpf-ph: calc(var(--stpf-u) * var(--stpf-art-h, 280) * var(--stpf-scale, 1));
}

/* Standing: pinned by the middle of the feet. */
.stpf-scene .stpf-layer--character {
	bottom: calc(var(--stpf-ground, 30px) + var(--stpf-h) * var(--stpf-y, 0) / 100);
	left: var(--stpf-char-x, 24%);
	z-index: 1;
	width: auto;
	height: var(--stpf-ph);
	translate: -50% 0;
	scale: var(--stpf-flip, 1) 1;
	will-change: auto;
}

/* Breathing: characters rise a hair and settle, slowly, each out of step with
   the others. Props stay put. About 1% of the piece's height, so a small
   Dangler breathes less than Dreamy. Stills with reduced motion. */
@media (prefers-reduced-motion: no-preference) {
	.stpf-scene .stpf-layer--character:not(.stpf-layer--prop) {
		animation: stpf-breathe 5.2s ease-in-out infinite;
	}

	.stpf-scene .stpf-layer--character:not(.stpf-layer--prop):nth-child(2n) {
		animation-duration: 5.9s;
		animation-delay: -2.1s;
	}

	.stpf-scene .stpf-layer--character:not(.stpf-layer--prop):nth-child(3n) {
		animation-duration: 4.7s;
		animation-delay: -3.4s;
	}
}

@keyframes stpf-breathe {
	0%,
	100% {
		transform: translateY(0);
	}

	50% {
		transform: translateY(calc(var(--stpf-ph) * -0.009));
	}
}

/* Hanging from the top edge: pinned at the top centre, and swings from there. */
.stpf-hang {
	position: absolute;
	top: calc(var(--stpf-h) * var(--stpf-y, 0) / 100 - 4px);
	left: var(--stpf-char-x, 30%);
	z-index: 1;
	height: var(--stpf-ph);
	translate: -50% 0;
	pointer-events: none;
}

.stpf-scene .stpf-hang__img {
	display: block;
	width: auto;
	height: 100%;
	max-width: none;
	margin: 0;
	border-radius: 0;
	box-shadow: none;
	scale: var(--stpf-flip, 1) 1;
	transform-origin: 50% 0;
	animation: stpf-swing 4.2s ease-in-out infinite alternate;
}

/* Light text for dark skies. A colour set on a block itself still wins. */
.stpf-scene--light-text .stpf-scene__content,
.stpf-scene--light-text .stpf-scene__content :is(h1, h2, h3, h4, h5, h6, p, li) {
	color: #fbf6ea;
}

/* The owner's heading, paragraph and button. Kept clear of the dark trees. */
.stpf-scene__content {
	position: relative;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 20px;
	box-sizing: border-box;
	max-width: 760px;
	margin: 0 auto;
	padding: 84px 24px calc(var(--stpf-h) * 0.48);
	text-align: center;
}

.stpf-scene__content > * {
	margin-top: 0;
	margin-bottom: 0;
}

.stpf-scene--no-trees .stpf-scene__content {
	padding-bottom: 64px;
}

/* Hills only: keep the content above the hill line. */
.stpf-scene--low .stpf-scene__content {
	padding-top: 56px;
	padding-bottom: calc(var(--stpf-h) * 0.26 + 32px);
}

/* Clearing: on narrow screens the content sits above the side trees... */
.stpf-scene--grove .stpf-scene__content {
	padding-top: 56px;
	padding-bottom: calc(var(--stpf-grove-h) + 24px);
}

/* ...and on wide screens it sits between them. */
@media (min-width: 900px) {
	.stpf-scene--grove .stpf-scene__content {
		max-width: min(760px, calc(100% - var(--stpf-grove-h) * 1.74));
		padding-bottom: calc(var(--stpf-h) * 0.26 + 32px);
	}
}

/* ---------- Extra pieces for the smaller scenes ---------- */

.stpf-scene {
	--stpf-grove-h: calc(var(--stpf-h) * 0.45);
}

@media (min-width: 900px) {
	.stpf-scene {
		--stpf-grove-h: calc(var(--stpf-h) * 0.72);
	}
}

.stpf-scene .stpf-layer--hills {
	bottom: 0;
	height: calc(var(--stpf-h) * 0.26);
	filter: drop-shadow(0 -4px 4px rgba(20, 50, 35, 0.2));
	will-change: auto;
}

/* Side trees: pinned to the bottom corners, 13:15, never cropped. */
.stpf-scene .stpf-layer--grove-left,
.stpf-scene .stpf-layer--grove-right {
	bottom: 0;
	width: calc(var(--stpf-grove-h) * 0.8667);
	height: var(--stpf-grove-h);
	filter: drop-shadow(0 -4px 5px rgba(10, 40, 25, 0.26));
	will-change: auto;
}

.stpf-scene .stpf-layer--grove-left {
	left: -12px;
	object-position: 0 100%;
}

.stpf-scene .stpf-layer--grove-right {
	right: -12px;
	object-position: 100% 100%;
}

.stpf-scene .stpf-layer--moon {
	top: calc(var(--stpf-h) * 0.1);
	right: 17%;
	width: 120px;
	height: 120px;
	filter: drop-shadow(0 4px 3px rgba(10, 15, 40, 0.35));
	transform: translateY(calc(var(--stpf-s, 0) * var(--stpf-k, 1) * 0.35px));
}

/* Stars: pinned to the top, cropped evenly from both sides. */
.stpf-scene .stpf-layer--stars {
	top: 0;
	height: calc(var(--stpf-h) * 0.72);
	background-position: 50% 0;
	filter: drop-shadow(0 2px 2px rgba(10, 15, 40, 0.3));
	transform: translateY(calc(var(--stpf-s, 0) * var(--stpf-k, 1) * 0.1px));
}

@media (max-width: 599px) {
	.stpf-scene .stpf-layer--moon {
		right: 8%;
		width: 84px;
		height: 84px;
	}
}

@media (max-width: 599px) {
	.stpf-scene {
		--stpf-h: var(--stpf-h-sm, 520px);
	}

	.stpf-scene .stpf-layer--sun {
		right: 8%;
		width: 84px;
		height: 84px;
	}

	.stpf-scene .stpf-layer--cloud-a {
		left: 4%;
		width: 150px;
		height: 60px;
	}

	.stpf-scene .stpf-layer--cloud-b {
		right: 18%;
		width: 110px;
		height: 44px;
	}

	.stpf-scene .stpf-layer--leaves-left,
	.stpf-scene .stpf-layer--leaves-right {
		top: -30px;
		width: 200px;
		height: 138px;
	}

	.stpf-scene .stpf-layer--leaves-left {
		left: -24px;
	}

	.stpf-scene .stpf-layer--leaves-right {
		right: -24px;
	}

	.stpf-scene__content {
		padding-top: 72px;
	}
}

/* ---------- 2. Vine ---------- */

/* Hidden until the script has measured a clear margin beside the story. */
.stpf-vine {
	position: fixed;
	top: 0;
	right: 6px;
	z-index: 6;
	display: none;
	width: 108px;
	height: 100vh;
	overflow: hidden;
	pointer-events: none;
}

@media (min-width: 1240px) {
	.stpf-vine.stpf-is-clear {
		display: block;
	}
}

.stpf-vine__stem {
	position: absolute;
	top: 0;
	left: 16px;
	width: 76px;
	height: calc(100% + 240px);
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='76' height='240' viewBox='0 0 76 240'%3E%3Cpath fill='%233F8259' d='M35 0h6v240h-6z'/%3E%3Cpath fill='%232F6B4A' d='M41 56l17-8 6 10-12 10-11-2zM35 176l-17-8-6 10 12 10 11-2z'/%3E%3C/svg%3E") 0 0 / 76px 240px repeat-y;
	filter: drop-shadow(2px 3px 3px rgba(10, 40, 25, 0.3));
	transform: translateY(calc(var(--stpf-vy, 0) * -1px));
	will-change: transform;
}

/* The sloth climbs down the vine as the page is read: 150px from the top at
   the start, 150px from the bottom at the end. */
.stpf-vine__sloth {
	position: absolute;
	top: 150px;
	left: 10px;
	width: 88px;
	height: 136px;
	transform: translateY(calc(var(--stpf-p, 0) * max(0px, 100vh - 436px)));
	will-change: transform;
}

.stpf-vine .stpf-vine__img {
	display: block;
	width: 88px;
	height: 136px;
	max-width: none;
	margin: 0;
	border-radius: 0;
	box-shadow: none;
	object-fit: contain;
	object-position: 50% 0;
	filter: drop-shadow(0 5px 4px rgba(40, 25, 10, 0.32));
	transform-origin: 50% 0;
	animation: stpf-swing 3.6s ease-in-out infinite alternate;
}

/* ---------- 3. Walking turtle ---------- */

/*
 * A strip anywhere in the page. The script sets --stpf-p from 0 (strip just
 * coming into view at the bottom of the window) to 1 (a third of the way down
 * from the top). Without the script, or with reduced motion, it stays at 0:
 * the turtle stands at the start of its walk.
 */
.stpf-walker {
	--stpf-walk-w: 110px;
	--stpf-walk-h: 70px;
	position: relative;
	height: calc(var(--stpf-walk-h) + 16px);
	margin-top: 0.5em;
	margin-bottom: 0.5em;
	overflow: hidden;
	pointer-events: none;
}

.stpf-walker--small {
	--stpf-walk-w: 80px;
	--stpf-walk-h: 51px;
}

.stpf-walker--large {
	--stpf-walk-w: 150px;
	--stpf-walk-h: 95px;
}

.stpf-walker__walk {
	position: absolute;
	bottom: 8px;
	left: 0;
	width: 100%;
	transform: translateX(calc(var(--stpf-p, 0) * (100% - var(--stpf-walk-w))));
	will-change: transform;
}

.stpf-walker--leftward .stpf-walker__walk {
	transform: translateX(calc((1 - var(--stpf-p, 0)) * (100% - var(--stpf-walk-w))));
}

.stpf-walker__face {
	width: var(--stpf-walk-w);
}

.stpf-walker--leftward .stpf-walker__face {
	transform: scaleX(-1);
}

.stpf-walker .stpf-walker__img {
	display: block;
	width: var(--stpf-walk-w);
	height: var(--stpf-walk-h);
	max-width: none;
	margin: 0;
	border-radius: 0;
	box-shadow: none;
	object-fit: contain;
	object-position: 50% 100%;
	filter: drop-shadow(0 4px 3px rgba(0, 0, 0, 0.3));
	animation: stpf-bob 1.1s steps(2, end) infinite;
}

/* ---------- 5. Footer vine ---------- */

/*
 * A vine printed just above the footer. Its stem sits exactly on the footer's
 * top edge: the strip is 28px tall and pulls the footer up by half of that.
 * Leaves above the edge are dark (they sit on the page), leaves below are
 * light (they sit on the dark footer).
 */
.stpf-fvine {
	position: relative;
	z-index: 3;
	height: 28px;
	margin-bottom: -14px;
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='28' viewBox='0 0 240 28'%3E%3Cpath fill='%235FA777' d='M0 12h240v4H0z'/%3E%3Cpath fill='%233F8259' d='M52 12l7-10 11 1-4 9z'/%3E%3Cpath fill='%239CCBA5' d='M172 16l7 10 11-1-4-9z'/%3E%3Cpath fill='%233F8259' d='M118 12l5-6 7 1-3 5z'/%3E%3C/svg%3E") 0 0 / 240px 28px repeat-x;
	filter: drop-shadow(0 2px 2px rgba(10, 40, 25, 0.25));
	pointer-events: none;
}

/* Footer characters live in Kadence footer widget areas. */
.site-footer-section:has(.stpf-fpiece) {
	align-items: center;
}

.site-bottom-footer-inner-wrap:has(.stpf-fpiece--hang) {
	padding-top: 0;
}

.footer-widget-area:has(.stpf-fpiece) .widget {
	margin: 0;
}

.footer-widget-area:has(.stpf-fpiece--hang) {
	align-self: flex-start;
}

.footer-widget-area:has(.stpf-fpiece--stand) {
	align-self: flex-end;
	padding-bottom: 12px;
}

.stpf-fpiece {
	display: flex;
	align-items: flex-end;
	gap: 2px;
	line-height: 0;
	pointer-events: none;
}

.stpf-fpiece .stpf-fpiece__img {
	display: block;
	width: auto;
	max-width: none;
	margin: 0;
	border-radius: 0;
	box-shadow: none;
}

/* Hands on the stem: the art's top edge is its grip. */
.stpf-fpiece--hang {
	position: relative;
	z-index: 4;
	margin-top: -3px;
	padding-bottom: 8px;
}

.stpf-fpiece--hang .stpf-fpiece__img {
	filter: drop-shadow(0 5px 4px rgba(0, 0, 0, 0.3));
	transform-origin: 50% 0;
	animation: stpf-swing 3.6s ease-in-out infinite alternate;
}

/* Each sloth on its own beat. */
.stpf-fpiece--dangler .stpf-fpiece__img {
	animation-duration: 3.1s;
	animation-delay: -1.3s;
}

.stpf-fpiece--brown .stpf-fpiece__img {
	animation-duration: 4.2s;
	animation-delay: -2.4s;
}

.stpf-fpiece--stand .stpf-fpiece__img {
	filter: drop-shadow(0 4px 3px rgba(0, 0, 0, 0.3));
}

/*
 * Phones and small tablets (Kadence's mobile footer width). Priority: the
 * turtle and his sign, then Dangler, then nobody else. The row wraps and the
 * copyright line takes its own line underneath.
 */
@media (min-width: 720px) {
	.site-footer-section:has(.stpf-fpiece) > .site-info {
		flex-shrink: 0;
		white-space: nowrap;
	}
}

@media (max-width: 719px) {
	.site-footer-section:has(.stpf-fpiece) {
		flex-wrap: wrap;
		justify-content: center;
		column-gap: 18px;
	}

	.site-footer-section:has(.stpf-fpiece) > .site-info {
		flex-basis: 100%;
		text-align: center;
		padding-bottom: 12px;
	}

	.footer-widget-area:has(.stpf-fpiece--dreamy),
	.footer-widget-area:has(.stpf-fpiece--brown) {
		display: none;
	}
}

@media (max-width: 479px) {
	.footer-widget-area:has(.stpf-fpiece--dangler) {
		display: none;
	}

	.site-bottom-footer-inner-wrap:has(.stpf-fpiece--hang) {
		padding-top: 18px;
	}
}

/* ---------- Motion ---------- */

@keyframes stpf-swing {
	from {
		transform: rotate(-3.5deg);
	}

	to {
		transform: rotate(3.5deg);
	}
}

@keyframes stpf-bob {
	from {
		transform: translateY(0);
	}

	to {
		transform: translateY(-3px);
	}
}

/* Reduced motion: a complete, still picture. */
@media (prefers-reduced-motion: reduce) {
	.stpf-scene .stpf-layer,
	.stpf-vine__stem,
	.stpf-vine__sloth {
		transform: none;
	}

	.stpf-vine .stpf-vine__img,
	.stpf-scene .stpf-hang__img,
	.stpf-walker .stpf-walker__img,
	.stpf-fpiece .stpf-fpiece__img {
		animation: none;
	}
}

/* ==========================================================================
   Extras: ground level, seasons, landmark, moving pieces, speech bubble,
   scene behind the header. Their reduced-motion rules are at the end.
   ========================================================================== */

/* How far above the bottom edge things stand. */
.stpf-scene {
	--stpf-ground: 30px;
}

.stpf-scene--ground {
	--stpf-ground: calc(var(--stpf-h) * 0.045);
}

/* Seasonal ground cover: flowers, fallen leaves or snow, lying over the ground. */
.stpf-scene .stpf-layer--ground-cover {
	bottom: 0;
	height: max(80px, var(--stpf-h) * 0.14);
	clip-path: inset(2px 0 0 0);
	will-change: auto;
}

/* A big piece behind the characters, such as the treehouse. Pinned by the middle of its base. */
.stpf-scene .stpf-layer--landmark {
	--stpf-landmark-h: min(320px, var(--stpf-h) * 0.72);
	bottom: calc(var(--stpf-ground) - 6px);
	left: var(--stpf-char-x, 70%);
	z-index: 1;
	width: calc(var(--stpf-landmark-h) * 0.75);
	height: var(--stpf-landmark-h);
	object-position: 50% 100%;
	filter: drop-shadow(0 -3px 5px rgba(10, 40, 25, 0.26));
	translate: -50% 0;
	will-change: auto;
}

/* ---------- Moving pieces ---------- */

/* Clouds drift a little by themselves, on top of their scroll movement. */
.stpf-scene--drift-clouds .stpf-layer--cloud-a {
	animation: stpf-drift-a 46s ease-in-out infinite alternate;
}

.stpf-scene--drift-clouds .stpf-layer--cloud-b {
	animation: stpf-drift-b 58s ease-in-out infinite alternate;
}

@keyframes stpf-drift-a {
	from {
		translate: -20px 0;
	}

	to {
		translate: 60px 0;
	}
}

@keyframes stpf-drift-b {
	from {
		translate: 30px 0;
	}

	to {
		translate: -50px 0;
	}
}

/*
 * Flyers. The outer box is as wide as the scene and slides across it; the
 * image inside bobs. Each has a resting spot for when motion is off.
 */
.stpf-fly {
	position: absolute;
	left: 0;
	z-index: 1;
	width: 100%;
	pointer-events: none;
}

.stpf-scene .stpf-fly__img {
	display: block;
	max-width: none;
	margin: 0;
	border-radius: 0;
	box-shadow: none;
	filter: drop-shadow(0 3px 2px rgba(40, 25, 10, 0.25));
}

.stpf-fly--butterfly {
	top: 50%;
	transform: translateX(22%);
	animation: stpf-cross 44s linear infinite;
}

.stpf-fly--butterfly .stpf-fly__img {
	width: 44px;
	height: 36px;
	animation: stpf-flutter 2.4s ease-in-out infinite alternate;
}

/* Fireflies: soft light low in the scene, no shadow. Each one drifts by itself inside the art. */
.stpf-fly--fireflies {
	bottom: calc(var(--stpf-ground, 30px) + var(--stpf-h) * 0.06);
	left: 50%;
	width: min(600px, 86%);
	translate: -50% 0;
}

.stpf-scene .stpf-fly--fireflies .stpf-fly__img {
	width: 100%;
	height: auto;
	filter: none;
}

.stpf-fly--bee {
	top: 58%;
	transform: translateX(58%);
	animation: stpf-cross 27s linear infinite -9s;
}

.stpf-fly--bee .stpf-fly__img {
	width: 30px;
	height: 26px;
	animation: stpf-buzz 0.8s ease-in-out infinite alternate;
}

/* The dragonfly flies right to left, so its art is mirrored. */
.stpf-fly--dragonfly {
	top: 32%;
	transform: translateX(78%);
	animation: stpf-cross-back 33s linear infinite -14s;
}

.stpf-fly--dragonfly .stpf-fly__img {
	width: 54px;
	height: 30px;
	scale: -1 1;
	animation: stpf-dart 5s ease-in-out infinite alternate;
}

/* Breeze: wind lines sweep across, then wait out of sight. Hidden when motion is off. */
.stpf-fly--breeze,
.stpf-fly--breeze-b {
	transform: translateX(-20%);
}

.stpf-fly--breeze {
	top: 28%;
	animation: stpf-gust 13s ease-in-out infinite;
}

.stpf-fly--breeze-b {
	top: 46%;
	animation: stpf-gust 17s ease-in-out infinite -6s;
}

.stpf-fly--breeze .stpf-fly__img,
.stpf-fly--breeze-b .stpf-fly__img {
	width: 140px;
	height: 44px;
	filter: none;
}

@keyframes stpf-cross {
	from {
		transform: translateX(-8%);
	}

	to {
		transform: translateX(104%);
	}
}

@keyframes stpf-cross-back {
	from {
		transform: translateX(104%);
	}

	to {
		transform: translateX(-8%);
	}
}

@keyframes stpf-gust {
	0% {
		transform: translateX(-20%);
	}

	28%,
	100% {
		transform: translateX(110%);
	}
}

@keyframes stpf-flutter {
	from {
		transform: translateY(-16px) rotate(-9deg);
	}

	to {
		transform: translateY(16px) rotate(9deg);
	}
}

@keyframes stpf-buzz {
	from {
		transform: translateY(-5px);
	}

	to {
		transform: translateY(5px);
	}
}

@keyframes stpf-dart {
	0%,
	35% {
		transform: translateY(0);
	}

	50%,
	85% {
		transform: translateY(-24px);
	}

	100% {
		transform: translateY(-8px);
	}
}

/*
 * Falling leaf. The box is a point on the ground; the leaf falls to it in six
 * seconds, slips behind the pile, and waits there until the ten seconds are up.
 */
.stpf-leaf {
	position: absolute;
	bottom: var(--stpf-ground);
	left: var(--stpf-leaf-x, 66%);
	z-index: 1;
	width: 0;
	height: 0;
	pointer-events: none;
}

.stpf-scene .stpf-leaf__fall,
.stpf-scene .stpf-leaf__pile {
	position: absolute;
	display: block;
	max-width: none;
	margin: 0;
	border-radius: 0;
	box-shadow: none;
}

.stpf-scene .stpf-leaf__fall {
	bottom: 2px;
	left: -13px;
	width: 26px;
	height: 26px;
	animation: stpf-fall 10s linear infinite;
}

.stpf-scene .stpf-leaf__pile {
	bottom: -8px;
	left: -48px;
	width: 96px;
	height: 40px;
	filter: drop-shadow(0 -2px 2px rgba(40, 25, 10, 0.2));
}

@keyframes stpf-fall {
	0% {
		transform: translate(46px, calc(var(--stpf-h) * -1)) rotate(0deg);
	}

	12% {
		transform: translate(-34px, calc(var(--stpf-h) * -0.8)) rotate(-55deg);
	}

	25% {
		transform: translate(38px, calc(var(--stpf-h) * -0.58)) rotate(45deg);
	}

	38% {
		transform: translate(-26px, calc(var(--stpf-h) * -0.36)) rotate(-40deg);
	}

	50% {
		transform: translate(18px, calc(var(--stpf-h) * -0.16)) rotate(28deg);
	}

	60%,
	100% {
		transform: translate(0, 0) rotate(8deg);
	}
}

/* ---------- Speech bubble ---------- */

.stpf-bubble {
	position: absolute;
	left: var(--stpf-char-x, 24%);
	z-index: 1;
	box-sizing: border-box;
	width: max-content;
	max-width: min(240px, 42%);
	padding: 12px 16px;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.35;
	color: #2b2a28;
	text-align: center;
	background: #fbf6ea;
	border-radius: 14px 18px 12px 20px;
	filter: drop-shadow(0 4px 3px rgba(40, 25, 10, 0.25));
	transform: translateX(-50%) rotate(-1.5deg);
}

.stpf-bubble::after {
	position: absolute;
	left: 50%;
	width: 20px;
	height: 15px;
	margin-left: -10px;
	content: "";
	background: inherit;
}

/* The bubble carries its piece's size and place, so it sits just past the head. */
.stpf-bubble {
	--stpf-ph: calc(var(--stpf-u) * var(--stpf-art-h, 280) * var(--stpf-scale, 1));
}

/* Above a standing character, tail pointing down. */
.stpf-bubble--up {
	bottom: calc(var(--stpf-ground) + var(--stpf-h) * var(--stpf-y, 0) / 100 + var(--stpf-ph) + 12px);
}

.stpf-bubble--up::after {
	top: calc(100% - 1px);
	clip-path: polygon(0 0, 100% 0, 35% 100%);
}

/* Below a hanging piece, tail pointing up. */
.stpf-bubble--down {
	top: calc(var(--stpf-h) * var(--stpf-y, 0) / 100 + var(--stpf-ph) + 10px);
}

.stpf-bubble--down::after {
	bottom: calc(100% - 1px);
	clip-path: polygon(35% 0, 0 100%, 100% 100%);
}

/* ---------- Scene behind the site header ---------- */

/*
 * The class is put on the html element by a one-line script printed with the
 * scene. The header is lifted out of the page flow and made see-through, so
 * the scene starts at the very top with the logo and menu over it.
 */
.stpf-header-over #masthead {
	position: absolute;
	right: 0;
	left: 0;
	z-index: 20;
	background: transparent;
}

.stpf-header-over #masthead .site-header-row-container-inner,
.stpf-header-over #masthead .site-header-inner-wrap,
.stpf-header-over #masthead .site-header-upper-inner-wrap,
.stpf-header-over #masthead #main-header,
.stpf-header-over #masthead #mobile-header {
	background: transparent;
}

.stpf-scene--behind-header .stpf-scene__content {
	padding-top: calc(84px + var(--stpf-header-h, 90px));
}

@media (max-width: 599px) {
	.stpf-scene .stpf-layer--landmark {
		--stpf-landmark-h: min(200px, var(--stpf-h) * 0.6);
	}

	.stpf-bubble {
		max-width: min(170px, 60%);
		padding: 9px 12px;
		font-size: 14px;
	}

	.stpf-scene--behind-header .stpf-scene__content {
		padding-top: calc(72px + var(--stpf-header-h, 70px));
	}
}

/* Reduced motion: everything above stays put. The breeze is hidden, as it only exists in motion. */
@media (prefers-reduced-motion: reduce) {
	.stpf-scene--drift-clouds .stpf-layer--cloud-a,
	.stpf-scene--drift-clouds .stpf-layer--cloud-b,
	.stpf-fly,
	.stpf-scene .stpf-fly__img,
	.stpf-scene .stpf-leaf__fall {
		animation: none;
	}

	.stpf-fly--breeze,
	.stpf-fly--breeze-b {
		display: none;
	}
}
