/* ============================================================
   Aidapt — Motion
   ------------------------------------------------------------
   "Motion has meaning — it carries the eye forward, never
   decorates." Movement follows the chevron: left → right.

   Fluid-interface rules (Apple-grade):
   · Respond on pointer-down, never on release.
   · Springs, not fixed curves, for anything a user can touch —
     they start from the current value and carry velocity, so
     motion is interruptible by default.
   · Two designer parameters: DAMPING (1.0 = no overshoot;
     ~0.8 = slight bounce, only after a gesture with momentum)
     and RESPONSE (seconds to reach target; not a duration).
   · Reduced motion = gentle crossfade, never dead silence.
   JS engine: window.AidaptMotion (components/motion/Motion.jsx)
   reads the --spring-* tokens below.
   ============================================================ */

:root {
  /* ---- Durations ---- */
  --dur-instant: 80ms; /* @kind other */
  --dur-fast: 140ms; /* @kind other */
  --dur-base: 220ms; /* @kind other */
  --dur-slow: 340ms; /* @kind other */
  --dur-slower: 520ms; /* @kind other */
  /* press feedback — the pointer-down highlight; near-instant */
  --dur-press: 90ms; /* @kind other */
  /* crossfade that SURVIVES prefers-reduced-motion */
  --dur-fade: 160ms; /* @kind other */

  /* ---- Spring parameters (damping ratio / response s) ----
     default : UI state changes            1.0 / 0.35
     move    : reposition, drag settle     1.0 / 0.40
     rotate  : rotation                    0.8 / 0.40
     sheet   : drawers, sheets, throws     0.8 / 0.30 */
  --spring-damping-default: 1.0; /* @kind other */
  --spring-response-default: 0.35; /* @kind other */
  --spring-damping-move: 1.0; /* @kind other */
  --spring-response-move: 0.4; /* @kind other */
  --spring-damping-rotate: 0.8; /* @kind other */
  --spring-response-rotate: 0.4; /* @kind other */
  --spring-damping-sheet: 0.8; /* @kind other */
  --spring-response-sheet: 0.3; /* @kind other */

  /* ---- Easings (named) ---- */
  --ease-forward:  cubic-bezier(0.16, 0.8, 0.32, 1);  /* @kind other */
  --ease-entrance: cubic-bezier(0.22, 1, 0.36, 1);    /* @kind other */
  --ease-exit:     cubic-bezier(0.4, 0, 1, 1);        /* @kind other */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);      /* @kind other */
  --ease-chevron:  cubic-bezier(0.34, 1.2, 0.64, 1);  /* @kind other */
  /* press-down: fast, decisive, no flourish */
  --ease-press:    cubic-bezier(0.33, 0, 0.67, 1);    /* @kind other */

  /* ---- Spring easings (CSS linear() approximations) ----
     For non-gesture CSS transitions that should FEEL sprung.
     Pair each with its duration token. Gesture-driven motion
     must use the JS engine instead (grabbable mid-flight). */
  --ease-spring: var(--ease-entrance); /* @kind other */
  --ease-spring-bounce: var(--ease-chevron); /* @kind other */
  --dur-spring: 500ms; /* @kind other */
  --dur-spring-bounce: 600ms; /* @kind other */

  /* ---- Composed transitions ---- */
  --transition-colors: color var(--dur-fast) var(--ease-standard),
                       background-color var(--dur-fast) var(--ease-standard),
                       border-color var(--dur-fast) var(--ease-standard); /* @kind other */
  --transition-transform: transform var(--dur-fast) var(--ease-forward); /* @kind other */
  --transition-base: all var(--dur-base) var(--ease-forward); /* @kind other */
  /* springy transform for release; pair with --dur-press override on :active */
  --transition-press: transform var(--dur-spring) var(--ease-spring); /* @kind other */
}

@supports (transition-timing-function: linear(0, 1)) {
  :root {
    /* critically damped (ζ=1.0, response .35) over 500ms */
    --ease-spring: linear(0, 0.122, 0.337, 0.537, 0.692, 0.801, 0.873, 0.921, 0.952, 0.971, 0.982, 0.99, 0.994, 0.997, 0.998, 1); /* @kind other */
    /* under-damped (ζ=0.8, response .40) over 600ms — ~1.5% overshoot */
    --ease-spring-bounce: linear(0, 0.141, 0.399, 0.639, 0.813, 0.922, 0.981, 1.007, 1.015, 1.014, 1.01, 1.007, 1.004, 1.002, 1, 1); /* @kind other */
  }
}

/* Reduced motion ≠ no feedback: transforms/springs collapse to
   instant, but --dur-fade stays for opacity crossfades. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-instant: 0ms; /* @kind other */
    --dur-fast: 0ms; /* @kind other */
    --dur-base: 0ms; /* @kind other */
    --dur-slow: 0ms; /* @kind other */
    --dur-slower: 0ms; /* @kind other */
    --dur-press: 0ms; /* @kind other */
    --dur-spring: 0ms; /* @kind other */
    --dur-spring-bounce: 0ms; /* @kind other */
  }
}
