/**
 * motion.css — Console motion tokens + keyframe library
 *
 * NEW, not a copy: @sovereigns/ui-tokens has no motion system today, only
 * three bare `transition: ... 120ms ease` declarations on buttons/inputs.
 * For a "premium, smooth, animated, responsive" console this needs real
 * tokens, so this file builds:
 *
 *   1. a duration scale
 *   2. a small set of easing curves
 *   3. a reusable library of keyframe animations, formalized from the
 *      motion vocabulary already proven out elsewhere in the monorepo:
 *      network/wallet's tradedesk.css (ttd-spin/ttd-shimmer/
 *      ttd-pulse-border/ttd-indet) and ark/desk/web's app.html + index.html
 *      (fade/spin/pulse, and the row flash-up/flash-down tick animation).
 *      Values are re-derived to use Console's own tokens (tokens.css),
 *      not copied verbatim — colors come from --color-success/-danger/
 *      -accent, not the wallet's or desk's hardcoded hexes.
 *
 * Depends on tokens.css (colors) but not on base.css/components.css —
 * safe to load in any order relative to those two.
 */

:root {
    /* ── Duration scale ────────────────────────────────────────────
       Snappy, not sluggish — a premium financial UI reacts instantly
       to input and settles smoothly, it doesn't make you wait on it. */
    --dur-instant: 80ms;      /* micro-feedback: checkbox tick, tap scale */
    --dur-fast: 150ms;        /* hover/focus states, button/input transitions */
    --dur-base: 220ms;        /* default — most enter/exit transitions */
    --dur-slow: 360ms;        /* content-enter, panel/sheet transitions */
    --dur-deliberate: 600ms;  /* value-flash, anything meant to be *noticed* */

    /* ── Easing curves ─────────────────────────────────────────────── */
    /* Standard — symmetric, for state changes that aren't entrances/exits
       (color, border, background transitions). */
    --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
    /* Entrances — fast start, gentle settle. This is the curve
       styles.css's .content-enter already uses; formalized as a token
       so new screens reach for the same feel instead of reinventing it. */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    /* Exits — mirror of ease-out, for things leaving the screen. */
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    /* Emphasis — a slight overshoot for moments that should feel alive
       (a confirmation, a live badge landing, a modal opening). Use
       sparingly — it's the "spring" in an otherwise restrained palette. */
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Entrance ──────────────────────────────────────────────────────
   Same shape as styles.css's existing `content-enter` keyframe,
   available here as a reusable utility for anything outside `.content`
   (cards appearing, list rows arriving, modal bodies). */

@keyframes sov-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.sov-anim-fade-in {
    animation: sov-fade-in var(--dur-slow) var(--ease-out) both;
}

/* ── Skeleton / shimmer loading state ──────────────────────────────
   For Tape Library / Monitoring screens loading data over Nostr —
   shows structure before content lands instead of a blank panel. */

@keyframes sov-shimmer {
    from {
        background-position: 200% 0;
    }
    to {
        background-position: -200% 0;
    }
}

.sov-skeleton {
    background: linear-gradient(
        90deg,
        var(--color-surface-elevated) 25%,
        var(--color-surface-hover) 37%,
        var(--color-surface-elevated) 63%
    );
    background-size: 400% 100%;
    animation: sov-shimmer 1.4s ease-in-out infinite;
    border-radius: var(--radius-sm, 8px);
}

/* ── Live / pulse indicator ─────────────────────────────────────────
   For a connected desk, a running job, a streaming tape — anything
   that should read as "alive right now" without being distracting. */

@keyframes sov-pulse-live {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(63, 191, 143, 0.35);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(63, 191, 143, 0.12);
    }
}

.sov-live-pulse {
    animation: sov-pulse-live 1.6s ease-in-out infinite;
}

/* ── Value flash (tick update) ────────────────────────────────────
   Formalized from ark/desk/web/index.html's row flash-up/flash-down —
   a brief background wash on a price/PnL cell when it updates, using
   Console's success/danger tokens instead of the desk's hardcoded
   green/red. Apply by toggling the class off then on (force reflow)
   each time the value changes, same pattern as the desk UI does. */

@keyframes sov-flash-up {
    from {
        background: var(--color-success-bg, rgba(63, 191, 143, 0.35));
    }
    to {
        background: transparent;
    }
}

@keyframes sov-flash-down {
    from {
        background: var(--color-danger-bg, rgba(217, 105, 95, 0.35));
    }
    to {
        background: transparent;
    }
}

.sov-flash-up {
    animation: sov-flash-up var(--dur-deliberate) var(--ease-out);
}

.sov-flash-down {
    animation: sov-flash-down var(--dur-deliberate) var(--ease-out);
}

/* ── Spinner ───────────────────────────────────────────────────── */

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

.sov-spin {
    animation: sov-spin 0.8s linear infinite;
}

/* ── Progress bar ──────────────────────────────────────────────────
   Determinate: animate `width` smoothly as it changes. Indeterminate:
   a sweeping segment, for progress with no known total (e.g. a tape
   fetch still discovering its universe). */

.sov-progress-track {
    height: 0.375rem;
    border-radius: var(--radius-sm, 8px);
    background: var(--color-surface);
    border: 1px solid var(--color-border-soft);
    overflow: hidden;
    position: relative;
}

.sov-progress-fill {
    height: 100%;
    border-radius: var(--radius-sm, 8px);
    background: linear-gradient(90deg, var(--color-accent-dim), var(--color-accent));
    transition: width var(--dur-slow) var(--ease-standard);
}

@keyframes sov-progress-indeterminate {
    0% {
        left: -35%;
    }
    100% {
        left: 100%;
    }
}

.sov-progress-fill.sov-indeterminate {
    position: absolute;
    width: 35% !important;
    background: linear-gradient(
        90deg,
        transparent,
        var(--color-accent),
        transparent
    );
    animation: sov-progress-indeterminate 1.3s ease-in-out infinite;
}

/* ── Reduced motion ───────────────────────────────────────────────
   Belt-and-suspenders: styles.css already turns off `.content > *`'s
   entrance animation under reduced-motion; this is the general-purpose
   net for everything else in this file (and anything future screens
   add), collapsing all animation/transition to effectively-instant
   rather than removing feedback entirely. */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
