/*
    urhema_motion.css — 13.8 Sensory craft, motion controls

    A three-state motion model layered on the EXISTING motion tokens
    (--ub-duration, --ub-duration-fast) already defined INVARIANT in
    urhema_tokens.css. This file adds NO new tokens on purpose: "built on
    existing tokens" means Reduced zeroes the tokens the rest of the system
    already animates through, in one place, rather than gating each
    animation by hand. A broad *-selector safety net catches anything that
    hardcodes a duration instead of reading the token.

    STATE MODEL — driven by data-motion on <html>:
        (absent) / "system"  honor the OS. prefers-reduced-motion governs.
        "reduced"            always reduce, regardless of OS.
        "full"               force motion on, even if the OS asks to reduce.

    "full" is the ONE case allowed to override a hard OS reduced-motion
    signal — precisely because it is an explicit, informed user choice. The
    DEFAULT (system) never silently ignores the OS. See 13.8-WIRING.md for
    why that distinction is the locked accessibility decision.

    The server writes data-motion from the member preference / cookie the
    same flash-free way it writes data-theme (Master.cshtml +
    IThemeService.ResolveMotionAsync — the latter NOT built yet). With no
    preference set the attribute is simply absent, "system" applies, and the
    media query below governs with ZERO server involvement. So this file
    already makes the whole site honor OS reduced-motion today, before the
    settings control that sets "reduced"/"full" exists.

    Orthogonal to theme: --ub-duration* are invariant in tokens.css and are
    never touched by urhema_theme.css, so nothing here interacts with the
    light / dark / sepia / (future) night palettes. Load order-independent
    (media query + attribute selectors + !important out-specific :root).
*/

/* ---- System default: defer to the OS, unless the user forced Full ---- */
@media (prefers-reduced-motion: reduce) {
    :root:not([data-motion="full"]) {
        --ub-duration: 0ms;
        --ub-duration-fast: 0ms;
    }

    /* Safety net: anything that hardcodes a duration instead of using the
       token. 0.01ms (not 0s) keeps transitionend / animationend callbacks
       firing — a real dependency for JS that waits on them — while being
       imperceptible. */
    :root:not([data-motion="full"]) *,
    :root:not([data-motion="full"]) *::before,
    :root:not([data-motion="full"]) *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---- Explicit Reduced: always, regardless of OS ---- */
:root[data-motion="reduced"] {
    --ub-duration: 0ms;
    --ub-duration-fast: 0ms;
}

:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

/* ---- "full" needs no rules of its own: it exists only to escape the
        media-query reduction above via :not([data-motion="full"]). ---- */
