/**
 * RUTI Motion (1.62.0) – the system breathes.
 * Cards rise in as they come into view, numbers count up, charts build, the page glides between screens,
 * critical things breathe softly. Only opacity and transform – the GPU does the work, the page stays light.
 *
 *   html.m-full  everything (desktop, good phones)
 *   html.m-lite  calm version for small devices / data saver (fades, short charts, no halo)
 *   html.m-off   the person turned motion off (or the device asks for reduced motion) – nothing moves
 *
 * Set by motion.js from the person's choice (Settings → Motion: Auto / On / Off), stored in the `motion` cookie.
 */

/* ---------- 1. Entrances ----------
   Before the script runs, the head marks <html class="m-pre">: cards wait unseen (no flash), then rise in as they come into view.
   The list must stay the same as CARD in motion.js. If the script never runs, the head removes m-pre after 3 s. */
html.m-pre :is(#main, main.mm) :is([class*="card"]:not([class*="cards"]):not([class*="card__"]), [class*="tile"]:not([class*="tiles"]):not([class*="tile__"]), [class*="kpi"]:not([class*="kpis"]):not([class*="kpi__"]), article, .settings-group, .cbi-risk, .cbi-alert, .empty-state, .view__head, .mcard, .ins-cover, .cbi-table, .mtable, table.mt, .panel, .lrn-skill, .lrn-item, .lrn-stat, .member, .vital, li.dose, .agenda__item, section.block, .pay-action, .chart-box, .table-wrap, .invite-banner, .labs-note, .plan-fit, .quick-add):not(.m-in) { opacity: 0; }
html.m-full.m-pre :is(#main, main.mm) :is([class*="card"]:not([class*="cards"]):not([class*="card__"]), [class*="tile"]:not([class*="tiles"]):not([class*="tile__"]), [class*="kpi"]:not([class*="kpis"]):not([class*="kpi__"]), article, .settings-group, .cbi-risk, .cbi-alert, .empty-state, .view__head, .mcard, .ins-cover, .cbi-table, .mtable, table.mt, .panel, .lrn-skill, .lrn-item, .lrn-stat, .member, .vital, li.dose, .agenda__item, section.block, .pay-action, .chart-box, .table-wrap, .invite-banner, .labs-note, .plan-fit, .quick-add):not(.m-in) { transform: translate3d(0, 14px, 0) scale(.985); }
html.m-pre .m-card.m-in:not(.m-done) {
    transition: opacity .52s cubic-bezier(.2, .8, .2, 1) var(--m-d, 0ms), transform .62s cubic-bezier(.2, .8, .2, 1) var(--m-d, 0ms);
}
html.m-lite.m-pre .m-card.m-in:not(.m-done) { transition: opacity .32s ease var(--m-d, 0ms); }

/* ---------- 2. Hover lift (pointer devices only) ---------- */
@media (hover: hover) and (pointer: fine) {
    html.m-full .m-card.m-lift.m-done { transition: transform .22s cubic-bezier(.2, .8, .2, 1), box-shadow .22s ease, background-color .2s ease, border-color .2s ease, color .2s ease; }
    html.m-full .m-card.m-lift.m-done:hover { transform: translate3d(0, -3px, 0); box-shadow: 0 14px 34px -14px rgba(15, 23, 42, .28); }
}

/* click halo – the soft ring under the finger / pointer */
.m-halo {
    position: fixed; z-index: 2147483000; left: 0; top: 0; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%;
    pointer-events: none; opacity: 0; background: radial-gradient(circle, rgba(148, 163, 184, .30) 0%, rgba(148, 163, 184, .12) 55%, rgba(148, 163, 184, 0) 70%);
    border: 1.5px solid rgba(148, 163, 184, .45);
}
.m-halo.is-on { animation: m-halo .5s cubic-bezier(.2, .8, .2, 1) forwards; }
@keyframes m-halo { 0% { opacity: .9; transform: translate3d(var(--hx), var(--hy), 0) scale(.4); } 100% { opacity: 0; transform: translate3d(var(--hx), var(--hy), 0) scale(1.5); } }

/* ---------- 3. Charts that build ---------- */
/* HTML bars (width:% / height:%) grow from their base */
html:not(.m-off) .m-grow-x { transform-origin: 0 50%; animation: m-grow-x .8s cubic-bezier(.2, .8, .2, 1) var(--m-d, 0ms) both; }
html[dir="rtl"]:not(.m-off) .m-grow-x { transform-origin: 100% 50%; }
html:not(.m-off) .m-grow-y { transform-origin: 50% 100%; animation: m-grow-y .8s cubic-bezier(.2, .8, .2, 1) var(--m-d, 0ms) both; }
@keyframes m-grow-x { from { transform: scaleX(0); } }
@keyframes m-grow-y { from { transform: scaleY(0); } }
/* SVG charts: columns rise, lines draw, dots pop, slices bloom */
html:not(.m-off) svg .m-svg-col { transform-box: fill-box; transform-origin: 50% 100%; animation: m-grow-y .75s cubic-bezier(.2, .8, .2, 1) var(--m-d, 0ms) both; }
html:not(.m-off) svg .m-svg-row { transform-box: fill-box; transform-origin: 0 50%; animation: m-grow-x .75s cubic-bezier(.2, .8, .2, 1) var(--m-d, 0ms) both; }
html:not(.m-off) svg .m-svg-line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: m-draw 1.1s cubic-bezier(.4, 0, .2, 1) var(--m-d, 0ms) forwards; }
html:not(.m-off) svg .m-svg-dot { transform-box: fill-box; transform-origin: center; animation: m-pop .4s cubic-bezier(.3, 1.4, .5, 1) var(--m-d, 0ms) both; }
html:not(.m-off) svg .m-svg-slice { transform-box: view-box; transform-origin: center; animation: m-bloom .7s cubic-bezier(.2, .8, .2, 1) var(--m-d, 0ms) both; }
@keyframes m-draw { to { stroke-dashoffset: 0; } }
@keyframes m-pop { from { transform: scale(0); opacity: 0; } }
@keyframes m-bloom { from { transform: scale(.82) rotate(-8deg); opacity: 0; } }
html.m-lite svg .m-svg-col, html.m-lite svg .m-svg-row, html.m-lite .m-grow-x, html.m-lite .m-grow-y { animation-duration: .45s; }

/* ---------- 4. Breathing – things that need attention ---------- */
html.m-full .m-breathe { animation: m-breathe 3.6s ease-in-out infinite; }
@keyframes m-breathe { 0%, 100% { box-shadow: 0 0 0 0 var(--m-glow, rgba(239, 68, 68, .0)); } 50% { box-shadow: 0 0 0 6px var(--m-glow, rgba(239, 68, 68, .14)); } }
html.m-full .m-beat { animation: m-beat 2.4s ease-in-out infinite; }
@keyframes m-beat { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .55; transform: scale(.82); } }
html.m-paused .m-breathe, html.m-paused .m-beat { animation-play-state: paused; }   /* tab in the background */

