/*
 * CLEAR animated gradient backgrounds (theme 0.3.4).
 * Source: CLEAR Gradient Exploration (brand refresh, Aug 2026): eight directions built from the
 * existing palette. Colour sits on one edge or corner and dissolves into white, leaving a calm zone
 * for the heading. Only CLEAR colours are used, at low strength; no hard stops.
 *
 * Use: add ONE class to a Divi section or row (Advanced > Attributes > CSS Class):
 *   clear-gradient-daybreak    01 Soft radial from the lower left. Green into Light Blue.        Calm: upper right
 *   clear-gradient-current     02 Wide, shallow wave along the base. Blue, Light Blue, Green.    Calm: upper band
 *   clear-gradient-meridian    03 Gentle diagonal from the upper left. Dark Blue, Blue, Lt Blue. Calm: lower right
 *   clear-gradient-halo        04 Luminous bloom in the upper right. Purple into Blue.           Calm: left third
 *   clear-gradient-estuary     05 Two overlapping fields. Green and Light Blue.                  Calm: upper right
 *   clear-gradient-first-light 06 Accent. Yellow into white, a whisper of Green. Use sparingly.  Calm: upper left
 *   clear-gradient-drift       07 Three blurred forms along the lower edge.                      Calm: upper half
 *   clear-gradient-quiet       08 Barely there. Light Blue and Mid-Grey, for dense pages.        Calm: most of the field
 *
 * How it works: two pseudo-element layers (::before, ::after) sit behind the content inside the
 * element (isolation + z-index -1), so Divi modules, the element's own Divi background and editing
 * are untouched. Each layer drifts and breathes with transform and opacity only, which the browser
 * composites on the GPU: no repaint per frame, no JavaScript, no filters. Two animations per layer
 * with unrelated durations, all "alternate" with ease-in-out, so the motion never restarts or jumps.
 * Layer 1 (with the white base) drifts and swells; layer 2 drifts, swells and breathes (opacity).
 *
 * Global controls (set on :root, or on one element to tune that area only):
 *   --clear-gradient-duration   base cycle; layers run at 0.8x to 1.3x of it (default 60s)
 *   --clear-gradient-drift      how far a layer travels, % of its own size (default 3%)
 *   --clear-gradient-scale      how much a layer grows at its widest (default 1.06)
 *   --clear-gradient-breathe    lowest opacity of layer 2 in its breathing cycle (default 0.8)
 *   --clear-gradient-intensity  multiplies every colour's strength (default 1; tablet/phone 0.85)
 *
 * Accessibility: prefers-reduced-motion shows the same composition, static. The theme's script adds a
 * "Pause background motion" button to each gradient area (WCAG 2.2.2); its choice is remembered.
 * Forced-colours mode and print drop the layers. Text colours in the calm zone are unchanged.
 */

:root {
	--clear-gradient-duration: 60s;
	--clear-gradient-drift: 3%;
	--clear-gradient-scale: 1.06;
	--clear-gradient-breathe: 0.8;
	--clear-gradient-intensity: 1;
	--clear-gradient-base: #FFFFFF;

	/* CLEAR palette as RGB channels, so strength can be set per layer (values from clear-tokens.css). */
	--clear-rgb-dark-blue: 34 28 78;
	--clear-rgb-blue: 15 79 245;
	--clear-rgb-light-blue: 0 186 240;
	--clear-rgb-green: 0 209 181;
	--clear-rgb-purple: 97 41 255;
	--clear-rgb-yellow: 252 190 0;
	--clear-rgb-mid-grey: 199 209 217;
}

/* ---------- Shared behaviour ---------- */

:is(.clear-gradient-daybreak, .clear-gradient-current, .clear-gradient-meridian, .clear-gradient-halo, .clear-gradient-estuary, .clear-gradient-first-light, .clear-gradient-drift, .clear-gradient-quiet) {
	--i: var(--clear-gradient-intensity);
	position: relative;
	isolation: isolate;
	overflow: clip;
}

:is(.clear-gradient-daybreak, .clear-gradient-current, .clear-gradient-meridian, .clear-gradient-halo, .clear-gradient-estuary, .clear-gradient-first-light, .clear-gradient-drift, .clear-gradient-quiet)::before,
:is(.clear-gradient-daybreak, .clear-gradient-current, .clear-gradient-meridian, .clear-gradient-halo, .clear-gradient-estuary, .clear-gradient-first-light, .clear-gradient-drift, .clear-gradient-quiet)::after {
	content: "";
	position: absolute;
	inset: -12%; /* larger than the area, so drifting never shows an edge */
	z-index: -1;
	display: block;
	visibility: visible;
	width: auto;
	height: auto;
	pointer-events: none;
	transform-origin: var(--clear-g-origin, 50% 50%);
	will-change: translate, scale, opacity;
	animation-timing-function: ease-in-out;
	animation-iteration-count: infinite;
	animation-direction: alternate;
}

