/* ==========================================================================
   FinMinion motion and ambience. Loaded last (after fm-page-layer.css).
     1. Ambient page background: drifting brand-colour aurora + a faint dot grid (light and dark)
     2. Page entrance: the page's top-level blocks rise in, one after another
     3. Component motion: grid rows, cards, buttons, inputs, popups, dialogs, toasts, badges
   Every animation sits inside prefers-reduced-motion: no-preference, so people who ask the
   system for less motion get a still interface. Only transform and opacity are animated where
   possible, so the effects stay on the compositor and cost little.
   ========================================================================== */

/* ---------- 1. ambient background ---------- */
:root {
    --fm-aurora-1: rgba(0, 58, 112, .2);      /* brand navy */
    --fm-aurora-2: rgba(240, 165, 0, .26);    /* brand gold */
    --fm-aurora-3: rgba(91, 156, 226, .26);   /* sky */
    --fm-aurora-4: rgba(0, 58, 112, .1);
    --fm-dot: rgba(0, 58, 112, .11);
    --fm-canvas-top: #f7f9fc;
}
html[data-bs-theme="dark"] {
    --fm-aurora-1: rgba(91, 156, 226, .2);
    --fm-aurora-2: rgba(242, 183, 63, .1);
    --fm-aurora-3: rgba(132, 104, 230, .14);  /* violet glow, dark only */
    --fm-aurora-4: rgba(91, 156, 226, .08);
    --fm-dot: rgba(231, 238, 246, .05);
    --fm-canvas-top: #101b29;
}

