/* Generated from nival-design (shared/motion.css; `npm run sync` there). Change it there, never here: this app's `npm test` fails while this file differs from what nival-design gives. */
/* ---------- Motion: Nival's ways in and out, one keyframe each (fade, rise, pop, slide, blur, breathe, page) ----------
 * The one set every app plays (the Nival manager, d05, 2026-11-24, of hand-drawn versions of a shared piece): the Shell, the
 * admin app and Nival Trader each wrote the same ones out. What differs (how far, how small) is set on the element that
 * plays it; these parameters aren't inherited, so a parent's never reaches its children. Their times and curves are the
 * tokens' (--t-*, --ease*), said where they're played. Nival Shell's rounded glass reads the frames as played
 * (roundedGlass.ts › motionOf). Reduced motion is each app's own rule, where it plays them. */
@property --rise-y { syntax: '<length-percentage>'; inherits: false; initial-value: 10px; }
@property --rise-out-y { syntax: '<length-percentage>'; inherits: false; initial-value: -6px; }
@property --pop-y { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --pop-s { syntax: '<number>'; inherits: false; initial-value: 0.6; }
@property --pop-out-y { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --pop-out-s { syntax: '<number>'; inherits: false; initial-value: 0.9; }
@property --slide-x { syntax: '<length-percentage>'; inherits: false; initial-value: 48px; }
@property --slide-s { syntax: '<number>'; inherits: false; initial-value: 1; }
@property --slide-out-x { syntax: '<length-percentage>'; inherits: false; initial-value: 48px; }
@property --slide-out-s { syntax: '<number>'; inherits: false; initial-value: 1; }
@property --breathe-from-o { syntax: '<number>'; inherits: false; initial-value: 1; }
@property --breathe-from-s { syntax: '<number>'; inherits: false; initial-value: 1; }
@property --breathe-o { syntax: '<number>'; inherits: false; initial-value: 0.5; }
@property --breathe-s { syntax: '<number>'; inherits: false; initial-value: 1; }
@property --ring-o { syntax: '<number>'; inherits: false; initial-value: 0.5; }
@property --ring-s { syntax: '<number>'; inherits: false; initial-value: 1.8; }
@property --n-idx { syntax: '<integer>'; inherits: false; initial-value: 0; }

/* Rises in from --rise-y below (a negative one drops in from above; a percentage is of its own height, as a value rolling
   in). */
@keyframes n-rise {
  from {
    opacity: 0;
    transform: translateY(var(--rise-y));
  }
  to {
    opacity: 1;
    transform: none;
  }
}
/* Goes up and away (--rise-out-y). */
@keyframes n-rise-out {
  to {
    opacity: 0;
    transform: translateY(var(--rise-out-y));
  }
}
/* Text coming in: out of a blur (--blur-in), a little from below (--blur-in-y), into sharp. */
@keyframes n-blur-in {
  from {
    opacity: 0;
    filter: blur(var(--blur-in));
    transform: translateY(var(--blur-in-y, 0));
  }
}
/* Pops in from small (--pop-s), from --pop-y away: badges, menus, cards, windows. */
@keyframes n-pop-in {
  from {
    opacity: 0;
    transform: translateY(var(--pop-y)) scale(var(--pop-s));
  }
}
@keyframes n-pop-out {
  to {
    opacity: 0;
    transform: translateY(var(--pop-out-y)) scale(var(--pop-out-s));
  }
}
@keyframes n-fade-in {
  from {
    opacity: 0;
  }
}
@keyframes n-fade-out {
  to {
    opacity: 0;
  }
}
/* In from the right (--slide-x, --slide-s) and back out to it (--slide-out-x, --slide-out-s). */
@keyframes n-slide-left {
  from {
    opacity: 0;
    transform: translateX(var(--slide-x)) scale(var(--slide-s));
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes n-slide-out-right {
  to {
    opacity: 0;
    transform: translateX(var(--slide-out-x)) scale(var(--slide-out-s));
  }
}
/* Turns for as long as it runs: only what turns by its nature (a scan, a cursor), never work (progress.css breathes). */
@keyframes n-spin {
  to {
    rotate: 1turn;
  }
}
/* Breathes between --breathe-from-o/-s and --breathe-o/-s: run it `infinite alternate`. */
@keyframes n-breathe {
  from {
    opacity: var(--breathe-from-o);
    scale: var(--breathe-from-s);
  }
  to {
    opacity: var(--breathe-o);
    scale: var(--breathe-s);
  }
}
/* A page change: the new page comes in from the side it was moved to, --page-dir 1 from the right (forward), -1 from the
   left (back), 0 in place, fading in. */
@keyframes n-page-in {
  from {
    opacity: 0;
    transform: translateX(calc(var(--page-dir, 0) * var(--page-x)));
  }
}
/* Its other half, the page it replaces going (page-step, below): out to the other side, -1 × --page-dir × --page-x, fading
   out, from wherever it is (a step taken again mid-way leaves from there). */
@keyframes n-page-out {
  to {
    opacity: 0;
    transform: translateX(calc(var(--page-dir, 0) * -1 * var(--page-x)));
  }
}
/* Expanding ring pulse from --ring-o to 0 opacity while scaling from 1 to --ring-s. */
@keyframes n-ring {
  from {
    opacity: var(--ring-o);
    scale: 1;
  }
  to {
    opacity: 0;
    scale: var(--ring-s);
  }
}
/* Ambient background glows: three slow organic drift loops (--n-drift-a / -b / -c). */
@keyframes drift-a {
  from {
    transform: translate(-8%, -6%) scale(1);
  }
  to {
    transform: translate(10%, 8%) scale(1.15);
  }
}
@keyframes drift-b {
  from {
    transform: translate(6%, -10%) scale(1.1);
  }
  to {
    transform: translate(-12%, 6%) scale(0.92);
  }
}
@keyframes drift-c {
  from {
    transform: translate(-10%, 8%) scale(0.95);
  }
  to {
    transform: translate(8%, -8%) scale(1.12);
  }
}
/* Listening pill sheen scanning across once with a calm pause before repeating (sd-motion-timings-1, Pick A). */
@keyframes n-sheen {
  60%,
  to {
    translate: 100% 0;
  }
}

/* ---------- Shared Motion Preset Library (e68, Renjume: pick from structured presets, never hardcode magic numbers) ----------
 * Declarative enter + paired [data-state='closing'] exit + pure-CSS child staggers + built-in reduced motion.
 * Paired with motion-presets.ts / motion-presets.js (MOTION_PRESETS, motionOptions) for JS Web Animations callers. */

/* Dock C Spine drawers, WindowsOf, TrayApps: slide smoothly out from the spine rail on enter, retract on exit. */
[data-n-motion='dock-popup'] {
  --slide-x: -8px;
  --slide-s: 0.98;
  transform-origin: left center;
  animation: n-slide-left var(--t-menu-in) var(--ease) backwards;
}
[data-n-motion='dock-popup'][data-state='closing'] {
  --slide-out-x: -8px;
  --slide-out-s: 0.98;
  animation: n-slide-out-right var(--t-exit-popup) var(--ease-in) forwards;
}

/* Keyed inner drawer swap when switching directly between Dock C drawers while the shell glides vertically (Renjume's
 * pick A on sd-dock-popup-switch-1, 2026-12-01): the new body rises in (--t-fast on --ease), while a copy of the old
 * popup stays inside the glass and fades out in place ([data-state='closing'], --t-exit-popup on --ease-in). */
[data-n-motion='dock-popup-swap'] {
  --rise-y: 6px;
  animation: n-rise var(--t-fast) var(--ease) backwards;
}
[data-n-motion='dock-popup-swap'][data-state='closing'] {
  animation: n-fade-out var(--t-exit-popup) var(--ease-in) forwards;
}

/* Popups, menus, selects, PowerMenu, NotificationCenter, BackgroundApps, ContextMenu. */
[data-n-motion='flyout'] {
  --pop-y: -6px;
  --pop-s: 0.94;
  animation: n-pop-in var(--t-menu-in) var(--ease) backwards;
}
[data-n-motion='flyout'][data-state='closing'] {
  --pop-out-y: -4px;
  --pop-out-s: 0.96;
  animation: n-pop-out var(--t-exit-popup) var(--ease-in) forwards;
}

/* Centered modal dialogs (ConfirmLayer, ClaudeSignIn, AskCard). */
[data-n-motion='modal'] {
  --pop-y: 6px;
  --pop-s: 0.96;
  transform-origin: center;
  animation: n-pop-in var(--t-menu-in) var(--ease) backwards;
}
[data-n-motion='modal'][data-state='closing'] {
  --pop-out-y: 4px;
  --pop-out-s: 0.96;
  animation: n-pop-out var(--t-exit-popup) var(--ease-in) forwards;
}

/* Corner toasts and notification cards. */
[data-n-motion='toast'] {
  --slide-x: 24px;
  animation: n-slide-left var(--t-list) var(--ease) backwards;
}
[data-n-motion='toast'][data-state='closing'] {
  animation: n-fade-out var(--t-exit-card) var(--ease-in) forwards;
}

/* Small floating chips, clear buttons, badges, attachment pills. */
[data-n-motion='chip'] {
  --pop-s: 0.72;
  animation: n-pop-in var(--t-fast) var(--ease) backwards;
}
[data-n-motion='chip'][data-state='closing'] {
  --pop-out-s: 0.72;
  animation: n-pop-out var(--t-exit-popup) var(--ease-in) forwards;
}

/* Zero-jump conditional row fold (Settings conditional rows, expandable sections).
 * Mount/unmount callers use data-state="open"|"closing" (@starting-style unfolds smoothly on mount and reverses cleanly
 * mid-transition); persistent toggle callers set data-folded="false"|"true" (transitions smoothly between 1fr and 0fr).
 * Inner wrapper keeps min-width: 0 + min-height: 0 so grid tracks collapse strictly to 0 px when folded, while
 * overflow-x stays visible at all times and overflow-y clips ONLY while folded or animating (step-end on open,
 * step-start on close via allow-discrete) so settled Dual-Rim focus halos (--n-ring-bleed) and hover lifts are NEVER
 * sliced off on any of the 4 sides without negative-margin sibling pull or width: 100% layout shifts (tracker/e100). */
[data-n-motion='row-fold'] {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition:
    grid-template-rows var(--t-mid) var(--ease),
    opacity var(--t-mid) var(--ease);
}
@starting-style {
  [data-n-motion='row-fold']:not([data-folded]) {
    grid-template-rows: 0fr;
    opacity: 0;
  }
}
[data-n-motion='row-fold'] > * {
  overflow-x: visible;
  overflow-y: visible;
  min-width: 0;
  min-height: 0;
  transition: overflow-y var(--t-mid) step-end allow-discrete;
}
@starting-style {
  [data-n-motion='row-fold']:not([data-folded]) > * {
    overflow-y: clip;
  }
}
[data-n-motion='row-fold']:is([data-state='closing'], [data-folded='true']) {
  grid-template-rows: 0fr;
  opacity: 0;
  pointer-events: none;
  transition:
    grid-template-rows var(--t-exit-card) var(--ease-in),
    opacity var(--t-exit-card) var(--ease-in);
}
[data-n-motion='row-fold']:is([data-state='closing'], [data-folded='true']) > * {
  overflow-y: clip;
  transition: overflow-y var(--t-exit-card) step-start allow-discrete;
}

/* Ceremonial shell startup / lock / goodbye curtain layers. */
[data-n-motion='curtain'] {
  animation: n-fade-in var(--t-curtain-in) var(--ease) backwards;
}
[data-n-motion='curtain'][data-state='closing'] {
  animation: n-fade-out var(--t-curtain-leave) var(--ease) forwards;
}
[data-n-motion='curtain-bloom'] {
  animation: n-fade-in var(--t-curtain-bloom) var(--ease) backwards;
}

/* What comes where a skeleton stood, in a place skeletons.js doesn't hold (a grid of tiles standing as their own skeleton:
   Nival Shell's Overview › Apps), and that skeleton going: the one fades in where the other fades out, in place, as
   skeletons.js' fill() swaps a place it holds; nothing of it rises in again from nothing after its skeleton (sv-motion-video's
   frames, 2026-12-01). */
[data-n-motion='skeleton-fill'] {
  animation: n-fade-in var(--t-fast) linear backwards;
}
[data-n-motion='skeleton-fill'][data-state='closing'] {
  animation: n-fade-out var(--t-fast) linear forwards;
}

/* A step to the next or the previous of a run, by its direction (Calendar's week, → and ←; Renjume's pick A on
   sd-calendar-week-motion-1, 2026-12-01: "Slide by direction"): what shows the new one comes in from the side it was
   stepped to, --page-dir 1 from the right and -1 from the left (a page change's n-page-in, --t-page on --ease), while a
   copy of what showed the old one, laid over where it was ([data-state='closing']), leaves the other way from wherever it
   is (n-page-out, --t-exit-popup on --ease-in). Both are set on the same frame; the copy goes once its exit ends. */
[data-n-motion='page-step'] {
  animation: n-page-in var(--t-page) var(--ease) backwards;
}
[data-n-motion='page-step'][data-state='closing'] {
  animation: n-page-out var(--t-exit-popup) var(--ease-in) forwards;
}

/* Pre-Nov-30 motion timings restored as named presets (Renjume's pick A on sd-motion-timings-1, 2026-12-02):
 * overview-top (40 ms wait), overview-card & swatch-rise (80 ms wait), curtain-leave (140 ms delay),
 * curtain-picture (250 ms delay), listen-sheen (2.8 s cycle), and listen-orb (2.4 s cycle). */
[data-n-motion='overview-top'] {
  --rise-y: -14px;
  --rise-out-y: -10px;
  animation: n-rise var(--t-list) var(--ease) var(--t-lead-top) backwards;
}
[data-n-motion='overview-card']:not([data-entered]) {
  --pop-y: 16px;
  --pop-s: 0.95;
  animation: n-pop-in var(--t-list) var(--ease) calc(var(--t-lead-cards) + min(var(--i, 0), 12) * var(--stagger)) backwards;
}
[data-n-motion='swatch-rise'] {
  animation: n-rise var(--t-list) var(--ease) calc(var(--t-lead-cards) + var(--i, var(--n-idx, 0)) * var(--stagger)) backwards;
}
[data-n-motion='curtain-leave'] {
  animation: n-fade-out var(--t-curtain-leave) var(--ease) var(--t-curtain-leave-delay) forwards;
}
[data-n-motion='curtain-picture'] {
  animation: n-fade-in var(--t-curtain-in) var(--ease) var(--t-curtain-picture-delay) backwards;
}
[data-n-motion='listen-sheen'] {
  animation: n-sheen var(--t-listen-sheen) var(--ease-io) infinite;
}
[data-n-motion='listen-orb'] {
  animation: n-spin var(--t-listen-orb) linear infinite;
}

/* Automatic pure-CSS child staggers (zero per-row JS boilerplate; --n-idx has inherits: false so grandchildren stay untouched). */
[data-n-stagger] > :nth-child(1) { --n-idx: 0; }
[data-n-stagger] > :nth-child(2) { --n-idx: 1; }
[data-n-stagger] > :nth-child(3) { --n-idx: 2; }
[data-n-stagger] > :nth-child(4) { --n-idx: 3; }
[data-n-stagger] > :nth-child(5) { --n-idx: 4; }
[data-n-stagger] > :nth-child(6) { --n-idx: 5; }
[data-n-stagger] > :nth-child(7) { --n-idx: 6; }
[data-n-stagger] > :nth-child(8) { --n-idx: 7; }
[data-n-stagger] > :nth-child(9) { --n-idx: 8; }
[data-n-stagger] > :nth-child(10) { --n-idx: 9; }
[data-n-stagger] > :nth-child(n + 11) { --n-idx: 10; }

/* Settings sections, developer tabs, Health cards: never override .settings-swatch, skeletons, or .n-fades scroll timelines. */
[data-n-stagger='settings'] > :is(.settings-row, .settings-block, .n-card, [data-n-stagger-item]):not(.settings-swatch):not([data-n-skeleton]):not(.n-fades) {
  --rise-y: 8px;
  animation: n-rise var(--t-list) var(--ease) calc(var(--stagger-lead, var(--t-press)) + min(var(--n-idx, 0), 8) * var(--stagger)) backwards;
}

/* Menus, Dock drawers, ContextMenu, Select, AccountsMenu: tight crisp 18 ms ladder capped at 10 steps. */
[data-n-stagger='menu'] > :is(.btn, .menu-row, .dock-tile, .dock-nival-tile, .dock-popup-btn, [data-n-stagger-item]):not([data-n-skeleton]):not(.n-fades) {
  --rise-y: 6px;
  animation: n-rise var(--t-menu-row) var(--ease) calc(min(var(--n-idx, 0), 10) * var(--menu-stagger)) backwards;
}

/* General vertical lists and card stacks: 30 ms ladder capped at 8 steps. */
[data-n-stagger='list'] > :not([data-n-skeleton]):not(.n-fades):not(style):not(script) {
  --rise-y: 8px;
  animation: n-rise var(--t-list) var(--ease) calc(var(--stagger-lead, 0 * var(--stagger)) + min(var(--n-idx, 0), 8) * var(--stagger)) backwards;
}

@media (prefers-reduced-motion: reduce) {
  [data-n-motion],
  [data-n-motion='row-fold'] > *,
  [data-n-stagger] > * {
    animation: none !important;
    transition: none !important;
  }
}
