/* BOEKUNA motion — short, calm movement so the app responds to what you do.
   Everything sits under html.boekuna-motion (set by motion.js) and stops for prefers-reduced-motion. */

/* 1. Buttons and cards change colour smoothly; the press itself (sink and spring back) lives in press.css. */
html.boekuna-motion :is(#mainApp,#modalRoot) :is(.btn,.icon-btn,.nav-item,.mobile-bottom-nav-item,button.card,.dashboard-attention-item,.quick-action,.action-row,.mobile-card-main,.modal-close){
  transition:transform .1s ease,background-color .12s ease,border-color .12s ease,color .12s ease!important;
}

/* 2. A new page eases in, quickly (Kwin 2026-10-26: switching pages felt slow). It starts half visible, so it is never blank. */
html.boekuna-motion #content.motion-enter{animation:boekuna-motion-rise .16s cubic-bezier(.2,.8,.2,1) both}
@keyframes boekuna-motion-rise{from{opacity:.4;transform:translateY(6px)}to{opacity:1;transform:none}}

/* 4. Chart bars grow up from the baseline, one group after the other. */
html.boekuna-motion #content.motion-enter .bar{transform-origin:bottom;animation:boekuna-motion-grow .36s cubic-bezier(.2,.8,.2,1) both}
html.boekuna-motion #content.motion-enter .bar-group:nth-child(2) .bar{animation-delay:.03s}
html.boekuna-motion #content.motion-enter .bar-group:nth-child(3) .bar{animation-delay:.06s}
html.boekuna-motion #content.motion-enter .bar-group:nth-child(4) .bar{animation-delay:.09s}
html.boekuna-motion #content.motion-enter .bar-group:nth-child(5) .bar{animation-delay:.12s}
html.boekuna-motion #content.motion-enter .bar-group:nth-child(n+6) .bar{animation-delay:.15s}
@keyframes boekuna-motion-grow{from{transform:scaleY(0)}to{transform:scaleY(1)}}

/* 6. List rows come with their page (no row-by-row stagger: the list is complete at once). */