/* a number that just changed flashes softly */
html:not(.m-off) .m-tick { animation: m-tick .6s ease; }
@keyframes m-tick { 30% { color: var(--color-primary, #38BDF8); } }

/* ---------- 5. Acting on a card: confirm glow, then it leaves and the list closes up ---------- */
html:not(.m-off) .m-acted { box-shadow: 0 0 0 2px var(--m-ok, #A3E635), 0 10px 30px -12px rgba(163, 230, 53, .55) !important; transition: box-shadow .16s ease, transform .16s ease; transform: scale(1.01); }
html:not(.m-off) .m-leave { animation: m-leave .3s cubic-bezier(.4, 0, .2, 1) forwards; overflow: hidden; }
@keyframes m-leave { to { opacity: 0; transform: translate3d(0, -6px, 0) scale(.97); } }

/* ---------- 6. Between pages (browsers that support it; others just open the page) ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: m-vt-out .16s ease both; }
::view-transition-new(root) { animation: m-vt-in .26s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes m-vt-out { to { opacity: 0; } }
@keyframes m-vt-in { from { opacity: 0; } }

/* ---------- 7. Off: nothing moves (RUTI's voice orb still shows when it listens) ---------- */
html.m-off *:not([class*="orb"]):not([class*="orb"] *):not([class*="splash"]):not([class*="splash"] *),
html.m-off *::before, html.m-off *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important;
    transition-duration: .001ms !important; transition-delay: 0ms !important; scroll-behavior: auto !important;
}
html.m-off::view-transition-old(root), html.m-off::view-transition-new(root) { animation: none; }

/* the Motion setting */
.m-choice { display: flex; gap: 6px; flex-wrap: wrap; }
.m-choice label { flex: 1 1 0; min-width: 84px; }
.m-choice input { position: absolute; opacity: 0; pointer-events: none; }
.m-choice span { display: grid; place-items: center; gap: 2px; padding: 10px 8px; border-radius: 12px; border: 1px solid var(--color-border, rgba(148, 163, 184, .35)); cursor: pointer; font-weight: 600; text-align: center; }
.m-choice span small { font-weight: 400; opacity: .7; font-size: 12px; }
.m-choice input:checked + span { border-color: var(--color-primary, #38BDF8); box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary, #38BDF8) 30%, transparent); }
.m-choice input:focus-visible + span { outline: 2px solid var(--color-primary, #38BDF8); outline-offset: 2px; }
.mdrawer__motion { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0; padding: 10px 12px; border-radius: 12px; background: rgba(148, 163, 184, .12); font-weight: 600; cursor: pointer; border: 0; width: 100%; color: inherit; font: inherit; }

@media print {
    html .m-card { opacity: 1 !important; transform: none !important; }
    .m-halo { display: none; }
}
