/*
 * Dark mode.
 *
 * This LIFTS the active palette rather than replacing it. A Harbour 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`, `on-dark` and `brand-on-dark` are
 * deliberately NOT touched. They sit 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.
 */

.lagoon-dark {
	color-scheme: dark;

	--wp--preset--color--base: #141418;
	--wp--preset--color--surface: #1d1d24;
	--wp--preset--color--contrast: #f2f2f5;
	--wp--preset--color--muted: #acabb8;
	--wp--preset--color--divider: #34343f;

	/* `dark` is the navy of the top bar, the services band and the footer. On
	   a dark page it has to go deeper than the page, or a band stops being a
	   separate thing. */
	--wp--preset--color--dark: #0b0b10;
}

/*
 * 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
 * #141418 the deep ones (harbour blue, plum) 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 (buttons, the testimonial box,
 * the call-to-action band), so redefining it reaches nothing else.
 *
 * build_theme.py reads this block, derives the dark palette for all eight
 * variations and refuses to build if any pair falls under AA.
 */
.lagoon-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: #141418;
}

/* Photographs are a touch bright against a dark page. */
@media (prefers-reduced-motion: no-preference) {
	.lagoon-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). */
.lagoon-dark .wp-block-button.lagoon-scheme-toggle > .wp-block-button__link::before {
	--lagoon-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.
 */
.lagoon-dark .lagoon-field__control,
.lagoon-dark .wp-block-search__input,
.lagoon-dark .wp-block-post-comments-form input:not([type="submit"]),
.lagoon-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. */
.lagoon-dark .lagoon-header.is-scrolled {
	box-shadow: 0 8px 24px rgb(0 0 0 / 0.55);
}

