/*
 * Dark mode.
 *
 * This LIFTS the active palette rather than replacing it. A Steel site stays
 * blue; only the grounds and the text invert. That is what lets one file
 * serve all eight palettes — and it is why the rules redefine the preset
 * variables themselves rather than restyling components: everything in the
 * theme, patterns and user content alike, already reads from those variables.
 *
 * `--wp--preset--color--overlay` is deliberately NOT touched. It is near-white
 * in every palette because it sits on photographs and on the `dark` ground,
 * both of which stay dark here.
 *
 * .dev/build_theme.py reads this file and audits the result, so the numbers
 * below are measured, not chosen by eye.
 */

.industry-dark {
	color-scheme: dark;

	--wp--preset--color--base: #141416;
	--wp--preset--color--charcoal: #0e0e10;
	--wp--preset--color--surface: #1c1c20;
	--wp--preset--color--contrast: #f3f1ee;
	--wp--preset--color--muted: #aba7a2;
	--wp--preset--color--divider: #34343b;

	/* `dark` is the ground under the dimmed photographs. On a dark page it has
	   to go deeper than the page, or a band stops being a separate thing. */
	--wp--preset--color--dark: #0b0b0d;
}

/*
 * The brand colours have to hold their own against a dark ground.
 *
 * Each palette's `primary` and `accent` are chosen for a white page; against
 * #141416 the deep ones (steel blue, signal red) disappear. Every lifted
 * colour is mixed from the palette's own `brand`, which dark mode never
 * redefines — a slug cannot be mixed from itself (that is a cycle, and CSS
 * drops the declaration) — so the lift keeps each palette's hue.
 *
 * A lifted `accent` is a light fill, so its label turns dark: `on-accent`
 * only ever appears paired with an accent fill, so redefining it reaches
 * nothing else. `accent-deep`, the button's edge, has to be LIGHT here to
 * show against the page.
 *
 * build_theme.py reads this block, derives the dark palette for all eight
 * variations and refuses to build if any pair falls under AA.
 */
.industry-dark {
	--wp--preset--color--primary: color-mix(in srgb, var(--wp--preset--color--brand) 70%, white);
	--wp--preset--color--primary-deep: color-mix(in srgb, var(--wp--preset--color--brand) 54%, white);
	--wp--preset--color--accent: color-mix(in srgb, var(--wp--preset--color--brand) 86%, white);
	--wp--preset--color--accent-deep: color-mix(in srgb, var(--wp--preset--color--brand) 62%, white);
	--wp--preset--color--on-accent: #141416;
}

/* Photographs are a touch bright against a dark page. */
@media (prefers-reduced-motion: no-preference) {
	.industry-dark img:not(.wp-block-cover__image-background):not([src$=".svg"]) {
		filter: brightness(0.94);
		transition: filter 0.2s ease;
	}
}

/* The toggle shows a sun once the page is dark (its moon is in style.css). */
.industry-dark .wp-block-button.industry-scheme-toggle > .wp-block-button__link::before {
	--industry-scheme-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M19.1 4.9 17 7M7 17l-2.1 2.1' stroke='black' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}

/*
 * Form controls do not inherit the page's colours, so they have to be told.
 * Without this the quote form stays a block of white in a dark page.
 */
.industry-dark .industry-field__control,
.industry-dark .wp-block-search__input,
.industry-dark .wp-block-post-comments-form input:not([type="submit"]),
.industry-dark .wp-block-post-comments-form textarea {
	background-color: var(--wp--preset--color--surface);
	border-color: var(--wp--preset--color--divider);
	color: var(--wp--preset--color--contrast);
}

/* The sticky header's shadow likewise. */
.industry-dark .industry-header.is-scrolled {
	box-shadow: 0 8px 24px rgb(0 0 0 / 0.55);
}
