/*
 * Novacare Pharmacy — Light and Dark appearances (public site only)
 * ---------------------------------------------------------------------------
 * Loaded on the public site only (never in the block editor, the Site Editor
 * or WordPress administration), so the editing screens always stay light.
 *
 * How the appearance is chosen
 *   - System (default): no data-appearance attribute on <html>; the
 *     prefers-color-scheme media query decides, also without JavaScript, and
 *     it follows the device live when the visitor changes it.
 *   - Light or Dark, chosen with the sun/moon toggle: assets/js/appearance.js
 *     sets data-appearance="light" | "dark" on <html> and remembers only that
 *     word in localStorage (or clears it when the choice matches the device).
 *     A small inline script in <head> (functions.php) applies a remembered
 *     choice before the first paint.
 *
 * Dark is not a filter: every colour role (page, surfaces, headings, text,
 * links, button fills and labels, borders, focus, success, warning, error) has
 * its own dark value in theme.json → settings.custom.dark, and each style
 * variation can set its own. The two blocks below map WordPress's colour
 * variables to those values. They must stay identical: qa-static checks it.
 */

:root {
	color-scheme: light dark;
}

:root[data-appearance="light"] {
	color-scheme: light;
}

/* Explicit choice: Dark ------------------------------------------------- */
:root[data-appearance="dark"],
:root[data-appearance="dark"] body {
	color-scheme: dark;
	--wp--preset--color--base: var(--wp--custom--dark--base);
	--wp--preset--color--surface: var(--wp--custom--dark--surface);
	--wp--preset--color--surface-muted: var(--wp--custom--dark--surface-muted);
	--wp--preset--color--brand: var(--wp--custom--dark--brand);
	--wp--preset--color--brand-dark: var(--wp--custom--dark--brand-dark);
	--wp--preset--color--accent: var(--wp--custom--dark--accent);
	--wp--preset--color--teal: var(--wp--custom--dark--teal);
	--wp--preset--color--text: var(--wp--custom--dark--text);
	--wp--preset--color--text-muted: var(--wp--custom--dark--text-muted);
	--wp--preset--color--border: var(--wp--custom--dark--border);
	--wp--preset--color--border-strong: var(--wp--custom--dark--border-strong);
	--wp--preset--color--focus: var(--wp--custom--dark--focus);
	--wp--preset--color--success: var(--wp--custom--dark--success);
	--wp--preset--color--warning: var(--wp--custom--dark--warning);
	--wp--preset--color--warning-surface: var(--wp--custom--dark--warning-surface);
	--wp--preset--color--danger: var(--wp--custom--dark--danger);
	--wp--preset--shadow--soft: 0 1px 2px rgba(0, 0, 0, 0.4);
	--wp--preset--shadow--lift: 0 8px 24px rgba(0, 0, 0, 0.45);
	--wp--custom--heading--color: var(--wp--custom--dark--heading);
	--wp--custom--label--color: var(--wp--custom--dark--label);
	--wp--custom--icon--color: var(--wp--custom--dark--icon);
	--wp--custom--shadow--color: var(--wp--custom--dark--shadow);
	--wp--custom--hero--background: var(--wp--custom--dark--hero--background);
	--wp--custom--hero--text: var(--wp--custom--dark--hero--text);
	--wp--custom--hero--heading: var(--wp--custom--dark--hero--heading);
	--wp--custom--hero--link: var(--wp--custom--dark--hero--link);
	--wp--custom--hero--button-background: var(--wp--custom--dark--hero--button-background);
	--wp--custom--hero--button-text: var(--wp--custom--dark--hero--button-text);
	--wp--custom--hero--button-hover: var(--wp--custom--dark--hero--button-hover);
	--wp--custom--hero--outline-background: var(--wp--custom--dark--hero--outline-background);
	--wp--custom--hero--outline-text: var(--wp--custom--dark--hero--outline-text);
	--wp--custom--hero--outline-border: var(--wp--custom--dark--hero--outline-border);
	--wp--custom--hero--outline-hover: var(--wp--custom--dark--hero--outline-hover);
	--wp--custom--hero--rule: var(--wp--custom--dark--hero--rule);
	--wp--custom--hero--art: var(--wp--custom--dark--hero--art);
	--wp--custom--counter--background: var(--wp--custom--dark--counter--background);
	--wp--custom--counter--text: var(--wp--custom--dark--counter--text);
	--wp--custom--counter--muted: var(--wp--custom--dark--counter--muted);
	--wp--custom--counter--link: var(--wp--custom--dark--counter--link);
	--wp--custom--counter--rule: var(--wp--custom--dark--counter--rule);
	--wp--custom--band--background: var(--wp--custom--dark--band--background);
	--wp--custom--band--text: var(--wp--custom--dark--band--text);
	--wp--custom--band--heading: var(--wp--custom--dark--band--heading);
	--wp--custom--band--link: var(--wp--custom--dark--band--link);
	--wp--custom--band--rule: var(--wp--custom--dark--band--rule);
	--wp--custom--band--art: var(--wp--custom--dark--band--art);
	--wp--custom--footer--background: var(--wp--custom--dark--footer--background);
	--wp--custom--footer--text: var(--wp--custom--dark--footer--text);
	--wp--custom--footer--heading: var(--wp--custom--dark--footer--heading);
	--wp--custom--footer--rule: var(--wp--custom--dark--footer--rule);
}

