/* ============================================
   Preloader - Full-screen Loading Screen
   Domain: Preloader UI and Animations

   Features:
   - Full-screen overlay
   - Mascot mascot animation
   - Progress bar
   - Network status detection
   - Smooth fade-out
   ============================================ */

/* ===== CSS Variables (Local Scope) ===== */
:root {
	--preloader-bg: #0a0c10;
	--preloader-bg-gradient: linear-gradient(
		180deg,
		#0d1117 0%,
		#0a0c10 50%,
		#050608 100%
	);
	--preloader-accent: #4ab848;
	--preloader-accent-light: #6fd466;
	--preloader-accent-glow: rgba(74, 184, 72, 0.5);
	--preloader-text: rgba(255, 255, 255, 0.7);
	--preloader-text-muted: rgba(255, 255, 255, 0.4);
	--preloader-transition: 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ===== Preloader Container ===== */
.preloader {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	/* Opaque background to hide background content during load */
	background: rgba(10, 12, 16, 0.92);
	backdrop-filter: blur(20px) saturate(120%);
	-webkit-backdrop-filter: blur(20px) saturate(120%);
	opacity: 1;
	visibility: visible;
	transition:
		opacity var(--preloader-transition),
		visibility var(--preloader-transition),
		backdrop-filter var(--preloader-transition);
	/* Block all background interactions */
	pointer-events: all;
}

/* Prevent FOUC - Override inline visibility:hidden */
.preloader__particles,
.preloader__glow,
.preloader__logo,
.preloader__version,
.preloader__content,
.preloader__bottom {
	visibility: visible;
}

/* On load complete */
.preloader.loaded {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

/* Hide preloader when body has page-loaded class */
body.page-loaded .preloader {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

/* ===== Background Effects ===== */
.preloader__particles {
	position: absolute;
	inset: 0;
	overflow: hidden;
	pointer-events: none;
}

.preloader__particle {
	position: absolute;
	width: 4px;
	height: 4px;
	background: var(--preloader-accent);
	border-radius: 50%;
	opacity: 0.3;
	animation: preloader-particle-float 6s ease-in-out infinite;
}

@keyframes preloader-particle-float {
	0%,
	100% {
		transform: translateY(0) scale(1);
		opacity: 0.2;
	}
	50% {
		transform: translateY(-40px) scale(1.5);
		opacity: 0.5;
	}
}

/* Glow Orbs - Subtle atmospheric effects */
.preloader__glow {
	position: absolute;
	border-radius: 50%;
	filter: blur(80px);
	opacity: 0.25;
	animation: preloader-orb-pulse 4s ease-in-out infinite;
	pointer-events: none;
}

.preloader__glow--primary {
	width: 350px;
	height: 350px;
	background: radial-gradient(
		circle,
		var(--preloader-accent) 0%,
		transparent 70%
	);
	top: 30%;
	left: 50%;
	transform: translateX(-50%);
}

.preloader__glow--secondary {
	width: 200px;
	height: 200px;
	background: radial-gradient(circle, #ff6b35 0%, transparent 70%);
	bottom: 20%;
	right: 20%;
	animation-delay: -2s;
}

@keyframes preloader-orb-pulse {
	0%,
	100% {
		opacity: 0.2;
		transform: translateX(-50%) scale(1);
	}
	50% {
		opacity: 0.35;
		transform: translateX(-50%) scale(1.1);
	}
}

/* ===== Main Content Card ===== */
.preloader__content {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 24px;
	z-index: 10;
	position: relative;
	/* Content card styling */
	padding: 40px 50px;
	background: rgba(10, 12, 16, 0.65);
	border-radius: 24px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	backdrop-filter: blur(16px);
	-webkit-backdrop-filter: blur(16px);
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

/* ===== Mascot Container ===== */
.preloader__mascot {
	position: relative;
	width: 180px;
	height: 180px;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Mascot Ring Animation */
.preloader__mascot-ring {
	position: absolute;
	inset: -15px;
	border-radius: 50%;
	border: 2.5px solid transparent;
	border-top-color: var(--preloader-accent);
	border-right-color: var(--preloader-accent-glow);
	animation: preloader-ring-rotate 3s linear infinite;
	box-shadow: 0 0 25px var(--preloader-accent-glow);
}

.preloader__mascot-ring::before {
	content: "";
	position: absolute;
	inset: 8px;
	border-radius: 50%;
	border: 2px solid transparent;
	border-bottom-color: var(--preloader-accent);
	border-left-color: var(--preloader-accent-glow);
	animation: preloader-ring-rotate 2s linear infinite reverse;
}

@keyframes preloader-ring-rotate {
	0% {
		transform: rotate(0deg);
	}
	100% {
		transform: rotate(360deg);
	}
}

/* Mascot Image */
.preloader__mascot-img {
	width: 140px;
	height: auto;
	animation: preloader-mascot-float 3s ease-in-out infinite;
	filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.5))
		drop-shadow(0 0 20px var(--preloader-accent-glow));
	z-index: 2;
}

@keyframes preloader-mascot-float {
	0%,
	100% {
		transform: translateY(0) rotate(-2deg);
	}
	50% {
		transform: translateY(-12px) rotate(2deg);
	}
}

/* Mascot Shadow */
.preloader__mascot-shadow {
	position: absolute;
	bottom: 5px;
	width: 80px;
	height: 16px;
	background: radial-gradient(ellipse, rgba(0, 0, 0, 0.4) 0%, transparent 70%);
	animation: preloader-shadow-pulse 3s ease-in-out infinite;
}

@keyframes preloader-shadow-pulse {
	0%,
	100% {
		transform: scale(1);
		opacity: 0.4;
	}
	50% {
		transform: scale(0.8);
		opacity: 0.2;
	}
}

/* ===== Brand Section ===== */
.preloader__brand {
	text-align: center;
	margin-top: 8px;
}

.preloader__title {
	font-family: "Lexend Exa", sans-serif;
	font-size: 2.2rem;
	font-weight: 800;
	letter-spacing: 5px;
	color: white;
	text-shadow: 0 0 30px var(--preloader-accent-glow);
	margin: 0;
}

.preloader__title span {
	background: linear-gradient(
		135deg,
		var(--preloader-accent) 0%,
		var(--preloader-accent-light) 100%
	);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}

.preloader__subtitle {
	font-family: "Lexend Exa", sans-serif;
	font-size: 0.7rem;
	color: var(--preloader-text-muted);
	letter-spacing: 3px;
	margin-top: 8px;
	text-transform: uppercase;
}

/* ===== Progress Bar ===== */
.preloader__progress {
	width: 260px;
	margin-top: 16px;
}

.preloader__progress-bar {
	width: 100%;
	height: 5px;
	background: rgba(255, 255, 255, 0.1);
	border-radius: 3px;
	overflow: hidden;
	position: relative;
}

.preloader__progress-fill {
	height: 100%;
	width: 0%;
	background: linear-gradient(
		90deg,
		var(--preloader-accent),
		var(--preloader-accent-light),
		var(--preloader-accent)
	);
	background-size: 200% 100%;
	border-radius: 3px;
	animation: preloader-bar-shimmer 1s linear infinite;
	box-shadow: 0 0 12px var(--preloader-accent);
	transition: width 0.3s ease-out;
}

@keyframes preloader-bar-shimmer {
	0% {
		background-position: 200% 0;
	}
	100% {
		background-position: -200% 0;
	}
}

.preloader__progress-info {
	display: flex;
	justify-content: space-between;
	margin-top: 8px;
	font-family: "Lexend Exa", sans-serif;
	font-size: 0.65rem;
	color: var(--preloader-text-muted);
}

.preloader__progress-percent {
	color: var(--preloader-accent);
	font-weight: 700;
}

/* ===== Loading Message ===== */
.preloader__message {
	font-family: "Lexend Exa", sans-serif;
	font-size: 0.8rem;
	color: var(--preloader-text);
	margin-top: 12px;
	animation: preloader-message-fade 2.5s ease-in-out infinite;
}

@keyframes preloader-message-fade {
	0%,
	100% {
		opacity: 0.6;
	}
	50% {
		opacity: 1;
	}
}

/* ===== Bottom Section ===== */
.preloader__bottom {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 16px;
	padding-bottom: 24px;
}

/* ===== Trust Badges ===== */
.preloader__badges {
	display: flex;
	gap: 12px;
	flex-wrap: wrap;
	justify-content: center;
}

.preloader__badge {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 20px;
	background: linear-gradient(
		135deg,
		rgba(255, 255, 255, 0.08) 0%,
		rgba(255, 255, 255, 0.02) 100%
	);
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 30px;
	color: rgba(255, 255, 255, 0.8);
	font-family: "Lexend Exa", sans-serif;
	font-size: 0.65rem;
	font-weight: 500;
	letter-spacing: 1.5px;
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	transition: transform 0.3s, opacity 0.3s, box-shadow 0.3s, background-color 0.3s, filter 0.3s ease;
	animation: preloader-badge-appear 0.6s ease-out backwards;
}

.preloader__badge:nth-child(1) {
	animation-delay: 0.2s;
}
.preloader__badge:nth-child(2) {
	animation-delay: 0.4s;
}
.preloader__badge:nth-child(3) {
	animation-delay: 0.6s;
}

@keyframes preloader-badge-appear {
	from {
		opacity: 0;
		transform: translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.preloader__badge:hover {
	background: linear-gradient(
		135deg,
		rgba(74, 184, 72, 0.15) 0%,
		rgba(74, 184, 72, 0.05) 100%
	);
	border-color: rgba(74, 184, 72, 0.4);
	transform: translateY(-2px);
	box-shadow: 0 8px 20px rgba(74, 184, 72, 0.15);
}

.preloader__badge-icon {
	font-size: 0.9rem;
	color: var(--preloader-accent);
	filter: drop-shadow(0 0 4px var(--preloader-accent-glow));
}

.preloader__badge-dot {
	width: 8px;
	height: 8px;
	background: var(--preloader-accent);
	border-radius: 50%;
	animation: preloader-badge-pulse 2s ease-in-out infinite;
	box-shadow:
		0 0 10px var(--preloader-accent),
		0 0 20px var(--preloader-accent-glow);
}

@keyframes preloader-badge-pulse {
	0%,
	100% {
		opacity: 1;
		transform: scale(1);
	}
	50% {
		opacity: 0.6;
		transform: scale(0.8);
	}
}

/* ===== Loading Dots ===== */
.preloader__dots {
	display: flex;
	gap: 8px;
	margin-top: 8px;
}

.preloader__dot {
	width: 8px;
	height: 8px;
	background: var(--preloader-accent);
	border-radius: 50%;
	animation: preloader-dot-bounce 1.4s ease-in-out infinite;
}

.preloader__dot:nth-child(1) {
	animation-delay: 0s;
}
.preloader__dot:nth-child(2) {
	animation-delay: 0.2s;
}
.preloader__dot:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes preloader-dot-bounce {
	0%,
	80%,
	100% {
		transform: scale(0.6);
		opacity: 0.4;
	}
	40% {
		transform: scale(1);
		opacity: 1;
		box-shadow: 0 0 12px var(--preloader-accent);
	}
}

/* ===== Bottom Slogan ===== */
.preloader__slogan {
	font-family: "Lexend Exa", sans-serif;
	font-size: 0.6rem;
	color: rgba(255, 255, 255, 0.35);
	letter-spacing: 4px;
	text-transform: uppercase;
}

.preloader__slogan span {
	color: var(--preloader-accent);
	opacity: 0.6;
}

/* ===== Bottom Line Decoration ===== */
.preloader__bottom-line {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	height: 2px;
	background: linear-gradient(
		90deg,
		transparent 0%,
		var(--preloader-accent) 50%,
		transparent 100%
	);
	background-size: 200% 100%;
	animation: preloader-line-shimmer 2s linear infinite;
	opacity: 0.6;
}

@keyframes preloader-line-shimmer {
	0% {
		background-position: -200% 0;
	}
	100% {
		background-position: 200% 0;
	}
}

/* ===== Top Logo ===== */
.preloader__logo {
	position: absolute;
	top: 24px;
	left: 24px;
}

.preloader__logo img {
	height: 36px;
	width: auto;
	filter: drop-shadow(0 0 10px var(--preloader-accent-glow));
}

/* ===== Version Badge ===== */
.preloader__version {
	position: absolute;
	top: 28px;
	right: 28px;
	font-family: "Lexend Exa", sans-serif;
	font-size: 0.55rem;
	color: rgba(255, 255, 255, 0.2);
	letter-spacing: 2px;
}

/* ===== Responsive Design ===== */

/* Tablet Optimization */
@media (max-width: 599px) {
	.preloader__content {
		padding: 32px 40px;
		gap: 20px;
	}

	.preloader__mascot {
		width: 160px;
		height: 160px;
	}

	.preloader__mascot-img {
		width: 120px;
	}

	.preloader__title {
		font-size: 2rem;
		letter-spacing: 4px;
	}

	.preloader__progress {
		width: 240px;
	}

	.preloader__bottom {
		bottom: 0;
		padding-bottom: 20px;
		gap: 12px;
	}

	.preloader__badges {
		gap: 8px;
		padding: 0 20px;
	}

	.preloader__badge {
		padding: 8px 14px;
		font-size: 0.55rem;
	}

	.preloader__slogan {
		font-size: 0.55rem;
		letter-spacing: 3px;
	}
}

/* Mobile Optimization */
@media (max-width: 599px) {
	.preloader__content {
		padding: 28px 32px;
		gap: 18px;
		border-radius: 20px;
	}

	.preloader__mascot {
		width: 140px;
		height: 140px;
	}

	.preloader__mascot-ring {
		inset: -12px;
	}

	.preloader__mascot-img {
		width: 100px;
	}

	.preloader__title {
		font-size: 1.6rem;
		letter-spacing: 3px;
	}

	.preloader__subtitle {
		font-size: 0.6rem;
		letter-spacing: 2px;
	}

	.preloader__progress {
		width: 200px;
	}

	.preloader__progress-info {
		font-size: 0.6rem;
	}

	.preloader__message {
		font-size: 0.7rem;
	}

	.preloader__bottom {
		bottom: 0;
		padding-bottom: 16px;
		gap: 8px;
	}

	/* Layout: Center-aligned compact badges */
	.preloader__badges {
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: center;
		gap: 6px;
		padding: 0 16px;
	}

	.preloader__badge {
		padding: 6px 10px;
		font-size: 0.45rem;
		gap: 5px;
		border-radius: 16px;
	}

	.preloader__badge-icon {
		font-size: 0.6rem;
	}

	.preloader__badge-dot {
		width: 5px;
		height: 5px;
	}

	.preloader__dots {
		gap: 6px;
	}

	.preloader__dot {
		width: 6px;
		height: 6px;
	}

	.preloader__slogan {
		font-size: 0.5rem;
		letter-spacing: 2px;
	}

	.preloader__logo {
		top: 16px;
		left: 16px;
	}

	.preloader__logo img {
		height: 28px;
	}

	.preloader__version {
		top: 20px;
		right: 16px;
		font-size: 0.5rem;
	}
}

/* Small Device Optimization */
@media (max-width: 375px) {
	.preloader__content {
		padding: 24px 24px;
		gap: 16px;
		margin: 0 16px;
	}

	.preloader__mascot {
		width: 120px;
		height: 120px;
	}

	.preloader__mascot-img {
		width: 85px;
	}

	.preloader__title {
		font-size: 1.4rem;
		letter-spacing: 2px;
	}

	.preloader__progress {
		width: 180px;
	}

	/* Bottom layout: Extremely compact */
	.preloader__bottom {
		bottom: 0;
		gap: 6px;
		padding-bottom: 12px;
	}

	/* Single row compact layout */
	.preloader__badges {
		flex-direction: row;
		gap: 4px;
		padding: 0 8px;
	}

	.preloader__badge {
		padding: 5px 8px;
		font-size: 0.4rem;
		letter-spacing: 0.5px;
		gap: 4px;
		border-radius: 12px;
	}

	.preloader__badge-icon {
		font-size: 0.55rem;
	}

	.preloader__badge-dot {
		width: 4px;
		height: 4px;
	}

	/* Smaller dots */
	.preloader__dots {
		gap: 4px;
		margin-top: 2px;
	}

	.preloader__dot {
		width: 4px;
		height: 4px;
	}

	.preloader__slogan {
		font-size: 0.4rem;
		letter-spacing: 1.5px;
	}

	.preloader__glow--primary {
		width: 250px;
		height: 250px;
	}

	.preloader__glow--secondary {
		width: 150px;
		height: 150px;
	}
}

/* Height-based adjustments */
@media (max-height: 700px) {
	.preloader__bottom {
		bottom: 0;
		gap: 6px;
		padding-bottom: 12px;
	}

	.preloader__badge {
		padding: 5px 10px;
		font-size: 0.45rem;
	}

	.preloader__dots {
		margin-top: 2px;
	}
}

@media (max-height: 600px) {
	.preloader__content {
		padding: 16px 24px;
		gap: 12px;
	}

	.preloader__mascot {
		width: 80px;
		height: 80px;
	}

	.preloader__mascot-img {
		width: 60px;
	}

	.preloader__title {
		font-size: 1.2rem;
	}

	.preloader__bottom {
		bottom: 0;
		gap: 4px;
		padding-bottom: 8px;
	}

	.preloader__badge {
		padding: 4px 8px;
		font-size: 0.4rem;
	}

	.preloader__slogan {
		font-size: 0.4rem;
	}
}

/* ===== Slow Network Indicator ===== */
.preloader--slow .preloader__message::after {
	content: " (Slow connection detected)";
	color: #ff9500;
}

/* ===== Reduced Motion Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
	.preloader__particle,
	.preloader__glow,
	.preloader__mascot-ring,
	.preloader__mascot-img,
	.preloader__mascot-shadow,
	.preloader__progress-fill,
	.preloader__message,
	.preloader__badge-dot {
		animation: none;
	}

	.preloader__mascot-ring {
		border-color: var(--preloader-accent);
	}
}

/* ==================================================
 * Mobile Performance Optimization (<600px)
 * Disable heavy decorative animations
 * ================================================== */
@media (max-width: 599px) {
	/* Hide secondary visual effects */
	.preloader__particle,
	.preloader__glow,
	.preloader__mascot-shadow {
		display: none;
	}

	/* Disable complex ring rotations */
	.preloader__mascot-ring,
	.preloader__mascot-ring::before {
		animation: none;
		border-color: var(--preloader-accent);
	}

	/* Stop mascot floating */
	.preloader__mascot-img {
		animation: none;
	}

	/* Disable dot bouncing */
	.preloader__dot {
		animation: none;
	}

	/* Disable bottom shimmer line */
	.preloader__bottom-line {
		animation: none;
	}
}
