/*
 * Minimal SGGW surface contract.
 *
 * The public palette exposes four adaptive neutral surfaces and two adaptive
 * accent surfaces. Default text and icons have one value per polarity. The
 * focus role selects a dark or light tone from the canonical Red ramp based
 * on the current surface polarity. Muted text plus functional and decorative
 * line roles remain mixed against the current surface.
 */

:root {
	color-scheme: light;

	/* Adaptive neutral surface levels. Both canonical ramps live in
	 * sggw-color-primitives.css; Green remains reserved for accents. */
	--sggw-surface-0: var(--sggw-color-sage-100);
	--sggw-surface-1: var(--sggw-color-sage-97);
	--sggw-surface-2: var(--sggw-color-sage-93);
	--sggw-surface-3: var(--sggw-color-sage-89);
	--sggw-surface-page: var(--sggw-surface-1);
	--sggw-surface-current: var(--sggw-surface-1);
	--sggw-surface-alternating: var(--sggw-surface-2);
	--sggw-module-default-surface: var(--sggw-surface-2);
	--sggw-module-default-alternating: var(--sggw-surface-3);
	--sggw-module-default-link-foreground: light-dark(
		var(--sggw-color-lime-45),
		var(--sggw-color-lime-60)
	);
	--sggw-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
	--sggw-module-default-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
	--sggw-accent-surface-0: var(--sggw-color-green-5);
	--sggw-accent-surface-1: var(--sggw-color-green-15);
	--sggw-adaptive-color-scheme: light;
	--sggw-adaptive-text-base: var(--sggw-color-sage-5);
	--sggw-adaptive-text-muted-weight: 59%;
	--sggw-adaptive-line-functional-weight: 47%;
	--sggw-adaptive-line-decorative-weight: 25%;
	--sggw-adaptive-button-background: var(--sggw-color-green-15);
	--sggw-adaptive-button-foreground: var(--sggw-color-sage-95);
	--sggw-adaptive-button-outline: var(--sggw-color-sage-10);
	--sggw-text-base: var(--sggw-adaptive-text-base);
	--sggw-text-muted-weight: var(--sggw-adaptive-text-muted-weight);
	--sggw-line-functional-weight: var(--sggw-adaptive-line-functional-weight);
	--sggw-line-decorative-weight: var(--sggw-adaptive-line-decorative-weight);
	--sggw-button-background: var(--sggw-adaptive-button-background);
	--sggw-button-foreground: var(--sggw-adaptive-button-foreground);
	--sggw-button-outline: var(--sggw-adaptive-button-outline);
	--sggw-button-background-hover: light-dark(
		var(--sggw-color-green-0),
		var(--sggw-color-green-100)
	);
	--sggw-button-foreground-hover: light-dark(
		var(--sggw-color-green-100),
		var(--sggw-color-green-0)
	);
	--sggw-link-foreground: light-dark(
		var(--sggw-color-lime-45),
		var(--sggw-color-lime-60)
	);
	--sggw-metadata-link-color: var(--sggw-link-foreground);
	--sggw-code-surface: light-dark(
		var(--sggw-color-sage-5),
		var(--sggw-color-sage-13)
	);
	--sggw-code-text: light-dark(
		var(--sggw-color-green-80),
		var(--sggw-color-green-90)
	);
	--sggw-preformatted-surface: light-dark(
		var(--sggw-color-sage-90),
		var(--sggw-color-sage-10)
	);
	--sggw-quote-surface: light-dark(
		var(--sggw-color-sage-100),
		var(--sggw-color-sage-18)
	);
	--sggw-timeline-date-accent: light-dark(
		var(--sggw-color-yellow-40),
		var(--sggw-color-yellow-60)
	);

	/* Semantic presets used by Gutenberg and compatibility aliases. */
	--wp--preset--color--sggw-surface-0: var(--sggw-surface-0);
	--wp--preset--color--sggw-surface-1: var(--sggw-surface-1);
	--wp--preset--color--sggw-surface-2: var(--sggw-surface-2);
	--wp--preset--color--sggw-surface-3: var(--sggw-surface-3);
	--wp--preset--color--sggw-green-0: var(--sggw-accent-surface-0);
	--wp--preset--color--sggw-green-10: var(--sggw-accent-surface-1);
}

