/**
 * Public CSS Design Tokens
 *
 * This file defines ALL CSS custom properties used by the public section rendering system.
 * It provides sensible defaults that work across all theme presets.
 *
 * Token sources (in order of precedence):
 * 1. Inline <style> in page layout template (from WebsiteVisualStrategy)
 * 2. This tokens.css file (base defaults)
 *
 * The page layout template injects provider-specific tokens for:
 * - --spacing-* (xs, sm, md, lg, xl, 2xl, 3xl, 4xl)
 * - --corner-* (subtle, default, bold, pill) + aliases (sm, md, lg, full)
 * - --anim-* (fast, normal, slow) + --stagger-* (tight, normal, relaxed)
 * - --ease-* (confident, magical, professional, spring)
 * - --elevation-* (sm, md, lg)
 * - --color-primary, --color-secondary, --color-accent
 * - --color-primary-rgb (for rgba usage)
 * - --font-weight-* (normal, medium, semibold, bold)
 * - --line-height-* (tight, normal, relaxed)
 * - --text-* (sm, base, lg, xl, 2xl) + heading scale
 *
 * This file provides defaults for tokens NOT injected by the layout template.
 */

:root {
    /* ==========================================================================
       VISUAL PREFERENCE MULTIPLIERS
       Set by page layout template from Brand Studio sliders.
       Default to 1 (neutral) when no preferences are configured.
       ========================================================================== */
    --density-multiplier: 1;
    --motion-multiplier: 1;
    --contrast-multiplier: 1;

    /* ==========================================================================
       SPACING SCALE
       Defaults in case layout template doesn't provide them.
       Scaled by --density-multiplier from layout density slider.
       ========================================================================== */
    --spacing-none: 0;
    --spacing-xs: calc(0.5rem * var(--density-multiplier, 1));
    --spacing-sm: calc(1rem * var(--density-multiplier, 1));
    --spacing-md: calc(1.5rem * var(--density-multiplier, 1));
    --spacing-lg: calc(2rem * var(--density-multiplier, 1));
    --spacing-xl: calc(3rem * var(--density-multiplier, 1));
    --spacing-2xl: calc(4rem * var(--density-multiplier, 1));
    --spacing-3xl: calc(6rem * var(--density-multiplier, 1));
    --spacing-4xl: calc(8rem * var(--density-multiplier, 1));

    /* ==========================================================================
       CORNER SCALE
       Defaults in case layout template doesn't provide them
       ========================================================================== */
    --corner-subtle: 4px;
    --corner-default: 8px;
    --corner-bold: 16px;
    --corner-pill: 9999px;

    /* Corner aliases (referenced by component CSS) */
    --corner-sm: var(--corner-subtle);
    --corner-md: var(--corner-default);
    --corner-lg: var(--corner-bold);
    --corner-full: var(--corner-pill);

    /* ==========================================================================
       ANIMATION SCALE
       Defaults in case layout template doesn't provide them.
       Scaled by --motion-multiplier from motion preference slider.
       When multiplier is 0, animations are effectively disabled.
       ========================================================================== */
    --anim-fast: calc(150ms * var(--motion-multiplier, 1));
    --anim-normal: calc(300ms * var(--motion-multiplier, 1));
    --anim-slow: calc(500ms * var(--motion-multiplier, 1));

    /* Stagger delays for sequential child animations */
    --stagger-tight: calc(50ms * var(--motion-multiplier, 1));
    --stagger-normal: calc(100ms * var(--motion-multiplier, 1));
    --stagger-relaxed: calc(150ms * var(--motion-multiplier, 1));

    /* Easing personality curves */
    --ease-confident: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-magical: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-professional: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.5, 1.8, 0.5, 0.8);

    /* ==========================================================================
       ELEVATION SCALE (box shadows)
       Defaults in case layout template doesn't provide them.
       When visual preferences are configured, the layout template overrides
       these with contrast-adjusted values from the server.
       ========================================================================== */
    --elevation-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --elevation-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --elevation-lg: 0 10px 15px rgba(0, 0, 0, 0.15);

    /* ==========================================================================
       COLOR TOKENS
       Primary colors come from layout template; these are additional semantic colors
       ========================================================================== */

    /* Primary color defaults (overridden by layout template) */
    --color-primary: #3B82F6;
    --color-primary-rgb: 59, 130, 246;
    --color-secondary: #10B981;
    --color-accent: #F59E0B;

    /* Surface colors for backgrounds */
    --color-surface: #ffffff;
    --color-surface-elevated: #ffffff;
    --color-surface-sunken: #f9fafb;

    /* Text colors */
    --color-text: #111827;
    --color-text-muted: #6b7280;
    --color-text-inverted: #ffffff;

    /* Border colors */
    --color-border: #e5e7eb;
    --color-border-light: #f3f4f6;

    /* Semantic colors */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --color-info: #3b82f6;

    /* Header & footer semantic tokens. base.css paints the site header and
       footer from these; the page layout overrides them per business from the
       planner's header/footer strategy and the brand's background/surface
       roles. Defaults sit over the surface/text layer so an unconfigured site
       never renders an unpainted header or footer. */
    --header-bg: var(--color-surface);
    --header-text: var(--color-text);
    --header-active: var(--color-primary);
    --footer-bg: var(--color-surface-sunken);
    --footer-text: var(--color-text);
    --footer-heading: var(--color-text);
    --footer-link: var(--color-text);

    /* Overlay for modals, hero backgrounds, etc. */
    --overlay-color: rgba(0, 0, 0, 0.5);

    /* Opacity scale */
    --opacity-disabled: 0.5;

    /* Icon sizes */
    --icon-size-sm: 16px;
    --icon-size-md: 24px;
    --icon-size-lg: 48px;

    /* ==========================================================================
       PRESET-SPECIFIC TOKENS
       Used by individual theme presets for consistent styling
       ========================================================================== */

    /* Warm Organic preset - shadow color (RGB for rgba() usage) */
    --color-shadow-warm: 139, 90, 43;

    /* Bold Brutalist preset - border and shadow colors */
    --color-border-brutalist: #111827;
    --color-shadow-brutalist: #111827;

    /* ==========================================================================
       TYPOGRAPHY SCALE
       Font sizes for heading and body text
       ========================================================================== */

    /* Heading sizes */
    --text-heading-xl: 3rem;
    --text-heading-lg: 2.25rem;
    --text-heading-md: 1.875rem;
    --text-heading-sm: 1.5rem;
    --text-heading-xs: 1.25rem;

    /* Body text sizes */
    --text-body-lg: 1.125rem;
    --text-body: 1rem;
    --text-body-sm: 0.875rem;

    /* Shorthand text sizes (referenced by component CSS) */
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;

    /* Extended heading sizes */
    --text-heading-2xl: clamp(3.5rem, 8vw, 9.5rem);

    /* Special text sizes */
    --text-label: 0.875rem;
    --text-caption: 0.75rem;

    /* ==========================================================================
       FONT WEIGHT SCALE
       ========================================================================== */
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    /* ==========================================================================
       LINE HEIGHT SCALE
       ========================================================================== */
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.75;

    /* ==========================================================================
       LAYOUT TOKENS
       ========================================================================== */

    /* Container max widths */
    --container-narrow: 768px;
    --container-default: 1200px;
    --container-wide: 1440px;

    /* Menu breakpoint */
    --menu-breakpoint: 768px;

    /* ==========================================================================
       CURSOR REACTIVITY
       Initial values for cursor tracking (set dynamically by cursor-reactive.js)
       ========================================================================== */
    --cursor-x: 0.5;
    --cursor-y: 0.5;
}

