/*
 * Theme resolution, the layer that needs neither JavaScript nor a server.
 *
 * Every public route is a static file built once (ADR-0002), so nothing on the server knows who
 * is asking when the HTML is written. That leaves the document itself to resolve the theme, and
 * this file is the part of it a browser applies before first paint with no scripting at all: it
 * is a render-blocking stylesheet linked from the head of app.html.
 *
 * Two inputs, one attribute. `prefers-color-scheme` is the default. An explicit choice arrives as
 * `data-theme="light"` or `data-theme="dark"` on the root element, written either by
 * static/theme.js from the preference cookie or, for a visitor with scripting off, by the
 * origin's /theme-preference.css override. The `:not([data-theme])` guard is what keeps the two
 * from fighting: the system rule stops applying the moment an explicit choice exists, so the
 * cascade order between them never has to be reasoned about again.
 *
 * `color-scheme` is the whole payload today and that is deliberate. It is the declaration that
 * repaints the canvas, the default text colour, the scrollbars and the form controls, which is
 * to say it is the thing whose absence produces a white flash on a dark-theme page.
 * CHK-SHELL-006 hangs the semantic token table off these same four selectors; nothing about the
 * resolution changes when it does.
 */

:root {
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme]) {
		color-scheme: dark;
	}
}

:root[data-theme='light'] {
	color-scheme: light;
}

:root[data-theme='dark'] {
	color-scheme: dark;
}

/*
 * High contrast is a complete palette choice, not a late component modifier. Keeping the two
 * choices on the same root attribute means the boot script, static routes and private routes all
 * resolve them before paint. The actual values stay in tokens.css.
 */
:root[data-theme='high-contrast-light'] {
	color-scheme: light;
}

:root[data-theme='high-contrast-dark'] {
	color-scheme: dark;
}
