/*
 * Page-navigation loader.
 *
 * Themed on SB Admin 2 through the Bootstrap 4 :root custom properties the
 * theme already defines (--primary, --gray, --font-family-sans-serif), each
 * with a literal fallback so the loader still reads correctly if
 * sb-admin-2.min.css fails to load.
 *
 * The 200ms fade below is duplicated as FADE_MS in fragments/loader.html.
 * Keep the two in sync.
 */

/* Fail-safe. Restated here because the id selector below would otherwise
   out-specify the UA stylesheet's [hidden] { display: none }. The markup ships
   this attribute, so a slow, stale or 404 copy of this file cannot flash an
   unstyled spinner onto the page. */
#pageLoader[hidden] {
	display: none;
}

#pageLoader {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 1080; /* above Bootstrap 4's tooltip (1070), modal (1050), backdrop (1040) */
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: rgba(248, 249, 252, .92); /* --light at 92% */
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
	font-family: var(--font-family-sans-serif, "Nunito", -apple-system,
		BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif);
	opacity: 0;
	pointer-events: none;
	transition: opacity 200ms ease;
}

/* pointer-events flips with the class rather than with the fade: clicks pass
   through the instant we start hiding, even with 200ms of fade left to run. */
#pageLoader.page-loader--visible {
	opacity: 1;
	pointer-events: auto;
}

.page-loader__content {
	padding: 1rem;
	text-align: center;
}

/* Sizing box only — this element does not rotate. See the markup comment in
   fragments/loader.html: the ring is the ::before below so the mark inside can
   stay still. Grown from 2.5rem to 3rem because 2.5rem left only 32px of inner
   void, and a logo mark large enough to read (28px) needs breathing room
   inside the ring rather than 2px of it. */
.page-loader__spinner {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 3rem;
	height: 3rem;
	margin: 0 auto .85rem;
}

.page-loader__spinner::before {
	content: "";
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	border: .25rem solid #eaecf4; /* gray-200 track; not exposed in :root */
	border-top-color: var(--primary, #4e73df);
	border-radius: 50%;
	animation: page-loader-spin .75s linear infinite;
}

/* 1.75rem inside a 3rem ring with a .25rem border leaves 6px of clear scrim on
   every side. `color` rather than fill/stroke: the SVG strokes are currentColor,
   so the mark is themed from this one declaration. The scrim is --light at 92%,
   so the mark must be brand blue — a white mark would vanish. */
.page-loader__logo {
	display: block; /* no inline baseline gap if flex is ever unavailable */
	width: 1.75rem;
	height: 1.75rem;
	color: var(--primary, #4e73df);
}

.page-loader__text {
	margin: 0;
	color: var(--gray, #858796); /* gray-600 */
	font-size: .85rem;
	font-weight: 600; /* Nunito reads thin at small sizes */
	letter-spacing: .02em;
}

.page-loader__dismiss {
	display: none;
	margin-top: .75rem;
	padding: 0;
	border: 0;
	background: none;
	color: var(--primary, #4e73df);
	font: inherit;
	font-size: .8rem;
	text-decoration: underline;
	cursor: pointer;
}

.page-loader__dismiss:focus {
	outline: 2px solid var(--primary, #4e73df);
	outline-offset: 2px;
}

/* Escalated: the navigation is clearly stuck, so surface the escape hatch. */
#pageLoader.page-loader--escalated {
	cursor: pointer;
}

#pageLoader.page-loader--escalated .page-loader__dismiss {
	display: inline-block;
}

@keyframes page-loader-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	#pageLoader {
		transition-duration: 0s;
	}
	/* A stopped three-quarter-transparent ring reads as a rendering artefact, so
	   close the circle — but paint it the flat gray-200 track colour, not
	   --primary. The mark inside is --primary and sits only 6px away; two
	   concentric blues that close together read as one muddy blob. Closed and
	   gray, the ring reads as a deliberate badge frame, the mark carries the
	   identity, and the .page-loader__text live region carries the "still loading"
	   meaning exactly as before.

	   The mark itself has no animation to disable — it is static by construction
	   (the rotation lives on the pseudo-element above). Keep it that way. */
	.page-loader__spinner::before {
		animation: none;
		border-color: #eaecf4;
	}
}
