/* ============================================================
   AAFE Advanced Backgrounds & Floating Effects - CSS
   ============================================================ */

/* ─── Base Container Stacking ────────────────────────────── */
[data-aafe-bg]:not([data-aafe-bg="none"]) {
	position: relative !important;
	overflow: hidden;
}

/* Background overlay items always sit behind content */
.aafe-bg-overlay-item,
.aafe-bg-canvas,
.aafe-bg-wave,
.aafe-bg-noise,
.aafe-bg-gradient,
.aafe-bg-particles-canvas {
	position: absolute !important;
	inset: 0 !important;
	width: 100% !important;
	height: 100% !important;
	pointer-events: none !important;
	z-index: 0 !important;
}

/* Ensure inner content sits securely above the background effects */
[data-aafe-bg]:not([data-aafe-bg="none"]) > .elementor-container,
[data-aafe-bg]:not([data-aafe-bg="none"]) > .elementor-widget-container,
[data-aafe-bg]:not([data-aafe-bg="none"]) > .elementor-widget-wrap,
[data-aafe-bg]:not([data-aafe-bg="none"]) > .e-con-inner,
[data-aafe-bg]:not([data-aafe-bg="none"]) > .elementor-element:not(.elementor-absolute):not(.elementor-fixed),
[data-aafe-bg]:not([data-aafe-bg="none"]) > :not(.aafe-bg-overlay-item):not(.aafe-bg-wave):not(.aafe-bg-noise):not(.aafe-bg-gradient):not(.aafe-bg-particles-canvas) {
	position: relative;
	z-index: 1;
}

/* ─── 1. Particles Canvas ────────────────────────────────── */
.aafe-bg-particles-canvas {
	display: block;
	max-width: 100%;
}

/* ─── 2. Flowing SVG Waves ───────────────────────────────── */
.aafe-bg-wave {
	height: auto !important;
	top: auto !important;
	bottom: 0 !important;
	inset: auto 0 0 0 !important;
	display: flex;
	align-items: flex-end;
	overflow: hidden;
	line-height: 0;
}

.aafe-bg-wave--top {
	top: 0 !important;
	bottom: auto !important;
	inset: 0 0 auto 0 !important;
	align-items: flex-start;
	transform: scaleY(-1);
}

.aafe-wave-svg {
	position: relative;
	width: 100%;
	height: var(--aafe-wave-height, 100px);
	min-height: 40px;
	display: block;
}

/* Multi-layer gentle wave parallax flow */
.aafe-wave-parallax > use {
	animation: aafe-wave-flow 25s cubic-bezier(0.55, 0.5, 0.45, 0.5) infinite;
}

.aafe-wave-parallax > use:nth-child(1) {
	animation-delay: -2s;
	animation-duration: 7s;
	opacity: 0.3;
}

.aafe-wave-parallax > use:nth-child(2) {
	animation-delay: -3s;
	animation-duration: 10s;
	opacity: 0.5;
}

.aafe-wave-parallax > use:nth-child(3) {
	animation-delay: -4s;
	animation-duration: 14s;
	opacity: 0.7;
}

.aafe-wave-parallax > use:nth-child(4) {
	animation-delay: -5s;
	animation-duration: 20s;
	opacity: 1;
}

.aafe-bg-wave--static .aafe-wave-parallax > use {
	animation: none !important;
}

@keyframes aafe-wave-flow {
	0%   { transform: translate3d(-90px, 0, 0); }
	100% { transform: translate3d(85px, 0, 0); }
}

/* ─── 3. Animated Gradient Background ───────────────────── */
.aafe-bg-gradient {
	position: absolute !important;
	inset: 0 !important;
	width: 100% !important;
	height: 100% !important;
	background-size: 300% 300% !important;
	background-position: 0% 50%;
	animation: aafe-gradient-shift var(--aafe-gradient-speed, 8s) ease infinite !important;
	pointer-events: none !important;
	z-index: 0 !important;
}

@keyframes aafe-gradient-shift {
	0%   { background-position: 0% 50%; }
	50%  { background-position: 100% 50%; }
	100% { background-position: 0% 50%; }
}

/* ─── 4. Noise / Grain Overlay ───────────────────────────── */
.aafe-bg-noise {
	position: absolute !important;
	inset: 0 !important;
	width: 100% !important;
	height: 100% !important;
	background-color: transparent !important;
	background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='aafeNoise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  2.5 0 0 -1.2 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23aafeNoise)'/%3E%3C/svg%3E");
	background-repeat: repeat !important;
	background-size: var(--aafe-noise-size, 120px) var(--aafe-noise-size, 120px) !important;
	opacity: var(--aafe-noise-opacity, 0.15) !important;
	pointer-events: none !important;
	z-index: 0 !important;
}

/* ─── 5. Floating Effects ────────────────────────────────── */

