/* ============================================================================
   Risper CRM — motion layer (04/11/2026)
   Loaded on every screen through partials/motion-assets, never inline.

   The small movements that tell a hand its tap landed. Each one is a FEEL, never
   a function: nothing here changes what a click, a drag or a save does — only how
   the moment looks. Driven by public/js/crm-motion.js, which adds the classes.

     1. Press      — a button sinks to 95% under the finger, then springs back
     2. Roll       — when a total changes, its new digits roll in one after another
     3. Lift       — a row picked up to reorder grows 5% and casts a shadow
     4. Expand     — a panel opens fast, then slows down (ease-out, 350ms)
     5. Done       — a "saved" message draws its circle, then its tick
     6. Backdrop   — a dialog dims the page behind it to ~2.5:1, so it stands alone
   (Pull-to-refresh resistance lives with the gesture, in crm-mobile.js.)

   Every movement uses the individual `scale` property, never `transform`, so it
   composes with any transform a button or a dragged row already carries (a
   translate(-50%) centring, Sortable's own translate3d) instead of replacing it.
   Every animation sits inside `prefers-reduced-motion: no-preference`: a person
   who has asked their device for less motion gets none of this.
   ============================================================================ */

/* ── 1. Press: sink to 95%, spring back ─────────────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
    .crm-press-down {
        scale: .95;
        transition: scale 90ms cubic-bezier(.2, 0, .2, 1);
    }
    /* The release overshoots a touch past 100% and settles: the spring. */
    .crm-press-up {
        transition: scale 320ms cubic-bezier(.34, 1.56, .64, 1);
    }
}

/* ── 2. Roll: changed digits rise into place, staggered by the script ──────── */
.crm-roll-d { display: inline-block; }
@media (prefers-reduced-motion: no-preference) {
    .crm-roll-d { animation: crm-roll-in 420ms cubic-bezier(.22, 1, .36, 1) both; }
}
@keyframes crm-roll-in {
    from { translate: 0 .6em; opacity: 0; }
    to   { translate: 0 0;    opacity: 1; }
}

/* ── 3. Lift: the row you picked up grows 5%; the others slide (Sortable's
         `animation` option, already set on every list) ───────────────────── */
@media (prefers-reduced-motion: no-preference) {
    .sortable-chosen:not(.sortable-ghost) {
        scale: 1.05;
        box-shadow: 0 12px 28px rgba(16, 24, 40, .18);
        transition: scale 160ms cubic-bezier(.2, 0, 0, 1), box-shadow 160ms ease-out;
        position: relative;
        z-index: 3;
    }
    /* The copy that follows the finger on touch screens (Sortable's fallback). */
    .sortable-fallback,
    .sortable-drag {
        scale: 1.05;
        box-shadow: 0 16px 36px rgba(16, 24, 40, .22);
    }
}

/* ── 4. Expand: Bootstrap's collapse keeps its 350ms, gains the ease-out ───── */
/* Duration untouched — Bootstrap reads it to know when the panel has opened. */
:root .collapsing { transition-timing-function: cubic-bezier(.22, 1, .36, 1); }

/* ── 5. Done: circle first, then the tick ───────────────────────────────────── */
.crm-tick {
    display: inline-block;
    width: 1.15em;
    height: 1.15em;
    vertical-align: -.2em;
    flex-shrink: 0;
    overflow: visible;
}
.crm-tick circle,
.crm-tick path {
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.crm-tick circle { stroke-width: 2; transform: rotate(-90deg); transform-origin: 50% 50%; }
.crm-tick path   { stroke-width: 2.3; }
@media (prefers-reduced-motion: no-preference) {
    .crm-tick circle,
    .crm-tick path {
        stroke-dasharray: 1;
        stroke-dashoffset: 1;
        animation: crm-tick-draw 360ms cubic-bezier(.65, 0, .35, 1) forwards;
    }
    .crm-tick path { animation-duration: 260ms; animation-delay: 320ms; }
}
@keyframes crm-tick-draw { to { stroke-dashoffset: 0; } }
/* A toast that never had an icon gets the mark beside its words. */
.crm-toast-ticked { display: flex; align-items: center; gap: 9px; }

/* ── 6. Backdrop: ~2.5:1 behind a dialog (Bootstrap's 0.5 leaves ~5:1) ───── */
:root .modal-backdrop { --bs-backdrop-opacity: .7; }
:root .offcanvas-backdrop.show { opacity: .7; }
