/* =========================================================================
 * App-wide motion (web portal) — matches the mobile app's motion language.
 * Covers: inline flash alerts, server-flash toasts (Toastr) slide, and a
 * content "landing" fade+rise on page load. Fully reduced-motion aware.
 * ======================================================================= */

:root {
    --hk-motion-enter: 240ms;
    --hk-motion-leave: 180ms;
    --hk-motion-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --hk-motion-rise: 16px;
}

@keyframes hkRiseIn {
    from { opacity: 0; transform: translateY(var(--hk-motion-rise)); }
    /* End at `none`, NOT translateY(0): with animation-fill-mode:both the final
     * keyframe is retained, and any non-none transform on an ancestor (e.g.
     * main.app-main) creates a containing block that breaks position:fixed for
     * descendant Bootstrap modals — they render mis-positioned/collapsed. `none`
     * animates identically (16px→0) but leaves no lingering transform. */
    to   { opacity: 1; transform: none; }
}
@keyframes hkFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---- Part 1.3 — inline flash alerts (were static) ---- */
.alert {
    animation: hkRiseIn var(--hk-motion-enter) var(--hk-motion-ease-out) both;
}

/* ---- Part 1.2 — server-flash toasts (Toastr) get a rise on top of the fade.
 * Toastr fades opacity via jQuery; the transform here composes cleanly. ---- */
#toast-container > div {
    animation: hkRiseIn var(--hk-motion-enter) var(--hk-motion-ease-out);
}

/* ---- Part 2.8 — page content "landing" on load ----
 * The main content wrapper rises in; cards/rows cascade with nth-child delays.
 * Scoped to common shells so it never fights admin/auth layouts. */
main.app-main,
.content-wrapper,
.page-content,
.erp-panel,
.cust-hero {
    animation: hkRiseIn var(--hk-motion-enter) var(--hk-motion-ease-out) both;
}

/* A light stagger for card grids / list rows that land together. */
.row > [class*="col-"] .card,
.erp-list .erp-list-row,
.table tbody tr {
    animation: hkFadeIn var(--hk-motion-enter) var(--hk-motion-ease-out) both;
}
.row > [class*="col-"]:nth-child(1) .card { animation-delay: 20ms; }
.row > [class*="col-"]:nth-child(2) .card { animation-delay: 60ms; }
.row > [class*="col-"]:nth-child(3) .card { animation-delay: 100ms; }
.row > [class*="col-"]:nth-child(4) .card { animation-delay: 140ms; }
.row > [class*="col-"]:nth-child(n+5) .card { animation-delay: 180ms; }

/* ---- Accessibility: honour the OS reduced-motion setting ---- */
@media (prefers-reduced-motion: reduce) {
    .alert,
    #toast-container > div,
    main.app-main, .content-wrapper, .page-content, .erp-panel, .cust-hero,
    .row > [class*="col-"] .card, .erp-list .erp-list-row, .table tbody tr {
        animation: none !important;
    }
}
