/*
 * Surface color schemes (shared)
 *
 * CSS variable overrides for surface style variations (Style 2 through Style 6).
 * Used by kindling/section, core/group, and kindling/card. Loaded globally on
 * every page and in the editor (GLOBAL_STYLESHEETS in functions.php), so the
 * schemes apply wherever a surface style is used.
 *
 * @package Kindling
 * @since 1.0.0
 *
 * Note: Default surface colors (the page ground, theme-01) are defined in theme.json.
 *
 * Every surface redeclares the full set of semantic tokens, not just the ones
 * that differ from the page default. Custom properties inherit, so a light card
 * (Style 2 or 3) nested in a dark section (Style 4) would otherwise keep the dark
 * section's inverse text, on-dark buttons and focus color.
 *
 * Tokens that theme.json defines as pointers to other tokens (for example the
 * external-link button, which mirrors the primary fill) are re-pointed here as
 * well. A custom property resolves its var() references on the element that
 * declares it, so a pointer declared on :root would keep the root values.
 *
 * Focus color is surface aware. The global link and button `:focus-visible`
 * outlines in theme.json reference `--wp--custom--color--focus`, so the ring
 * follows the surface automatically. Accent teal (theme-14) is the brand focus
 * color but only clears WCAG 2.1 non-text contrast on the dark grounds
 * (5.8:1 on theme-03, 4.4:1 on theme-12); light grounds use the text-safe teal
 * (theme-13, 3.5:1 or better), and the accent ground uses theme-03 (5.8:1).
 */

/*
 * Light surface base (Style 2, Style 3 and Style 6).
 */
.is-style-style-2,
.is-style-style-3,
.is-style-style-6 {
	--wp--custom--color--border: var(--wp--preset--color--theme-09);
	--wp--custom--color--caption: var(--wp--preset--color--theme-07);
	--wp--custom--color--focus: var(--wp--preset--color--theme-13);
	--wp--custom--color--text--body: var(
		--wp--custom--color--text--body-on-light-surface
	);
	--wp--custom--color--text--body-large: var(--wp--preset--color--theme-03);
	--wp--custom--color--text--heading: var(--wp--preset--color--theme-03);
	--wp--custom--color--text--subheading: var(--wp--preset--color--theme-13);
	--wp--custom--color--text--link: var(--wp--preset--color--theme-03);
	--wp--custom--color--text--link-hover: var(--wp--preset--color--theme-13);
	--wp--custom--color--text--link-underline: var(--wp--preset--color--theme-14);
	--wp--custom--color--icon--fill: var(--wp--preset--color--theme-03);
	--wp--custom--color--icon--stroke: var(--wp--preset--color--theme-03);
	--wp--custom--color--icon--hover--fill: var(--wp--preset--color--theme-06);
	--wp--custom--color--icon--hover--stroke: var(--wp--preset--color--theme-06);

	/* Primary action: theme-03 fill, theme-06 hover, theme-08 pressed. */
	--wp--custom--color--button--fill--background: var(--wp--preset--color--theme-03);
	--wp--custom--color--button--fill--border: var(--wp--preset--color--theme-03);
	--wp--custom--color--button--fill--icon: var(--wp--preset--color--theme-01);
	--wp--custom--color--button--fill--text: var(--wp--preset--color--theme-01);
	--wp--custom--color--button--fill--hover--background: var(--wp--preset--color--theme-06);
	--wp--custom--color--button--fill--hover--border: var(--wp--preset--color--theme-06);
	--wp--custom--color--button--fill--hover--icon: var(--wp--preset--color--theme-01);
	--wp--custom--color--button--fill--hover--text: var(--wp--preset--color--theme-01);
	--wp--custom--color--button--fill--active--background: var(--wp--preset--color--theme-08);
	--wp--custom--color--button--fill--active--border: var(--wp--preset--color--theme-08);
	--wp--custom--color--button--fill--active--text: var(--wp--preset--color--theme-01);

	--wp--custom--color--button--outline--background: transparent;
	--wp--custom--color--button--outline--border: var(--wp--preset--color--theme-03);
	--wp--custom--color--button--outline--text: var(--wp--preset--color--theme-03);
	--wp--custom--color--button--outline--hover--background: transparent;
	--wp--custom--color--button--outline--hover--border: var(--wp--preset--color--theme-06);
	--wp--custom--color--button--outline--hover--text: var(--wp--preset--color--theme-06);

	--wp--custom--color--button--fill-light--background: var(--wp--preset--color--theme-09);
	--wp--custom--color--button--fill-light--text: var(--wp--preset--color--theme-03);
	--wp--custom--color--button--fill-light--hover--background: var(--wp--preset--color--theme-01);
	--wp--custom--color--button--fill-light--hover--text: var(--wp--preset--color--theme-03);

	--wp--custom--color--button--tertiary--icon: var(--wp--preset--color--theme-03);
	--wp--custom--color--button--tertiary--text: var(--wp--preset--color--theme-03);
	--wp--custom--color--button--tertiary--hover--icon: var(--wp--preset--color--theme-13);
	--wp--custom--color--button--tertiary--hover--text: var(--wp--preset--color--theme-13);
}