:root[data-sggw-color-scheme="light"] {
	color-scheme: light;
	--sggw-surface-0: var(--sggw-color-sage-100);
	--sggw-surface-1: var(--sggw-color-sage-97);
	--sggw-surface-2: var(--sggw-color-sage-93);
	--sggw-surface-3: var(--sggw-color-sage-89);
	--sggw-surface-page: var(--sggw-surface-1);
	--sggw-surface-current: var(--sggw-surface-1);
	--sggw-surface-alternating: var(--sggw-surface-2);
	--sggw-module-default-surface: var(--sggw-surface-2);
	--sggw-module-default-alternating: var(--sggw-surface-3);
	--sggw-accent-surface-0: var(--sggw-color-green-5);
	--sggw-accent-surface-1: var(--sggw-color-green-15);
	--sggw-adaptive-color-scheme: light;
	--sggw-adaptive-text-base: var(--sggw-color-sage-5);
	--sggw-adaptive-text-muted-weight: 59%;
	--sggw-adaptive-line-functional-weight: 47%;
	--sggw-adaptive-line-decorative-weight: 25%;
	--sggw-adaptive-button-background: var(--sggw-color-green-15);
	--sggw-adaptive-button-foreground: var(--sggw-color-sage-95);
	--sggw-adaptive-button-outline: var(--sggw-color-sage-10);
	--sggw-text-base: var(--sggw-adaptive-text-base);
	--sggw-text-muted-weight: var(--sggw-adaptive-text-muted-weight);
	--sggw-line-functional-weight: var(--sggw-adaptive-line-functional-weight);
	--sggw-line-decorative-weight: var(--sggw-adaptive-line-decorative-weight);
	--sggw-button-background: var(--sggw-adaptive-button-background);
	--sggw-button-foreground: var(--sggw-adaptive-button-foreground);
	--sggw-button-outline: var(--sggw-adaptive-button-outline);
}

:root[data-sggw-color-scheme="dark"] {
	color-scheme: dark;
	/* Dark surfaces are role-mapped rather than mechanically mirrored:
	 * page < section < card < raised. Pure black remains outside the normal
	 * surface hierarchy. */
	--sggw-surface-0: var(--sggw-color-sage-13);
	--sggw-surface-1: var(--sggw-color-sage-5);
	--sggw-surface-2: var(--sggw-color-sage-10);
	--sggw-surface-3: var(--sggw-color-sage-15);
	--sggw-surface-page: var(--sggw-surface-1);
	--sggw-surface-current: var(--sggw-surface-1);
	--sggw-surface-alternating: var(--sggw-surface-2);
	--sggw-module-default-surface: var(--sggw-surface-0);
	--sggw-module-default-alternating: var(--sggw-surface-3);
	--sggw-module-default-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
	--sggw-accent-surface-0: var(--sggw-color-green-5);
	--sggw-accent-surface-1: var(--sggw-color-green-10);
	--sggw-adaptive-color-scheme: dark;
	--sggw-adaptive-text-base: var(--sggw-color-sage-100);
	--sggw-adaptive-text-muted-weight: 73%;
	--sggw-adaptive-line-functional-weight: 47%;
	--sggw-adaptive-line-decorative-weight: 29%;
	--sggw-adaptive-button-background: var(--sggw-color-green-95);
	--sggw-adaptive-button-foreground: var(--sggw-color-green-15);
	--sggw-adaptive-button-outline: var(--sggw-color-sage-90);
	--sggw-text-base: var(--sggw-adaptive-text-base);
	--sggw-text-muted-weight: var(--sggw-adaptive-text-muted-weight);
	--sggw-line-functional-weight: var(--sggw-adaptive-line-functional-weight);
	--sggw-line-decorative-weight: var(--sggw-adaptive-line-decorative-weight);
	--sggw-button-background: var(--sggw-adaptive-button-background);
	--sggw-button-foreground: var(--sggw-adaptive-button-foreground);
	--sggw-button-outline: var(--sggw-adaptive-button-outline);
}

