/* shared/motion.css — Cerebro DS motion rules (D1 §3).

   Source: design-system-v116 styles/motion.css, transcribed with:
   - P-09 (approved): skeleton/spinner durations now use the
     --c-motion-shimmer / --c-motion-spin tokens (values unchanged).
   - §3.1 contract: the [data-c-motion="off"] kill switch now covers the
     attribute on the .c-theme root, on any ancestor, or on a subtree —
     and also forces scroll-behavior:auto + removes press transforms,
     matching the reduced-motion contract. v1.16 only handled the
     attribute sitting on .c-theme itself.
   - §3.2 opt-in helpers (.c-enter, .c-stagger, .c-scroll-smooth) at the
     bottom — proposal-derived, additive only. */

/* Same timings and reflection geometry as the accepted Graphite motion prototype. */
.c-theme :is(.c-btn,.c-icon-btn,.c-filter,.c-list-row,.c-attachment) { transition:box-shadow 220ms var(--c-motion-ease),border-color 220ms var(--c-motion-ease),color 180ms ease,background-color 180ms ease,transform var(--c-motion-press) var(--c-motion-ease); }
.c-theme :is(.c-input,.c-select,.c-textarea,.c-input-wrap,.c-composer,.c-label) { transition:border-color var(--c-motion-focus) var(--c-motion-ease),box-shadow var(--c-motion-focus) var(--c-motion-ease),background-color var(--c-motion-focus) var(--c-motion-ease),outline-color var(--c-motion-focus) var(--c-motion-ease),color var(--c-motion-focus) var(--c-motion-ease); }
.c-btn[data-variant=primary]::after { transition:opacity 160ms ease,transform 0s 160ms; }
@media(hover:hover) { .c-btn[data-variant=primary]:hover:not(:disabled)::after { opacity:.34; transform:translateX(300%) skewX(-18deg); transition:transform var(--c-motion-sheen) var(--c-motion-ease),opacity 160ms ease; } .c-link .c-icon:last-child { transition:transform 220ms var(--c-motion-ease); } .c-link:hover .c-icon:last-child { transform:translateX(2px); } }
.c-btn:active:not(:disabled):not([aria-disabled=true]) { transform:translateY(1px) scale(.984); }
.c-icon-btn:active:not(:disabled) { transform:scale(.91); }
.c-btn[data-variant=primary]:active:not(:disabled) { box-shadow:inset 0 1px 3px #3a475759,0 1px #ffffff0f; }
.c-tabs[data-c-ready]::before,.c-segmented[data-c-ready]::before { transition:transform var(--c-motion-switch) var(--c-motion-ease),width var(--c-motion-switch) var(--c-motion-ease),height var(--c-motion-switch) var(--c-motion-ease),opacity 180ms ease; }
.c-list[data-c-ready]::before,.c-list[data-c-ready]::after { transition:transform 310ms var(--c-motion-ease),height var(--c-motion-focus) var(--c-motion-ease),width var(--c-motion-focus) var(--c-motion-ease),opacity 180ms ease; }
.c-switch,.c-switch::before { transition:transform var(--c-motion-switch) var(--c-motion-ease),background-color var(--c-motion-fast) ease,border-color var(--c-motion-fast) ease; }
.c-disclosure-body { transition:grid-template-rows var(--c-motion-switch) var(--c-motion-ease); }
.c-disclosure>button .c-icon { transition:transform var(--c-motion-switch) var(--c-motion-ease); }
.c-progress>span { transition:width var(--c-motion-switch) var(--c-motion-ease); }
.c-skeleton { animation:c-shimmer var(--c-motion-shimmer) linear infinite; }
.c-spinner { animation:c-spin var(--c-motion-spin) linear infinite; }
@keyframes c-spin { to { transform:rotate(360deg); } }
@keyframes c-shimmer { to { background-position:-200% 0; } }

/* Motion kill switch — §3.1: [data-c-motion="off"] disables all CSS
   animation/transition, forces scroll-behavior:auto, and removes press
   transforms. The attribute may sit on the .c-theme root, on an ancestor
   (e.g. <html> for a user preference), or on a subtree inside .c-theme. */
:is(.c-theme[data-c-motion=off],[data-c-motion=off] .c-theme,.c-theme [data-c-motion=off]),
:is(.c-theme[data-c-motion=off],[data-c-motion=off] .c-theme,.c-theme [data-c-motion=off]) *,
:is(.c-theme[data-c-motion=off],[data-c-motion=off] .c-theme,.c-theme [data-c-motion=off]) *::before,
:is(.c-theme[data-c-motion=off],[data-c-motion=off] .c-theme,.c-theme [data-c-motion=off]) *::after { animation:none!important; transition:none!important; scroll-behavior:auto!important; }
:is(.c-theme[data-c-motion=off],[data-c-motion=off] .c-theme,.c-theme [data-c-motion=off]) :is(.c-btn,.c-icon-btn):active { transform:none; }

/* User preference always wins, including JS animation (see runtime). */
@media(prefers-reduced-motion:reduce) { .c-theme *,.c-theme *::before,.c-theme *::after { animation:none!important; transition:none!important; scroll-behavior:auto!important; } .c-theme .c-btn:active,.c-theme .c-icon-btn:active { transform:none; } }

/* ---- §3.2 opt-in helpers (proposal-derived; additive, gated by the
   reduced-motion and data-c-motion=off blocks above) ---- */

/* M-1: page/section enter — opacity 0→1 + translateY(4px→0), 160–240ms.
   Apply to a region root; runs once when it mounts. */
@keyframes c-enter { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }
.c-theme .c-enter { animation:c-enter var(--c-motion-fast) var(--c-motion-ease) both; }

/* M-2: list enter stagger — ≤48ms per item, capped at 8 animated items;
   items 9+ appear instantly (no animation). */
.c-theme .c-stagger>* { animation:c-enter var(--c-motion-fast) var(--c-motion-ease) both; }
.c-theme .c-stagger>:nth-child(2){animation-delay:48ms}
.c-theme .c-stagger>:nth-child(3){animation-delay:96ms}
.c-theme .c-stagger>:nth-child(4){animation-delay:144ms}
.c-theme .c-stagger>:nth-child(5){animation-delay:192ms}
.c-theme .c-stagger>:nth-child(6){animation-delay:240ms}
.c-theme .c-stagger>:nth-child(7){animation-delay:288ms}
.c-theme .c-stagger>:nth-child(8){animation-delay:336ms}
.c-theme .c-stagger>:nth-child(n+9) { animation:none; }

/* M-13: opt-in smooth scrolling for in-page anchors. Reduced-motion and
   the off switch force scroll-behavior:auto via the gates above. */
.c-theme .c-scroll-smooth { scroll-behavior:smooth; }