/*
 * Dark surface base (Style 4 and Style 5).
 *
 * The primary action flips to theme-04 with navy text; hover lightens to
 * theme-11 and pressed darkens to theme-05. Outline buttons and link rules use
 * the inverse color.
 */
.is-style-style-4,
.is-style-style-5 {
	--wp--custom--color--border: color-mix(
		in srgb,
		var(--wp--preset--color--theme-01) 20%,
		transparent
	);
	--wp--custom--color--caption: var(--wp--preset--color--theme-18);
	--wp--custom--color--focus: var(--wp--preset--color--theme-14);
	--wp--custom--color--text--body: var(
		--wp--custom--color--text--body-on-dark-surface
	);
	--wp--custom--color--text--body-large: var(
		--wp--custom--color--text--body-on-dark-surface
	);
	--wp--custom--color--text--heading: var(
		--wp--custom--color--text--body-on-dark-surface
	);
	--wp--custom--color--text--subheading: var(--wp--preset--color--theme-04);
	--wp--custom--color--text--link: var(
		--wp--custom--color--text--link-on-dark-surface
	);
	--wp--custom--color--text--link-hover: var(--wp--preset--color--theme-14);
	--wp--custom--color--text--link-underline: var(--wp--preset--color--theme-14);
	--wp--custom--color--icon--fill: var(
		--wp--custom--color--text--body-on-dark-surface
	);
	--wp--custom--color--icon--stroke: var(
		--wp--custom--color--text--body-on-dark-surface
	);
	--wp--custom--color--icon--hover--fill: var(--wp--preset--color--theme-14);
	--wp--custom--color--icon--hover--stroke: var(--wp--preset--color--theme-14);

	--wp--custom--color--button--fill--background: var(--wp--preset--color--theme-04);
	--wp--custom--color--button--fill--border: var(--wp--preset--color--theme-05);
	--wp--custom--color--button--fill--icon: var(--wp--preset--color--theme-03);
	--wp--custom--color--button--fill--text: var(--wp--preset--color--theme-03);
	--wp--custom--color--button--fill--hover--background: var(--wp--preset--color--theme-11);
	--wp--custom--color--button--fill--hover--border: var(--wp--preset--color--theme-11);
	--wp--custom--color--button--fill--hover--icon: var(--wp--preset--color--theme-03);
	--wp--custom--color--button--fill--hover--text: var(--wp--preset--color--theme-03);
	--wp--custom--color--button--fill--active--background: var(--wp--preset--color--theme-05);
	--wp--custom--color--button--fill--active--border: var(--wp--preset--color--theme-05);
	--wp--custom--color--button--fill--active--text: var(--wp--preset--color--theme-03);

	--wp--custom--color--button--outline--background: transparent;
	--wp--custom--color--button--outline--border: var(
		--wp--custom--color--text--body-on-dark-surface
	);
	--wp--custom--color--button--outline--text: var(
		--wp--custom--color--text--body-on-dark-surface
	);
	--wp--custom--color--button--outline--hover--background: color-mix(
		in srgb,
		var(--wp--preset--color--theme-01) 20%,
		transparent
	);
	--wp--custom--color--button--outline--hover--border: var(
		--wp--custom--color--text--body-on-dark-surface
	);
	--wp--custom--color--button--outline--hover--text: var(
		--wp--custom--color--text--body-on-dark-surface
	);

	--wp--custom--color--button--fill-light--background: var(--wp--preset--color--theme-09);
	--wp--custom--color--button--fill-light--text: var(--wp--preset--color--theme-03);
	--wp--custom--color--button--fill-light--hover--background: var(--wp--preset--color--theme-01);
	--wp--custom--color--button--fill-light--hover--text: var(--wp--preset--color--theme-03);

	--wp--custom--color--button--tertiary--icon: var(
		--wp--custom--color--text--body-on-dark-surface
	);
	--wp--custom--color--button--tertiary--text: var(
		--wp--custom--color--text--body-on-dark-surface
	);
	--wp--custom--color--button--tertiary--hover--icon: var(--wp--preset--color--theme-14);
	--wp--custom--color--button--tertiary--hover--text: var(--wp--preset--color--theme-14);
}

/*
 * Pointer tokens re-resolved per surface.
 *
 * The external-link button mirrors the surface's primary action. The Separator
 * block's line (theme-23 on the page ground) follows each surface's border,
 * since theme-23 would disappear on Mist and glare on the dark grounds.
 */