/* ==========================================================================
   OS-LEVEL REDUCED MOTION (WCAG 2.3.3)
   When the visitor's operating system advertises a reduced-motion
   preference, collapse the motion multiplier to 0 regardless of the
   operator's per-site motion configuration. This is the accessibility
   baseline: visitors with vestibular disorders or motion sensitivities
   must be respected even when an operator's Brand Studio motion slider
   leans high. !important is necessary because the layout template's
   inline <style> block re-asserts --motion-multiplier unconditionally
   on every render — without !important the source-order cascade would
   restore the operator's value when the OS prefers reduced motion.

   The operator-controlled VisualStrategy.ForceReducedMotion path in
   the layout still produces a 0 multiplier when set, so the operator
   can opt in to reduced motion for all visitors without depending on
   the OS signal. Both signals collapse motion the same way; this rule
   adds the OS baseline so visitors with motion sensitivity are
   respected even when the operator has not opted in.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    :root {
        --motion-multiplier: 0 !important;
    }
}

/* ==========================================================================
   DARK MODE SUPPORT
   When data-theme="dark" is set on body or html
   ========================================================================== */

[data-theme="dark"] {
    --color-surface: #1f2937;
    --color-surface-elevated: #374151;
    --color-surface-sunken: #111827;

    --color-text: #f9fafb;
    --color-text-muted: #9ca3af;
    --color-text-inverted: #111827;

    --color-border: #374151;
    --color-border-light: #4b5563;

    /* Re-resolve the header/footer defaults over the dark surface layer */
    --header-bg: var(--color-surface);
    --header-text: var(--color-text);
    --footer-bg: var(--color-surface-sunken);
    --footer-text: var(--color-text);
    --footer-heading: var(--color-text);
    --footer-link: var(--color-text);

    --overlay-color: rgba(0, 0, 0, 0.7);
}
