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

/* ── Preloader container ──────────────────────────────────────────────────── */
#spc-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 ────────────────────────────────────────────────────────── */
.spc-preloader-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 18px;
	padding: 20px;
}

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

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

/* ── Text ─────────────────────────────────────────────────────────────────── */
.spc-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)
   ═══════════════════════════════════════════════════════════════════════════ */
.spc-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: spc-rotate 0.75s linear infinite;
	will-change: transform;
}

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

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

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

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

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

/* ═══════════════════════════════════════════════════════════════════════════
   Animation 3 — Loading bar
   ═══════════════════════════════════════════════════════════════════════════ */
.spc-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;
}

.spc-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: spc-bar-travel 1.4s ease-in-out infinite;
	will-change: transform, width;
}

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

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

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

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

/* ── Fade-out state ───────────────────────────────────────────────────────── */
/* The transition duration is applied inline by the JS controller. */
#spc-preloader.spc-fading {
	pointer-events: none;
}

/* ── 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) {
	.spc-spinner {
		animation: none;
		border-top-color: currentColor;
		opacity: 0.6;
	}

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

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

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