/* =====================================================================
   Rack Loader — servers sliding into a rack, looping
   Shown on first paint; also reusable via [data-fr-loader]
   ===================================================================== */

.fr-loader {
	position: fixed;
	inset: 0;
	z-index: 999;
	display: grid;
	place-items: center;
	background: var(--ink);
	transition: opacity .5s var(--ease), visibility .5s var(--ease);
}
.fr-loader.is-done {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

/* ---------- Stage ---------- */
.fr-loader__stage {
	position: relative;
	width: 220px;
	height: 260px;
}

/* ---------- Rack ---------- */
.fr-loader__rack {
	position: absolute;
	inset: 0 0 auto 0;
	height: 100%;
	border: 2px solid var(--line);
	border-radius: 12px;
	background: linear-gradient(180deg, #0b0f15, #11171f);
	padding: 10px;
	display: flex;
	flex-direction: column;
	gap: 6px;
	overflow: hidden;
	box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, .04);
}
/* rack rails */
.fr-loader__rack::before,
.fr-loader__rack::after {
	content: '';
	position: absolute;
	top: 8px;
	bottom: 8px;
	width: 3px;
	background: repeating-linear-gradient(180deg, var(--line) 0 4px, transparent 4px 10px);
	opacity: .7;
}
.fr-loader__rack::before { left: 5px; }
.fr-loader__rack::after { right: 5px; }

/* ---------- Empty slot (target) ---------- */
.fr-loader__slot {
	flex: 1;
	border: 1px dashed var(--line);
	border-radius: 4px;
	background: rgba(255, 255, 255, .012);
}

/* ---------- Server unit ---------- */
.fr-loader__unit {
	position: absolute;
	left: 14px;
	right: 14px;
	height: 26px;
	display: flex;
	align-items: center;
	gap: 7px;
	padding: 0 9px;
	border-radius: 4px;
	background: linear-gradient(180deg, #1a222c, #131a22);
	border: 1px solid var(--line);
	font-family: ui-monospace, Menlo, Consolas, monospace;
	font-size: 9px;
	color: var(--muted);
	white-space: nowrap;
	overflow: hidden;
	box-shadow: 0 4px 12px rgba(0, 0, 0, .5);
	opacity: 0;
}

/* LED strip */
.fr-loader__unit::before {
	content: '';
	width: 3px;
	height: 3px;
	border-radius: 50%;
	background: var(--brand);
	box-shadow: 6px 0 0 var(--brand), 12px 0 0 var(--brand);
	flex-shrink: 0;
	opacity: .9;
}

/* Vent lines */
.fr-loader__unit::after {
	content: '';
	margin-inline-start: auto;
	width: 42px;
	height: 8px;
	flex-shrink: 0;
	background: repeating-linear-gradient(90deg, var(--line) 0 2px, transparent 2px 5px);
}

/* ---------- Motion: each unit flies in, docks, then rack "settles" ---------- */
.fr-loader__unit { animation: fr-unit-dock 4.2s var(--ease) infinite; }
.fr-loader__unit--1 { animation-delay: 0s;    top: 12px; }
.fr-loader__unit--2 { animation-delay: .55s;  top: 46px; }
.fr-loader__unit--3 { animation-delay: 1.1s;  top: 80px; }
.fr-loader__unit--4 { animation-delay: 1.65s; top: 114px; }
.fr-loader__unit--5 { animation-delay: 2.2s;  top: 148px; }
.fr-loader__unit--6 { animation-delay: 2.75s; top: 182px; }

@keyframes fr-unit-dock {
	0%    { opacity: 0; transform: translate(150px, -78px) scale(.86) rotate(-4deg); }
	14%   { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); }
	22%   { transform: translate(0, 0) scale(1.03); }
	26%   { transform: translate(0, 0) scale(1); }
	92%   { opacity: 1; transform: translate(0, 0) scale(1); }
	100%  { opacity: 0; transform: translate(0, -14px) scale(.97); }
}

/* ---------- Status line ---------- */
.fr-loader__meta {
	position: absolute;
	left: 50%;
	bottom: -34px;
	transform: translateX(-50%);
	white-space: nowrap;
	font-family: ui-monospace, Menlo, Consolas, monospace;
	font-size: 11px;
	letter-spacing: .16em;
	text-transform: uppercase;
	color: var(--muted);
}
.fr-loader__meta b {
	color: var(--brand);
	font-weight: 700;
}

/* Progress rail */
.fr-loader__bar {
	position: absolute;
	left: 0;
	bottom: -56px;
	width: 220px;
	height: 2px;
	background: var(--line);
	border-radius: 2px;
	overflow: hidden;
}
.fr-loader__bar i {
	display: block;
	height: 100%;
	width: 40%;
	background: var(--grad);
	border-radius: 2px;
	animation: fr-load-bar 1.5s var(--ease) infinite;
}
@keyframes fr-load-bar {
	0%   { transform: translateX(-100%); }
	100% { transform: translateX(250%); }
}

/* ---------- Label ---------- */
.fr-loader__label {
	position: fixed;
	left: 50%;
	bottom: 34px;
	transform: translateX(-50%);
	display: flex;
	align-items: center;
	gap: 8px;
	font-family: Vazirmatn, sans-serif;
	font-size: 12px;
	color: var(--muted);
	white-space: nowrap;
}

/* ---------- Small variant for AJAX loading states ---------- */
.fr-loader-mini {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: var(--muted);
	font-size: .82rem;
}
.fr-loader-mini__rack {
	position: relative;
	width: 34px;
	height: 24px;
	border: 1px solid var(--line);
	border-radius: 4px;
	background: var(--surface);
	overflow: hidden;
	flex-shrink: 0;
}
.fr-loader-mini__rack i {
	position: absolute;
	left: 3px;
	right: 3px;
	height: 4px;
	border-radius: 1px;
	background: var(--brand);
	animation: fr-mini-dock 1.6s var(--ease) infinite;
}
.fr-loader-mini__rack i:nth-child(2) { animation-delay: .35s; }
.fr-loader-mini__rack i:nth-child(3) { animation-delay: .7s; }
@keyframes fr-mini-dock {
	0%   { opacity: 0; transform: translateX(16px); }
	30%  { opacity: 1; transform: translateX(0); }
	85%  { opacity: 1; transform: translateX(0); }
	100% { opacity: 0; transform: translateX(0); }
}

@media (max-width: 480px) {
	.fr-loader__stage { transform: scale(.85); }
}