@media (prefers-color-scheme: dark) {
	:root:not([data-sggw-color-scheme]) {
		color-scheme: dark;
		--sggw-surface-0: var(--sggw-color-sage-13);
		--sggw-surface-1: var(--sggw-color-sage-5);
		--sggw-surface-2: var(--sggw-color-sage-10);
		--sggw-surface-3: var(--sggw-color-sage-15);
		--sggw-surface-page: var(--sggw-surface-1);
		--sggw-surface-current: var(--sggw-surface-1);
		--sggw-surface-alternating: var(--sggw-surface-2);
		--sggw-module-default-surface: var(--sggw-surface-0);
		--sggw-module-default-alternating: var(--sggw-surface-3);
		--sggw-module-default-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
		--sggw-accent-surface-0: var(--sggw-color-green-5);
		--sggw-accent-surface-1: var(--sggw-color-green-10);
		--sggw-adaptive-color-scheme: dark;
		--sggw-adaptive-text-base: var(--sggw-color-sage-100);
		--sggw-adaptive-text-muted-weight: 73%;
		--sggw-adaptive-line-functional-weight: 47%;
		--sggw-adaptive-line-decorative-weight: 29%;
		--sggw-adaptive-button-background: var(--sggw-color-green-95);
		--sggw-adaptive-button-foreground: var(--sggw-color-green-15);
		--sggw-adaptive-button-outline: var(--sggw-color-sage-90);
		--sggw-text-base: var(--sggw-adaptive-text-base);
		--sggw-text-muted-weight: var(--sggw-adaptive-text-muted-weight);
		--sggw-line-functional-weight: var(--sggw-adaptive-line-functional-weight);
		--sggw-line-decorative-weight: var(--sggw-adaptive-line-decorative-weight);
		--sggw-button-background: var(--sggw-adaptive-button-background);
		--sggw-button-foreground: var(--sggw-adaptive-button-foreground);
		--sggw-button-outline: var(--sggw-adaptive-button-outline);
	}
}

/* Adaptive surfaces. Legacy Sage classes alias the same hierarchy so saved
 * content follows the active scheme without a database migration. */
:where(
	.has-sggw-sage-100-background-color,
	.has-sggw-sage-95-background-color,
	.has-sggw-sage-90-background-color,
	.has-sggw-sage-85-background-color,
	.has-sggw-surface-0-background-color,
	.has-sggw-surface-1-background-color,
	.has-sggw-surface-2-background-color,
	.has-sggw-surface-3-background-color,
	.sggw-surface-0,
	.sggw-surface-1,
	.sggw-surface-2,
	.sggw-surface-3,
	.sggw-surface-context-0,
	.sggw-surface-context-1,
	.sggw-surface-context-2,
	.sggw-surface-context-3,
	.has-white-background-color:not(.wp-block-cover__background)
) {
	color-scheme: var(--sggw-adaptive-color-scheme);
	--sggw-text-base: var(--sggw-adaptive-text-base);
	--sggw-text-muted-weight: var(--sggw-adaptive-text-muted-weight);
	--sggw-line-functional-weight: var(--sggw-adaptive-line-functional-weight);
	--sggw-line-decorative-weight: var(--sggw-adaptive-line-decorative-weight);
	--sggw-button-background: var(--sggw-adaptive-button-background);
	--sggw-button-foreground: var(--sggw-adaptive-button-foreground);
	--sggw-button-outline: var(--sggw-adaptive-button-outline);
}

:where(
	.has-sggw-sage-100-background-color,
	.has-sggw-surface-0-background-color,
	.sggw-surface-0,
	.sggw-surface-context-0,
	.has-white-background-color:not(.wp-block-cover__background)
) {
	--sggw-surface-current: var(--sggw-surface-0);
	--sggw-surface-alternating: var(--sggw-surface-1);
	--sggw-module-default-surface: var(--sggw-surface-1);
	--sggw-module-default-alternating: var(--sggw-surface-2);
	--sggw-module-default-link-foreground: light-dark(
		var(--sggw-color-lime-45),
		var(--sggw-color-lime-60)
	);
	--sggw-link-foreground: light-dark(
		var(--sggw-color-lime-49),
		var(--sggw-color-lime-60)
	);
	--sggw-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
	--sggw-module-default-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
}

