/*
 * Dark mode. The page head sets <html data-theme> from
 * the visitor's choice (the header toggle, kept in localStorage) or their
 * system setting, before anything is drawn.
 *
 * The palette is swapped where a colour has one job: backgrounds darken,
 * text lightens, lines dim. Three colours do two jobs and are handled after
 * the palette: ink (text, and the dark bands and buttons), white (cards, and
 * text on purple and dark), and accent (buttons, and links, which use the
 * lighter purple on a dark page).
 */
[data-theme="dark"] {
	color-scheme: dark;

	/* The serif accent word in headings, and purple text (below). */
	--mkwp-em: var(--wp--preset--color--accent-soft);
	--mk-accent-text: var(--wp--preset--color--accent-soft);

	/* What stays dark in the drawings (screens, overlays, code panels), as
	   the dark bands do, and the white on it. Light mode uses ink and white. */
	--mk-dark: #0a090e;
	--mk-on-dark: #fff;

	/* Surfaces. */
	--wp--preset--color--paper: #121118;
	--wp--preset--color--white: #1b1a23;
	--wp--preset--color--tint: #1f1d29;
	--wp--preset--color--tint-2: #1e1c27;
	--wp--preset--color--chip: #262433;

	/* Lines and borders. */
	--wp--preset--color--line: #2a2836;
	--wp--preset--color--line-2: #312f3e;
	--wp--preset--color--line-3: #34323f;
	--wp--preset--color--line-4: #2e2c3a;
	--wp--preset--color--border-soft: #353240;
	--wp--preset--color--stroke: #3b3949;
	--wp--preset--color--border-strong: #4a4759;

	/* Text, light to quiet. */
	--wp--preset--color--ink: #f2f0f7;
	--wp--preset--color--ink-2: #e3e0ec;
	--wp--preset--color--text-2: #d0cddb;
	--wp--preset--color--nav: #c3c0d0;
	--wp--preset--color--body: #aeabbe;
	--wp--preset--color--subtle: #9693a8;
	--wp--preset--color--quiet: #7c798f;
	--wp--preset--color--faint: #625f74;

	/* Purples: text tones lighten, background tints darken. accent,
	   accent-strong, accent-hover and accent-soft stay as they are. */
	--wp--preset--color--accent-deep: oklch(0.82 0.09 285);
	--wp--preset--color--accent-ink: oklch(0.8 0.08 285);
	--wp--preset--color--accent-pale: oklch(0.4 0.11 285);
	--wp--preset--color--accent-tint: oklch(0.27 0.06 285);
	--wp--preset--color--accent-tint-2: oklch(0.24 0.05 285);
	--wp--preset--color--accent-wash: oklch(0.22 0.04 285);

	/* Greens and ambers, the same way. */
	--wp--preset--color--green: oklch(0.78 0.13 150);
	--wp--preset--color--green-deep: oklch(0.82 0.11 150);
	--wp--preset--color--green-tint: oklch(0.27 0.05 150);
	--wp--preset--color--amber: oklch(0.83 0.11 75);
	--wp--preset--color--amber-tint: oklch(0.28 0.05 75);
}

/* Ink as a background: the dark bands, badges and dark buttons stay dark,
   a step below the page, with their cream and white text. */
[data-theme="dark"] .has-ink-background-color {
	background-color: #0a090e !important;
}

/* White as text (on purple and on the dark bands) stays white. */
[data-theme="dark"] .has-white-color {
	color: #fff !important;
}

/* Purple as text (labels, kickers) reads in the lighter purple. */
[data-theme="dark"] .has-accent-color,
[data-theme="dark"] .has-accent-hover-color {
	color: var(--mk-accent-text) !important;
}

/* Ink on the bright tints that stay as they are (chips such as the
   Founder's License tag) stays dark. */
[data-theme="dark"] :is(.has-accent-soft-background-color, .has-green-bright-background-color, .has-amber-bright-background-color, .has-green-mid-background-color).has-ink-color {
	color: #1c1a24 !important;
}

/* Ghost buttons sit on the purple and dark bands: white text. */
[data-theme="dark"] .wp-block-button.is-style-ghost > .wp-block-button__link {
	color: #fff;
}

/* Light colours used as text (in light mode only on the dark bands, such as
   the Founder's License ticks) keep their light values. */
[data-theme="dark"] .has-paper-color {
	color: #fafaf8 !important;
}

[data-theme="dark"] .has-tint-color {
	color: #f6f5f9 !important;
}

