/* ============================================================
   motion.css — Phase 1 micro-interactions
   "Everything responds": buttons press, cards lift, rows slide,
   content fades up. transform/opacity only — GPU-cheap, no layout
   thrash. All gated behind prefers-reduced-motion.

   Selector scope rule: NEVER use bare element selectors (`button`,
   `[role="button"]`). Their blast radius is the whole app and they
   clobber transitions on form controls, modals, and critical
   destructive-action buttons. Stick to MAC-namespaced classes.
   ============================================================ */

@media (prefers-reduced-motion: no-preference) {

  /* ── Universal press feel — opt-in classes only ── */
  .refresh-btn,
  .cc-tab,
  .btn-primary,
  .btn-primary-action,
  [data-mac-press] {
    transition: background-color 0.15s var(--ease),
                border-color 0.15s var(--ease),
                color 0.15s var(--ease),
                transform 0.15s var(--ease),
                box-shadow 0.15s var(--ease);
  }
  .refresh-btn:active,
  .cc-tab:active,
  .btn-primary:active,
  .btn-primary-action:active,
  [data-mac-press]:active {
    transform: scale(0.97);
  }

  /* ── View/tab content entry: fade and lift ──
     The previous view uses display:none (it cannot transition out), so
     the new one fades up to soften the snap. Opacity and transform only:
     until 2026-11-11 this also blurred the whole page for 260 ms, which
     repaints a long Journal page blurred on every tab switch. */
  .app-page-shell:not(.is-hidden) {
    animation: mac-fade-up 0.26s var(--ease);
  }

  /* The chart shell is destroyed + re-created on every ticker click in
     the cockpit, so a blanket fade-in fired on every selection. Removed
     — the chart's own loading spinner already covers the gap. */
}

@keyframes mac-fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes mac-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Number flash: price/percent changed on refresh ──
   Applied by JS when a refreshed value moves beyond a meaningful
   threshold (see _flashClass in cockpit.js). One-shot keyframe;
   element is freshly rendered each cycle so the animation self-cleans.
   Subtle enough to coexist with reduced-motion. */
@keyframes mac-flash-up {
  0%   { background-color: var(--green-flash); }
  100% { background-color: transparent; }
}
@keyframes mac-flash-dn {
  0%   { background-color: var(--red-flash); }
  100% { background-color: transparent; }
}
.mac-flash-up { animation: mac-flash-up 0.9s ease-out; }
.mac-flash-dn { animation: mac-flash-dn 0.9s ease-out; }