:where(
	.has-sggw-sage-95-background-color,
	.has-sggw-surface-1-background-color,
	.sggw-surface-1,
	.sggw-surface-context-1
) {
	--sggw-surface-current: var(--sggw-surface-1);
	--sggw-surface-alternating: var(--sggw-surface-2);
	--sggw-module-default-surface: var(--sggw-surface-2);
	--sggw-module-default-alternating: var(--sggw-surface-3);
	--sggw-module-default-link-foreground: light-dark(
		var(--sggw-color-lime-45),
		var(--sggw-color-lime-60)
	);
	--sggw-link-foreground: light-dark(
		var(--sggw-color-lime-45),
		var(--sggw-color-lime-60)
	);
	--sggw-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
	--sggw-module-default-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
}

:where(
	.has-sggw-sage-90-background-color,
	.has-sggw-surface-2-background-color,
	.sggw-surface-2,
	.sggw-surface-context-2
) {
	--sggw-surface-current: var(--sggw-surface-2);
	--sggw-surface-alternating: var(--sggw-surface-3);
	--sggw-module-default-surface: var(--sggw-surface-3);
	--sggw-module-default-alternating: var(--sggw-surface-2);
	--sggw-module-default-link-foreground: light-dark(
		var(--sggw-color-lime-40),
		var(--sggw-color-lime-60)
	);
	--sggw-link-foreground: light-dark(
		var(--sggw-color-lime-45),
		var(--sggw-color-lime-60)
	);
	--sggw-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
	--sggw-module-default-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
}

:where(
	.has-sggw-sage-85-background-color,
	.has-sggw-surface-3-background-color,
	.sggw-surface-3,
	.sggw-surface-context-3
) {
	--sggw-surface-current: var(--sggw-surface-3);
	--sggw-surface-alternating: var(--sggw-surface-2);
	--sggw-module-default-surface: var(--sggw-surface-2);
	--sggw-module-default-alternating: var(--sggw-surface-3);
	--sggw-module-default-link-foreground: light-dark(
		var(--sggw-color-lime-45),
		var(--sggw-color-lime-60)
	);
	--sggw-link-foreground: light-dark(
		var(--sggw-color-lime-40),
		var(--sggw-color-lime-60)
	);
	--sggw-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
	--sggw-module-default-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
}

/* Core Cover derives its polarity from media rather than the theme scheme. */
:where(.wp-block-cover.is-light) {
	color-scheme: light;
	--sggw-surface-current: var(--sggw-color-sage-97);
	--sggw-surface-alternating: var(--sggw-color-sage-93);
	--sggw-module-default-surface: var(--sggw-color-sage-93);
	--sggw-module-default-alternating: var(--sggw-color-sage-89);
	--sggw-module-default-link-foreground: var(--sggw-color-lime-45);
	--sggw-module-default-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
	--sggw-text-base: var(--sggw-color-sage-5);
	--sggw-text-muted-weight: 59%;
	--sggw-line-functional-weight: 47%;
	--sggw-line-decorative-weight: 25%;
	--sggw-button-background: var(--sggw-color-green-15);
	--sggw-button-foreground: var(--sggw-color-sage-95);
	--sggw-button-outline: var(--sggw-color-sage-10);
	--sggw-link-foreground: var(--sggw-color-lime-45);
	--sggw-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
}

/*
 * Core Cover owns the polarity decision for arbitrary overlay colors through
 * its native .is-light class. Use the retained brand-dark role as a fallback;
 * known green overlay presets receive their more precise level below.
 */
:where(.wp-block-cover:not(.is-light)) {
	color-scheme: dark;
	--sggw-surface-current: var(--sggw-accent-surface-1);
	--sggw-surface-alternating: var(--sggw-accent-surface-0);
	--sggw-module-default-surface: var(--sggw-accent-surface-0);
	--sggw-module-default-alternating: var(--sggw-accent-surface-1);
	--sggw-module-default-link-foreground: var(--sggw-color-lime-60);
	--sggw-module-default-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
	--sggw-text-base: var(--sggw-color-sage-100);
	--sggw-text-muted-weight: 79%;
	--sggw-line-functional-weight: 45%;
	--sggw-line-decorative-weight: 24%;
	--sggw-text: var(--sggw-color-sage-100);
	--sggw-text-muted: color-mix(in oklab, var(--sggw-color-sage-100) 79%, var(--sggw-surface-current));
	--sggw-line-functional: color-mix(in oklab, var(--sggw-text) 45%, var(--sggw-surface-current));
	--sggw-line-decorative: color-mix(in oklab, var(--sggw-text) 24%, var(--sggw-surface-current));
	--sggw-line: var(--sggw-line-functional);
	--sggw-button-background: var(--sggw-color-green-95);
	--sggw-button-foreground: var(--sggw-color-green-15);
	--sggw-button-outline: var(--sggw-color-sage-90);
	--sggw-link-foreground: var(--sggw-color-lime-60);
	--sggw-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
}

