/* =====================================================================
   Taskify — performance layer (loaded last, at the end of <body>)
   1. Always: cheaper glass (smaller blur, no saturate), no fixed-attachment
      background repaint on scroll, no always-running blurred glow.
   2. Visual effects (set in layout.blade.php, toggled in the navbar):
      html.perf-lite = Light (the default): blur only on small surfaces
        (navbar, modals, menus), cheap shadows, no glows, no endless
        decorative animations, entrances short and transform/opacity only.
      html.fx-min = weak device / reduced motion / slow frames: no blur at
        all and (almost) no motion.
      html.fx-paused = tab hidden: everything paused.
   3. Sidebar: native scrolling for the menu list.
===================================================================== */

/* ---------- 1. always ---------- */
html body,
html body.is-glass {
    --g-blur: blur(12px) !important;
}
html body:is(.has-menu, #_fx) #layout-menu {
    --sb-glass-blur: blur(12px) !important;
}

/* the page wash: paint it once on a fixed layer instead of repainting the
   whole viewport on every scroll (background-attachment: fixed) */
html.is-glass {
    background-attachment: scroll !important;
}
html.is-glass::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: inherit;
    transform: translateZ(0);
}
html.is-glass { background-size: 0 0 !/* ---------- 2. visual effects ---------- */

/* --- Light: no blur on big surfaces (cards, panels, sidebar, page) ... */
html.perf-lite *,
html.perf-lite *::before,
html.perf-lite *::after {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}
/* ... keep a small blur where it is cheap and reads as "glass": navbar, dialogs, menus, toasts */
html.perf-lite:not(.fx-min) .layout-navbar,
html.perf-lite:not(.fx-min) .modal-content,
html.perf-lite:not(.fx-min) .ta-dialog,
html.perf-lite:not(.fx-min) .qop-modal .qop-body,
html.perf-lite:not(.fx-min) .dropdown-menu,
html.perf-lite:not(.fx-min) #toast-container > .toast {
    -webkit-backdrop-filter: blur(10px) !important;
    backdrop-filter: blur(10px) !important;
}
/* the panels lose their blur, so they get (almost) opaque instead */
html.perf-lite body {
    --d-glass: rgba(255, 255, 255, .92) !important;
    --d-glass-strong: rgba(255, 255, 255, .97) !important;
    --d-topbar: rgba(255, 255, 255, .86) !important;
    --d-menu: rgba(255, 255, 255, .97) !important;
    --d-field: rgba(255, 255, 255, .85) !important;
    /* cheaper shadows: small blur radius, no second (neumorphic) light shadow */
    --d-shadow: 0 4px 14px -8px rgba(60, 48, 130, .22) !important;
    --d-shadow-hover: 0 6px 18px -8px rgba(122, 43, 242, .26) !important;
    --d-raise-sm: inset 0 0 0 1px rgba(255, 255, 255, .7), 0 1px 4px -1px rgba(60, 48, 130, .16) !important;
}
html.perf-lite[data-app-theme="dark"] body {
    --d-glass: rgba(26, 20, 42, .94) !important;
    --d-glass-strong: rgba(24, 19, 40, .97) !important;
    --d-topbar: rgba(26, 20, 42, .88) !important;
    --d-menu: rgba(22, 17, 36, .97) !important;
    --d-field: rgba(40, 32, 62, .9) !important;
    --d-shadow: 0 4px 14px -8px rgba(0, 0, 0, .6) !important;
    --d-shadow-hover: 0 6px 18px -8px rgba(0, 0, 0, .7) !important;
    --d-raise-sm: inset 0 0 0 1px rgba(255, 255, 255, .08), 0 1px 4px -1px rgba(0, 0, 0, .4) !important;
}
html.perf-lite body:is(.has-menu, #_fx) #layout-menu {
    --sb-glass: rgba(255, 255, 255, .95) !important;
}
html.perf-lite[data-app-theme="dark"] body:is(.has-menu, #_fx) #layout-menu {
    --sb-glass: rgba(26, 20, 42, .96) !important;
}
/* large blurred glows are expensive to rasterise */
html.perf-lite #layout-menu.menu-container::before {
    display: none !important;
}
html.perf-lite .dash-donut,
html.perf-lite .apexcharts-canvas svg { filter: none !important; }
html.perf-lite .glass-page .tl-tab.is-active::after { box-shadow: none !important; }

/* endless decorative animations off (spinners / loaders keep spinning) */
html.perf-lite .tl-approval.is-pending i,
html.perf-lite .ap-pulse,
html.perf-lite .buy-button,
html.perf-lite .buy-button::after,
html.perf-lite .attention-ring,
html.perf-lite .ws-name-mark i {
    animation: none !important;
}
/* entrances: no stagger, short */
html.perf-lite *,
html.perf-lite *::before,
html.perf-lite *::after {
    animation-delay: 0s !important;
    transition-delay: 0s !important;
}
html.perf-lite .dash-reveal {
    animation: fx-in .22s ease-out both !important;
}
@keyframes fx-in { from { opacity: 0; transform: translateY(6px); } }

/* --- Minimal: weak device, reduced motion, or frames still dropping --- */
html.fx-min *,
html.fx-min *::before,
html.fx-min *::after {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    /* .01ms (not none) keeps transitionend / animationend firing for scripts that wait for them */
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
}
/* ... but loading spinners must still turn */
html.fx-min .spinner-border,
html.fx-min .spinner-grow,
html.fx-min .bx-spin,
html.fx-min .ta-file.is-busy .ta-file-text small::after {
    animation-duration: .75s !important;
    animation-iteration-count: infinite !important;
}

/* --- Tab hidden: nothing runs --- */
html.fx-paused *,
html.fx-paused *::before,
html.fx-paused *::after {
    animation-play-state: paused !important;
}

 {
    animation: none !important;
}
/* entrance animations: keep them, but short and without stagger */
html.perf-lite *,
html.perf-lite *::before,
html.perf-lite *::after {
    animation-delay: 0s !important;
    transition-delay: 0s !important;
}

/* ---------- 3. sidebar scrolling ---------- */
/* perfect-scrollbar forces overflow:hidden on .ps, and the list never got a
   bounded height, so it was clipped instead of scrolling. */
html body #layout-menu.layout-menu.menu-container {
    display: flex !important;
    flex-direction: column !important;
}
html body #layout-menu.layout-menu.menu-container > .menu-inner,
html body #layout-menu.layout-menu.menu-container > .menu-inner.ps {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, .35) transparent;
}
html body #layout-menu .menu-inner > * { flex-shrink: 0 !important; }
html body #layout-menu .menu-inner > .ps__rail-x,
html body #layout-menu .menu-inner > .ps__rail-y { display: none !important; }
html body #layout-menu .menu-inner::-webkit-scrollbar { width: 6px; }
html body #layout-menu .menu-inner::-webkit-scrollbar-thumb { border-radius: 6px; background: rgba(139, 92, 246, .35); }
html body #layout-menu .menu-inner::-webkit-scrollbar-track { background: transparent; }
