/*
 * Layer: base. Element-level defaults above core's `wordpress` layer.
 * Order is declared by mu-plugins/cascade-layers.php. Keep selectors at
 * zero specificity (`:where()`) so components override without a fight.
 * Colours read the piece slots (tokens.css), so a story's palette reaches
 * every element under its root.
 */
@layer base {

	:where(body) {
		border-block-start:
			var(--wp--custom--border--top-rule) solid
			var(--mark);
		font-synthesis: none;
		overflow-wrap: break-word;
	}

	:where([data-piece]) {
		background-color: var(--paper);
		color: var(--ink);
	}

	:where(h1, h2, h3, h4, h5, h6) {
		text-wrap: balance;
	}

	/* One italic phrase per headline, in the mark colour. */
	:where(h1, h2, h3, h4, h5, h6) :where(em, i) {
		color: var(--mark);
	}

	:where(p, li, dd, figcaption, blockquote) {
		text-wrap: pretty;
	}

	:where(code, kbd, samp, pre, time) {
		font-family: var(--wp--preset--font-family--mono);
		font-variant-numeric: tabular-nums;
	}

	:where(a:any-link) {
		text-decoration-thickness: var(--wp--custom--link--underline-width);
		text-underline-offset: var(--wp--custom--link--underline-offset);
	}

	:where(hr) {
		border: 0;
		border-block-start: var(--wp--custom--border--hair) solid var(--rule);
	}

	:where(a:any-link, button, input, select, textarea, summary, [tabindex]) {

		&:focus-visible {
			outline: var(--wp--custom--focus--width) solid var(--mark);
			outline-offset: var(--wp--custom--focus--offset);
		}
	}

	::selection {
		background-color: color-mix(in oklab, var(--mark) 22%, var(--paper));
		color: var(--ink);
	}

	@media (prefers-reduced-motion: no-preference) {

		:where(a:any-link) {
			transition:
				color var(--wp--custom--motion--hover)
				var(--wp--custom--motion--ease-out);
		}
	}
}
