/* Override the existing palette only in dark mode; keep Global Styles in light mode. */
:root[data-bc-color-mode="light"] {
	color-scheme: light;
}

:root[data-bc-color-mode="dark"] {
	color-scheme: dark;
	background-color: #15191d;
	--wp--preset--color--base: #15191d;
	--wp--preset--color--main: #eef2f5;
	--wp--preset--color--secondary: #b2beca;
	--wp--preset--color--tertiary: #222a32;
	--wp--preset--color--primary: #9ac9e7;
	--wp--preset--color--main-accent: #bac9d6;
	--wp--preset--color--primary-accent: #3d596e;
	--wp--preset--color--border-light: #47596a;
	--wp--preset--color--border-dark: #8295a7;
}

:root[data-bc-color-mode="dark"] body {
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--main);
}

:root[data-bc-color-mode="dark"] .has-primary-background-color {
	background-color: #003353 !important;
	border-color: #003353 !important;
}

:root[data-bc-color-mode="dark"] .has-primary-background-color:is(.has-base-color, .wp-block-button__link),
:root[data-bc-color-mode="dark"] .has-primary-background-color :is(.has-base-color, .has-main-accent-color, .wp-block-post-terms.has-main-accent-color a),
:root[data-bc-color-mode="dark"] .wp-block-post-terms.has-primary-background-color a {
	color: var(--wp--preset--color--main) !important;
}

:root[data-bc-color-mode="dark"] .jetpack-subscribe-modal__modal-content > .wp-block-group.has-border-color {
	border-color: var(--wp--preset--color--border-light) !important;
}

/* Keep the light-only, transparent Likes iframe on a matching canvas. */
:root[data-bc-color-mode="dark"] .jetpack-likes-widget-wrapper iframe {
	color-scheme: light;
}

:root[data-bc-color-mode="dark"] .wp-block-comments .wp-block-comment-template .has-base-background-color {
	border-bottom-color: var(--wp--preset--color--border-light) !important;
}

:root[data-bc-color-mode="dark"] :is(.wp-block-jetpack-subscriptions input[type="email"], #commentform :is(#author, #email, #url, #comment)) {
	color: var(--wp--preset--color--main);
	background-color: var(--wp--preset--color--tertiary);
	border-color: var(--wp--preset--color--border-dark);
}

:root[data-bc-color-mode="dark"] :is(.wp-block-jetpack-subscriptions input[type="email"], #commentform :is(#author, #email, #url, #comment))::placeholder {
	color: var(--wp--preset--color--secondary);
	opacity: 1;
}

:root[data-bc-color-mode="dark"] :is(.wp-block-jetpack-subscriptions input[type="email"], #commentform :is(#author, #email, #url, #comment)):focus-visible {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-bc-color-mode]) {
		color-scheme: dark;
		background-color: #15191d;
		--wp--preset--color--base: #15191d;
		--wp--preset--color--main: #eef2f5;
		--wp--preset--color--secondary: #b2beca;
		--wp--preset--color--tertiary: #222a32;
		--wp--preset--color--primary: #9ac9e7;
		--wp--preset--color--main-accent: #bac9d6;
		--wp--preset--color--primary-accent: #3d596e;
		--wp--preset--color--border-light: #47596a;
		--wp--preset--color--border-dark: #8295a7;
	}

	:root:not([data-bc-color-mode]) body {
		background-color: var(--wp--preset--color--base);
		color: var(--wp--preset--color--main);
	}

	:root:not([data-bc-color-mode]) .has-primary-background-color {
		background-color: #003353 !important;
		border-color: #003353 !important;
	}

	:root:not([data-bc-color-mode]) .has-primary-background-color:is(.has-base-color, .wp-block-button__link),
	:root:not([data-bc-color-mode]) .has-primary-background-color :is(.has-base-color, .has-main-accent-color, .wp-block-post-terms.has-main-accent-color a),
	:root:not([data-bc-color-mode]) .wp-block-post-terms.has-primary-background-color a {
		color: var(--wp--preset--color--main) !important;
	}

	:root:not([data-bc-color-mode]) .jetpack-subscribe-modal__modal-content > .wp-block-group.has-border-color {
		border-color: var(--wp--preset--color--border-light) !important;
	}

	/* Keep the light-only, transparent Likes iframe on a matching canvas. */
	:root:not([data-bc-color-mode]) .jetpack-likes-widget-wrapper iframe {
		color-scheme: light;
	}

	:root:not([data-bc-color-mode]) .wp-block-comments .wp-block-comment-template .has-base-background-color {
		border-bottom-color: var(--wp--preset--color--border-light) !important;
	}

	:root:not([data-bc-color-mode]) :is(.wp-block-jetpack-subscriptions input[type="email"], #commentform :is(#author, #email, #url, #comment)) {
		color: var(--wp--preset--color--main);
		background-color: var(--wp--preset--color--tertiary);
		border-color: var(--wp--preset--color--border-dark);
	}

	:root:not([data-bc-color-mode]) :is(.wp-block-jetpack-subscriptions input[type="email"], #commentform :is(#author, #email, #url, #comment))::placeholder {
		color: var(--wp--preset--color--secondary);
		opacity: 1;
	}

	:root:not([data-bc-color-mode]) :is(.wp-block-jetpack-subscriptions input[type="email"], #commentform :is(#author, #email, #url, #comment)):focus-visible {
		outline: 2px solid var(--wp--preset--color--primary);
		outline-offset: 2px;
	}
}

/* Match the three-column related-posts group in both saved and file templates. */
.single-post .wp-block-group.alignfull.has-primary-background-color:has(> .wp-block-query > .wp-block-post-template.columns-3) {
	background-color: var(--wp--preset--color--base) !important;
	color: var(--wp--preset--color--main);
}

.single-post .wp-block-group.alignfull.has-primary-background-color:has(> .wp-block-query > .wp-block-post-template.columns-3) .wp-block-post-title a {
	color: var(--wp--preset--color--main) !important;
}

.single-post .wp-block-group.alignfull.has-primary-background-color:has(> .wp-block-query > .wp-block-post-template.columns-3) :is(.wp-block-post-terms, .wp-block-post-terms a, .wp-block-post-date) {
	color: var(--wp--preset--color--secondary) !important;
}

/* Show keyboard focus on theme and subscription controls, not just the picker. */
:where(.wp-site-blocks, .jetpack-subscribe-modal) :is(a[href], button, input:not([type="hidden"]), select, textarea, summary):focus-visible {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}

/* Keep text links identifiable on hover without changing their contrast. */
:where(.entry-content, .wp-block-navigation, .wp-block-post-title, .wp-block-post-terms) a:is(:hover, :focus-visible) {
	text-decoration-line: underline;
	text-decoration-thickness: .12em;
	text-underline-offset: .15em;
}
