/* ══ Motion ══════════════════════════════════════════════════════════════════════════════════
   The one place the app's movement lives. Nothing animates with a literal duration or easing —
   every transition and animation reads these tokens (MotionTokenTests), so the whole app's motion
   is tuned here and Reduce Motion is honoured by one block below rather than by each component.

   What moves, and why: a press answers the finger, a hover says "this is live", a menu or a dialog
   comes from where it was asked for, new content settles into place instead of appearing. Nothing
   animates to decorate, nothing blocks — every interaction stays usable mid-motion — and only
   opacity and transform move, which the compositor runs without laying the page out again.
   See .claude/rules/ui-conventions.md → Motion. */
:root {
    /* ── Durations ─────────────────────────────────────────────────────────────────────────── */
    --aura-dur-press: 100ms;   /* a button giving under the pointer */
    --aura-dur-hover: 140ms;   /* hover, focus, a colour or a border changing state */
    --aura-dur-fast: 180ms;    /* a menu, a popover, a tooltip, a chevron */
    --aura-dur-base: 220ms;    /* a tab, new content arriving, a page */
    --aura-dur-dialog: 240ms;  /* a dialog or the command palette */
    --aura-dur-drawer: 300ms;  /* a drawer sliding in */
    --aura-dur-exit: 160ms;    /* anything leaving — exits are quicker than entrances */
    --aura-dur-chart: 500ms;   /* a chart drawing its series */
    --aura-dur-count: 700ms;   /* a dashboard figure counting up to its value (auraUi.countUp) */
    --aura-dur-draw: 360ms;    /* a stroke drawing itself (SuccessMark) */
    --aura-dur-ambient: 1400ms; /* a skeleton's shimmer: slow, so it reads as waiting, not alarm */
    --aura-dur-spin: 800ms;    /* one turn of a spinner — it keeps turning under Reduce Motion: it says work is happening */

    /* ── Easing ────────────────────────────────────────────────────────────────────────────── */
    /* Standard: quick out of the gate, a long gentle settle — for state changes. */
    --aura-ease-standard: cubic-bezier(0.2, 0, 0, 1);
    /* Out: decelerate into place — for anything arriving. */
    --aura-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    /* In: accelerate away — for anything leaving. */
    --aura-ease-in: cubic-bezier(0.4, 0, 1, 1);
    /* Spring: a damped spring (ζ ≈ 0.78) that overshoots by 2% and settles — for a press released,
       a dialog landing, a check appearing. Sampled from the spring's own equation. */
    --aura-ease-spring: linear(0, 0.089, 0.277, 0.48, 0.659, 0.798, 0.896, 0.959, 0.995, 1.013, 1.019,
        1.019, 1.016, 1.012, 1.008, 1.005, 1.003, 1.001, 1, 1, 1);

    /* ── Distances ─────────────────────────────────────────────────────────────────────────── */
    /* How far things travel. Small on purpose: motion should be felt, not watched. */
    --aura-motion-distance: 6px;
    --aura-press-scale: 0.97;
    --aura-enter-scale: 0.96;
    --aura-popover-scale: 0.98;
    --aura-stagger-step: 28ms;       /* rows of a short list, one after another */
    --aura-stagger-step-card: 56ms;  /* a dashboard's cards, one after another — a card's beat, not a row's */
    /* How long a drawn stroke is, in its own units (SuccessMark's tick). */
    --aura-draw-length: 32;
}

/* Browsers without linear() (Safari before 17.2, Firefox before 112) get the nearest curve. */
@supports not (transition-timing-function: linear(0, 1)) {
    :root {
        --aura-ease-spring: cubic-bezier(0.34, 1.3, 0.64, 1);
    }
}

/* Reduce Motion: nothing travels, scales or springs — content fades in place, as Apple's own does,
   briefly. `data-aura-motion="reduced"` is the design playground's switch for previewing it. */
@media (prefers-reduced-motion: reduce) {
    :root:not([data-aura-motion="full"]) {
        --aura-dur-press: 1ms;
        --aura-dur-fast: 100ms;
        --aura-dur-base: 140ms;
        --aura-dur-dialog: 140ms;
        --aura-dur-drawer: 1ms;
        --aura-dur-exit: 1ms;
        --aura-dur-chart: 1ms;
        --aura-dur-count: 1ms;
        --aura-dur-draw: 1ms;
        --aura-dur-ambient: 0ms;
        --aura-ease-spring: var(--aura-ease-standard);
        --aura-motion-distance: 0px;
        --aura-press-scale: 1;
        --aura-enter-scale: 1;
        --aura-popover-scale: 1;
        --aura-stagger-step: 0ms;
        --aura-stagger-step-card: 0ms;
    }
}

:root[data-aura-motion="reduced"] {
    --aura-dur-press: 1ms;
    --aura-dur-fast: 100ms;
    --aura-dur-base: 140ms;
    --aura-dur-dialog: 140ms;
    --aura-dur-drawer: 1ms;
    --aura-dur-exit: 1ms;
    --aura-dur-chart: 1ms;
    --aura-dur-count: 1ms;
    --aura-dur-draw: 1ms;
    --aura-dur-ambient: 0ms;
    --aura-ease-spring: var(--aura-ease-standard);
    --aura-motion-distance: 0px;
    --aura-press-scale: 1;
    --aura-enter-scale: 1;
    --aura-popover-scale: 1;
    --aura-stagger-step: 0ms;
    --aura-stagger-step-card: 0ms;
}

