/* CreaBud motion system (#114) — « Calme & précis ».
   One vocabulary for the whole app. Rules:
   - Only transform and opacity move (GPU compositing, no layout, no reflow during motion).
   - Enter settles (spring with ~1 % overshoot, never a cartoon bounce); exit is faster and leaves.
   - Distance is short (12–18 px for pages, the sheet's own height for sheets): motion explains
     where something comes from, it never decorates.
   - Money is never distorted: a changing amount counts from its old value to the exact new one,
     and the final text is always the app's own formatted value.
   - Reduce Motion: slides become short dissolves, counters jump to the value, no stagger.
   The choreography itself lives in js/motion.js (Web Animations API, interruptible). */

:root{
  --m-fast:140ms;      /* press feedback, small state changes */
  --m-base:220ms;      /* component state, backdrop */
  --m-page:260ms;      /* tab / screen change */
  --m-sheet:380ms;     /* sheet enter (spring) */
  --m-exit:200ms;      /* every exit */
  --m-ease-out:cubic-bezier(.2,.8,.2,1);
  --m-ease-in:cubic-bezier(.4,0,1,1);
  --m-ease-press:cubic-bezier(.3,.7,.4,1);
}

/* js/motion.js owns sheet/menu/page motion when it runs (html.m-on). */
html.m-on .modal-ov .modal{animation:none!important}
html.m-on section.tab.active{animation:none}
/* A sheet that is closing stays painted for its exit, but no longer takes touches. */
.modal-ov.m-leaving{display:flex!important;pointer-events:none}
.modal-ov.m-leaving *{pointer-events:none!important}

/* ---------- Add: the signature control ---------- */
.mobilebar .mobile-add-circle{transition:transform var(--m-fast) var(--m-ease-press)}
.mobilebar .mobile-add:active .mobile-add-circle{transform:scale(.9)}
/* While the Add menu is open, a twin of the Add button floats above the dim at the exact same place
   (js/motion.js), so the + → × change stays visible and the × closes the menu. The tab bar itself
   stays under the dim, untouched. */
.m-add-twin{position:fixed;z-index:96;margin:0;padding:0;border:0;background:none;cursor:pointer;
  display:flex;align-items:center;justify-content:center;-webkit-tap-highlight-color:transparent}
