/*
 * Base styles for the page, in the norn.base layer: color-scheme and base typography.
 * It defines no design tokens: every component carries each shared token as the fallback of its custom property, compiled from `tokens.json`.
 * Adds one utility class, `.visually-hidden`: text that is read but not shown, and shows while it or a child has focus.
 */
@layer norn.base {
	:root {
		color-scheme: light dark;
	}

	@media (prefers-reduced-motion: no-preference) {
		html {
			scroll-behavior: smooth;
		}
	}

	body {
		min-block-size: 100dvh;
		margin: 0;
		background: var(--norn-surface-base, light-dark(#ffffff, #101216));
		color: var(--norn-text-base, light-dark(#16181d, #eceef3));
		font-family: var(--norn-font-body, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
		font-size: var(--norn-font-size-m, 1rem);
		line-height: 1.5;
	}

	h1,
	h2,
	h3,
	h4,
	h5,
	h6 {
		font-family: var(--norn-font-heading, var(--norn-font-body, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif));
		line-height: 1.15;
		text-wrap: balance;
	}

	p,
	li {
		text-wrap: pretty;
	}

	a {
		color: var(--norn-text-accent, light-dark(oklch(from color-mix(in oklch, var(--norn-ui-accent, #2346d4) 82%, black) min(l, 0.5) c h), oklch(from color-mix(in oklch, var(--norn-ui-accent, #2346d4) 55%, white) max(l, 0.72) c h)));
		text-decoration: underline dotted;
		text-decoration-color: currentcolor;
		text-decoration-thickness: 1px;
		text-underline-offset: 0.2em;
		overflow-wrap: break-word;

		&:is(:hover, :focus-visible) {
			text-decoration-style: solid;
		}
	}

	/* The one focus ring. A component that the ring would clip draws it inset, at the negative of the offset. */
	:focus-visible {
		outline: var(--norn-ui-focus-width, 2px) solid var(--norn-text-accent, light-dark(oklch(from color-mix(in oklch, var(--norn-ui-accent, #2346d4) 82%, black) min(l, 0.5) c h), oklch(from color-mix(in oklch, var(--norn-ui-accent, #2346d4) 55%, white) max(l, 0.72) c h)));
		outline-offset: var(--norn-ui-focus-offset, 2px);
	}

	main:focus {
		outline: none;
	}

	/* Off screen but still read. Shows while it, or a child, has focus. */
	.visually-hidden:not(:focus-within, :active) {
		position: absolute;
		inline-size: 1px;
		block-size: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}
}
