/* =============================================
   LOADER
   ============================================= */

/* --- Overlay --- */
.loader-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: linear-gradient(135deg, #1a0533 0%, #2d1155 30%, #4a1a7a 60%, #1a0533 100%);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	z-index: 99999;
	transition: opacity 0.6s ease, visibility 0.6s ease;
	overflow: hidden;
}

.loader-overlay.hidden {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

/* --- Grid background --- */
.loader-grid {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-image:
		linear-gradient(rgba(168, 85, 247, 0.06) 1px, transparent 1px),
		linear-gradient(90deg, rgba(168, 85, 247, 0.06) 1px, transparent 1px);
	background-size: 60px 60px;
	animation: gridMove 4s linear infinite;
}

@keyframes gridMove {
	0% { transform: translate(0, 0); }
	100% { transform: translate(60px, 60px); }
}

/* --- Particles --- */
.loader-particles {
	position: absolute;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

.particle {
	position: absolute;
	width: 2px;
	height: 2px;
	background: rgba(168, 85, 247, 0.6);
	border-radius: 50%;
	animation: floatUp linear infinite;
}

.particle:nth-child(1) { left: 10%; animation-duration: 6s; animation-delay: 0s; }
.particle:nth-child(2) { left: 20%; animation-duration: 8s; animation-delay: 1s; width: 3px; height: 3px; }
.particle:nth-child(3) { left: 35%; animation-duration: 7s; animation-delay: 2s; }
.particle:nth-child(4) { left: 50%; animation-duration: 9s; animation-delay: 0.5s; width: 3px; height: 3px; }
.particle:nth-child(5) { left: 65%; animation-duration: 6.5s; animation-delay: 1.5s; }
.particle:nth-child(6) { left: 75%; animation-duration: 8.5s; animation-delay: 3s; width: 4px; height: 4px; background: rgba(139, 92, 246, 0.4); }
.particle:nth-child(7) { left: 85%; animation-duration: 7.5s; animation-delay: 2.5s; }
.particle:nth-child(8) { left: 45%; animation-duration: 10s; animation-delay: 0s; }

@keyframes floatUp {
	0% { transform: translateY(100vh) scale(0); opacity: 0; }
	10% { opacity: 1; }
	90% { opacity: 1; }
	100% { transform: translateY(-10vh) scale(1); opacity: 0; }
}

/* --- Robot icon --- */
.loader-robot {
	position: relative;
	width: 80px;
	height: 80px;
	margin-bottom: 40px;
	z-index: 2;
}

.robot-head {
	width: 80px;
	height: 60px;
	border: 2px solid rgba(168, 85, 247, 0.8);
	border-radius: 20px 20px 16px 16px;
	position: relative;
	animation: robotFloat 3s ease-in-out infinite;
	background: rgba(168, 85, 247, 0.05);
	box-shadow:
		0 0 20px rgba(168, 85, 247, 0.2),
		inset 0 0 20px rgba(168, 85, 247, 0.05);
}

.robot-eye {
	position: absolute;
	width: 10px;
	height: 10px;
	border: 2px solid #a855f7;
	border-radius: 50%;
	top: 20px;
	animation: eyeBlink 4s ease-in-out infinite;
}

.robot-eye.left { left: 18px; }
.robot-eye.right { right: 18px; }

.robot-eye::after {
	content: '';
	position: absolute;
	width: 4px;
	height: 4px;
	background: #a855f7;
	border-radius: 50%;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	box-shadow: 0 0 6px #a855f7;
}

.robot-antenna {
	position: absolute;
	top: -15px;
	left: 50%;
	transform: translateX(-50%);
	width: 2px;
	height: 15px;
	background: rgba(168, 85, 247, 0.6);
}

.robot-antenna::after {
	content: '';
	position: absolute;
	top: -4px;
	left: 50%;
	transform: translateX(-50%);
	width: 8px;
	height: 8px;
	background: #a855f7;
	border-radius: 50%;
	box-shadow: 0 0 10px #a855f7, 0 0 20px rgba(168, 85, 247, 0.4);
	animation: antennaPulse 2s ease-in-out infinite;
}

.robot-mouth {
	position: absolute;
	bottom: 10px;
	left: 50%;
	transform: translateX(-50%);
	width: 20px;
	height: 2px;
	background: rgba(168, 85, 247, 0.5);
	border-radius: 2px;
}

.robot-neck {
	width: 20px;
	height: 10px;
	border-left: 2px solid rgba(168, 85, 247, 0.5);
	border-right: 2px solid rgba(168, 85, 247, 0.5);
	margin: 0 auto;
}

@keyframes robotFloat {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-8px); }
}