/* 1. Up & Down */
.elementor-widget.aafe-floating-yes.aafe-float-dir-up-down > .elementor-widget-container,
.elementor-widget.aafe-floating-yes.aafe-float-dir-up-down:not(:has(> .elementor-widget-container)) > *,
.elementor-column.aafe-floating-yes.aafe-float-dir-up-down > .elementor-widget-wrap,
.elementor-section.aafe-floating-yes.aafe-float-dir-up-down > .elementor-container,
.e-con.aafe-floating-yes.aafe-float-dir-up-down > .e-con-inner,
.e-con.aafe-floating-yes.aafe-float-dir-up-down:not(:has(> .e-con-inner)) {
	animation: aafe-float-updown var(--aafe-float-duration, 3s) ease-in-out var(--aafe-float-delay, 0s) infinite alternate;
}

@keyframes aafe-float-updown {
	from { transform: translateY(0); }
	to   { transform: translateY(calc(var(--aafe-float-distance, 15px) * -1)); }
}

/* 2. Left & Right */
.elementor-widget.aafe-floating-yes.aafe-float-dir-left-right > .elementor-widget-container,
.elementor-widget.aafe-floating-yes.aafe-float-dir-left-right:not(:has(> .elementor-widget-container)) > *,
.elementor-column.aafe-floating-yes.aafe-float-dir-left-right > .elementor-widget-wrap,
.elementor-section.aafe-floating-yes.aafe-float-dir-left-right > .elementor-container,
.e-con.aafe-floating-yes.aafe-float-dir-left-right > .e-con-inner,
.e-con.aafe-floating-yes.aafe-float-dir-left-right:not(:has(> .e-con-inner)) {
	animation: aafe-float-lr var(--aafe-float-duration, 3s) ease-in-out var(--aafe-float-delay, 0s) infinite alternate;
}

@keyframes aafe-float-lr {
	from { transform: translateX(0); }
	to   { transform: translateX(var(--aafe-float-distance, 15px)); }
}

/* 3. Rotate */
.elementor-widget.aafe-floating-yes.aafe-float-dir-rotate > .elementor-widget-container,
.elementor-widget.aafe-floating-yes.aafe-float-dir-rotate:not(:has(> .elementor-widget-container)) > *,
.elementor-column.aafe-floating-yes.aafe-float-dir-rotate > .elementor-widget-wrap,
.elementor-section.aafe-floating-yes.aafe-float-dir-rotate > .elementor-container,
.e-con.aafe-floating-yes.aafe-float-dir-rotate > .e-con-inner,
.e-con.aafe-floating-yes.aafe-float-dir-rotate:not(:has(> .e-con-inner)) {
	animation: aafe-float-rotate var(--aafe-float-duration, 3s) linear var(--aafe-float-delay, 0s) infinite;
}

@keyframes aafe-float-rotate {
	from { transform: rotate(0deg); }
	to   { transform: rotate(360deg); }
}

/* 4. Pulse / Scale */
.elementor-widget.aafe-floating-yes.aafe-float-dir-pulse > .elementor-widget-container,
.elementor-widget.aafe-floating-yes.aafe-float-dir-pulse:not(:has(> .elementor-widget-container)) > *,
.elementor-column.aafe-floating-yes.aafe-float-dir-pulse > .elementor-widget-wrap,
.elementor-section.aafe-floating-yes.aafe-float-dir-pulse > .elementor-container,
.e-con.aafe-floating-yes.aafe-float-dir-pulse > .e-con-inner,
.e-con.aafe-floating-yes.aafe-float-dir-pulse:not(:has(> .e-con-inner)) {
	animation: aafe-float-pulse var(--aafe-float-duration, 3s) ease-in-out var(--aafe-float-delay, 0s) infinite alternate;
}

@keyframes aafe-float-pulse {
	from { transform: scale(1); }
	to   { transform: scale(calc(1 + (var(--aafe-float-distance, 15px) / 150))); }
}

/* 5. Shake */
.elementor-widget.aafe-floating-yes.aafe-float-dir-shake > .elementor-widget-container,
.elementor-widget.aafe-floating-yes.aafe-float-dir-shake:not(:has(> .elementor-widget-container)) > *,
.elementor-column.aafe-floating-yes.aafe-float-dir-shake > .elementor-widget-wrap,
.elementor-section.aafe-floating-yes.aafe-float-dir-shake > .elementor-container,
.e-con.aafe-floating-yes.aafe-float-dir-shake > .e-con-inner,
.e-con.aafe-floating-yes.aafe-float-dir-shake:not(:has(> .e-con-inner)) {
	animation: aafe-float-shake var(--aafe-float-duration, 0.5s) ease-in-out var(--aafe-float-delay, 0s) infinite;
}

@keyframes aafe-float-shake {
	0%, 100% { transform: translateX(0); }
	20%       { transform: translateX(calc(var(--aafe-float-distance, 15px) * -0.35)); }
	40%       { transform: translateX(calc(var(--aafe-float-distance, 15px) * 0.35)); }
	60%       { transform: translateX(calc(var(--aafe-float-distance, 15px) * -0.2)); }
	80%       { transform: translateX(calc(var(--aafe-float-distance, 15px) * 0.2)); }
}

/* Respect prefers-reduced-motion accessibility */
@media (prefers-reduced-motion: reduce) {
	.aafe-floating-yes > *,
	.aafe-wave-parallax > use,
	.aafe-bg-gradient {
		animation: none !important;
	}
}
