/*
 * Runtime colour modes.
 *
 * Light is the default (theme.json + light.json). Dark mode is a per-user
 * runtime toggle, so we override the preset CSS custom properties under
 * [data-theme="dark"] rather than relying on the editor style variation
 * (which is a global admin choice, not per-visitor).
 *
 * <html data-theme="..."> is stamped before paint from localStorage, so the
 * correct palette appears without a flash. The plugin toggle flips the
 * attribute and persists the same value.
 *
 * SINGLE SOURCE OF TRUTH for the *runtime* dark palette is the block below.
 * Light values live in theme.json. Whole-site style variations are not part of
 * the runtime color-mode contract.
 */

/* `:root[...]` (0,2,0) not `[...]` (0,1,0): WP now prints a late
   `global-styles-css-custom-properties-inline-css` that re-declares every
   --wp--preset--color--* on :root AFTER this file loads. At equal specificity
   the later source wins, so a plain [data-theme="dark"] selector was clobbered
   back to the light palette and the toggle did nothing. The :root qualifier
   outranks :root alone, so the dark palette wins regardless of load order. */
:root[data-theme="dark"] {
	--wp--preset--color--base: #0a0a0a;
	--wp--preset--color--surface: #171717;
	--wp--preset--color--surface-raised: #1c1c1c;
	--wp--preset--color--border: #262626;
	--wp--preset--color--contrast: #fafafa;
	--wp--preset--color--contrast-secondary: #a3a3a3;
	--wp--preset--color--contrast-tertiary: #8a8a8a;

	/* Brand tokens DERIVE from the configured brand (BrandingStore →
	   --wp--custom--brand--* via theme.json), lightened for dark surfaces.
	   We can't self-reference the preset (circular), so we mix the base custom
	   var — same pattern as the category accent below. Mix amounts are tuned to
	   the previous hand-picked dark values (brand ≈ #ff4338, hover ≈ #ff5c52,
	   accent ≈ #7aa7ff); hex fallbacks keep an old/unstyled cache rendering. */
	--wp--preset--color--brand: color-mix(in oklch, var(--wp--custom--brand--base, #ff3b30) 90%, #fff);
	--wp--preset--color--brand-hover: color-mix(in oklch, var(--wp--custom--brand--hover, #d92c22) 72%, #fff);
	--wp--preset--color--accent: color-mix(in oklch, var(--wp--custom--brand--accent, #1a73e8) 62%, #fff);
	--wp--preset--color--on-brand: #fff;

	/* Sidebar token family (shadcn Sidebar). Dark sidebar reads as its own plane —
	   #131313 sits between base #0a0a0a and surface-raised #1c1c1c. */
	--wp--preset--color--sidebar: #131313;
	--wp--preset--color--sidebar-foreground: #a3a3a3;
	--wp--preset--color--sidebar-accent: #262626;
	--wp--preset--color--sidebar-accent-foreground: #fafafa;
	--wp--preset--color--sidebar-border: #262626;
	--wp--preset--color--sidebar-primary: color-mix(in oklch, var(--wp--custom--brand--base, #ff3b30) 90%, #fff);
	--wp--preset--color--sidebar-primary-foreground: #fff;
	--wp--preset--color--sidebar-ring: color-mix(in oklch, var(--wp--custom--brand--accent, #1a73e8) 62%, #fff);

	--wp--preset--shadow--sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
	--wp--preset--shadow--md: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.4);
	--wp--preset--shadow--lg: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.5);

	color-scheme: dark;
}

:root[data-theme="light"] {
	color-scheme: light;
}

/* Arm a short property fade only after the first user toggle. This avoids
   first-paint animation and full-document snapshot work on large pages. */
html.minami-mode-ready,
html.minami-mode-ready body,
html.minami-mode-ready .minami-card,
html.minami-mode-ready .wp-block-template-part {
	transition:
		background-color var(--minami-dur-short, 150ms),
		border-color var(--minami-dur-short, 150ms),
		color var(--minami-dur-short, 150ms);
}

/* …but keep the card's hover lift/scale + shadow easing — this colour-mode rule
   otherwise replaces the base .minami-card transition (higher specificity) and
   makes the hover transform snap. Re-add the spatial transitions for cards. */
html.minami-mode-ready .minami-card {
	transition:
		background-color var(--minami-dur-short, 150ms),
		border-color var(--minami-dur-short) var(--minami-ease-emphasized),
		color var(--minami-dur-short, 150ms),
		box-shadow var(--minami-dur-short) var(--minami-ease-emphasized),
		transform var(--minami-dur-medium) var(--minami-ease-spring);
}
