/*
 * captivr design tokens (WP0 contract, frozen once WP0 is merged; names may only be added, never renamed/removed)
 * ------------------------------------------------------------------------------------------------------------
 * Delivery:
 *   1. This static file: spacing, radii, layout, z-index, touch target, motion, focus ring, plus FALLBACK values
 *      for every colour token (= DesignTokens.Fallback, kept in sync by TenantContrastTests).
 *   2. App.razor renders the tenant colour tokens inline in <head> right after this file
 *      (<style id="cv-tenant-tokens">:root{--cv-primary:...}</style>, ITenantThemeService.GetDesignTokensCssAsync),
 *      so the loading screen, static SSR pages and the first interactive paint are branded.
 *   MudBlazor components keep reading --mud-palette-* (mapped from the same tokens in TenantThemeService.AdjustTheme);
 *   all custom CSS (*.razor.css of the work packages) reads --cv-* only. Never hard-code colours.
 *
 * Colour tokens (tenant, derived by DesignTokens from the tenant's Primary/Secondary/Tertiary):
 *   --cv-primary            fill of filled primary components (CI colour)
 *   --cv-on-primary         text/icons on --cv-primary and --cv-primary-hover (>= 4.5:1, black or white)
 *   --cv-primary-text       brand colour for text, links, outlines, icons, selected states on surfaces (>= 4.5:1)
 *   --cv-primary-hover      hover/pressed fill (same hue, contrast with on-colour never drops)
 *   --cv-primary-lighten    decorative tint (no text on it)
 *   --cv-primary-brand      raw CI colour (decorative only; equals --cv-primary unless the fill strategy darkens it)
 *   --cv-primary-rgb        "r,g,b" of --cv-primary for rgba(var(--cv-primary-rgb), .12) state layers
 *   same set for secondary and tertiary (--cv-secondary, --cv-on-secondary, --cv-secondary-text, ...)
 *   --cv-surface            page/card background            --cv-surface-variant  grouped/subtle background
 *   --cv-text               body text (>= 4.5:1)             --cv-text-muted       secondary text (>= 4.5:1)
 *   --cv-border             input outlines/boundaries (>= 3:1)  --cv-divider       decorative separators only
 *   --cv-focus              focus ring colour (= --cv-primary-text)
 *   --cv-success|warning|error|info          readable status fill (also usable as text on white)
 *   --cv-on-success|warning|error|info       text on the status fill
 *   --cv-success|...-text                    status text on surfaces and on the status surface tint
 *   --cv-success|...-surface                 light status background (alerts, notices)
 *
 * Static tokens (this file):
 *   --cv-space-1..7         4 / 8 / 12 / 16 / 24 / 32 / 48 px
 *   --cv-radius-s|m|l|pill  8 / 12 (default, = MudBlazor DefaultBorderRadius) / 16 / 999 px (pill: chips, badges)
 *   --cv-radius-cta         14 px (primary and destructive buttons)
 *   --cv-shadow-1..3        elevation levels
 *   --cv-appbar-h           56px (= MudBlazor AppbarHeight)
 *   --cv-safe-top|right|bottom|left   env(safe-area-inset-*)
 *   --cv-bottom-inset       height reserved at the bottom by the consent bar / sticky CTAs (default 0px); anything
 *                           fixed at the bottom must sit above it: bottom: calc(var(--cv-bottom-inset) + var(--cv-space-4))
 *   --cv-z-content|sticky|drawer|appbar|sheet|dialog|snackbar|reconnect   one z-index scale, aligned with MudBlazor's
 *                           --mud-zindex-* so custom layers interleave correctly with Mud drawers, app bar and dialogs
 *   --cv-touch              48px minimum touch target   --cv-touch-cta  52px primary CTA height
 *   --cv-motion-fast|normal 150ms / 250ms (0ms with prefers-reduced-motion)   --cv-ease  standard easing
 *   --cv-focus-ring         box-shadow for custom focus styles (white halo + 2px focus colour)
 *   --cv-font-family        Roboto (self-hosted) + system fallback
 *   Polish (tactile layer, utilities in captivr-polish.css):
 *   --cv-ease-out, --cv-motion-press, --cv-press-scale(-icon), --cv-lift(-card), --cv-transition-tactile
 *   --cv-edge, --cv-edge-highlight   1px inner edge / top highlight (inset shadows, never a layout-changing border)
 *   --cv-gradient-primary(-soft), --cv-gradient-surface     brand fill, active tint, card wash (tenant-derived)
 *   --cv-shadow-cta(-hover|-press), --cv-shadow-card(-hover), --cv-input-glow
 */

