/**
 * Smart Preload — Front-end Stylesheet
 *
 * Base structural styles only. Colours and sizes are injected via
 * wp_add_inline_style() from devlsmpr_build_inline_css() in renderer.php.
 */

/* ── Preloader container ──────────────────────────────────────────────────── */
#devlsmpr-preloader {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	/* Default background: overridden by inline CSS */
	background-color: #ffffff;
}

/* ── Inner wrapper ────────────────────────────────────────────────────────── */
.devlsmpr-preloader-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 18px;
	padding: 20px;
}

/* ── Logo ─────────────────────────────────────────────────────────────────── */
.devlsmpr-logo {
	display: flex;
	align-items: center;
	justify-content: center;
}

.devlsmpr-logo img {
	max-width: 200px;
	max-height: 90px;
	object-fit: contain;
	display: block;
}

/* ── Text ─────────────────────────────────────────────────────────────────── */
.devlsmpr-text {
	font-size: 15px;
	line-height: 1.5;
	text-align: center;
	color: #444;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
	             Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
	max-width: 280px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Animation 1 — Spinner (circular)
   ═══════════════════════════════════════════════════════════════════════════ */
.devlsmpr-spinner {
	/* Width/height set by inline CSS */
	width: 60px;
	height: 60px;
	border: 4px solid rgba(0, 0, 0, 0.1);
	border-radius: 50%;
	/* border-top-color set by inline CSS */
	border-top-color: #2563eb;
	box-sizing: border-box;
	animation: devlsmpr-rotate 0.75s linear infinite;
	will-change: transform;
}

@keyframes devlsmpr-rotate {
	to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Animation 2 — Pulsing dots
   ═══════════════════════════════════════════════════════════════════════════ */
.devlsmpr-dots {
	display: flex;
	align-items: center;
	gap: 8px;
}

.devlsmpr-dots span {
	/* Width/height/background set by inline CSS */
	width: 14px;
	height: 14px;
	background-color: #2563eb;
	border-radius: 50%;
	display: inline-block;
	animation: devlsmpr-pulse 1.3s ease-in-out infinite;
	will-change: transform, opacity;
}

.devlsmpr-dots span:nth-child(1) { animation-delay: 0s; }
.devlsmpr-dots span:nth-child(2) { animation-delay: 0.18s; }
.devlsmpr-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes devlsmpr-pulse {
	0%, 100% {
		transform: scale(0.55);
		opacity: 0.45;
	}
	45% {
		transform: scale(1);
		opacity: 1;
	}
}

/* ═══════════════════════════════════════════════════════════════════════════
   Animation 3 — Loading bar
   ═══════════════════════════════════════════════════════════════════════════ */
.devlsmpr-bar {
	/* Width/height set by inline CSS */
	width: 200px;
	height: 4px;
	background-color: rgba(0, 0, 0, 0.08);
	border-radius: 99px;
	overflow: hidden;
	position: relative;
}

.devlsmpr-bar-inner {
	/* Height and background set by inline CSS */
	position: absolute;
	top: 0;
	left: 0;
	height: 100%;
	width: 45%;
	background-color: #2563eb;
	border-radius: 99px;
	animation: devlsmpr-bar-travel 1.4s ease-in-out infinite;
	will-change: transform, width;
}

@keyframes devlsmpr-bar-travel {
	0% {
		transform: translateX(-100%);
		width: 45%;
	}
	50% {
		width: 65%;
	}
	100% {
		transform: translateX(260%);
		width: 35%;
	}
}

/* ═══════════════════════════════════════════════════════════════════════════
   Animation 4 — Minimal (single pulsing bar)
   ═══════════════════════════════════════════════════════════════════════════ */
.devlsmpr-minimal {
	/* Width set by inline CSS */
	width: 52px;
	height: 4px;
	position: relative;
}

.devlsmpr-minimal::before {
	content: '';
	position: absolute;
	inset: 0;
	/* Background set by inline CSS */
	background-color: #2563eb;
	border-radius: 99px;
	animation: devlsmpr-minimal-breathe 1.5s ease-in-out infinite;
	will-change: transform, opacity;
}

@keyframes devlsmpr-minimal-breathe {
	0%, 100% {
		transform: scaleX(0.3);
		opacity: 0.35;
	}
	50% {
		transform: scaleX(1);
		opacity: 1;
	}
}

/* ── Exit transitions ─────────────────────────────────────────────────────── */
/*
 * The same transition rules intentionally target both the real front-end
 * preloader and the admin preview overlay.
 *
 * Reveal effects use transform instead of clip-path for broader browser
 * compatibility and more predictable rendering.
 */
#devlsmpr-preloader.devlsmpr-is-exiting,
#devlsmpr-preview-overlay.devlsmpr-is-exiting {
	pointer-events: none;
	will-change: opacity, transform;
	transition-duration: var(--devlsmpr-exit-duration, 300ms);
	transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
	transition-property: opacity, transform;
	backface-visibility: hidden;
}

/* Fade */
#devlsmpr-preloader.devlsmpr-exit-fade,
#devlsmpr-preview-overlay.devlsmpr-exit-fade {
	opacity: 0;
}

/* Slide up */
#devlsmpr-preloader.devlsmpr-exit-slide-up,
#devlsmpr-preview-overlay.devlsmpr-exit-slide-up {
	transform: translate3d(0, -100%, 0);
}

/* Slide down */
#devlsmpr-preloader.devlsmpr-exit-slide-down,
#devlsmpr-preview-overlay.devlsmpr-exit-slide-down {
	transform: translate3d(0, 100%, 0);
}

/* Zoom out — deliberately stronger than 1.1.0 so the effect is visible. */
#devlsmpr-preloader.devlsmpr-exit-zoom-out,
#devlsmpr-preview-overlay.devlsmpr-exit-zoom-out {
	opacity: 0;
	transform: scale(0.82);
}

/* Reveal vertically from the centre. */
#devlsmpr-preloader.devlsmpr-exit-reveal-vertical,
#devlsmpr-preview-overlay.devlsmpr-exit-reveal-vertical {
	transform: scaleY(0);
	transform-origin: 50% 50%;
}

/* Reveal horizontally from the centre. */
#devlsmpr-preloader.devlsmpr-exit-reveal-horizontal,
#devlsmpr-preview-overlay.devlsmpr-exit-reveal-horizontal {
	transform: scaleX(0);
	transform-origin: 50% 50%;
}

/* ── Accessibility: respect reduced-motion preference ────────────────────────
   Users who have enabled "Reduce motion" in their OS/browser accessibility
   settings will not see spinning or bouncing animations.                    */
@media (prefers-reduced-motion: reduce) {
	#devlsmpr-preloader.devlsmpr-is-exiting,
	#devlsmpr-preview-overlay.devlsmpr-is-exiting {
		transition: none !important;
	}

	.devlsmpr-spinner {
		animation: none;
		border-top-color: currentColor;
		opacity: 0.6;
	}

	.devlsmpr-dots span {
		animation: none;
		opacity: 0.7;
	}

	.devlsmpr-bar-inner {
		animation: none;
		width: 60%;
		opacity: 0.7;
	}

	.devlsmpr-minimal::before {
		animation: none;
		transform: scaleX(1);
		opacity: 0.7;
	}
}
