/* Hide custom elements until they are defined, with a two-second fallback if loading fails.
 * Animate an internal state rather than visibility itself: animating visibility on a host
 * suppresses CSS Custom Highlight painting in iOS Safari, even after the element is defined.
 */
@keyframes hideBriefly {
	0%,
	100% {
		--sh-undefined-visibility: hidden;
	}
}

:not(:defined) {
	visibility: var(--sh-undefined-visibility, visible);
	animation: hideBriefly 2s;
}

/* Add a scroll margin to the targeted element (e.g. anchor links) */
:target {
	scroll-margin-block-start: 2em;
}

/* Default focus outline */
:focus-visible {
	outline: var(--sh-focus-outline);
	outline-offset: var(--sh-focus-outline-offset);
}

/* Default body styles */
body {
	box-sizing: border-box;
	min-block-size: 100dvh;
	margin: 0;
	font-family: var(--sh-font-family);
}

/* Only apply the following styles if the user has not set a preference for reduced motion */
@media (prefers-reduced-motion: no-preference) {
	:root {
		interpolate-size: allow-keywords;
	}

	html {
		scroll-behavior: smooth;
	}
}
