/**
 * Global Screen-Blocking Loader Component
 *
 * Provides a universal, accessible, modal overlay loader that blocks all
 * interaction across the entire screen while asynchronous operations, forms,
 * or background processes run.
 *
 * @package WellnessDirectoryCore
 */

/* ==========================================================================
   Root Lock & Overlay Container
   ========================================================================== */

/* Prevent scrolling, touch movement, and user interaction on the page */
html.wd-loader-locked,
body.wd-loader-locked {
	overflow: hidden !important;
	touch-action: none !important;
	user-select: none !important;
	-webkit-user-select: none !important;
}

/* Base overlay: covers 100% of viewport at the highest z-index */
.wd-global-loader {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	width: 100vw;
	height: 100vh;
	z-index: 99999999; /* Highest priority above modals, menus, and admin bars */
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	box-sizing: border-box;
	background: rgba(10, 17, 32, 0.72);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
	            visibility 0.22s cubic-bezier(0.16, 1, 0.3, 1);
	cursor: wait;
	outline: none;
}

/* Active state: completely visible and absorbs ALL pointer & touch interactions */
.wd-global-loader.is-active {
	opacity: 1;
	visibility: visible;
	pointer-events: auto !important;
}

/* ==========================================================================
   Loader Card
   ========================================================================== */

.wd-global-loader__card {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	max-width: 420px;
	width: 100%;
	min-width: 280px;
	padding: 32px 28px;
	box-sizing: border-box;
	background: var(--wd-cream, #ffffff);
	border: 1px solid var(--wd-border, #dce6f2);
	border-radius: var(--wd-radius-lg, 16px);
	box-shadow: 0 24px 48px -12px rgba(10, 17, 32, 0.35),
	            0 0 0 1px rgba(255, 255, 255, 0.12);
	text-align: center;
	transform: scale(0.94) translateY(6px);
	opacity: 0;
	transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1),
	            opacity 0.24s ease;
	pointer-events: auto;
}

.wd-global-loader.is-active .wd-global-loader__card {
	transform: scale(1) translateY(0);
	opacity: 1;
}

/* ==========================================================================
   Orbital Dual Spinner
   ========================================================================== */

.wd-global-loader__spinner-wrap {
	position: relative;
	width: 56px;
	height: 56px;
	margin: 0 auto 18px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.wd-global-loader__spinner {
	width: 52px;
	height: 52px;
	border-radius: 50%;
	border: 3.5px solid var(--wd-surface, #e8f0fb);
	border-top-color: var(--wd-primary, #0066ff);
	border-right-color: var(--wd-primary-neon, #00c2ff);
	animation: wdLoaderSpin 0.85s cubic-bezier(0.4, 0, 0.2, 1) infinite;
	box-shadow: 0 0 16px rgba(0, 102, 255, 0.16);
}

.wd-global-loader__spinner-dot {
	position: absolute;
	width: 8px;
	height: 8px;
	background: var(--wd-primary, #0066ff);
	border-radius: 50%;
	box-shadow: 0 0 10px var(--wd-primary-neon, #00c2ff);
	animation: wdLoaderPulse 1.6s ease-in-out infinite;
}

@keyframes wdLoaderSpin {
	0% {
		transform: rotate(0deg);
	}
	100% {
		transform: rotate(360deg);
	}
}

@keyframes wdLoaderPulse {
	0%, 100% {
		transform: scale(0.8);
		opacity: 0.6;
	}
	50% {
		transform: scale(1.25);
		opacity: 1;
	}
}

/* ==========================================================================
   Typography & Content
   ========================================================================== */

.wd-global-loader__title {
	font-family: var(--wd-font, "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
	font-size: 1.125rem;
	font-weight: 600;
	line-height: 1.35;
	color: var(--wd-ink, #0a1120);
	margin: 0 0 8px 0;
	letter-spacing: -0.015em;
}

.wd-global-loader__message {
	font-family: var(--wd-font, "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
	font-size: 0.875rem;
	line-height: 1.5;
	color: var(--wd-text-muted, #5f7085);
	margin: 0;
	max-width: 320px;
}

/* Accessible Screen Reader announcement */
.wd-global-loader__sr-only {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

[data-theme="dark"] .wd-global-loader,
.dark .wd-global-loader {
	background: rgba(5, 9, 18, 0.82);
}

[data-theme="dark"] .wd-global-loader__card,
.dark .wd-global-loader__card {
	background: #111a2e;
	border-color: rgba(255, 255, 255, 0.12);
	box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.7),
	            0 0 0 1px rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .wd-global-loader__title,
.dark .wd-global-loader__title {
	color: #f6f9fd;
}

[data-theme="dark"] .wd-global-loader__message,
.dark .wd-global-loader__message {
	color: #9cb0c9;
}

[data-theme="dark"] .wd-global-loader__spinner,
.dark .wd-global-loader__spinner {
	border-color: rgba(255, 255, 255, 0.1);
	border-top-color: var(--wd-primary-neon, #00c2ff);
	border-right-color: var(--wd-primary, #0066ff);
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
	.wd-global-loader,
	.wd-global-loader__card {
		transition: none !important;
	}

	.wd-global-loader__spinner {
		animation-duration: 2s !important;
	}

	.wd-global-loader__spinner-dot {
		animation: none !important;
		opacity: 0.8 !important;
	}
}