/* Accent surfaces retain their dark polarity but adapt one tonal step in dark
 * mode. Legacy Green 0/10 classes collapse into the retained semantic pair. */
:where(
	.has-sggw-green-0-background-color,
	.has-sggw-green-5-background-color,
	.has-sggw-green-10-background-color,
	.has-sggw-green-15-background-color,
	.is-sggw-dark-surface-level-0,
	.is-sggw-dark-surface-level-3,
	.sggw-surface-accent-0,
	.sggw-surface-accent-1,
	.sggw-surface-context-accent-0,
	.sggw-surface-context-accent-1
) {
	color-scheme: dark;
	--sggw-text-base: var(--sggw-color-sage-100);
	--sggw-text-muted-weight: 73%;
	--sggw-line-functional-weight: 47%;
	--sggw-line-decorative-weight: 29%;
	--sggw-button-background: var(--sggw-color-green-95);
	--sggw-button-foreground: var(--sggw-color-green-15);
	--sggw-button-outline: var(--sggw-color-sage-90);
	--sggw-link-foreground: var(--sggw-color-lime-60);
	--sggw-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
	--sggw-module-default-link-foreground: var(--sggw-color-lime-60);
	--sggw-module-default-inline-link-decoration-rest: var(--sggw-link-decoration-rest);
}

:where(
	.has-sggw-green-5-background-color,
	.has-sggw-green-0-background-color,
	.is-sggw-dark-surface-level-0,
	.sggw-surface-accent-0,
	.sggw-surface-context-accent-0
) {
	--sggw-surface-current: var(--sggw-accent-surface-0);
	--sggw-surface-alternating: var(--sggw-accent-surface-1);
	--sggw-module-default-surface: var(--sggw-accent-surface-1);
	--sggw-module-default-alternating: var(--sggw-accent-surface-0);
}

:where(
	.has-sggw-green-15-background-color,
	.has-sggw-green-10-background-color,
	.is-sggw-dark-surface-level-3,
	.sggw-surface-accent-1,
	.sggw-surface-context-accent-1
) {
	--sggw-surface-current: var(--sggw-accent-surface-1);
	--sggw-surface-alternating: var(--sggw-accent-surface-0);
	--sggw-module-default-surface: var(--sggw-accent-surface-0);
	--sggw-module-default-alternating: var(--sggw-accent-surface-1);
}