.is-style-style-2,
.is-style-style-3,
.is-style-style-4,
.is-style-style-5,
.is-style-style-6 {
	--wp--custom--color--separator: var(--wp--custom--color--border);
	--wp--custom--color--button--external-link--background: var(
		--wp--custom--color--button--fill--background
	);
	--wp--custom--color--button--external-link--text: var(
		--wp--custom--color--button--fill--text
	);
	--wp--custom--color--button--external-link--icon: var(
		--wp--custom--color--button--fill--icon
	);
	--wp--custom--color--button--external-link--hover--background: var(
		--wp--custom--color--button--fill--hover--background
	);
	--wp--custom--color--button--external-link--hover--text: var(
		--wp--custom--color--button--fill--hover--text
	);
	--wp--custom--color--button--external-link--hover--icon: var(
		--wp--custom--color--button--fill--hover--icon
	);
}

/*
 * Style 2: subtle light section (Mist, theme-09)
 *
 * CSS variable overrides for `kindling/styles/surfaces/style-2.json`.
 * The ground matches the default border and light fill, so both step up.
 */
.is-style-style-2 {
	--wp--custom--color--background: var(--wp--preset--color--theme-09);
	--wp--custom--color--border: var(--wp--preset--color--theme-18);
	--wp--custom--color--button--fill-light--background: var(--wp--preset--color--theme-01);
	--wp--custom--color--button--fill-light--hover--background: var(--wp--preset--color--theme-10);
}

/*
 * Style 3: warm light section (Cream, theme-10)
 *
 * CSS variable overrides for `kindling/styles/surfaces/style-3.json`.
 */
.is-style-style-3 {
	--wp--custom--color--background: var(--wp--preset--color--theme-10);
}

/*
 * Style 4: primary dark section (Navy, theme-03)
 *
 * CSS variable overrides for `kindling/styles/surfaces/style-4.json`.
 */
.is-style-style-4 {
	--wp--custom--color--background: var(--wp--preset--color--theme-03);
}

/*
 * Style 5: secondary dark section (Forest, theme-12)
 *
 * CSS variable overrides for `kindling/styles/surfaces/style-5.json`.
 * Type sits in the cream tone (theme-10) rather than pure white.
 */
.is-style-style-5 {
	--wp--custom--color--background: var(--wp--preset--color--theme-12);
	--wp--custom--color--caption: color-mix(
		in srgb,
		var(--wp--preset--color--theme-10) 75%,
		transparent
	);
	--wp--custom--color--text--body: var(--wp--preset--color--theme-10);
	--wp--custom--color--text--body-large: var(--wp--preset--color--theme-10);
	--wp--custom--color--text--heading: var(--wp--preset--color--theme-10);
	--wp--custom--color--text--link: var(--wp--preset--color--theme-10);
	--wp--custom--color--icon--fill: var(--wp--preset--color--theme-10);
	--wp--custom--color--icon--stroke: var(--wp--preset--color--theme-10);
	--wp--custom--color--button--outline--border: var(--wp--preset--color--theme-10);
	--wp--custom--color--button--outline--text: var(--wp--preset--color--theme-10);
	--wp--custom--color--button--outline--hover--border: var(--wp--preset--color--theme-10);
	--wp--custom--color--button--outline--hover--text: var(--wp--preset--color--theme-10);
	--wp--custom--color--button--tertiary--icon: var(--wp--preset--color--theme-10);
	--wp--custom--color--button--tertiary--text: var(--wp--preset--color--theme-10);
}

/*
 * Style 6: accent section (Teal, theme-14)
 *
 * CSS variable overrides for `kindling/styles/surfaces/style-6.json`.
 * Heading-colored type only: every text, link, icon and focus token is
 * theme-03 (5.8:1), with theme-08 for hover so it stays readable on the ground.
 */
.is-style-style-6 {
	--wp--custom--color--background: var(--wp--preset--color--theme-14);
	--wp--custom--color--border: color-mix(
		in srgb,
		var(--wp--preset--color--theme-03) 25%,
		transparent
	);
	--wp--custom--color--caption: var(--wp--preset--color--theme-03);
	--wp--custom--color--focus: var(--wp--preset--color--theme-03);
	--wp--custom--color--text--body: var(--wp--preset--color--theme-03);
	--wp--custom--color--text--subheading: var(--wp--preset--color--theme-03);
	--wp--custom--color--text--link-hover: var(--wp--preset--color--theme-08);
	--wp--custom--color--text--link-underline: var(--wp--preset--color--theme-03);
	--wp--custom--color--icon--hover--fill: var(--wp--preset--color--theme-08);
	--wp--custom--color--icon--hover--stroke: var(--wp--preset--color--theme-08);
	--wp--custom--color--button--outline--hover--border: var(--wp--preset--color--theme-08);
	--wp--custom--color--button--outline--hover--text: var(--wp--preset--color--theme-08);
	--wp--custom--color--button--tertiary--hover--icon: var(--wp--preset--color--theme-08);
	--wp--custom--color--button--tertiary--hover--text: var(--wp--preset--color--theme-08);
}
