/**
 * AES Design Kit v6 — global loader
 *
 * Reusable overlay/spinner for async UI. The markup is created by
 * `assets/theme/js/loader.js`; this file only defines appearance.
 *
 * API:
 *   AESLoader.show(target, { label, fixed, passive, ariaLabel });
 *   AESLoader.hide(target);
 *
 * Scope: global. `.aes-is-loading` is applied to the target and
 * `.aes-loader` is appended to the target (or to <body> with `fixed`).
 */

.aes-is-loading {
	position: relative;
}

.aes-loader {
	box-sizing: border-box;
	position: absolute;
	inset: 0;
	z-index: 50;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: var(--aes-ref-space-3);
	padding: var(--aes-ref-space-4);
	color: var(--aes-sys-color-text-muted);
	background: color-mix(
		in srgb,
		var(--aes-sys-color-surface) 72%,
		transparent
	);
	cursor: progress;
}

/* Viewport overlay: use when the target is taller than the viewport. */
.aes-loader--fixed {
	position: fixed;
	z-index: 9999;
}

/* Spinner only: no veil and no pointer blocking. */
.aes-loader--passive {
	pointer-events: none;
	background: transparent;
}

.aes-loader__spinner {
	box-sizing: border-box;
	width: var(--aes-ref-control-xs);
	height: var(--aes-ref-control-xs);
	border: var(--aes-sys-border-width-strong) solid
		var(--aes-sys-color-border-control);
	border-block-start-color: var(--aes-sys-color-action-primary);
	border-radius: 50%;
	animation: aes-loader-spin 0.8s linear infinite;
}

.aes-loader__label {
	font-family: var(--aes-ref-font-body);
	font-size: var(--aes-sys-font-size-body-sm);
	font-weight: var(--aes-ref-weight-regular);
	line-height: var(--aes-ref-leading-ui);
	text-align: center;
}

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

@media (prefers-reduced-motion: reduce) {
	.aes-loader__spinner {
		animation: none;
	}
}
