/* 50-v2-motion.css — the new interface's motion (body.ui-v2; ui/motion-v2.js). When a page opens its main amount
   counts up from 0 (about 1.3 s, slowing to a stop), its blocks rise into place one after another and the rows inside
   follow, bars fill from their start, the lit bar item springs, sheets slide up from the bottom over a fading backdrop,
   and the type switch of تسجيل عملية slides its thumb. The page itself never fades (no blank moment between pages).
   One curve for everything that arrives: --v2-ease (fast start, long soft landing). Only transform and opacity
   move. Page motion plays only while a page is opening (.v2-enter, ~1.5 s, set by _v2Enter), so a redraw after a
   save never replays it. Under prefers-reduced-motion: reduce nothing moves; the switch's thumb just sits. */
.ui-v2 { --v2-ease: cubic-bezier(.16, 1, .3, 1); --v2-spring: cubic-bezier(.34, 1.56, .64, 1); }

/* ── The sliding thumb of a segmented switch (.v2-seg--thumb; style="--seg-n --seg-i --seg-from") ── */
.ui-v2 { --v2-dir: -1; }                     /* RTL: the next item is to the left */
.ui-v2[dir="ltr"], [dir="ltr"] .ui-v2 { --v2-dir: 1; }
.ui-v2 .v2-seg--thumb { position: relative; isolation: isolate; }
.ui-v2 .v2-seg--thumb > .is-on { background: none; box-shadow: none; }
.ui-v2 .v2-seg--thumb::before {
    content: ''; position: absolute; z-index: -1; top: 4px; bottom: 4px; inset-inline-start: 4px;
    width: calc((100% - 8px - (var(--seg-n, 1) - 1) * 4px) / var(--seg-n, 1));
    border-radius: 11px; background: var(--c-surface); box-shadow: var(--el-1);
    transform: translateX(calc(var(--seg-i, 0) * (100% + 4px) * var(--v2-dir)));
}