/*
 * Layer 1 carries the white base, so the calm zone is white whatever the element's own background.
 * It never fades (swell = scale only): fading it would let the Divi background underneath show through.
 */
:is(.clear-gradient-daybreak, .clear-gradient-current, .clear-gradient-meridian, .clear-gradient-halo, .clear-gradient-estuary, .clear-gradient-first-light, .clear-gradient-drift, .clear-gradient-quiet)::before {
	background: var(--clear-g1), var(--clear-gradient-base);
	animation-name: clear-gradient-drift, clear-gradient-swell;
	animation-duration: calc(var(--clear-gradient-duration) * 0.8), calc(var(--clear-gradient-duration) * 1.1);
	animation-delay: calc(var(--clear-gradient-duration) * -0.35), calc(var(--clear-gradient-duration) * -0.6);
	--dx: var(--clear-gradient-drift);
	--dy: calc(var(--clear-gradient-drift) * -0.6);
}

/* Layer 2 moves the other way at a different pace, so the shape changes as well as the position. */
:is(.clear-gradient-daybreak, .clear-gradient-current, .clear-gradient-meridian, .clear-gradient-halo, .clear-gradient-estuary, .clear-gradient-first-light, .clear-gradient-drift, .clear-gradient-quiet)::after {
	background: var(--clear-g2);
	animation-name: clear-gradient-drift, clear-gradient-breathe;
	animation-duration: var(--clear-gradient-duration), calc(var(--clear-gradient-duration) * 1.3);
	animation-delay: calc(var(--clear-gradient-duration) * -0.1), calc(var(--clear-gradient-duration) * -0.9);
	--dx: calc(var(--clear-gradient-drift) * -0.8);
	--dy: calc(var(--clear-gradient-drift) * 0.7);
}

@keyframes clear-gradient-drift {
	from { translate: 0 0; }
	to { translate: var(--dx) var(--dy); }
}

@keyframes clear-gradient-swell {
	from { scale: 1; }
	to { scale: var(--clear-gradient-scale); }
}

/* Layer 2 only (it has no base): changes the intensity as well as the size. */
@keyframes clear-gradient-breathe {
	from { scale: 1; opacity: 1; }
	to { scale: var(--clear-gradient-scale); opacity: var(--clear-gradient-breathe); }
}

/* ---------- The eight compositions (desktop) ---------- */
/*
 * Strengths are alpha over white; peaks stay at or below the brand "medium" tints (about 26-34%).
 * Sizes (0.3.8): blob radii are in vw with a px minimum, not % of the section. As a % of the section
 * height, blobs on short, wide heroes (e.g. 2000 x 370px intros) became thin streaks. The vw values
 * reproduce the approved Home hero at 1920px exactly; the px minimum keeps blobs full on phones.
 * (Chrome rejects max() mixing % with other units inside gradient sizes, so % is not used for radii.)
 * Positions stay in % of the layer, so colour keeps to its edge or corner on any height. The layer is
 * 24% larger than the area (inset -12%), so the area's bottom edge is at about 90% and its top at 10%:
 * edge blobs are anchored there, otherwise fixed-size blobs fall out of view on tall phone heroes.
 */

.clear-gradient-daybreak {
	--clear-g-origin: 0% 100%;
	--clear-g1: radial-gradient(ellipse max(590px, 77vw) max(360px, 35vw) at 6% 88%, rgb(var(--clear-rgb-green) / calc(0.34 * var(--i))), rgb(var(--clear-rgb-light-blue) / calc(0.14 * var(--i))) 46%, transparent 76%);
	--clear-g2: radial-gradient(ellipse max(440px, 57vw) max(260px, 23vw) at 22% 92%, rgb(var(--clear-rgb-light-blue) / calc(0.2 * var(--i))), transparent 72%);
}

.clear-gradient-current {
	--clear-g-origin: 50% 100%;
	--clear-g1: radial-gradient(ellipse max(670px, 87vw) max(240px, 17vw) at 30% 93%, rgb(var(--clear-rgb-blue) / calc(0.2 * var(--i))), rgb(var(--clear-rgb-light-blue) / calc(0.12 * var(--i))) 44%, transparent 74%);
	--clear-g2: radial-gradient(ellipse max(630px, 82vw) max(220px, 15vw) at 72% 93%, rgb(var(--clear-rgb-green) / calc(0.2 * var(--i))), rgb(var(--clear-rgb-light-blue) / calc(0.1 * var(--i))) 46%, transparent 76%);
}

