/* @svelte-lean/styles — skeleton (Tier 0, aria-hidden placeholders).
 * Markup: <div aria-busy="true"> <span data-slean="skeleton" data-variant="text"
 * aria-hidden="true"></span> … </div>. The container that is loading carries aria-busy; the
 * placeholders are hidden from assistive technology. Variant (data-variant, MUI's): text (a line;
 * the last of several is shorter), rectangular (an image or a card), rounded (the same with the
 * medium radius), circular (an avatar); without one, a bar. Sizes of the circular one:
 * data-size="small|large". The shimmer is a band in the background moved by a keyframe animation; at
 * rest, and under reduced motion where the duration tokens are 0ms, the band is outside the box
 * and the placeholder is a flat tint. */
@layer slean.reset, slean.tokens, slean.base, slean.components, slean.compositions, slean.utilities;

@layer slean.components {
	:where([data-slean='skeleton']) {
		display: block;
		inline-size: 100%;
		block-size: 1rem;
		border-radius: var(--slean-radius-sm);
		background-color: var(--slean-muted);
		background-image: linear-gradient(
			90deg,
			transparent 40%,
			var(--slean-muted-hover) 50%,
			transparent 60%
		);
		background-size: 300% 100%;
		background-position: 100% 0;
		background-repeat: no-repeat;
		animation: slean-skeleton-shimmer calc(var(--slean-duration-slow) * 7) linear infinite;
	}

	/* The band crosses the box between 75% and 25%; the rest of the cycle is the pause. */
	@keyframes slean-skeleton-shimmer {
		from {
			background-position: 100% 0;
		}

		to {
			background-position: 0 0;
		}
	}

	:where([data-slean='skeleton']:dir(rtl)) {
		animation-direction: reverse;
	}

	/* A line of text: the height of the text around it, spaced like lines. */
	:where([data-slean='skeleton'][data-variant='text']) {
		block-size: 0.75em;
		margin-block: 0.375em;
	}

	:where([data-slean='skeleton'][data-variant='text']:last-child:not(:first-child)) {
		inline-size: 60%;
	}

	:where([data-slean='skeleton'][data-variant='circular']) {
		flex: none;
		inline-size: var(--slean-control-height-md);
		block-size: var(--slean-control-height-md);
		border-radius: 50%;
	}

	:where([data-slean='skeleton'][data-variant='circular'][data-size='small']) {
		inline-size: var(--slean-control-height-sm);
		block-size: var(--slean-control-height-sm);
	}

	:where([data-slean='skeleton'][data-variant='circular'][data-size='large']) {
		inline-size: 3.5rem;
		block-size: 3.5rem;
	}

	:where([data-slean='skeleton'][data-variant='rectangular']),
	:where([data-slean='skeleton'][data-variant='rounded']) {
		block-size: 8rem;
		border-radius: 0;
	}

	:where([data-slean='skeleton'][data-variant='rounded']) {
		border-radius: var(--slean-radius-md);
	}

	/* Forced colors drop background colors; keep the shapes as outlines. */
	@media (forced-colors: active) {
		:where([data-slean='skeleton']) {
			border: 1px solid GrayText;
			background-image: none;
		}
	}
}