:root {
    /* ---- colour fallbacks (overridden by the inline tenant block in App.razor) ---- */
    --cv-primary: #1976D2;
    --cv-on-primary: #FFFFFF;
    --cv-primary-text: #1871C8;
    --cv-primary-hover: #1562AE;
    --cv-primary-lighten: #378FE7;
    --cv-primary-brand: #1976D2;
    --cv-primary-rgb: 25,118,210;
    --cv-secondary: #424242;
    --cv-on-secondary: #FFFFFF;
    --cv-secondary-text: #424242;
    --cv-secondary-hover: #2E2E2E;
    --cv-secondary-lighten: #5C5C5C;
    --cv-secondary-brand: #424242;
    --cv-secondary-rgb: 66,66,66;
    --cv-tertiary: #00796B;
    --cv-on-tertiary: #FFFFFF;
    --cv-tertiary-text: #00796B;
    --cv-tertiary-hover: #005047;
    --cv-tertiary-lighten: #00AC98;
    --cv-tertiary-brand: #00796B;
    --cv-tertiary-rgb: 0,121,107;
    --cv-surface: #FFFFFF;
    --cv-surface-variant: #F3F4F6;
    --cv-text: #1A1C1E;
    --cv-text-muted: #5B6068;
    --cv-border: #7D828A;
    --cv-divider: #E2E4E8;
    --cv-focus: #1871C8;
    --cv-success: #2E7C32;
    --cv-on-success: #FFFFFF;
    --cv-success-text: #2E7C32;
    --cv-success-surface: #EAF2EA;
    --cv-warning: #B55202;
    --cv-on-warning: #FFFFFF;
    --cv-warning-text: #B55202;
    --cv-warning-surface: #FDF0E6;
    --cv-error: #CE2B2B;
    --cv-on-error: #FFFFFF;
    --cv-error-text: #CE2B2B;
    --cv-error-surface: #FBEAEA;
    --cv-info: #0273B1;
    --cv-on-info: #FFFFFF;
    --cv-info-text: #0273B1;
    --cv-info-surface: #E6F3FA;

    /* ---- media stage (static, same in light and dark mode): letterbox behind players/photos and text on it ---- */
    --cv-stage: #0B0C0E;
    --cv-on-stage: #FFFFFF;

    /* ---- typography ---- */
    --cv-font-family: Roboto, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;

    /* ---- spacing ---- */
    --cv-space-1: 4px;
    --cv-space-2: 8px;
    --cv-space-3: 12px;
    --cv-space-4: 16px;
    --cv-space-5: 24px;
    --cv-space-6: 32px;
    --cv-space-7: 48px;

    /* ---- radii and elevation ---- */
    --cv-radius-s: 8px;
    --cv-radius-m: 12px;
    --cv-radius-l: 16px;
    --cv-radius-pill: 999px;
    --cv-radius-cta: 14px; /* primary/destructive buttons (PO design: A+B mix) */
    --cv-shadow-1: 0 1px 2px rgba(0, 0, 0, .12), 0 1px 3px rgba(0, 0, 0, .08);
    --cv-shadow-2: 0 2px 6px rgba(0, 0, 0, .12), 0 4px 12px rgba(0, 0, 0, .08);
    --cv-shadow-3: 0 6px 16px rgba(0, 0, 0, .14), 0 12px 32px rgba(0, 0, 0, .10);

    /* ---- layout ---- */
    --cv-appbar-h: 56px;
    --cv-safe-top: env(safe-area-inset-top, 0px);
    --cv-safe-right: env(safe-area-inset-right, 0px);
    --cv-safe-bottom: env(safe-area-inset-bottom, 0px);
    --cv-safe-left: env(safe-area-inset-left, 0px);
    --cv-bottom-inset: 0px;

    /* ---- z-index (relative order: content < sticky < drawer < app bar < sheet/dialog < snackbar < reconnect) ---- */
    --cv-z-content: 0;
    --cv-z-sticky: 1050;
    --cv-z-drawer: var(--mud-zindex-drawer, 1100);
    --cv-z-appbar: var(--mud-zindex-appbar, 1300);
    --cv-z-sheet: var(--mud-zindex-dialog, 1400);
    --cv-z-dialog: var(--mud-zindex-dialog, 1400);
    --cv-z-snackbar: var(--mud-zindex-snackbar, 1500);
    --cv-z-reconnect: 1700;

    /* ---- touch targets ---- */
    --cv-touch: 48px;
    --cv-touch-cta: 52px;

    /* ---- motion ---- */
    --cv-motion-fast: 150ms;
    --cv-motion-normal: 250ms;
    --cv-ease: cubic-bezier(.2, 0, 0, 1);

    /* ---- focus ---- */
    --cv-focus-ring: 0 0 0 2px var(--cv-surface), 0 0 0 4px var(--cv-focus);

    /* ---- polish: tactile motion, depth, gradients (applied by captivr-polish.css and the Cv* components) ----
       Motion only touches transform/opacity plus quick colour/shadow fades; dark-mode values live in captivr-polish.css.
       Gradients run between --cv-primary and --cv-primary-hover only: --cv-on-primary is >= 4.5:1 on both, so text
       contrast is guaranteed for every tenant. */
    --cv-ease-out: cubic-bezier(.22, 1, .36, 1);
    --cv-motion-press: 90ms;      /* press-in: instant; the release eases back with --cv-motion-fast */
    --cv-press-scale: .98;        /* buttons, rows, cards */
    --cv-press-scale-icon: .92;   /* small icon buttons need a stronger cue */
    --cv-lift: -1px;              /* hover lift of buttons (translateY) */
    --cv-lift-card: -2px;         /* hover lift of clickable cards */
    --cv-transition-tactile: transform var(--cv-motion-fast) var(--cv-ease-out), box-shadow var(--cv-motion-fast) var(--cv-ease-out), background-color var(--cv-motion-fast) var(--cv-ease-out), border-color var(--cv-motion-fast) var(--cv-ease-out), color var(--cv-motion-fast) var(--cv-ease-out), opacity var(--cv-motion-fast) var(--cv-ease-out);
    --cv-edge: rgba(0, 0, 0, .06);             /* 1px inner edge (inset shadow, no layout change) */
    --cv-edge-highlight: rgba(255, 255, 255, .18); /* top inner highlight on filled brand fills */
    --cv-gradient-primary: linear-gradient(180deg, var(--cv-primary) 0%, var(--cv-primary-hover) 100%);
    --cv-gradient-primary-soft: linear-gradient(180deg, rgba(var(--cv-primary-rgb), .12) 0%, rgba(var(--cv-primary-rgb), .06) 100%);
    --cv-gradient-surface: radial-gradient(120% 90% at 0% 0%, rgba(var(--cv-primary-rgb), .04) 0%, rgba(var(--cv-primary-rgb), 0) 60%);
    --cv-shadow-cta: inset 0 1px 0 var(--cv-edge-highlight), 0 1px 2px rgba(var(--cv-primary-rgb), .20), 0 4px 10px -2px rgba(var(--cv-primary-rgb), .30);
    --cv-shadow-cta-hover: inset 0 1px 0 var(--cv-edge-highlight), 0 2px 4px rgba(var(--cv-primary-rgb), .22), 0 10px 20px -6px rgba(var(--cv-primary-rgb), .40);
    --cv-shadow-cta-press: inset 0 1px 0 var(--cv-edge-highlight), 0 1px 1px rgba(var(--cv-primary-rgb), .24);
    --cv-shadow-card: inset 0 0 0 1px var(--cv-edge), 0 1px 2px rgba(0, 0, 0, .05), 0 2px 8px -2px rgba(0, 0, 0, .06);
    --cv-shadow-card-hover: inset 0 0 0 1px var(--cv-edge), 0 4px 10px -2px rgba(0, 0, 0, .08), 0 14px 28px -8px rgba(0, 0, 0, .14);
    --cv-input-glow: 0 0 0 3px rgba(var(--cv-primary-rgb), .18);
}

@media (prefers-reduced-motion: reduce) {
    :root {
        --cv-motion-fast: 0ms;
        --cv-motion-normal: 0ms;
    }

    html {
        scroll-behavior: auto;
    }

    /* Transitions collapse; progress spinners (animations) keep running because they carry status. */
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Visible keyboard focus for every interactive element (zero specificity, components may refine it). */
:where(a, button, input, select, textarea, summary, [role="button"], [tabindex]:not([tabindex="-1"])):focus-visible {
    outline: 2px solid var(--cv-focus);
    outline-offset: 2px;
    box-shadow: 0 0 0 2px var(--cv-surface);
}