/* Rebind only the runtime variables changed by block variants and states. */
:where(
	:root,
	.editor-styles-wrapper,
	.wp-site-blocks,
	.wp-block-cover,
	.has-sggw-sage-100-background-color,
	.has-sggw-sage-95-background-color,
	.has-sggw-sage-90-background-color,
	.has-sggw-sage-85-background-color,
	.has-sggw-surface-0-background-color,
	.has-sggw-surface-1-background-color,
	.has-sggw-surface-2-background-color,
	.has-sggw-surface-3-background-color,
	.sggw-surface-0,
	.sggw-surface-1,
	.sggw-surface-2,
	.sggw-surface-3,
	.sggw-surface-context-0,
	.sggw-surface-context-1,
	.sggw-surface-context-2,
	.sggw-surface-context-3,
	.has-white-background-color:not(.wp-block-cover__background),
	.has-sggw-green-5-background-color,
	.has-sggw-green-15-background-color,
	.has-sggw-green-0-background-color,
	.has-sggw-green-10-background-color,
	.is-sggw-dark-surface-level-0,
	.is-sggw-dark-surface-level-3,
	.sggw-surface-accent-0,
	.sggw-surface-accent-1,
	.sggw-surface-context-accent-0,
	.sggw-surface-context-accent-1
) {
	--sggw-text: var(--sggw-text-base);
	--sggw-text-muted: color-mix(
		in oklab,
		var(--sggw-text-base) var(--sggw-text-muted-weight),
		var(--sggw-surface-current)
	);
	--sggw-line-focus: light-dark(
		var(--sggw-color-red-35),
		var(--sggw-color-red-70)
	);
	--sggw-line-functional: color-mix(
		in oklab,
		var(--sggw-text) var(--sggw-line-functional-weight),
		var(--sggw-surface-current)
	);
	--sggw-line-decorative: color-mix(
		in oklab,
		var(--sggw-text) var(--sggw-line-decorative-weight),
		var(--sggw-surface-current)
	);
	--sggw-line: var(--sggw-line-functional);

	/* Paint the resolved role; descendants such as Navigation may inherit it. */
	color: var(--sggw-text);

	/* Twenty Twenty-Four compatibility names. */
	--wp--preset--color--base: var(--sggw-surface-current);
	--wp--preset--color--base-2: var(--sggw-surface-alternating);
	--wp--preset--color--contrast: var(--sggw-text);
	--wp--preset--color--contrast-2: var(--sggw-text);
	--wp--preset--color--contrast-3: var(--sggw-text);

	/*
	 * Runtime variables overridden by block variants or interaction states.
	 * Static component recipes should reference the short --sggw-* roles
	 * directly and must not be added to this list.
	 */
	--wp--custom--component--button--background: var(--sggw-button-background);
	--wp--custom--component--button--background-hover: var(--sggw-button-background-hover);
	--wp--custom--component--button--background-pressed: var(--sggw-button-background);
	--wp--custom--component--button--foreground: var(--sggw-button-foreground);
	--wp--custom--component--button--foreground-hover: var(--sggw-button-foreground-hover);
	--wp--custom--component--button--outline--border: var(--sggw-button-outline);
	--wp--custom--component--button--outline--foreground: var(--sggw-button-outline);
	--wp--custom--component--cover--current-duotone-filter: none;
	--wp--custom--component--cover--current-image-filter: none;
	--wp--custom--component--cover--on-surface: var(--sggw-text);
	--wp--custom--component--form-control--background: transparent;
	--wp--custom--component--form-control--border-color: var(--sggw-line);
	--wp--custom--component--form-control--focus-color: var(--sggw-line-focus);
	--wp--custom--component--form-control--foreground: var(--sggw-text);
	--wp--custom--component--form-control--label-color: var(--sggw-text);
	--wp--custom--component--form-control--placeholder: var(--sggw-text-muted);
	--wp--custom--component--icon--color: var(--sggw-text);
	--wp--custom--component--navigation--background-hover: var(--sggw-surface-alternating);
	--wp--custom--component--navigation--background-pressed: var(--sggw-surface-alternating);
	--wp--custom--component--navigation--focus-color: var(--sggw-line-focus);
	--wp--custom--component--navigation--foreground: var(--sggw-text);
	--wp--custom--component--navigation--interaction-accent: var(--sggw-link-foreground);
	--wp--custom--component--navigation--local--item-background-active: var(--sggw-surface-alternating);
	--wp--custom--component--navigation--local--item-background-hover: var(--sggw-surface-alternating);
	--wp--custom--component--navigation--local--selected-accent-color: var(--sggw-button-background);
	--wp--custom--component--navigation--overlay--background: var(--sggw-surface-current);
	--wp--custom--component--navigation--overlay--foreground: var(--sggw-text);
	--wp--custom--component--navigation--panel--background: var(--sggw-surface-current);
	--wp--custom--component--navigation--panel--foreground: var(--sggw-text);
	--wp--custom--component--navigation--top-level--foreground: var(--sggw-text);
	--wp--custom--component--social-links--background: transparent;
	--wp--custom--component--social-links--background-hover: var(--sggw-surface-alternating);
	--wp--custom--component--social-links--background-pressed: var(--sggw-surface-alternating);
	--wp--custom--component--social-links--foreground: var(--sggw-text);
}

/* Paint semantic surfaces and reinterpret old Sage choices as adaptive aliases. */
.has-sggw-surface-0-background-color,
.has-sggw-sage-100-background-color,
.sggw-surface-0,
.has-white-background-color:not(.wp-block-cover__background) {
	background-color: var(--sggw-surface-0) !important;
}