/* ── Keyframes ───────────────────────────────────────────────────────────────────────────── */
/* Each starts from its "from" state and ends on the element's own style, so with
   animation-fill-mode: backwards nothing lingers afterwards — a transform left on an element
   would make it the containing block of every fixed overlay inside it. */
@keyframes aura-enter {
    from {
        opacity: 0;
        transform: translateY(var(--aura-motion-distance));
    }
}

/* Arriving from above: an alert sliding down into its place. */
@keyframes aura-enter-down {
    from {
        opacity: 0;
        transform: translateY(calc(var(--aura-motion-distance) * -1));
    }
}

@keyframes aura-enter-scale {
    from {
        opacity: 0;
        transform: translateY(calc(var(--aura-motion-distance) * 1.5)) scale(var(--aura-enter-scale));
    }
}

/* A menu or popover dropping from its anchor. */
@keyframes aura-drop {
    from {
        opacity: 0;
        transform: translateY(calc(var(--aura-motion-distance) * -0.75)) scale(var(--aura-popover-scale));
    }
}

/* A toast rising from the bottom edge. */
@keyframes aura-rise {
    from {
        opacity: 0;
        transform: translateY(calc(var(--aura-motion-distance) * 2)) scale(var(--aura-popover-scale));
    }
}

@keyframes aura-fade-in {
    from {
        opacity: 0;
    }
}

/* A check or a badge appearing: grows from small, springs past full size, settles. */
@keyframes aura-pop {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
}

/* A bar growing out to its length from its start (a giving breakdown's years and months), on the
   chart's duration — which Reduce Motion cuts to nothing, so the bar is simply there. */
@keyframes aura-grow-x {
    from {
        transform: scaleX(0);
    }
}

/* A stroke drawing itself (SuccessMark): from its dash offset to nothing. */
@keyframes aura-draw {
    from {
        stroke-dashoffset: var(--aura-draw-length);
    }
}

/* A skeleton's shimmer: a soft band sweeping across, left to right. */
@keyframes aura-shimmer {
    from {
        background-position: 100% 0;
    }
    to {
        background-position: -100% 0;
    }
}

@keyframes aura-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Utilities ───────────────────────────────────────────────────────────────────────────── */
/* New content settling into place. On a plain element a page or component renders. */
.aura-enter {
    animation: aura-enter var(--aura-dur-base) var(--aura-ease-out) backwards;
}

.aura-fade-in {
    animation: aura-fade-in var(--aura-dur-base) var(--aura-ease-standard) backwards;
}

/* A short list arriving: each child a beat after the one before, the seventh onward together, so
   a long list never makes anyone wait for its end. */
.aura-enter-stagger {
    --aura-stagger: var(--aura-stagger-step);
}

/* A dashboard's cards: the same settle, a card's beat apart, so the page fills top to bottom as
   its data arrives rather than all at once. */
.aura-enter-stagger--cards {
    --aura-stagger: var(--aura-stagger-step-card);
}

/* The one ladder: each child of a stagger gets its beat — 0 for the first, 1 for the second… the
   seventh onward sharing 6 — inherited, so the child's own animation or one deeper inside it (a bar
   in a row) can wait its turn: animation-delay: calc(step * var(--aura-beat)). `aura-beats` gives a
   list the beats without the entrance, for one that animates something of its own; a settling
   table's rows take them too (MudBlazor renders the body, so it can't carry the class). */
:is(.aura-enter-stagger, .aura-beats, .aura-table--settle .mud-table-body) > :nth-child(1) { --aura-beat: 0; }
:is(.aura-enter-stagger, .aura-beats, .aura-table--settle .mud-table-body) > :nth-child(2) { --aura-beat: 1; }
:is(.aura-enter-stagger, .aura-beats, .aura-table--settle .mud-table-body) > :nth-child(3) { --aura-beat: 2; }
:is(.aura-enter-stagger, .aura-beats, .aura-table--settle .mud-table-body) > :nth-child(4) { --aura-beat: 3; }
:is(.aura-enter-stagger, .aura-beats, .aura-table--settle .mud-table-body) > :nth-child(5) { --aura-beat: 4; }
:is(.aura-enter-stagger, .aura-beats, .aura-table--settle .mud-table-body) > :nth-child(6) { --aura-beat: 5; }
:is(.aura-enter-stagger, .aura-beats, .aura-table--settle .mud-table-body) > :nth-child(n+7) { --aura-beat: 6; }

.aura-enter-stagger > * {
    animation: aura-enter var(--aura-dur-base) var(--aura-ease-out) backwards;
    animation-delay: calc(var(--aura-stagger) * var(--aura-beat, 0));
}

/* A table whose rows settle in when a new page or filter arrives (aura-table--settle on the
   MudTable): each row a row's beat apart, as a list's; the page replays it (auraUi.replayEntrance)
   only when the view changes, so a row's own action never does. */
.mud-table.aura-table--settle .mud-table-body > .mud-table-row {
    animation: aura-enter var(--aura-dur-base) var(--aura-ease-out) backwards;
    animation-delay: calc(var(--aura-stagger-step) * var(--aura-beat, 0));
}

/* A chart (Ui/ChartFrame, with aura-fade-in for its arrival): waiting for new data it dims, as a
   table's rows do (skin.css), rather than giving way to a skeleton. */
.aura-chart {
    transition: opacity var(--aura-dur-base) var(--aura-ease-standard);
}

.aura-chart[aria-busy="true"] {
    opacity: var(--aura-busy-opacity);
}
