/**
 * Theme colour bridge.
 *
 * A store owner sets their brand colour once, at theme level, and expects every plugin to
 * follow it. These custom properties are the single place this plugin reads colour from -
 * style rules use `var(--wcdp-*)` and never a literal.
 *
 * Why each chain tries several names: Reign and BuddyX both ship full token systems, but
 * they are DIFFERENT VOCABULARIES. Reign defines no `--bx-*` tokens and BuddyX defines no
 * `--reign-*` tokens, so a bridge that knows only one of them silently falls through to the
 * literal on the other. Verified on a Reign install: every `--reign-*` token below resolves
 * and no `--bx-color-*` token does.
 *
 * The preset slugs differ too. Reign's accent preset is `primary`; BuddyX's is `accent`. So
 * `var(--wp--preset--color--primary)` alone resolves to nothing on BuddyX - both slugs are
 * tried before the literal.
 *
 * Order per chain: BuddyX token, Reign token, both preset slugs, then a literal that is only
 * ever reached on a theme with no token system at all.
 *
 * @package Woo_Document_Preview
 * @since   1.6.2
 */

:root,
.wcdp-preview-container,
.wcdp-pro-preview-container {
	/* Brand accent - buttons, focus rings, active states. */
	--wcdp-accent: var(--bx-color-accent,
		var(--reign-accent-color,
		var(--wp--preset--color--primary,
		var(--wp--preset--color--accent, #0073aa))));

	/* Text that sits ON the accent. Themes rarely expose this, so it is derived. */
	--wcdp-on-accent: var(--bx-color-button-fg,
		var(--reign-site-button-text-color, #fff));

	/* Page background. */
	--wcdp-surface: var(--bx-color-bg-page,
		var(--reign-site-body-bg-color,
		var(--wp--preset--color--base, #fff)));

	/* Raised surface - cards, panels sitting on the page background. */
	--wcdp-surface-raised: var(--bx-color-bg-elevated,
		var(--reign-site-sections-bg-color, #fff));

	/* Body text. */
	--wcdp-text: var(--bx-color-text,
		var(--reign-site-body-text-color,
		var(--wp--preset--color--contrast, #1d2327)));

	/* Secondary text - captions, help text. */
	--wcdp-text-muted: var(--bx-color-fg-muted,
		var(--reign-site-alternate-text-color, #646970));

	/* Headings. */
	--wcdp-heading: var(--bx-color-heading,
		var(--reign-site-headings-color, var(--wcdp-text)));

	/* Borders and rules. */
	--wcdp-border: var(--bx-color-border,
		var(--reign-site-border-color, #dcdcde));

	/* Links. */
	--wcdp-link: var(--bx-color-link,
		var(--reign-site-link-color, var(--wcdp-accent)));

	/*
	 * Status colours. These are SEMANTIC, not brand: an error must read as an error even on
	 * a store whose brand colour is red. Reign exposes them; BuddyX does not, so the literal
	 * is the common path rather than a last resort.
	 */
	--wcdp-success: var(--reign-color-success, #007017);
	--wcdp-error: var(--reign-color-error, #b32d2e);
}

/*
 * Dark mode is driven by the THEME, not by this plugin. Reign and BuddyX both flip their
 * tokens on their own selector, so bridging the tokens means dark mode already works and
 * this plugin must not add a competing switch - a plugin that pins its own dark palette
 * fights the theme it is supposed to follow.
 *
 * The one thing worth stating explicitly: on a theme with NO token system, the literals
 * above are light. Follow the OS there rather than staying light on a dark desktop.
 */
@media (prefers-color-scheme: dark) {
	:root:not([data-bx-mode="light"]):not([data-theme="light"]) {
		--wcdp-surface: var(--bx-color-bg-page,
			var(--reign-site-body-bg-color,
			var(--wp--preset--color--base, #16171a)));

		--wcdp-surface-raised: var(--bx-color-bg-elevated,
			var(--reign-site-sections-bg-color, #1d1f22));

		--wcdp-text: var(--bx-color-text,
			var(--reign-site-body-text-color,
			var(--wp--preset--color--contrast, #ecede8)));

		--wcdp-text-muted: var(--bx-color-fg-muted,
			var(--reign-site-alternate-text-color, #8c8f88));

		--wcdp-border: var(--bx-color-border,
			var(--reign-site-border-color, #34373b));
	}
}

/*
 * File-format colours.
 *
 * These identify the FORMAT, not the store - a shopper reads Word blue as "this is a Word
 * document", and following the theme accent would make every format look identical. They
 * are tokens rather than literals so a store owner who wants them on-brand can override
 * them from the theme, while the defaults stay the colours people recognise. That also
 * leaves the stylesheet with no raw hex islands, which is what the presentation floor asks
 * for.
 */
:root {
	--wcdp-format-pdf: #c82333;
	--wcdp-format-doc: #2b579a;
	--wcdp-format-doc-dark: #1e4176;
	--wcdp-format-xls: #217346;
	--wcdp-format-xls-dark: #185c37;
	--wcdp-format-ppt: #d24726;
	--wcdp-format-ppt-dark: #b23a1f;
	--wcdp-format-txt: #5a6268;
}
