/* PrettyWellFit Entrance — house entrance motion.
 * Values arrive as custom properties from Settings > PrettyWellFit Elements
 * (inlined after this file); the ones below are fallbacks only.
 * The hidden state engages only once the head script has confirmed
 * live JS (html.pwf-js) and never under reduced motion; without either,
 * every element is simply visible. The delay is pure CSS:
 * (order - 1) x step, start to start, from the element's own trigger.
 */

:root {
	--pwf-ent-distance: 22px;
	--pwf-ent-dur: 700ms;
	--pwf-ent-ease: cubic-bezier(0.16, 1, 0.3, 1);
	--pwf-ent-step: 120ms;
}

/* PrettyWellFit Entrance owns the element: any native Elementor entrance on
 * the same wrapper (animate.css keyframes) is disabled outright, and
 * the native pre-animation hidden state is defeated so a stray native
 * setting can never strand or double-animate an opted-in element. */
.pwf-entrance {
	animation: none !important;
}

.pwf-entrance.elementor-invisible {
	visibility: visible !important;
}

@media (prefers-reduced-motion: no-preference) {
	html.pwf-js .pwf-entrance {
		opacity: 0;
		transform: translateY(var(--pwf-ent-distance));
	}

	html.pwf-js .pwf-entrance.sw-in {
		opacity: 1;
		transform: none;
		transition:
			opacity var(--pwf-ent-dur) var(--pwf-ent-ease),
			transform var(--pwf-ent-dur) var(--pwf-ent-ease);
		transition-delay: calc((var(--pwf-ent-order, 1) - 1) * var(--pwf-ent-step));
	}

	/* Entered and settled: the stagger delay and entrance duration
	 * stop governing the element, so later state changes (hover
	 * fades and the like) react immediately. */
	html.pwf-js .pwf-entrance.sw-in.sw-settled {
		transition-duration: 300ms;
		transition-delay: 0ms;
	}

	/* Blur-aware entrance: an element carrying (or containing) a
	 * Background Blur container must never animate opacity — a group
	 * mid-fade seals its backdrop and the blur cannot sample until it
	 * lands. These elements hide with visibility instead and rise in
	 * with the same motion; the blur is live from the first visible
	 * pixel. */
	html.pwf-js .pwf-entrance.pwf-bgblur,
	html.pwf-js .pwf-entrance:has(.pwf-bgblur) {
		opacity: 1;
		visibility: hidden;
	}

	html.pwf-js .pwf-entrance.sw-in.pwf-bgblur,
	html.pwf-js .pwf-entrance.sw-in:has(.pwf-bgblur) {
		visibility: visible;
	}
}

/* ---- Frames ----
 * A container marked data-pwf-frame claims the .pwf-entrance elements
 * inside it: the engine never observes them, and the frame's own
 * timeline states reveal them instead, with the same motion and the
 * same (order - 1) x step stagger. Inside a pinned stage, viewport
 * entry happens long before the frame is visible, so the timeline is
 * the only correct trigger. Owner blocks below map each frame widget's
 * broadcast states onto the house entrance.
 */

@media (prefers-reduced-motion: no-preference) {
	/* Reveal Scroll Video end frame. Children stagger in when the
	 * timeline reveals the frame; when it unreveals, they ride the
	 * frame's own fast uniform 300ms fade back to hidden, so a reset
	 * is never visible. */
	html.pwf-js .pwf-reveal.is-end-revealed [data-pwf-frame] .pwf-entrance {
		opacity: 1;
		transform: none;
		transition:
			opacity var(--pwf-ent-dur) var(--pwf-ent-ease),
			transform var(--pwf-ent-dur) var(--pwf-ent-ease);
		transition-delay: calc((var(--pwf-ent-order, 1) - 1) * var(--pwf-ent-step));
	}

	html.pwf-js .pwf-reveal.is-end-unrevealing [data-pwf-frame] .pwf-entrance {
		transition: opacity 300ms ease, transform 300ms ease;
		transition-delay: 0ms;
	}

	/* Hero Scroll Video composed end frame: same contract, keyed to the
	 * hero's own trigger classes. */
	html.pwf-js .pwf-hero.is-revealed [data-pwf-frame] .pwf-entrance {
		opacity: 1;
		transform: none;
		transition:
			opacity var(--pwf-ent-dur) var(--pwf-ent-ease),
			transform var(--pwf-ent-dur) var(--pwf-ent-ease);
		transition-delay: calc((var(--pwf-ent-order, 1) - 1) * var(--pwf-ent-step));
	}

	html.pwf-js .pwf-hero.is-unrevealing [data-pwf-frame] .pwf-entrance {
		transition: opacity 300ms ease, transform 300ms ease;
		transition-delay: 0ms;
	}
}


/* ---- Entrance Blur ----
 * Optional (Settings > PrettyWellFit Elements): elements arrive soft and
 * resolve sharp with the same duration, ease, and stagger as the rise.
 * Gated by html.pwf-entblur so the feature costs nothing when off.
 * Background Blur carriers are excluded everywhere: a filter would make
 * them a backdrop root and wall their own blur off.
 */

@media (prefers-reduced-motion: no-preference) {
	html.pwf-js.pwf-entblur .pwf-entrance:not(.pwf-bgblur):not(:has(.pwf-bgblur)) {
		filter: blur(var(--pwf-ent-blur, 0px));
	}

	html.pwf-js.pwf-entblur .pwf-entrance.sw-in:not(.pwf-bgblur):not(:has(.pwf-bgblur)) {
		filter: blur(0);
		transition:
			opacity var(--pwf-ent-dur) var(--pwf-ent-ease),
			transform var(--pwf-ent-dur) var(--pwf-ent-ease),
			filter var(--pwf-ent-dur) var(--pwf-ent-ease);
		transition-delay: calc((var(--pwf-ent-order, 1) - 1) * var(--pwf-ent-step));
	}

	html.pwf-js.pwf-entblur .pwf-entrance.sw-in.sw-settled:not(.pwf-bgblur):not(:has(.pwf-bgblur)) {
		transition-duration: 300ms;
		transition-delay: 0ms;
	}

	/* Frame-claimed elements resolve on their frame's own states. */
	html.pwf-js.pwf-entblur .pwf-reveal.is-end-revealed [data-pwf-frame] .pwf-entrance:not(.pwf-bgblur):not(:has(.pwf-bgblur)),
	html.pwf-js.pwf-entblur .pwf-hero.is-revealed [data-pwf-frame] .pwf-entrance:not(.pwf-bgblur):not(:has(.pwf-bgblur)) {
		filter: blur(0);
		transition:
			opacity var(--pwf-ent-dur) var(--pwf-ent-ease),
			transform var(--pwf-ent-dur) var(--pwf-ent-ease),
			filter var(--pwf-ent-dur) var(--pwf-ent-ease);
		transition-delay: calc((var(--pwf-ent-order, 1) - 1) * var(--pwf-ent-step));
	}

	html.pwf-js.pwf-entblur .pwf-reveal.is-end-unrevealing [data-pwf-frame] .pwf-entrance:not(.pwf-bgblur):not(:has(.pwf-bgblur)),
	html.pwf-js.pwf-entblur .pwf-hero.is-unrevealing [data-pwf-frame] .pwf-entrance:not(.pwf-bgblur):not(:has(.pwf-bgblur)) {
		transition: opacity 300ms ease, transform 300ms ease, filter 300ms ease;
		transition-delay: 0ms;
	}
}
