/**
 * "Brand gradient" style for the Group block (inc/brand-gradient.php).
 *
 * Replaces the stretched brand PNG with a CSS mesh: a base ramp that walks the
 * brand hues in oklch (no grey mid-tones), soft colour blobs that drift slowly
 * on top, and a film of noise to hide banding.
 *
 * The deeper colours (coral, pink, purple) sit where white text goes: the logo
 * on the left and the navigation on the right. The pale ones (turquoise, blue,
 * yellow) stay at the outer edges and in the gap between logo and navigation.
 */
.wp-block-group.is-style-aea-brand-gradient {
	--aea-g-turquoise: #52C3B9;
	--aea-g-blue: #57C8E6;
	--aea-g-yellow: #F8E094;
	/* Slightly deeper than the palette swatches so white text holds up. */
	--aea-g-coral: #EC8156;
	--aea-g-pink: #DD4FA4;
	--aea-g-purple: #9C74AB;

	--aea-g-noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

	--aea-g-base: linear-gradient(
		96deg,
		var(--aea-g-coral) 0%,
		var(--aea-g-pink) 30%,
		var(--aea-g-pink) 56%,
		var(--aea-g-purple) 86%,
		var(--aea-g-purple) 100%
	);

	/* Fallback for browsers without color-mix(): the ramp alone. */
	background-color: var(--aea-g-pink);
	background-image: var(--aea-g-base);
	color: #FFFFFF;
}

@supports (background: linear-gradient(in oklch, red, blue)) {
	.wp-block-group.is-style-aea-brand-gradient {
		--aea-g-base: linear-gradient(
			96deg in oklch,
			var(--aea-g-coral) 0%,
			var(--aea-g-pink) 30%,
			var(--aea-g-pink) 56%,
			var(--aea-g-purple) 86%,
			var(--aea-g-purple) 100%
		);
	}
}

@supports (color: color-mix(in srgb, red 50%, transparent)) {
	.wp-block-group.is-style-aea-brand-gradient {
		/* Layer order, top first: noise, yellow, blue, turquoise (left), turquoise (right), purple, base. */
		background-image:
			var(--aea-g-noise),
			radial-gradient(closest-side, color-mix(in srgb, var(--aea-g-yellow) 95%, transparent), color-mix(in srgb, var(--aea-g-yellow) 55%, transparent) 48%, transparent),
			radial-gradient(closest-side, color-mix(in srgb, var(--aea-g-blue) 95%, transparent), color-mix(in srgb, var(--aea-g-blue) 50%, transparent) 50%, transparent),
			radial-gradient(closest-side, var(--aea-g-turquoise), color-mix(in srgb, var(--aea-g-turquoise) 55%, transparent) 55%, transparent),
			radial-gradient(closest-side, var(--aea-g-turquoise), color-mix(in srgb, var(--aea-g-blue) 55%, transparent) 55%, transparent),
			radial-gradient(closest-side, color-mix(in srgb, var(--aea-g-purple) 80%, transparent), color-mix(in srgb, var(--aea-g-purple) 35%, transparent) 50%, transparent),
			var(--aea-g-base);
		background-repeat: repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
		/* Blobs are taller than the box, so a higher vertical % moves them up. */
		background-size: 180px 180px, 44% 240%, 46% 220%, 18% 260%, 20% 240%, 30% 220%, 100% 100%;
		background-position: 0 0, 27% 82%, 50% 4%, -13% 44%, 115% 79%, 79% 17%, 0 0;
		background-blend-mode: soft-light, normal, normal, normal, normal, normal, normal;
		animation: aea-brand-gradient-drift 28s ease-in-out infinite alternate;
	}
}

/* Each blob wanders within its own patch so the colours behind the text hold. */
@keyframes aea-brand-gradient-drift {
	0% {
		background-position: 0 0, 27% 82%, 50% 4%, -13% 44%, 115% 79%, 79% 17%, 0 0;
	}
	50% {
		background-position: 0 0, 33% 68%, 42% 16%, -11% 62%, 113% 60%, 85% 38%, 0 0;
	}
	100% {
		background-position: 0 0, 22% 92%, 58% -6%, -14% 30%, 117% 92%, 73% 4%, 0 0;
	}
}

/* Narrow screens: the logo and menu button reach the edges, so only the blue glow stays. */
@media (max-width: 781px) {
	.wp-block-group.is-style-aea-brand-gradient {
		background-size: 180px 180px, 0 0, 70% 220%, 0 0, 0 0, 50% 220%, 100% 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wp-block-group.is-style-aea-brand-gradient {
		animation: none;
	}
}
