/**
 * BuddyPress Check-ins Pro — frontend design tokens (Layer 2).
 *
 * The single source of truth for colour / spacing / radius / shadow / type on
 * the customer-facing surfaces. Mirrors the admin token set (--bpchkpro-admin-*)
 * but on the frontend prefix --bpchkpro-* and with theme.json fallbacks, so the
 * plugin adopts the host theme's brand + dark mode automatically and only falls
 * back to the Wbcom palette when the theme exposes nothing.
 *
 * Three-layer model (ux-foundation): component CSS reads these Layer-2 tokens;
 * each token chains to the theme's Layer-1 (--wp--preset--*) with a hard hex
 * fallback. Never put raw hex / px in component CSS — add or read a token here.
 *
 * @since 2.4.0
 */

:root,
.bpchkpro-app,
.bpchkpro-member-settings {
	/* Accent (links, primary action, focus ring, active toggle).
	   Each token chains through the active theme's own design tokens —
	   BuddyX / BuddyX Pro (--bx-color-*) then Reign (--reign-*) then the
	   generic WordPress preset, then a Wbcom hex fallback. Only one theme is
	   active at a time, so the undefined themes' vars fall through cleanly. */
	--bpchkpro-accent:        var( --bx-color-accent, var( --reign-colors-theme, var( --wp--preset--color--primary, #2563eb ) ) );
	--bpchkpro-accent-hover:  var( --bx-color-link-hover, var( --reign-site-link-hover-color, var( --wp--preset--color--primary-dark, #1d4ed8 ) ) );
	--bpchkpro-accent-soft:   #eff6ff;
	--bpchkpro-on-accent:     var( --reign-site-button-text-color, #ffffff );

	/* Check-in brand gradient — the plugin's distinctive purple -> pink fill on
	   the check-in button / marker accents. Kept as a brand identity (not
	   theme-derived) but tokenised so a site can override it in one place. */
	--bpchkpro-brand-from:     #673ab7;
	--bpchkpro-brand-to:       #e91e63;
	--bpchkpro-brand-gradient: linear-gradient( to left, var( --bpchkpro-brand-from ), var( --bpchkpro-brand-to ) );

	/* Text. */
	--bpchkpro-text:          var( --bx-color-fg, var( --reign-site-body-text-color, var( --wp--preset--color--contrast, #1e293b ) ) );
	--bpchkpro-text-muted:    var( --bx-color-fg-muted, var( --reign-site-alternate-text-color, #64748b ) );
	--bpchkpro-text-faint:    var( --bx-color-fg-muted, #94a3b8 );

	/* Surfaces + borders. */
	--bpchkpro-surface:       var( --bx-color-bg-elevated, var( --reign-site-sections-bg-color, var( --wp--preset--color--base, #ffffff ) ) );
	--bpchkpro-surface-alt:   var( --bx-color-bg-subtle, var( --reign-site-secondary-bg-color, #f8fafc ) );
	--bpchkpro-surface-hover: var( --bx-color-bg-muted, var( --reign-site-secondary-bg-color, #f1f5f9 ) );
	--bpchkpro-border:        var( --bx-color-border, var( --reign-site-border-color, #e2e8f0 ) );
	--bpchkpro-border-strong: var( --bx-color-divider, var( --reign-site-border-color, #cbd5e1 ) );

	/* Semantic status (shared with admin set). */
	--bpchkpro-success:       #16a34a;
	--bpchkpro-success-soft:  #dcfce7;
	--bpchkpro-warn:          #b45309;
	--bpchkpro-warn-soft:     #fef9c3;
	--bpchkpro-danger:        var( --bx-color-error, #dc2626 );
	--bpchkpro-danger-soft:   #fee2e2;
	--bpchkpro-info:          #2563eb;
	--bpchkpro-info-soft:     #dbeafe;

	/* Spacing scale. */
	--bpchkpro-space-xs:      4px;
	--bpchkpro-space-sm:      8px;
	--bpchkpro-space-md:      12px;
	--bpchkpro-space-lg:      16px;
	--bpchkpro-space-xl:      20px;
	--bpchkpro-space-2xl:     24px;
	--bpchkpro-space-3xl:     32px;
	--bpchkpro-space-4xl:     48px;

	/* Radius. */
	--bpchkpro-radius-sm:     6px;
	--bpchkpro-radius:        8px;
	--bpchkpro-radius-lg:     12px;
	--bpchkpro-radius-full:   9999px;

	/* Shadow. */
	--bpchkpro-shadow:        0 1px 3px rgba( 0, 0, 0, 0.06 ), 0 1px 2px rgba( 0, 0, 0, 0.04 );
	--bpchkpro-shadow-hover:  0 4px 6px rgba( 0, 0, 0, 0.07 ), 0 2px 4px rgba( 0, 0, 0, 0.04 );

	/* Typography (family always inherits the theme). */
	--bpchkpro-text-xs:       12px;
	--bpchkpro-text-sm:       13px;
	--bpchkpro-text-base:     14px;
	--bpchkpro-text-md:       15px;
	--bpchkpro-text-lg:       18px;
	--bpchkpro-text-xl:       20px;
	--bpchkpro-font-medium:   500;
	--bpchkpro-font-semibold: 600;
	--bpchkpro-font-bold:     700;
	--bpchkpro-leading-tight: 1.25;
	--bpchkpro-leading:       1.5;

	/* Motion. */
	--bpchkpro-transition-fast: 0.12s ease;

	/* Controls. */
	--bpchkpro-tap-target:    40px;
}

/*
 * Dark mode. The plugin OWNS its dark colour layer rather than relying on the
 * host theme flipping --wp--preset--color--* / --bx-color-* tokens (which it
 * does not do for every value — the *-soft status tints and on-accent text have
 * no theme chain, so the light fallbacks would leak in dark mode and render
 * light-on-light, e.g. the member privacy notice + the BuddyPress feedback box).
 *
 * Keyed on every dark signal the host themes emit: BuddyX / BuddyX Pro / Reign
 * data-bx-mode + body classes, the generic data-theme, plus the legacy
 * .bpchkpro-dark / .buddyx-dark-mode / html.dark hooks we already shipped. The
 * prefers-color-scheme fallback below (guarded with html[data-bx-mode="light"])
 * covers dark-OS setups whose theme exposes no class/attribute. (basecamp
 * 10019094055)
 *
 * IMPORTANT: the :root light block above also sets these tokens ON the
 * component containers (.bpchkpro-app / .bpchkpro-member-settings). A token set
 * directly on a closer element wins for its own subtree regardless of selector
 * specificity, so the dark override MUST re-set the tokens on those same
 * containers (the `<signal> .bpchkpro-app/.bpchkpro-member-settings` rows
 * below) — keying only on <html>/<body> would be shadowed by the component's
 * own local declaration and the dark values would never reach the component.
 */
html[data-bx-mode="dark"],
body.buddyx-dark-theme,
body.dark-theme,
[data-theme="dark"],
.bpchkpro-dark,
.buddyx-dark-mode,
html.dark,
body.dark-mode,
html[data-bx-mode="dark"] .bpchkpro-app,
html[data-bx-mode="dark"] .bpchkpro-member-settings,
body.buddyx-dark-theme .bpchkpro-app,
body.buddyx-dark-theme .bpchkpro-member-settings,
body.dark-theme .bpchkpro-app,
body.dark-theme .bpchkpro-member-settings,
[data-theme="dark"] .bpchkpro-app,
[data-theme="dark"] .bpchkpro-member-settings,
.bpchkpro-dark .bpchkpro-app,
.bpchkpro-dark .bpchkpro-member-settings,
.buddyx-dark-mode .bpchkpro-app,
.buddyx-dark-mode .bpchkpro-member-settings,
html.dark .bpchkpro-app,
html.dark .bpchkpro-member-settings,
body.dark-mode .bpchkpro-app,
body.dark-mode .bpchkpro-member-settings {
	--bpchkpro-text:          #e5e7eb;
	--bpchkpro-text-muted:    #9ca3af;
	--bpchkpro-text-faint:    #6b7280;
	--bpchkpro-on-accent:     #ffffff;
	--bpchkpro-surface:       #1f2430;
	--bpchkpro-surface-alt:   #262c3a;
	--bpchkpro-surface-hover: #2d3441;
	--bpchkpro-border:        #3a4253;
	--bpchkpro-border-strong: #4b5563;

	/* Status tints — the light-only fallbacks above have no theme chain, so
	   they must be flipped here or they leak as light-on-dark. */
	--bpchkpro-accent-soft:   #1e293b;
	--bpchkpro-success-soft:  #14271c;
	--bpchkpro-warn-soft:     #2b2410;
	--bpchkpro-danger-soft:   #2a1416;
	--bpchkpro-info-soft:     #16233a;
}

@media (prefers-color-scheme: dark) {
	html:not([data-bx-mode="light"]):not([data-bx-mode="auto"]),
	html:not([data-bx-mode="light"]):not([data-bx-mode="auto"]) .bpchkpro-app,
	html:not([data-bx-mode="light"]):not([data-bx-mode="auto"]) .bpchkpro-member-settings {
		--bpchkpro-text:          #e5e7eb;
		--bpchkpro-text-muted:    #9ca3af;
		--bpchkpro-text-faint:    #6b7280;
		--bpchkpro-on-accent:     #ffffff;
		--bpchkpro-surface:       #1f2430;
		--bpchkpro-surface-alt:   #262c3a;
		--bpchkpro-surface-hover: #2d3441;
		--bpchkpro-border:        #3a4253;
		--bpchkpro-border-strong: #4b5563;
		--bpchkpro-accent-soft:   #1e293b;
		--bpchkpro-success-soft:  #14271c;
		--bpchkpro-warn-soft:     #2b2410;
		--bpchkpro-danger-soft:   #2a1416;
		--bpchkpro-info-soft:     #16233a;
	}
}