/* System: Dark, unless the visitor chose Light -------------------------- */
@media (prefers-color-scheme: dark) {
	:root:not([data-appearance="light"]),
	:root:not([data-appearance="light"]) body {
		color-scheme: dark;
		--wp--preset--color--base: var(--wp--custom--dark--base);
		--wp--preset--color--surface: var(--wp--custom--dark--surface);
		--wp--preset--color--surface-muted: var(--wp--custom--dark--surface-muted);
		--wp--preset--color--brand: var(--wp--custom--dark--brand);
		--wp--preset--color--brand-dark: var(--wp--custom--dark--brand-dark);
		--wp--preset--color--accent: var(--wp--custom--dark--accent);
		--wp--preset--color--teal: var(--wp--custom--dark--teal);
		--wp--preset--color--text: var(--wp--custom--dark--text);
		--wp--preset--color--text-muted: var(--wp--custom--dark--text-muted);
		--wp--preset--color--border: var(--wp--custom--dark--border);
		--wp--preset--color--border-strong: var(--wp--custom--dark--border-strong);
		--wp--preset--color--focus: var(--wp--custom--dark--focus);
		--wp--preset--color--success: var(--wp--custom--dark--success);
		--wp--preset--color--warning: var(--wp--custom--dark--warning);
		--wp--preset--color--warning-surface: var(--wp--custom--dark--warning-surface);
		--wp--preset--color--danger: var(--wp--custom--dark--danger);
		--wp--preset--shadow--soft: 0 1px 2px rgba(0, 0, 0, 0.4);
		--wp--preset--shadow--lift: 0 8px 24px rgba(0, 0, 0, 0.45);
		--wp--custom--heading--color: var(--wp--custom--dark--heading);
		--wp--custom--label--color: var(--wp--custom--dark--label);
		--wp--custom--icon--color: var(--wp--custom--dark--icon);
		--wp--custom--shadow--color: var(--wp--custom--dark--shadow);
		--wp--custom--hero--background: var(--wp--custom--dark--hero--background);
		--wp--custom--hero--text: var(--wp--custom--dark--hero--text);
		--wp--custom--hero--heading: var(--wp--custom--dark--hero--heading);
		--wp--custom--hero--link: var(--wp--custom--dark--hero--link);
		--wp--custom--hero--button-background: var(--wp--custom--dark--hero--button-background);
		--wp--custom--hero--button-text: var(--wp--custom--dark--hero--button-text);
		--wp--custom--hero--button-hover: var(--wp--custom--dark--hero--button-hover);
		--wp--custom--hero--outline-background: var(--wp--custom--dark--hero--outline-background);
		--wp--custom--hero--outline-text: var(--wp--custom--dark--hero--outline-text);
		--wp--custom--hero--outline-border: var(--wp--custom--dark--hero--outline-border);
		--wp--custom--hero--outline-hover: var(--wp--custom--dark--hero--outline-hover);
		--wp--custom--hero--rule: var(--wp--custom--dark--hero--rule);
		--wp--custom--hero--art: var(--wp--custom--dark--hero--art);
		--wp--custom--counter--background: var(--wp--custom--dark--counter--background);
		--wp--custom--counter--text: var(--wp--custom--dark--counter--text);
		--wp--custom--counter--muted: var(--wp--custom--dark--counter--muted);
		--wp--custom--counter--link: var(--wp--custom--dark--counter--link);
		--wp--custom--counter--rule: var(--wp--custom--dark--counter--rule);
		--wp--custom--band--background: var(--wp--custom--dark--band--background);
		--wp--custom--band--text: var(--wp--custom--dark--band--text);
		--wp--custom--band--heading: var(--wp--custom--dark--band--heading);
		--wp--custom--band--link: var(--wp--custom--dark--band--link);
		--wp--custom--band--rule: var(--wp--custom--dark--band--rule);
		--wp--custom--band--art: var(--wp--custom--dark--band--art);
		--wp--custom--footer--background: var(--wp--custom--dark--footer--background);
		--wp--custom--footer--text: var(--wp--custom--dark--footer--text);
		--wp--custom--footer--heading: var(--wp--custom--dark--footer--heading);
		--wp--custom--footer--rule: var(--wp--custom--dark--footer--rule);
	}
}