@media (prefers-reduced-motion: no-preference) {
    .ui-v2 .v2-seg--thumb.is-sliding::before { animation: v2SegSlide 280ms var(--ease-out); }
    @keyframes v2SegSlide { from { transform: translateX(calc(var(--seg-from, 0) * (100% + 4px) * var(--v2-dir))); } }

    /* The part under the chips and the amount after a type change */
    .ui-v2 .v2-cap__pick.is-swap { animation: v2Swap 260ms var(--ease-out); }
    .ui-v2 .v2-cap__amount.is-swap { animation: v2AmtSwap 220ms var(--ease-out); }
    @keyframes v2Swap { from { opacity: 0; transform: translateY(8px); } }
    @keyframes v2AmtSwap { from { opacity: .4; transform: scale(.96); } }

    /* Other switches (السجل | التحليل, periods): the chosen one fades its white pill in */
    .ui-v2 .v2-seg:not(.v2-seg--thumb) > .is-on { animation: v2SegOn 200ms var(--ease-out); }
    @keyframes v2SegOn { from { box-shadow: none; background: transparent; } }

    /* The bottom bar: the lit item's pill springs in */
    .ui-v2 .v2-nav__item.is-on .v2-nav__ic { animation: v2NavPop 420ms var(--v2-spring); }
    @keyframes v2NavPop { from { transform: scale(.7); opacity: .5; } }

    /* A page opening. The page itself never fades: the old whole-page fade (01-base.css .view → fadeIn, from
       opacity 0) blanked the screen for a moment on every switch, so it is off here. The first block is there at
       once; the blocks under it rise 14px into place from a faint start (never from blank), 60 ms apart. */
    .ui-v2 .main-content > .view { animation: none; }
    .ui-v2 .v2-enter :is(.v2-card, .v2t-heros, .v2t-omni, .v2t-sh, .v2t-due, .v2-sec-head, .v2-group-title, .v2-chips, .v2-seg, .v2t-note, .v2p-boxes) {
        animation: v2Rise 620ms var(--v2-ease) both;
    }
    .ui-v2 .v2-enter :is(.v2-card, .v2t-heros, .v2t-omni, .v2t-sh, .v2t-due, .v2-sec-head, .v2-group-title, .v2-chips, .v2-seg, .v2t-note, .v2p-boxes):nth-child(2) { animation-delay: 60ms; }
    .ui-v2 .v2-enter :is(.v2-card, .v2t-heros, .v2t-omni, .v2t-sh, .v2t-due, .v2-sec-head, .v2-group-title, .v2-chips, .v2-seg, .v2t-note, .v2p-boxes):nth-child(3) { animation-delay: 120ms; }
    .ui-v2 .v2-enter :is(.v2-card, .v2t-heros, .v2t-omni, .v2t-sh, .v2t-due, .v2-sec-head, .v2-group-title, .v2-chips, .v2-seg, .v2t-note, .v2p-boxes):nth-child(4) { animation-delay: 180ms; }
    .ui-v2 .v2-enter :is(.v2-card, .v2t-heros, .v2t-omni, .v2t-sh, .v2t-due, .v2-sec-head, .v2-group-title, .v2-chips, .v2-seg, .v2t-note, .v2p-boxes):nth-child(n+5) { animation-delay: 240ms; }
    .ui-v2 .v2-enter .v2t-sec:nth-of-type(n+3) :is(.v2-card, .v2t-sh, .v2t-due, .v2t-note) { animation-delay: 300ms; }
    .ui-v2 .v2-enter .v2t-col + .v2t-col :is(.v2-card, .v2t-sh) { animation-delay: 180ms; }
    @keyframes v2Rise { from { opacity: .15; transform: translateY(14px); } }

    /* …the rows inside a card follow it, one after another (the first six; the rest come with the sixth) */
    .ui-v2 .v2-enter :is(.v2-list, .v2t-hs) > * { animation: v2RowIn 520ms var(--v2-ease) both; animation-delay: 140ms; }
    .ui-v2 .v2-enter :is(.v2-list, .v2t-hs) > :nth-child(2) { animation-delay: 185ms; }
    .ui-v2 .v2-enter :is(.v2-list, .v2t-hs) > :nth-child(3) { animation-delay: 230ms; }
    .ui-v2 .v2-enter :is(.v2-list, .v2t-hs) > :nth-child(4) { animation-delay: 275ms; }
    .ui-v2 .v2-enter :is(.v2-list, .v2t-hs) > :nth-child(5) { animation-delay: 320ms; }
    .ui-v2 .v2-enter :is(.v2-list, .v2t-hs) > :nth-child(n+6) { animation-delay: 365ms; }
    @keyframes v2RowIn { from { opacity: 0; transform: translateY(8px); } }

    /* …the main amount arrives with its count (ui/motion-v2.js) */
    .ui-v2 .v2-enter :is(.v2t-hero__big, .v2m-nw__amt, .v2-an-big) { animation: v2AmtIn 700ms var(--v2-ease) both; }
    @keyframes v2AmtIn { from { opacity: .2; transform: translateY(6px) scale(.97); } }

    /* …and its bars fill from their start edge, slowly */
    .ui-v2 .v2-enter :is(.v2t-cyc__fill, .v2t-bar > span, .v2t-sts__bar > span, .v2m-bar__fill, .v2c-bar > span, .v2-an-bar > span, .v2p-stack > span) {
        transform-origin: right center;
        animation: v2Grow 1000ms var(--v2-ease) 200ms both;
    }
    .ui-v2 .v2-enter .v2-an-bar-d { transform-origin: center bottom; animation: v2GrowUp 900ms var(--v2-ease) 200ms both; }
    .ui-v2 .v2-enter .v2t-cyc__now { animation: v2Rise 500ms var(--v2-ease) 900ms both; }
    @keyframes v2Grow { from { transform: scaleX(0); } }
    @keyframes v2GrowUp { from { transform: scaleY(0); } }

    /* Sheets (detail, add, edit): the backdrop fades and the sheet slides up from the bottom edge on phones;
       on a wide screen it rises a little into the middle. */
    .ui-v2 .modal-overlay.active { animation: v2Fade 260ms ease-out; }
    .ui-v2 .modal-overlay.active > .v2-sheet { animation: v2SheetUp 460ms var(--v2-ease); }
    @keyframes v2Fade { from { opacity: 0; } }
    @keyframes v2SheetUp { from { transform: translateY(40%); opacity: .4; } }
    @media (min-width: 769px) {
        @keyframes v2SheetUp { from { transform: translateY(18px) scale(.98); opacity: 0; } }
    }

    /* A touch is felt: rows darken a little, buttons and tiles give way */
    .ui-v2 :is(.v2-row, .v2-chip, .v2t-due, .v2m-action) { transition: background-color 160ms ease-out, transform 160ms var(--v2-ease); }
    .ui-v2 :is(.v2-row, .v2t-due):active { transform: scale(.985); }
    .ui-v2 :is(.v2-chip, .v2m-action):active { transform: scale(.96); }
}