.clear-gradient-meridian {
	--clear-g-origin: 0% 0%;
	--clear-g1: linear-gradient(152deg, rgb(var(--clear-rgb-dark-blue) / calc(0.4 * var(--i))) 8%, rgb(var(--clear-rgb-blue) / calc(0.24 * var(--i))) 26%, rgb(var(--clear-rgb-light-blue) / calc(0.1 * var(--i))) 46%, transparent 66%);
	--clear-g2: radial-gradient(ellipse max(475px, 62vw) max(150px, 20vw) at 10% 8%, rgb(var(--clear-rgb-blue) / calc(0.14 * var(--i))), transparent 72%);
}

.clear-gradient-halo {
	--clear-g-origin: 85% 15%;
	--clear-g1: radial-gradient(ellipse max(400px, 52vw) max(190px, 25vw) at 83% 17%, rgb(var(--clear-rgb-purple) / calc(0.22 * var(--i))), rgb(var(--clear-rgb-blue) / calc(0.1 * var(--i))) 48%, transparent 74%);
	--clear-g2: radial-gradient(ellipse max(345px, 45vw) max(160px, 21vw) at 96% 6%, rgb(var(--clear-rgb-light-blue) / calc(0.16 * var(--i))), transparent 72%);
}

.clear-gradient-estuary {
	--clear-g-origin: 20% 90%;
	--clear-g1: radial-gradient(ellipse max(380px, 46vw) max(260px, 20vw) at 12% 88%, rgb(var(--clear-rgb-green) / calc(0.28 * var(--i))), transparent 72%);
	--clear-g2: radial-gradient(ellipse max(420px, 52vw) max(240px, 18vw) at 38% 95%, rgb(var(--clear-rgb-light-blue) / calc(0.22 * var(--i))), transparent 72%);
}

.clear-gradient-first-light {
	--clear-g-origin: 90% 90%;
	--clear-g1: radial-gradient(ellipse max(380px, 50vw) max(300px, 21vw) at 90% 88%, rgb(var(--clear-rgb-yellow) / calc(0.3 * var(--i))), rgb(var(--clear-rgb-yellow) / calc(0.1 * var(--i))) 44%, transparent 72%);
	--clear-g2: radial-gradient(ellipse max(325px, 42vw) max(180px, 13vw) at 70% 94%, rgb(var(--clear-rgb-green) / calc(0.12 * var(--i))), transparent 72%);
}

.clear-gradient-drift {
	--clear-g-origin: 50% 90%;
	--clear-g1: radial-gradient(ellipse max(220px, 26vw) max(150px, 13vw) at 13% 80%, rgb(var(--clear-rgb-blue) / calc(0.2 * var(--i))), transparent 72%), radial-gradient(ellipse max(200px, 24vw) max(140px, 12vw) at 87% 76%, rgb(var(--clear-rgb-light-blue) / calc(0.2 * var(--i))), transparent 72%);
	--clear-g2: radial-gradient(ellipse max(220px, 26vw) max(140px, 12vw) at 50% 95%, rgb(var(--clear-rgb-green) / calc(0.18 * var(--i))), transparent 72%);
}

.clear-gradient-quiet {
	--clear-g-origin: 100% 100%;
	--clear-g1: radial-gradient(ellipse max(495px, 64vw) max(300px, 28vw) at 96% 88%, rgb(var(--clear-rgb-mid-grey) / calc(0.3 * var(--i))), transparent 72%);
	--clear-g2: radial-gradient(ellipse max(380px, 50vw) max(240px, 21vw) at 92% 92%, rgb(var(--clear-rgb-light-blue) / calc(0.1 * var(--i))), transparent 72%);
}
/*
 * Tablet and phone (Divi stacks columns at 980px): the heading then spans the full width, so the
 * colour is softened and compositions that sit high move to the lower edge, keeping the top calm.
 */