/* the colour field is larger than the screen so it can drift without showing an edge */
.nv-app::before {
    inset: -18vmax;
    background:
        radial-gradient(40vmax 32vmax at 24% 22%, var(--fm-aurora-1), transparent 70%),
        radial-gradient(36vmax 30vmax at 80% 18%, var(--fm-aurora-2), transparent 70%),
        radial-gradient(44vmax 36vmax at 70% 80%, var(--fm-aurora-3), transparent 72%),
        radial-gradient(32vmax 28vmax at 18% 78%, var(--fm-aurora-4), transparent 70%),
        linear-gradient(180deg, var(--fm-canvas-top), var(--nv-bg) 60%);
}
.nv-app::after {   /* dot grid, strongest at the top of the page and fading out */
    content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background-image: radial-gradient(var(--fm-dot) 1px, transparent 1.4px);
    background-size: 22px 22px;
    -webkit-mask-image: radial-gradient(ellipse 85% 65% at 50% 0%, #000 25%, transparent 78%);
    mask-image: radial-gradient(ellipse 85% 65% at 50% 0%, #000 25%, transparent 78%);
}

@media (prefers-reduced-motion: no-preference) {
    .nv-app::before { animation: fmAurora 46s ease-in-out infinite alternate; will-change: transform; }
}
@keyframes fmAurora {
    0%   { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
    50%  { transform: translate3d(2.5vmax, -2vmax, 0) rotate(3deg) scale(1.06); }
    100% { transform: translate3d(-2vmax, 1.5vmax, 0) rotate(-2deg) scale(1.03); }
}

/* ---------- shared keyframes ---------- */
@keyframes fmRise { from { opacity: 0; transform: translateY(14px); } }
@keyframes fmFade { from { opacity: 0; } }
@keyframes fmDrop { from { opacity: 0; transform: translateY(-6px); } }
@keyframes fmZoom { from { opacity: 0; transform: translateY(10px) scale(.96); } }
@keyframes fmSlideIn { from { opacity: 0; transform: translateX(28px); } }
@keyframes fmPop { 0% { opacity: 0; transform: scale(.6); } 70% { transform: scale(1.06); } 100% { opacity: 1; transform: none; } }
@keyframes fmFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes fmSheen { from { transform: translateX(-120%) skewX(-18deg); } to { transform: translateX(260%) skewX(-18deg); } }

@media (prefers-reduced-motion: no-preference) {

    /* ---------- 2. page entrance ---------- */
    /* top-level blocks of a page (toolbars, cards, grids) rise in turn; the page header animates itself */
    .nv-page > :not(.fm-ph):not(.fm-modal-overlay) { animation: fmRise 520ms var(--nv-ease) both; }
    .nv-page > :nth-child(2) { animation-delay: 70ms; }
    .nv-page > :nth-child(3) { animation-delay: 140ms; }
    .nv-page > :nth-child(4) { animation-delay: 200ms; }
    .nv-page > :nth-child(5) { animation-delay: 250ms; }
    .nv-page > :nth-child(n+6) { animation-delay: 290ms; }

    /* repeated tiles inside a page: task cards, board columns, stat tiles */
    .fm-tcards > .fm-tcard,
    .nv-board > .nv-col,
    .fm-stats > * { animation: fmZoom 460ms var(--nv-ease) both; }
    .fm-tcards > .fm-tcard:nth-child(2), .nv-board > .nv-col:nth-child(2), .fm-stats > :nth-child(2) { animation-delay: 50ms; }
    .fm-tcards > .fm-tcard:nth-child(3), .nv-board > .nv-col:nth-child(3), .fm-stats > :nth-child(3) { animation-delay: 100ms; }
    .fm-tcards > .fm-tcard:nth-child(4), .nv-board > .nv-col:nth-child(4), .fm-stats > :nth-child(4) { animation-delay: 150ms; }
    .fm-tcards > .fm-tcard:nth-child(5), .nv-board > .nv-col:nth-child(5), .fm-stats > :nth-child(5) { animation-delay: 190ms; }
    .fm-tcards > .fm-tcard:nth-child(n+6) { animation-delay: 230ms; }

    /* ---------- 3. components ---------- */

    /* data grids: rows fade in after a load, sort or page change; hover is a smooth tint */
    .rz-data-grid .rz-data-row { animation: fmFade 360ms var(--nv-ease) both; }
    .rz-data-grid .rz-data-row:nth-child(2) { animation-delay: 25ms; }
    .rz-data-grid .rz-data-row:nth-child(3) { animation-delay: 50ms; }
    .rz-data-grid .rz-data-row:nth-child(4) { animation-delay: 75ms; }
    .rz-data-grid .rz-data-row:nth-child(5) { animation-delay: 100ms; }
    .rz-data-grid .rz-data-row:nth-child(n+6) { animation-delay: 120ms; }
    .rz-datatable .rz-grid-table tbody td { transition: background-color var(--nv-d-base) var(--nv-ease); }

    /* cards that are items (task cards, kanban cards) lift on hover; big form cards stay put */
    .fm-tcard, .nv-kc > .fm-tcard { transition: transform 260ms var(--nv-ease), box-shadow 260ms var(--nv-ease), border-color 260ms var(--nv-ease); }
    .fm-tcard:hover { transform: translateY(-3px); box-shadow: var(--nv-shadow-2); border-color: color-mix(in srgb, var(--nv-primary) 28%, var(--nv-line)); }

    /* buttons: a light sheen crosses primary buttons on hover; every button gives a small press */
    .rz-button.rz-primary { position: relative; overflow: hidden; isolation: isolate; }
    .rz-button.rz-primary::after {
        content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 40%; z-index: -1; pointer-events: none;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .28), transparent);
        transform: translateX(-120%) skewX(-18deg);
    }
    .rz-button.rz-primary:hover:not(.rz-state-disabled)::after { animation: fmSheen 750ms ease-out; }
    .rz-button:active:not(.rz-state-disabled) { transform: scale(.97); transition-duration: 80ms; }
    .rz-button .rzi { transition: transform 260ms cubic-bezier(.34, 1.56, .64, 1); }
    .rz-button:hover:not(.rz-state-disabled) .rzi { transform: scale(1.12); }

    /* inputs: focus ring and border ease in instead of snapping */
    .rz-textbox, .rz-textarea, .rz-dropdown, .rz-numeric, .rz-datepicker > .rz-inputtext, .rz-autocomplete,
    .form-control, .form-select {
        transition: border-color var(--nv-d-base) var(--nv-ease), box-shadow var(--nv-d-base) var(--nv-ease), background-color var(--nv-d-base);
    }

    /* pop-ups: drop-down lists, date pickers, menus and tooltips open with a short drop */
    .rz-dropdown-panel, .rz-multiselect-panel, .rz-autocomplete-panel, .rz-datepicker-popup-container,
    .rz-popup, .rz-menu .rz-navigation-menu, .rz-contextmenu, .nv-pop { animation: fmDrop 180ms var(--nv-ease) both; }
    .rz-tooltip { animation: fmFade 160ms ease-out both; }

    /* dialogs: the mask fades, the dialog zooms in; the app's own modals (fm-modal-*) match */
    .rz-dialog-mask, .fm-modal-overlay { animation: fmFade 220ms ease-out both; }
    .rz-dialog:not(.rz-dialog-side) { animation: fmZoom 280ms var(--nv-ease) both; }
    .rz-dialog-side { animation: fmSlideIn 300ms var(--nv-ease) both; }
    .fm-modal-content { animation: fmZoom 300ms var(--nv-ease) both; }

    /* notifications slide in from the right */
    .rz-notification-item-wrapper, .rz-notification-item { animation: fmSlideIn 340ms var(--nv-ease) both; }

    /* small things: status badges pop, empty-state icons float, tabs and links ease their colour */
    .rz-badge { animation: fmPop 360ms var(--nv-ease) both; }
    .fm-empty__icon { animation: fmPop 520ms var(--nv-ease) both, fmFloat 5s ease-in-out 600ms infinite; }
    .rz-tabview-nav li a, .fm-task__more, .fm-ph__crumb a, a { transition: color var(--nv-d-base) var(--nv-ease), background-color var(--nv-d-base) var(--nv-ease); }
    .rz-tabview-panel { animation: fmFade 260ms ease-out both; }

    /* filter toolbar search icon follows focus */
    .fm-search > .rzi { transition: color var(--nv-d-base), transform var(--nv-d-base) var(--nv-ease); }
    .fm-search:focus-within > .rzi { color: var(--nv-primary); transform: translateY(-50%) scale(1.1); }
}