/*
 * The logo: the reversed artwork (white wordmark) on dark pages, so the name
 * stays legible. Same size, same link and the same accessible name; only one
 * of the two header images is ever displayed.
 */
:root[data-appearance="dark"] .nc-logo--light {
	display: none;
}

/* !important overrides the HTML hidden attribute that hides this logo until CSS loads. */
:root[data-appearance="dark"] .nc-logo--dark.nc-logo--full {
	display: block !important;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-appearance="light"]) .nc-logo--light {
		display: none;
	}

	:root:not([data-appearance="light"]) .nc-logo--dark.nc-logo--full {
		display: block !important;
	}
}

/*
 * The appearance toggle offers the other appearance: a moon ("Switch to dark
 * appearance") on a light page, a sun ("Switch to light appearance") on a dark
 * one. CSS decides, so it is right before any script runs and follows the
 * device live; the hidden part leaves the accessibility tree.
 */
:root[data-appearance="dark"] .nc-theme-toggle__state--to-dark {
	display: none;
}

:root[data-appearance="dark"] .nc-theme-toggle__state--to-light {
	display: inline-flex;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-appearance="light"]) .nc-theme-toggle__state--to-dark {
		display: none;
	}

	:root:not([data-appearance="light"]) .nc-theme-toggle__state--to-light {
		display: inline-flex;
	}
}

/*
 * Review page only: logo tiles keep the backgrounds the artwork was drawn for
 * (the full-colour logo on white), in either appearance.
 */
:root[data-appearance="dark"] .wp-block-group.nc-logo-tile:not(.nc-logo-tile--dark) {
	background: #fff;
	color: #263749;
}

:root[data-appearance="dark"] .nc-logo-tile:not(.nc-logo-tile--dark) figcaption {
	color: #56636f;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-appearance="light"]) .wp-block-group.nc-logo-tile:not(.nc-logo-tile--dark) {
		background: #fff;
		color: #263749;
	}

	:root:not([data-appearance="light"]) .nc-logo-tile:not(.nc-logo-tile--dark) figcaption {
		color: #56636f;
	}
}

/*
 * Switching appearance happens at once: colours change in one frame instead
 * of some controls fading while the page around them has already changed.
 */
.nc-appearance-switching,
.nc-appearance-switching *,
.nc-appearance-switching *::before,
.nc-appearance-switching *::after {
	transition: none !important;
}