@keyframes eyeBlink {
	0%, 42%, 46%, 100% { transform: scaleY(1); }
	44% { transform: scaleY(0.1); }
}

@keyframes antennaPulse {
	0%, 100% { box-shadow: 0 0 10px #a855f7, 0 0 20px rgba(168, 85, 247, 0.4); }
	50% { box-shadow: 0 0 15px #a855f7, 0 0 35px rgba(168, 85, 247, 0.6); }
}

/* --- Progress bar --- */
.loader-progress-container {
	position: relative;
	width: 280px;
	z-index: 2;
	margin-bottom: 20px;
}

.loader-progress-track {
	width: 100%;
	height: 3px;
	background: rgba(168, 85, 247, 0.15);
	border-radius: 3px;
	overflow: hidden;
	position: relative;
}

.loader-progress-bar {
	height: 100%;
	width: 0%;
	background: linear-gradient(90deg, #7c3aed, #a855f7, #c084fc);
	border-radius: 3px;
	transition: width 0.3s ease;
	position: relative;
	box-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
}

.loader-progress-glow {
	position: absolute;
	top: -2px;
	right: -1px;
	width: 20px;
	height: 7px;
	background: radial-gradient(circle, rgba(168, 85, 247, 0.8) 0%, transparent 70%);
	border-radius: 50%;
}

/* --- Text --- */
.loader-percentage {
	font-family: 'Courier New', monospace;
	font-size: 14px;
	color: rgba(168, 85, 247, 0.9);
	text-align: center;
	margin-top: 16px;
	letter-spacing: 4px;
	font-weight: 300;
	z-index: 2;
}

.loader-text {
	font-family: 'Inter', 'Segoe UI', sans-serif;
	font-size: 11px;
	color: rgba(255, 255, 255, 0.35);
	text-transform: uppercase;
	letter-spacing: 6px;
	margin-top: 8px;
	z-index: 2;
}

/* --- Scanlines --- */
.loader-scanlines {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: repeating-linear-gradient(
		0deg,
		transparent,
		transparent 2px,
		rgba(0, 0, 0, 0.03) 2px,
		rgba(0, 0, 0, 0.03) 4px
	);
	pointer-events: none;
	z-index: 1;
}

/* --- Corner decorations --- */
.loader-corner {
	position: absolute;
	width: 30px;
	height: 30px;
	z-index: 2;
}

.loader-corner::before,
.loader-corner::after {
	content: '';
	position: absolute;
	background: rgba(168, 85, 247, 0.3);
}

.loader-corner.tl { top: 30px; left: 30px; }
.loader-corner.tl::before { top: 0; left: 0; width: 30px; height: 1px; }
.loader-corner.tl::after { top: 0; left: 0; width: 1px; height: 30px; }

.loader-corner.tr { top: 30px; right: 30px; }
.loader-corner.tr::before { top: 0; right: 0; width: 30px; height: 1px; }
.loader-corner.tr::after { top: 0; right: 0; width: 1px; height: 30px; }

.loader-corner.bl { bottom: 30px; left: 30px; }
.loader-corner.bl::before { bottom: 0; left: 0; width: 30px; height: 1px; }
.loader-corner.bl::after { bottom: 0; left: 0; width: 1px; height: 30px; }

.loader-corner.br { bottom: 30px; right: 30px; }
.loader-corner.br::before { bottom: 0; right: 0; width: 30px; height: 1px; }
.loader-corner.br::after { bottom: 0; right: 0; width: 1px; height: 30px; }

/* --- Side lines --- */
.loader-side-line {
	position: absolute;
	background: rgba(168, 85, 247, 0.1);
	z-index: 1;
}

.loader-side-line.left {
	left: 30px;
	top: 50%;
	transform: translateY(-50%);
	width: 1px;
	height: 200px;
}

.loader-side-line.right {
	right: 30px;
	top: 50%;
	transform: translateY(-50%);
	width: 1px;
	height: 200px;
}

/* --- Content visibility --- */
.content-hidden {
	opacity: 0;
	visibility: hidden;
}

.content-visible {
	opacity: 1;
	visibility: visible;
	transition: opacity 0.5s ease 0.3s;
}