.m-add-twin[hidden]{display:none}
.m-add-twin>span{box-sizing:border-box;display:flex;align-items:center;justify-content:center}
.m-add-twin svg{width:28px;height:28px}
/* The Add menu grows from the button, not from the middle of the screen. */
html.m-on #fab-menu-ov{align-items:flex-end;padding-bottom:calc(96px + env(safe-area-inset-bottom))}
html.m-on #fab-menu-ov .modal{transform-origin:50% 100%}
@media (min-width:901px){html.m-on #fab-menu-ov{align-items:center;padding-bottom:20px}}

/* ---------- tab bar & menus: our own press feedback replaces the grey/blue tap flash ---------- */
.mobilebar button,.fab-opt,.m-add-twin{-webkit-tap-highlight-color:transparent}
.fab-opt{transition:background-color var(--m-fast) var(--m-ease-out),transform var(--m-fast) var(--m-ease-press)}
.mobilebar button:not(.mobile-add) svg{transition:transform var(--m-fast) var(--m-ease-press)}
.mobilebar button:not(.mobile-add):active svg{transform:scale(.86)}

/* ---------- save confirmation (only after the cloud confirms) ---------- */
.m-toast{position:fixed;left:50%;bottom:calc(92px + env(safe-area-inset-bottom));z-index:1001;
  display:flex;align-items:center;gap:10px;width:max-content;max-width:min(calc(100vw - 32px),420px);box-sizing:border-box;
  white-space:normal;text-wrap:balance;overflow-wrap:anywhere;
  padding:10px 16px 10px 12px;border-radius:22px;font:600 15px/1.25 var(--font-body,system-ui);
  color:var(--m-toast-ink,#fff);background:var(--m-toast-bg,#1f1830);
  box-shadow:0 8px 24px rgba(20,12,40,.22);transform:translateX(-50%);pointer-events:none}
.m-toast[hidden]{display:none}
.m-toast .m-ico{width:22px;height:22px;flex:0 0 22px}
.m-toast .m-ico circle{fill:none;stroke:currentColor;stroke-width:2;opacity:.35}
.m-toast .m-ico path{fill:none;stroke:currentColor;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round;display:none}
/* Only a confirmed save shows the tick; a failure shows "!", the Lab "not verified" state shows "i". */
.m-toast[data-state="ok"] .m-ico .m-tick{display:block;stroke-dasharray:20;stroke-dashoffset:20;animation:m-draw 280ms 60ms var(--m-ease-out) forwards}
.m-toast[data-state="ok"] .m-ico circle{opacity:1;stroke:#5fe3a8}
.m-toast[data-state="pending"] .m-ico circle{stroke-dasharray:44 20;animation:m-turn .9s linear infinite;transform-origin:50% 50%}
.m-toast[data-state="warn"] .m-ico .m-bang{display:block}
.m-toast[data-state="warn"] .m-ico circle{opacity:1;stroke:#ffb35c}
.m-toast[data-state="info"] .m-ico .m-info{display:block}
.m-toast[data-state="info"] .m-ico circle{opacity:1;stroke:#9fb4ff}
html[data-theme="light"] .m-toast,html[data-theme="auto"] .m-toast{--m-toast-bg:#211a33}
html:is([data-theme="mono-yellow"],[data-theme="mono-orange"]) .m-toast{--m-toast-bg:#202735}
@media (min-width:901px){.m-toast{bottom:28px}}

@media (prefers-reduced-motion:reduce){
  .mobilebar .mobile-add-circle,.mobilebar .mobile-add-circle svg,.mobilebar button svg{transition:none}
  .m-toast[data-state="ok"] .m-ico .m-tick{animation:none;stroke-dashoffset:0}
  .m-toast[data-state="pending"] .m-ico circle{animation:none}
}

/* Sub-screen ghost (integration lot 1): the previous screen leaving, never interactive. */
.m-sub-ghost{position:fixed;inset:0;overflow:hidden;pointer-events:none;z-index:2}

/* Financial visualisation (integration lots 3–6, 9) */
@property --m-r{syntax:"<length>";inherits:false;initial-value:0px}
.m-theme-wash{position:fixed;inset:0;z-index:2147483000;pointer-events:none;
  -webkit-mask:radial-gradient(circle at var(--m-x) var(--m-y),transparent var(--m-r),#000 calc(var(--m-r) + 1px));
          mask:radial-gradient(circle at var(--m-x) var(--m-y),transparent var(--m-r),#000 calc(var(--m-r) + 1px))}
.m-sprout{display:inline-block;width:26px;height:26px;margin-right:8px;vertical-align:-7px;position:relative;flex:0 0 26px}
.m-sprout svg{width:100%;height:100%;overflow:visible}
.m-sprout .st{fill:none;stroke:var(--green-text,#1d9c7f);stroke-width:4;stroke-linecap:round}
.m-sprout .lf{fill:var(--green-text,#1d9c7f);opacity:0}
.m-sprout [data-leaf="4"]{opacity:0}
.m-sprout .cn{fill:#ffc34d;stroke:#d4931a;stroke-width:2}.m-sprout .cm{fill:none;stroke:#7a4f00;stroke-width:2;stroke-linecap:round}
.m-sprout[data-stage="1"] [data-leaf="1"],
.m-sprout[data-stage="2"] :is([data-leaf="1"],[data-leaf="2"]),
.m-sprout[data-stage="3"] :is([data-leaf="1"],[data-leaf="2"],[data-leaf="3"]),
.m-sprout[data-stage="4"] [data-leaf]{opacity:1}
.m-bloom{position:absolute;inset:-8px;border-radius:50%;pointer-events:none;background:radial-gradient(circle,rgba(39,201,167,.5),rgba(39,201,167,0) 68%)}
.debt-prog{position:relative}
.debt-prog[data-m-seg]::after{content:"";position:absolute;inset:0;pointer-events:none;border-radius:inherit;
  background:repeating-linear-gradient(90deg,transparent 0 calc(100% / var(--m-seg) - 2px),var(--card,#fff) calc(100% / var(--m-seg) - 2px) calc(100% / var(--m-seg)))}
.m-seg-pulse{position:absolute;inset:-3px;border-radius:inherit;pointer-events:none;box-shadow:0 0 0 3px rgba(39,201,167,.55)}
.m-deco-clip{position:absolute;inset:0;border-radius:inherit;overflow:hidden;pointer-events:none;z-index:2}
.m-deco-sheen{position:absolute;top:-20%;bottom:-20%;left:0;width:40%;pointer-events:none;opacity:0;
  background:linear-gradient(90deg,rgba(255,255,255,0),rgba(255,255,255,.45),rgba(255,255,255,0))}
@media (prefers-reduced-motion:reduce){.m-theme-wash,.m-seg-pulse,.m-deco-sheen,.m-bloom{display:none}}
/* Frame budget (bench docs/qa/MOTION_FRAME_BENCH.md, 2026-11-24): the dim's 4 px backdrop blur had to be re-filtered on
   every frame of its opacity fade — 26–30 of 40 Add-menu entrances dropped frames (≈4 frames > 20 ms each) against 0 of 40
   without Motion, on an idle machine. Animated overlays keep the tint (a touch deeper) without that blur; the menu card and
   sheets keep their own frosted glass. Measured after: 0 dropped-frame trials for the Add menu and the expense sheet. */
html.m-on .modal-ov{backdrop-filter:none;-webkit-backdrop-filter:none;background:rgba(60,30,70,.5)}