/* 5. A check mark draws itself in toasts that confirm something worked. */
html.boekuna-motion .toast.motion-success{display:flex;align-items:center;gap:9px}
.motion-check{width:20px;height:20px;flex:0 0 20px}
.motion-check circle{fill:#63D471;transform-origin:center;animation:boekuna-motion-pop .32s cubic-bezier(.2,.8,.2,1) both}
.motion-check path{fill:none;stroke:#0E2A16;stroke-width:2.6;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:16;animation:boekuna-motion-draw .3s .18s cubic-bezier(.2,.8,.2,1) both}
@keyframes boekuna-motion-pop{from{transform:scale(.3);opacity:0}to{transform:scale(1);opacity:1}}
@keyframes boekuna-motion-draw{from{stroke-dashoffset:16}to{stroke-dashoffset:0}}

/* 8. A status that just became "Betaald" pops once. */
html.boekuna-motion .badge.motion-paid{animation:boekuna-motion-stamp .45s cubic-bezier(.2,.8,.2,1)}
@keyframes boekuna-motion-stamp{0%{transform:scale(1)}40%{transform:scale(1.22)}100%{transform:scale(1)}}

/* C. On a phone a new screen comes from the side of the tab you tapped. */
@media (max-width:820px){
  html.boekuna-motion #content.motion-enter.motion-dir-right{animation:boekuna-motion-from-right .18s cubic-bezier(.2,.8,.2,1) both}
  html.boekuna-motion #content.motion-enter.motion-dir-left{animation:boekuna-motion-from-left .18s cubic-bezier(.2,.8,.2,1) both}
}
@keyframes boekuna-motion-from-right{from{opacity:.4;transform:translateX(14px)}to{opacity:1;transform:none}}
@keyframes boekuna-motion-from-left{from{opacity:.4;transform:translateX(-14px)}to{opacity:1;transform:none}}

/* A. A new item slides into its place and lights up green for a moment. */
html.boekuna-motion :is(tr,.mobile-card-row).motion-new{animation:boekuna-motion-slot .4s cubic-bezier(.2,.8,.2,1) both,boekuna-motion-glow 1.6s ease-out both}
html.boekuna-motion tr.motion-new>td{animation:boekuna-motion-glow 1.6s ease-out both}
@keyframes boekuna-motion-slot{from{opacity:0;transform:translateY(-12px)}to{opacity:1;transform:none}}
@keyframes boekuna-motion-glow{0%,35%{background-color:rgba(99,212,113,.22)}100%{background-color:transparent}}

/* B. A removed item slides out; motion.js then closes the gap. */
html.boekuna-motion .motion-ghost{pointer-events:none;animation:boekuna-motion-out .24s cubic-bezier(.4,0,.2,1) forwards}
@keyframes boekuna-motion-out{to{opacity:0;transform:translateX(32px)}}

/* D. A new receipt flies to Bonnen, which bumps once. */
.motion-fly{position:fixed;left:0;top:0;z-index:2000;width:44px;height:44px;border-radius:12px;background:#63D471;display:grid;place-items:center;pointer-events:none}
.motion-fly svg{width:22px;height:22px;fill:none;stroke:#0E2A16;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
html.boekuna-motion .motion-bump{animation:boekuna-motion-bump .45s cubic-bezier(.2,.8,.2,1)}
@keyframes boekuna-motion-bump{40%{transform:scale(1.18)}}

/* E. A detail window grows out of the row you tapped (motion.js sets the origin). */
html.boekuna-motion #modalRoot .modal.motion-from-row{animation:boekuna-motion-grow-in .2s cubic-bezier(.2,.8,.2,1) both!important}
@keyframes boekuna-motion-grow-in{from{opacity:0;transform:scale(.88,.4)}to{opacity:1;transform:none}}

/* 5. A total that changed shows how much it moved. */
html.boekuna-motion .motion-delta-host{position:relative}
.motion-delta{position:absolute;right:14px;bottom:12px;font-size:12px;font-weight:700;border-radius:999px;padding:2px 8px;pointer-events:none;animation:boekuna-motion-float 1.4s cubic-bezier(.2,.8,.2,1) both}
.motion-delta.is-up{background:#ECFAEE;color:#1F7A35}
.motion-delta.is-down{background:#FDECEA;color:#A3271F}
@keyframes boekuna-motion-float{0%{opacity:0;transform:translateY(6px)}20%{opacity:1;transform:none}75%{opacity:1}100%{opacity:0;transform:translateY(-10px)}}

/* 1-4. A livelier overview, kept calm: a plain trend line on profit and quiet mini-charts. */
.motion-kpi-extra{display:flex;flex-direction:column;gap:6px;margin-top:8px;min-width:0;text-align:left}
.motion-trend{display:block;font-size:12px;font-weight:600;line-height:1.3;color:#5E6870}
.motion-trend .motion-arrow{margin-right:3px}
.motion-trend.is-good .motion-arrow{color:#1F7A35}
.motion-trend.is-bad .motion-arrow{color:#C0392B}
.motion-spark-wrap{position:relative;height:22px;opacity:.85}
.motion-spark{display:block;width:100%;height:22px;overflow:visible}
.motion-spark-line{fill:none;stroke:var(--spark);stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;vector-effect:non-scaling-stroke}
.motion-spark-area{fill:var(--spark);opacity:.07}
.motion-spark-dot{position:absolute;width:6px;height:6px;margin:-3px 0 0 -3px;border-radius:50%;background:var(--spark)}
.motion-kpi-extra.is-entering .motion-spark-line{animation:boekuna-motion-line .9s .15s cubic-bezier(.2,.8,.2,1) backwards}
.motion-kpi-extra.is-entering .motion-spark-dot{animation:boekuna-motion-show .25s .95s both}
.motion-kpi-extra.is-entering .motion-trend{animation:boekuna-motion-show .35s .25s both}
@keyframes boekuna-motion-line{from{stroke-dasharray:100;stroke-dashoffset:100}to{stroke-dasharray:100;stroke-dashoffset:0}}
@keyframes boekuna-motion-show{from{opacity:0}to{opacity:1}}
.motion-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

html[data-theme="dark"] .motion-trend{color:#B7C0C6}
html[data-theme="dark"] .motion-trend.is-good .motion-arrow{color:#7FE08B}
html[data-theme="dark"] .motion-trend.is-bad .motion-arrow{color:#FF9A92}
html[data-theme="dark"] .motion-delta.is-up{background:#1D2C21;color:#7FE08B}
html[data-theme="dark"] .motion-delta.is-down{background:#33201E;color:#FF9A92}

@media (prefers-reduced-motion:reduce){
  html.boekuna-motion #content.motion-enter,
  html.boekuna-motion #content.motion-enter *,
  html.boekuna-motion .badge.motion-paid,
  .motion-check circle,.motion-check path,
  .motion-kpi-extra *,.motion-delta,.motion-bump,
  html.boekuna-motion :is(tr,.mobile-card-row).motion-new,html.boekuna-motion tr.motion-new>td,
  html.boekuna-motion #modalRoot .modal.motion-from-row{animation:none!important}
  html.boekuna-motion :is(#mainApp,#modalRoot) :is(.btn,.icon-btn,.nav-item,.mobile-bottom-nav-item,button.card,.dashboard-attention-item,.quick-action,.action-row,.mobile-card-main,.modal-close):active:not(:disabled){transform:none!important}
}

/* M1 (roast room, Kwin 2026-10-26), phone only: a sheet slides up from below the screen like on iOS and slides back down when it
   closes (motion.js keeps a copy of it on screen for that); a swipe down on its top closes it. */
@media (max-width:820px){
  /* The dim is a layer behind the sheet, so the sheet itself never fades. */
  html.boekuna-motion body #modalRoot#modalRoot .modal-backdrop:not(.invoice-page-backdrop){background:transparent!important}
  html.boekuna-motion body #modalRoot#modalRoot .modal-backdrop:not(.invoice-page-backdrop)::before{content:"";position:fixed;inset:0;background:rgba(10,14,12,.5);opacity:var(--sheet-dim,1);animation:boekuna-sheet-fade .2s ease backwards;pointer-events:none}
  html.boekuna-motion body #modalRoot#modalRoot .modal-backdrop:not(.invoice-page-backdrop)>.modal{position:relative;z-index:1}
  html.boekuna-motion body #modalRoot#modalRoot .modal:not(.invoice-page),html.boekuna-motion body #modalRoot#modalRoot .modal.motion-from-row:not(.invoice-page){animation:boekuna-sheet-up .3s cubic-bezier(.32,.72,0,1) both!important}
  html.boekuna-motion body #modalRoot#modalRoot :is(.modal-backdrop,.modal).motion-sheet-swap,html.boekuna-motion body #modalRoot#modalRoot .motion-sheet-swap::before{animation:none!important}
  html.boekuna-motion body #modalRoot#modalRoot .modal-backdrop.motion-sheet-ghost{pointer-events:none}
  html.boekuna-motion body #modalRoot#modalRoot .modal-backdrop.motion-sheet-ghost::before{animation:boekuna-sheet-fade-out .2s ease forwards}
  html.boekuna-motion body #modalRoot#modalRoot .motion-sheet-ghost .modal{animation:boekuna-sheet-down .2s cubic-bezier(.32,.72,0,1) forwards!important}
  html.boekuna-motion body #modalRoot#modalRoot .modal.is-dragging{animation:none!important;transition:none!important}
  html.boekuna-motion body #modalRoot#modalRoot .modal.is-settling{transition:transform .24s cubic-bezier(.32,.72,0,1)!important}
  html.boekuna-motion body #modalRoot#modalRoot .modal:not(.invoice-page) .modal-head{-webkit-user-select:none;user-select:none}
  /* iPhone Safari paints a scroll area that starts below the screen only up to the old screen edge, so the bottom of a sliding
     sheet stayed empty until you touched it (Kwin 2026-10-26, + > Bon). While the sheet slides in, its body is not a scroll area
     yet; motion.js lifts that when the slide ends, which also makes the browser paint the whole sheet. */
  html.boekuna-motion body #modalRoot#modalRoot .modal.sheet-entering :is(.modal-body,.modal-foot){overflow:hidden!important}
  html.boekuna-motion body #modalRoot#modalRoot .modal:not(.invoice-page){-webkit-backface-visibility:hidden;backface-visibility:hidden}
}
@keyframes boekuna-sheet-up{from{transform:translateY(100%)}to{transform:none}}
@keyframes boekuna-sheet-down{from{transform:translateY(var(--sheet-from,0))}to{transform:translateY(100%)}}
@keyframes boekuna-sheet-fade{from{opacity:0}to{opacity:1}}
@keyframes boekuna-sheet-fade-out{to{opacity:0}}
@media (prefers-reduced-motion:reduce){
  html.boekuna-motion body #modalRoot#modalRoot .modal-backdrop,html.boekuna-motion body #modalRoot#modalRoot .modal{animation:none!important}
  html.boekuna-motion body #modalRoot#modalRoot .modal-backdrop::before{animation:none!important}
}

/* Soepeler (Kwin 2026-10-29: "alles moet een beetje soepel zijn").
   Only cheap properties change smoothly: colours, opacity, a transform. A tab or button that also eased its letter weight, size
   or padding re-laid the page out on every frame (the tab bar did, because it sits outside #mainApp). */
html.boekuna-motion :is(a,button,input,select,textarea){transition-property:color,background-color,border-color,box-shadow,opacity,transform}
html.boekuna-motion #mobileBottomNav .mobile-bottom-nav-item{transition-property:color,background-color,opacity,transform!important}
/* Totals that count up keep every digit the same width, so the number does not wobble while it runs. */
html.boekuna-motion :is(.metric-value,.dashboard-summary-value){font-variant-numeric:tabular-nums}
/* Long lists open faster on a phone: rows below the screen are only laid out and painted once you scroll to them. The tables
   behind Inkomsten, Kosten, Bank and Bonnen are swapped for calm rows (mobile-product.js), so their own rows never need it. */
@media (max-width:820px){
  html.boekuna-motion #content .mobile-card-list>.mobile-card-row{content-visibility:auto;contain-intrinsic-size:auto 89px}
  html.boekuna-motion #content :is(.mobile-invoices,.mobile-expenses,.mobile-bank,.mobile-documents)>tbody>tr{content-visibility:auto;contain-intrinsic-size:auto 168px}
  /* The screen that slides in beside you while you swipe (vegen.js) and the one moving with your finger are drawn in full:
     rows that were skipped would pop in half way through the swipe (Kwin 2026-11-05, "niet altijd soepel"). */
  html.boekuna-motion :is(#content.bk-peek,#content.bk-paging) :is(.mobile-card-list>.mobile-card-row,:is(.mobile-invoices,.mobile-expenses,.mobile-bank,.mobile-documents)>tbody>tr){content-visibility:visible}
}
/* iPhone (Safari and the app): content-visibility can leave parts of a row unpainted after scrolling, such as the amount on
   the right (Kwin 2026-11-05: "ik zie de bedragen niet bij Inkomsten"). The lists are short enough to draw in full there. */
@supports (-webkit-touch-callout:none){
  html.boekuna-motion #content :is(.mobile-card-list>.mobile-card-row,:is(.mobile-invoices,.mobile-expenses,.mobile-bank,.mobile-documents)>tbody>tr){content-visibility:visible}
}
/* Volledige check 2026-11-06: in the phone band the amount has no card around it, so the chip sat on the cents. There it floats above the amount. */
.motion-delta-host:not(.card)>.motion-delta{bottom:auto;top:-20px;right:-4px}
