/*
 * Dark mode.
 *
 * This LIFTS the active palette rather than replacing it. A Hunter site stays
 * green; 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.
 */

.horseclub-dark {
	color-scheme: dark;

	--wp--preset--color--base: #141416;
	--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` is chosen to clear AA against white; against
 * #141416 most of them do not. Mixing the palette's own `accent` (and, for the
 * warm end of the button gradient, `accent-warm`) toward white lifts each one
 * without flattening the differences between them.
 *
 * The slugs mixed here are load-bearing: a colour-mix on an undefined variable
 * makes the whole declaration invalid, so `primary` would stop resolving and
 * every button would render as bare text while every text check still passed.
 * build_theme.py refuses to build if this file names a slug the palette does
 * not define.
 *
 * `on-primary` turns over with the fill. A lifted `primary` is a light fill,
 * so a white label on it is unreadable; `on-primary` only ever appears paired
 * with a primary fill, so redefining it here reaches nothing else.
 */
.horseclub-dark {
	--wp--preset--color--primary: color-mix(in srgb, var(--wp--preset--color--accent) 72%, white);
	--wp--preset--color--primary-deep: color-mix(in srgb, var(--wp--preset--color--accent) 56%, white);
	--wp--preset--color--primary-warm: color-mix(in srgb, var(--wp--preset--color--accent-warm) 72%, white);
	--wp--preset--color--on-primary: #141416;
}

/* Photographs are a touch bright against a dark page. */
@media (prefers-reduced-motion: no-preference) {
	.horseclub-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). */
.horseclub-dark .wp-block-button.horseclub-scheme-toggle > .wp-block-button__link::before {
	--horseclub-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 booking form stays a block of white in a dark page.
 */
.horseclub-dark .horseclub-field__control,
.horseclub-dark .wp-block-search__input,
.horseclub-dark .wp-block-post-comments-form input,
.horseclub-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);
}

/* A native date picker draws its own indicator in black. */
.horseclub-dark input[type="date"]::-webkit-calendar-picker-indicator {
	filter: invert(1);
}

/* A shadow barely registers against a dark page: cards lift on a deeper one. */
.horseclub-dark .is-style-horseclub-card:hover,
.horseclub-dark .is-style-horseclub-card:focus-within {
	box-shadow: 0 14px 34px rgb(0 0 0 / 0.5);
}

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