[data-theme="dark"] .has-tint-2-color {
	color: #f3f2f7 !important;
}

[data-theme="dark"] .has-chip-color {
	color: #f2f1f5 !important;
}

[data-theme="dark"] .has-line-color {
	color: #ecebf0 !important;
}

[data-theme="dark"] .has-line-2-color {
	color: #e6e4ee !important;
}

[data-theme="dark"] .has-line-3-color {
	color: #e2e0ea !important;
}

[data-theme="dark"] .has-line-4-color {
	color: #e8e6ee !important;
}

[data-theme="dark"] .has-border-soft-color {
	color: #dcd8e8 !important;
}

[data-theme="dark"] .has-stroke-color {
	color: #d9d7e0 !important;
}

[data-theme="dark"] .has-border-strong-color {
	color: #cfcdd8 !important;
}

/* The playground's browser bar is the visitor's browser, so it goes dark
   with the page; the sample site under it stays light. */
[data-theme="dark"] .mkpg-chrome {
	background: var(--wp--preset--color--chip);
}

[data-theme="dark"] .mkpg-light {
	background: var(--wp--preset--color--border-strong);
}

[data-theme="dark"] .mkpg-url {
	background: var(--wp--preset--color--paper);
	color: var(--wp--preset--color--subtle);
}

/* The live demos show a modal on someone's site: they keep the light look
   (the multi-step and WooCommerce demos, the Style editor preview's stage;
   the playground's sample site is light already). */
[data-theme="dark"] .mkms,
[data-theme="dark"] .mkwoo,
[data-theme="dark"] .mksp-stage {
	color-scheme: light;
	--mk-accent-text: var(--wp--preset--color--accent);
	--wp--preset--color--paper: #fafaf8;
	--wp--preset--color--white: #fff;
	--wp--preset--color--tint: #f6f5f9;
	--wp--preset--color--tint-2: #f3f2f7;
	--wp--preset--color--chip: #f2f1f5;
	--wp--preset--color--line: #ecebf0;
	--wp--preset--color--line-2: #e6e4ee;
	--wp--preset--color--line-3: #e2e0ea;
	--wp--preset--color--line-4: #e8e6ee;
	--wp--preset--color--border-soft: #dcd8e8;
	--wp--preset--color--stroke: #d9d7e0;
	--wp--preset--color--border-strong: #cfcdd8;
	--wp--preset--color--ink: #1c1a24;
	--wp--preset--color--ink-2: #2c2a38;
	--wp--preset--color--text-2: #3a3848;
	--wp--preset--color--nav: #4a4858;
	--wp--preset--color--body: #55536a;
	--wp--preset--color--subtle: #7a788a;
	--wp--preset--color--quiet: #9b98a8;
	--wp--preset--color--faint: #b3b0c0;
	--wp--preset--color--accent-deep: oklch(0.42 0.16 285);
	--wp--preset--color--accent-ink: oklch(0.42 0.12 285);
	--wp--preset--color--accent-pale: oklch(0.86 0.07 285);
	--wp--preset--color--accent-tint: oklch(0.95 0.03 285);
	--wp--preset--color--accent-tint-2: oklch(0.97 0.02 285);
	--wp--preset--color--accent-wash: oklch(0.98 0.012 285);
	--wp--preset--color--green: oklch(0.45 0.12 150);
	--wp--preset--color--green-deep: oklch(0.38 0.1 150);
	--wp--preset--color--green-tint: oklch(0.95 0.05 150);
	--wp--preset--color--amber: oklch(0.42 0.1 70);
	--wp--preset--color--amber-tint: oklch(0.95 0.05 80);
}

/* Links: the lighter purple reads on a dark page. Only the default link
   colour (no extra weight): links the pages colour themselves keep it. */
:where([data-theme="dark"]) a:where(:not(.wp-element-button)) {
	color: var(--wp--preset--color--accent-soft);
}

:where([data-theme="dark"]) a:where(:not(.wp-element-button)):hover {
	color: oklch(0.86 0.09 285);
}

/* The logo is the mono white version in dark mode (brand/logo/mark-white.svg):
   the mark's outline and inner block, and the name. */
[data-theme="dark"] .mkwp-mark {
	filter: brightness(0) invert(1);
}

[data-theme="dark"] :is(.mkwp-logo, .mkwp-logo a) {
	color: #fff;
}

/* Screenshots of WordPress's light admin sit a little softer on a dark page. */
[data-theme="dark"] .mk-shot img {
	border-color: var(--wp--preset--color--line-2);
	box-shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 35%);
}
