/* =====================================================================
   smooth.css  — final performance layer (load it LAST, after ios-glass.css)
   Delete its <link> to undo everything in here.

   WHY THE SITE FELT LAGGY (measured, not guessed):
   1. Every .glass-card ran an infinite background-position animation (lgSheenIdle).
      That is a main-thread repaint of a 4-layer gradient on every card, every frame, forever.
   2. ~30 elements on screen had backdrop-filter at once (cards, inputs, nav buttons, FAQ items...) on top of
      two live full-screen canvases + animated orbs. Each blur re-runs whenever anything behind it changes.
   3. Entrance animations (gBlurIn / gBlurSoft / gBlurPop / gBlurScroll) animated filter: blur() on up to 8 elements
      per tab switch and on every feed/material card while scrolling.
   4. A handful of other infinite loops animating box-shadow / background-position (paint, not compositor).

   RULES USED HERE
   - @layer + !important: important declarations inside a cascade layer beat ALL unlayered !important rules,
     so this wins against the older override stacks without any specificity tricks. Browsers without @layer
     (pre-2022) simply skip the block and keep the old look.
   - Plain (non-important) rules + redefined @keyframes below only need to come later in the cascade.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1) BACKDROP BLUR: keep it only where it is visible and cheap.
   --------------------------------------------------------------------- */
@layer smooth {
    /* Repeated / nested surfaces: translucent background only (the look is nearly identical because what sits
       behind them is already soft gradients + blurry orbs), but the GPU no longer re-blurs 20+ layers per frame. */
    html body :is(
        .glass-card, .glass-panel, .fx-card, .gl-card, .sp-card, .on-card, .tilt-lift-card, .faq-item, .flow-sk-card,
        .dash-cell, .glass-main-panel, .group-tabs, .nav-btn,
        .glass-sidebar nav, .glass-sidebar > div:first-child,
        .sv-snd, .sv-x, .sv-play, .fx-chip, .gl-chip, .on-chip, .sp-pill, .vc-skip, .vc-cover-inner,
        input, textarea, select, #va-status, #va-card, #fx-top,
        .glass-sidebar *
    ) {
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
    }

    /* main.css gives EVERY tailwind translucent background (bg-slate-950/50, bg-indigo-950/80 ...) its own
       blur(8px) saturate(1.8): icon chips, 9px progress bars, tiny buttons, badges. None of it is visible.
       The surfaces that SHOULD stay frosted are excluded explicitly (kept in the rules below). */
    html body [class*="bg-"]:not(.glass-sidebar):not(.glass-header):not(.glass-modal):not(#ntf-panel):not(.modal-root):not(#toast-container > *) {
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
    }

    /* The few big "chrome" surfaces keep a lighter blur. The :not() list mirrors the existing performance rules
       (video playing / scrolling / weak devices / user turned blur off) so those keep switching blur off. */
    html:not(.vid-playing):not(.is-scrolling):not(.perf-lite):not(.perf-mid):not(.blur-off) body :is(.glass-sidebar, .glass-header) {
        -webkit-backdrop-filter: blur(12px) saturate(135%) !important;
        backdrop-filter: blur(12px) saturate(135%) !important;
    }

    /* Modals: ONE cheap full-screen blur on the dim layer; the card on top no longer stacks a second 28-44px blur. */
    html:not(.vid-playing):not(.perf-lite):not(.perf-mid):not(.blur-off) body .modal-root:not(.hidden) {
        -webkit-backdrop-filter: blur(6px) saturate(120%) !important;
        backdrop-filter: blur(6px) saturate(120%) !important;
    }
    html body :is(.modal-root > div, .glass-modal, .sp-modal-card) {
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
    }

    /* Small floating panels that really benefit from the frosted look: moderate blur. */
    html:not(.vid-playing):not(.perf-lite):not(.perf-mid):not(.blur-off) body :is(#ntf-panel, #toast-container > *) {
        -webkit-backdrop-filter: blur(14px) saturate(140%) !important;
        backdrop-filter: blur(14px) saturate(140%) !important;
    }
}

/* ---------------------------------------------------------------------
   2) ENDLESS PAINT LOOPS -> off (plain rules, they only need to load last)
   --------------------------------------------------------------------- */
/* the big one: idle sheen on every glass card */
.dark-theme .glass-card,
.light-theme .glass-card { animation-name: none; }

.text-glow-gradient { animation: none; }
.border-glow-gradient::before { animation: none; }

html.perf-full #welcome-message { animation: none; }
html.perf-full [id$="progress-bar"] > div,
html.perf-full #dashboard-xp-progress-bar { animation: none; }

/* avatar / logo keep their gentle float (transform = GPU only) but lose the expanding box-shadow ring */
html.perf-full #profile-avatar,
html.perf-full #login-logo {  }

/* button shimmer on hover looped background-position forever */
html.perf-full button.bg-indigo-600:not(:disabled):hover::after,
html.perf-full button.bg-indigo-500:not(:disabled):hover::after { animation: none; }

/* ---------------------------------------------------------------------
   3) ENTRANCE ANIMATIONS WITHOUT filter: blur()  (same motion, GPU-only: opacity + transform)
      Redefining the keyframes keeps every existing selector working.
   --------------------------------------------------------------------- */
@keyframes gBlurIn     { from { opacity: 0; transform: translate3d(0, 14px, 0) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes gBlurSoft   { from { opacity: 0; transform: translate3d(0, 10px, 0); }            to { opacity: 1; transform: none; } }
@keyframes gBlurPop    { from { opacity: 0; }                                                 to { opacity: 1; } }
@keyframes gBlurScroll { from { opacity: 0; transform: translate3d(0, 18px, 0); }            to { opacity: 1; transform: none; } }
/* nav glow pulsed box-shadow every frame; opacity alone gives the same "breathing" */
@keyframes navBarGlow  { 0%, 100% { opacity: .65; } 50% { opacity: 1; } }

/* ---------------------------------------------------------------------
   4) SMALL FREE WINS
   --------------------------------------------------------------------- */
#workspace-view-scroll { overscroll-behavior: contain; }
html { -webkit-tap-highlight-color: transparent; }
button, a, [role="button"], .nav-btn, input, select, textarea { touch-action: manipulation; }   /* no double-tap-zoom delay */

/* ---------------------------------------------------------------------
   5) TAB EXIT: stage.js promises "nothing is blurred", but an older rule (graphics.css) still applied
      filter: blur(5px) to the WHOLE outgoing page for 180ms on every tab switch (one huge layer re-rasterised
      at the exact moment of switching). Same direction + fade, no blur.
   --------------------------------------------------------------------- */
@layer smooth {
    html body .view-panel.view-fade-out {
        filter: none !important;
        transition: opacity .14s ease, transform .14s ease !important;
    }
}
