/* ══════════════════════════════════════════════════════════════════════════════
   ShiftHR UI Kit — Pass B · MOTION SYSTEM
   ──────────────────────────────────────────────────────────────────────────────
   The CSS-only animation/transition/scroll-driven layer of the kit (brief §5.3).
   Motion TOKENS live in tokens.css (--duration-*, --ease-*, --reveal-shift); this
   file is the reusable UTILITY + PATTERN layer that consumes them. One vocabulary
   so every surface (marketing, app, admin) moves the same way.

   HARD RULES: zero JS · no pointer-tracking · everything degrades gracefully where
   scroll-driven animations aren't supported · everything respects
   prefers-reduced-motion · above-the-fold content is NEVER gated behind a reveal.
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── 1. Transition utilities ──────────────────────────────────────────────────── */
.mo-trans       { transition: all var(--duration-normal) var(--ease-standard); }
.mo-trans-fast  { transition: all var(--duration-fast)   var(--ease-standard); }
.mo-trans-slow  { transition: all var(--duration-slow)   var(--ease-out); }
.mo-lift        { transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out); }
.mo-lift:hover  { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.mo-press:active{ transform: translateY(1px) scale(.99); }

/* Theme switch — surfaces cross-fade their colour tokens (240ms house duration). */
.mo-theme-x,
.app-shell, .admin-shell, body {
    transition: background-color var(--duration-normal) var(--ease-standard),
                color var(--duration-normal) var(--ease-standard),
                border-color var(--duration-normal) var(--ease-standard);
}

/* ── 2. Entrance keyframes (used by modal/toast/popover + .mo-in*) ─────────────── */
@keyframes mo-fade      { from { opacity: 0; } to { opacity: 1; } }
@keyframes mo-rise      { from { opacity: 0; transform: translateY(var(--reveal-shift)); } to { opacity: 1; transform: translateY(0); } }
@keyframes mo-scale-in  { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.mo-in       { animation: mo-rise var(--duration-slow) var(--ease-out) both; }
.mo-in-fade  { animation: mo-fade var(--duration-normal) var(--ease-standard) both; }
.mo-in-scale { animation: mo-scale-in var(--duration-normal) var(--ease-out) both; }
/* stagger children (set --i: 0,1,2… inline) */
.mo-stagger > * { animation: mo-rise var(--duration-slow) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms); }

/* ── 3. Scroll-driven reveal (animation-timeline: view()) ──────────────────────
   Progressive enhancement: the element's RESTING state is the visible end-state,
   so any engine without scroll-timelines (or reduced-motion) simply shows content.
   We only ENABLE the from-hidden animation where @supports confirms view(). */
.mo-reveal { /* resting = visible (safe default) */ }
@supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
        .mo-reveal {
            animation: mo-rise both;
            animation-timeline: view();
            animation-range: entry 0% entry 60%;
        }
        .mo-reveal--scale { animation-name: mo-scale-in; }
    }
}

/* ── 4. Pin / sticky pattern ──────────────────────────────────────────────────── */
.mo-pin { position: sticky; top: var(--header-height); }

/* ── 5. Scroll-snap (page-per-scroll; relaxed proximity per Pass A marketing) ──── */
.mo-snap-y { scroll-snap-type: y proximity; }
.mo-snap-x { scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.mo-snap-start { scroll-snap-align: start; }

/* ── 6. Ambient mesh (the "ephemeral" feeling — CSS only, NO pointer-tracking) ─── */
.mo-mesh { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.mo-mesh::before, .mo-mesh::after {
    content: ""; position: absolute; width: 60%; aspect-ratio: 1; border-radius: var(--radius-full);
    filter: blur(90px); opacity: .5; animation-play-state: var(--mesh-state, running);
}
.mo-mesh::before { top: -18%; left: -10%; background: radial-gradient(circle, rgba(var(--color-culture-rgb), .30), transparent 70%); animation: mo-drift1 var(--duration-ambient) var(--ease-in-out) infinite alternate; }
.mo-mesh::after  { bottom: -22%; right: -12%; background: radial-gradient(circle, rgba(var(--color-recognition-rgb), .28), transparent 70%); animation: mo-drift2 calc(var(--duration-ambient) * 1.3) var(--ease-in-out) infinite alternate; }
@keyframes mo-drift1 { to { transform: translate(7%, 5%) scale(1.18); } }
@keyframes mo-drift2 { to { transform: translate(-6%, -4%) scale(1.12); } }

/* ── 7. Directed-clarity affordances (animated scroll cues) ────────────────────── */
.mo-cue { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; color: var(--color-neutral-500); }
.mo-cue svg { width: 22px; height: 22px; color: var(--color-brand); animation: mo-bob 1.9s var(--ease-in-out) infinite; }
@keyframes mo-bob { 0%, 100% { transform: translateY(0); opacity: .5; } 50% { transform: translateY(5px); opacity: 1; } }
.mo-chev-x svg { animation: mo-bob-x 1.9s var(--ease-in-out) infinite; }
@keyframes mo-bob-x { 0%, 100% { transform: translateX(0); opacity: .5; } 50% { transform: translateX(5px); opacity: 1; } }

/* ── 8. Expand / collapse (org-chart, accordions) — grid-rows trick, CSS only ──── */
.mo-collapse { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--duration-normal) var(--ease-standard); }
.mo-collapse.is-open { grid-template-rows: 1fr; }
.mo-collapse > * { overflow: hidden; }

/* ── 9. Global reduced-motion contract ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .mo-in, .mo-in-fade, .mo-in-scale, .mo-stagger > *, .mo-reveal { animation: none !important; }
    .mo-mesh::before, .mo-mesh::after { animation: none; }
    .mo-cue svg, .mo-chev-x svg { animation: none; }
    .mo-lift:hover { transform: none; }
    /* Every other movement stops too (A8, C11; Feature UIK, #1360): the transitions end at once, the press never
       shifts, a collapse opens without sliding; a colour or a panel still changes. */
    .mo-trans, .mo-trans-fast, .mo-trans-slow, .mo-lift, .mo-collapse { transition: none; }
    .mo-press:active { transform: none; }
}
