/* Site-wide theme palettes — admin-selected via the "Davimo Theme" settings
 * page (includes/theme/class-davimo-theme.php), output server-side as
 * data-theme="..." on <html> (language_attributes filter) so every visitor
 * gets the same theme with no flash-of-wrong-theme. Only 2 admin themes:
 * default and sage (terracotta and an admin-controlled "dark" were both
 * removed — see the note below the sage block).
 *
 * This file is also the single source of truth for the visitor-controlled
 * dark mode OVERRIDE (the [data-visitor-mode="dark"] block at the bottom),
 * which is independent of and takes precedence over whichever [data-theme]
 * is active — see includes/visitor-mode/class-davimo-visitor-mode.php for
 * how data-visitor-mode gets onto <html> (client-side, no-flash inline
 * script + localStorage, NOT this file's admin data-theme mechanism).
 *
 * Must be enqueued BEFORE cart-drawer.css (which still owns the theme-
 * INDEPENDENT tokens: radius, spacing, type scale, --davimo-rose-light,
 * --davimo-crosssell-thumb-size) so cart-drawer.css's bare :root block can
 * no longer redefine the 9 theme-dependent tokens below — that would
 * silently win the cascade (equal specificity, later source) and make
 * every theme but "default" render dead. If a 3rd admin theme is ever
 * added, define all 9 tokens here — partial palettes leave earlier CSS
 * reading `undefined`.
 *
 * --davimo-surface is a card/panel background distinct from the page body
 * background (--davimo-offwhite) — default/sage keep it plain white since
 * product photography (white product-image boxes) reads correctly against
 * any light page background; only the dark-mode override actually
 * diverges. Any CSS with a hardcoded white content-panel background should
 * route through var(--davimo-surface, #fff), not a literal #fff.
 *
 * --davimo-on-clay is the text color paired with a var(--davimo-clay)
 * background (the sitewide button/CTA fill, see product-page.css /
 * cart-drawer.css / home.css / header.css) — kept as its own token rather
 * than reusing --davimo-offwhite directly so it can stay stable if
 * --davimo-offwhite's role/value ever changes for an unrelated reason.
 *
 * Contrast ratios below are computed WCAG 2.1 relative-luminance contrast,
 * not eyeballed.
 */

[data-theme="default"] {
	--davimo-green: #1B2624;
	--davimo-offwhite: #EAE7E1;
	--davimo-rose: #BC8F8F;
	--davimo-mist: #E3E0DF;
	--davimo-clay: #9C5233;
	--davimo-gold: #B08D57;
	--davimo-text-primary: #1B2624;
	--davimo-text-secondary: #5C6B65;
	--davimo-surface: #FFFFFF;
	--davimo-on-clay: #EAE7E1; /* 4.64:1 vs --davimo-clay — clears AA */
}

[data-theme="sage"] {
	--davimo-green: #2C3B34;
	--davimo-offwhite: #EDEFE9;
	/* Decorative only — 3.76:1 against --davimo-offwhite, fails 4.5:1 AA
	   text minimum. Safe for backgrounds/fills (cart badge, buttons paired
	   with a dark text color already routed through --davimo-green), not
	   safe as this theme's *text* color anywhere --davimo-rose is used as
	   `color` (e.g. .davimo-pdp__tier-save, .star-rating) — those specific
	   spots stay under-contrast on this theme, flagged, not silently fixed
	   here since the fix is a component-level accent swap, not a token
	   value change. */
	--davimo-rose: #6B7F5D;
	--davimo-mist: #DCE3D8;
	/* Clay is the one constant accent across every light theme — 4.94:1
	   here, clears AA. */
	--davimo-clay: #9C5233;
	--davimo-gold: #B08D57;
	--davimo-text-primary: #2C3B34;
	--davimo-text-secondary: #5F6E63; /* 4.65:1 vs --davimo-offwhite */
	--davimo-surface: #FFFFFF;
	--davimo-on-clay: #EAE7E1; /* clay is unchanged (#9C5233) on sage too — 4.64:1, same pairing as default */
}

/* Terracotta and the admin "Dark Mode" theme (formerly here) were both
   removed — Terracotta was never adopted, and Dark Mode was rebuilt as a
   visitor-controlled, admin-independent layer instead (see the
   [data-visitor-mode="dark"] override block below, and
   includes/visitor-mode/class-davimo-visitor-mode.php). Only 2 admin
   themes remain: default and sage. */

/* Visitor-controlled dark mode — independent of and takes precedence over
 * whichever [data-theme] (default/sage) is active, per data-visitor-mode
 * on <html> (see class-davimo-visitor-mode.php). Placed last in source
 * order so it wins the cascade over both [data-theme="default"] and
 * [data-theme="sage"] regardless of which is also present on <html> at
 * the same time (equal specificity across all three selectors — a single
 * attribute selector each — so source order decides).
 *
 * --davimo-green / --davimo-offwhite invert roles here rather than just
 * changing value, matching every existing consumer's pairing convention
 * (background:var(--davimo-green) + color:var(--davimo-offwhite) for
 * buttons/badges, or plain color:var(--davimo-green) against a page
 * background of var(--davimo-offwhite) for body text) — confirmed via a
 * full grep of every var(--davimo-green) use before choosing this, not
 * assumed. Swapping both consistently keeps every pairing at the same
 * contrast, just flipped light-on-dark instead of dark-on-light.
 */
[data-visitor-mode="dark"] {
	--davimo-green: #EAE7E1;
	--davimo-offwhite: #14201D;
	--davimo-surface: #1F2B27; /* card/section bg, one step up from page bg */
	--davimo-mist: #1F2B27; /* same value as surface — no separate mist tone needed once the base page bg is already dark */
	--davimo-rose: #C9A0A0; /* 7.19:1 vs --davimo-offwhite */
	--davimo-clay: #C97A4E;
	--davimo-gold: #B08D57; /* 4.74:1 vs --davimo-surface — unchanged, already designed for a dark badge background */
	--davimo-text-primary: #EAE7E1;
	--davimo-text-secondary: #9FAFA8; /* 7.31:1 vs --davimo-offwhite */
	/* Text-on-clay pairing: #14201D (== this override's own --davimo-offwhite
	   value) verified 5.09:1 against clay #C97A4E — clears AA. The light
	   themes' #EAE7E1 fails here (2.67:1), confirmed by direct calculation,
	   not assumed from the default/sage value. */
	--davimo-on-clay: #14201D;
}