.has-sggw-surface-1-background-color,
.has-sggw-sage-95-background-color,
.sggw-surface-1 {
	background-color: var(--sggw-surface-1) !important;
}

.has-sggw-surface-2-background-color,
.has-sggw-sage-90-background-color,
.sggw-surface-2 {
	background-color: var(--sggw-surface-2) !important;
}

.has-sggw-surface-3-background-color,
.has-sggw-sage-85-background-color,
.sggw-surface-3 {
	background-color: var(--sggw-surface-3) !important;
}

/* Explicit brand-dark surfaces remain inverse, but follow the active mode. */
.has-sggw-green-5-background-color { background-color: var(--sggw-accent-surface-0) !important; }
.has-sggw-green-15-background-color { background-color: var(--sggw-accent-surface-1) !important; }
.has-sggw-green-0-background-color { background-color: var(--sggw-accent-surface-0) !important; }
.has-sggw-green-10-background-color { background-color: var(--sggw-accent-surface-1) !important; }
.sggw-surface-accent-0 { background-color: var(--sggw-accent-surface-0) !important; }
.sggw-surface-accent-1 { background-color: var(--sggw-accent-surface-1) !important; }

/* Saved palette choices collapse into the active default semantic role. */
:where(
	.has-sggw-text-default-color,
	.has-sggw-text-accent-color,
	.has-sggw-sage-100-color,
	.has-sggw-sage-95-color,
	.has-sggw-sage-90-color,
	.has-sggw-sage-85-color,
	.has-sggw-green-5-color,
	.has-sggw-green-15-color,
	.has-sggw-surface-0-color,
	.has-sggw-surface-1-color,
	.has-sggw-surface-2-color,
	.has-sggw-surface-3-color,
	.has-sggw-green-0-color,
	.has-sggw-green-10-color
) {
	color: var(--sggw-text) !important;
}

/* Muted remains semantic and therefore follows every nested surface. */
.has-sggw-text-muted-color {
	color: var(--sggw-text-muted) !important;
}

/* Optional editorial accent reserved for the date or stage of a timeline. */
.has-sggw-timeline-date-accent-color {
	color: var(--sggw-timeline-date-accent) !important;
}

:where(
	.has-sggw-sage-100-border-color,
	.has-sggw-sage-95-border-color,
	.has-sggw-sage-90-border-color,
	.has-sggw-sage-85-border-color,
	.has-sggw-green-5-border-color,
	.has-sggw-green-15-border-color,
	.has-sggw-surface-0-border-color,
	.has-sggw-surface-1-border-color,
	.has-sggw-surface-2-border-color,
	.has-sggw-surface-3-border-color,
	.has-sggw-green-0-border-color,
	.has-sggw-green-10-border-color
) {
	border-color: var(--sggw-line-functional) !important;
}

/* Core blocks that put their visible text on descendants inherit the role. */
:where(
	.has-sggw-text-default-color,
	.has-sggw-text-muted-color,
	.has-sggw-text-accent-color
) :where(
	.wp-block-post-excerpt__excerpt,
	p,
	cite,
	table,
	th,
	td,
	figcaption,
	a,
	.wp-block-search__label,
	.wp-block-search__input,
	.wp-block-post-terms__prefix,
	.wp-block-post-terms__separator
) {
	color: inherit;
}

@media (forced-colors: active) {
	:where(
		:root,
		.editor-styles-wrapper,
		.wp-site-blocks,
		.wp-block-cover,
		.has-background,
		.is-sggw-dark-surface-level-0,
		.is-sggw-dark-surface-level-3
	) {
		--sggw-link-decoration-rest: underline;
		--sggw-inline-link-decoration-rest: underline;
		--sggw-link-foreground: LinkText;
		--sggw-module-default-inline-link-decoration-rest: underline;
		--sggw-module-default-link-foreground: LinkText;
	}

	:where(
		.has-sggw-text-default-color,
		.has-sggw-text-muted-color,
		.has-sggw-text-accent-color,
		.has-sggw-timeline-date-accent-color
	) {
		color: CanvasText !important;
	}
}