@media (max-width: 980px) {
	:root {
		--clear-gradient-intensity: 0.85;
	}

	.clear-gradient-meridian {
		--clear-g-origin: 100% 100%;
		--clear-g1: linear-gradient(332deg, rgb(var(--clear-rgb-dark-blue) / calc(0.3 * var(--i))) 6%, rgb(var(--clear-rgb-blue) / calc(0.2 * var(--i))) 22%, rgb(var(--clear-rgb-light-blue) / calc(0.08 * var(--i))) 40%, transparent 58%);
		--clear-g2: radial-gradient(ellipse 75vw 80vw at 90% 96%, rgb(var(--clear-rgb-blue) / calc(0.12 * var(--i))), transparent 72%);
	}

	.clear-gradient-halo {
		--clear-g-origin: 80% 80%;
		--clear-g1: radial-gradient(ellipse 88vw 90vw at 78% 80%, rgb(var(--clear-rgb-purple) / calc(0.2 * var(--i))), rgb(var(--clear-rgb-blue) / calc(0.09 * var(--i))) 48%, transparent 74%);
		--clear-g2: radial-gradient(ellipse 88vw 94vw at 96% 92%, rgb(var(--clear-rgb-light-blue) / calc(0.14 * var(--i))), transparent 72%);
	}
}

/* ---------- Pause control (added by clear-ui.js) ---------- */

.clear-motion-toggle {
	position: absolute;
	/*
	 * Top right of the area, aligned with the right edge of the 1240px content container (0.3.7). At the
	 * bottom it overlapped the last line of short intro heroes on phones. It is also the area's first
	 * element, so keyboard users reach the pause control before the moving content.
	 */
	right: max(var(--clear-gutter, 24px), calc((100% - var(--clear-container, 1240px)) / 2 + var(--clear-gutter, 24px)));
	top: 12px;
	z-index: 3;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 28px;
	padding: 4px 12px 4px 10px;
	border: 1px solid var(--clear-mid-grey);
	border-radius: var(--clear-radius-pill);
	background: rgb(255 255 255 / 0.82);
	color: var(--clear-text-muted);
	font: 700 12px/1.2 var(--clear-font-body);
	cursor: pointer;
}

.clear-motion-toggle:hover {
	color: var(--clear-text);
	border-color: var(--clear-border-field);
}

.clear-motion-toggle__icon {
	display: inline-block;
	width: 8px;
	height: 10px;
	border-left: 3px solid currentColor;
	border-right: 3px solid currentColor;
}

.clear-motion-toggle[data-paused="true"] .clear-motion-toggle__icon {
	width: 0;
	height: 0;
	border-top: 5px solid transparent;
	border-bottom: 5px solid transparent;
	border-left: 8px solid currentColor;
	border-right: 0;
}

/* Phones: icon only (32px target), so it stays clear of content such as the Home hero badge. The text remains the accessible name. */
@media (max-width: 767px) {
	.clear-motion-toggle {
		right: var(--clear-gutter, 20px);
		width: 32px;
		height: 32px;
		padding: 0;
		gap: 0;
		justify-content: center;
		border-radius: 50%;
	}

	.clear-motion-toggle__text {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}
}

/* ---------- Static states ---------- */

html.clear-motion-paused :is(.clear-gradient-daybreak, .clear-gradient-current, .clear-gradient-meridian, .clear-gradient-halo, .clear-gradient-estuary, .clear-gradient-first-light, .clear-gradient-drift, .clear-gradient-quiet)::before,
html.clear-motion-paused :is(.clear-gradient-daybreak, .clear-gradient-current, .clear-gradient-meridian, .clear-gradient-halo, .clear-gradient-estuary, .clear-gradient-first-light, .clear-gradient-drift, .clear-gradient-quiet)::after {
	animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
	:is(.clear-gradient-daybreak, .clear-gradient-current, .clear-gradient-meridian, .clear-gradient-halo, .clear-gradient-estuary, .clear-gradient-first-light, .clear-gradient-drift, .clear-gradient-quiet)::before,
	:is(.clear-gradient-daybreak, .clear-gradient-current, .clear-gradient-meridian, .clear-gradient-halo, .clear-gradient-estuary, .clear-gradient-first-light, .clear-gradient-drift, .clear-gradient-quiet)::after {
		animation: none;
		will-change: auto;
	}

	.clear-motion-toggle {
		display: none;
	}
}

@media (forced-colors: active), print {
	:is(.clear-gradient-daybreak, .clear-gradient-current, .clear-gradient-meridian, .clear-gradient-halo, .clear-gradient-estuary, .clear-gradient-first-light, .clear-gradient-drift, .clear-gradient-quiet)::before,
	:is(.clear-gradient-daybreak, .clear-gradient-current, .clear-gradient-meridian, .clear-gradient-halo, .clear-gradient-estuary, .clear-gradient-first-light, .clear-gradient-drift, .clear-gradient-quiet)::after {
		display: none;
	}

	.clear-motion-toggle {
		display: none;
	}
}
