/* perf-v2.css: smoothness layer. Loaded last. Only cost/compositing changes; looks stay the same. */

/* 1. The two drifting background blobs sit BEHIND dozens of backdrop-blur panels. Animating them forces every blur to be recomputed each frame (the main source of lag). Keep them, but still. */
html::before, html::after { animation: none !important; will-change: auto !important; transform: translateZ(0); }
@media (hover: hover) and (pointer: fine) and (min-width: 1100px) {
  html:not(.lowfx):not(.pv-busy)::before { animation: lqDriftA 60s ease-in-out infinite alternate !important; }
  html:not(.lowfx):not(.pv-busy)::after { animation: lqDriftB 75s ease-in-out infinite alternate !important; }
}

/* 2. Full-screen chat and big sheets: the panel is already ~80% opaque, a 30px blur over the whole screen is pure cost. */
html #chx, html #chx .cc-wrap, html #sa, html .wm-sheet {
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
  background-color: rgba(5, 5, 8, .94) !important;
}
html #chx .wcx-h, html #chx .wcx-in, html #chx .wcx-typ { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }

/* 3. Cheaper blur everywhere else: smaller radius, no saturate() pass on touch / weak devices. */
@media (pointer: coarse), (max-width: 820px) {
  :root, html[data-theme], [data-theme] { --lq-blur: 12px; --wg-blur: 12px; }
  html header, html .sah, html .bm-bd, html .dsr, html .m3-seg, html .lb-pn {
    -webkit-backdrop-filter: blur(10px) !important; backdrop-filter: blur(10px) !important;
  }
}
html.lowfx *, html.lowfx *::before, html.lowfx *::after {
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
}
html.lowfx header { background: rgba(8, 8, 11, .96) !important; }
html.lowfx .wcx-m, html.lowfx .card { box-shadow: none !important; }

/* 4. Chat scroll container: contain overscroll, native momentum. */
#wcx-list { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scroll-behavior: auto; }

/* 5. Avatar decorations: own compositor layer, paused + unpainted off screen. */
.dw { contain: layout style; }
.dsv { transform: translateZ(0); backface-visibility: hidden; will-change: auto; image-rendering: auto; }
.dw.off .dsv { visibility: hidden; }
.dw .pav, .dw img.pav { transform: translateZ(0); }
img.dsv, img.pfxi { transition-duration: .18s !important; }

/* 6. Profile effects: single composited layer; not painted while the card is off screen or the tab is hidden. */
.pfx { contain: strict; transform: translateZ(0); isolation: isolate; }
.pfx .pfxi { transform: translateZ(0); backface-visibility: hidden; }
.pfx.off, .pfx.off .pfxi { visibility: hidden; }
html.pv-hidden .pfx .pfxi, html.pv-hidden .dsv { visibility: hidden; }

/* 7. Name styles: background-position animations repaint text every frame. Pause them when off screen, and while scrolling fast. */
.nsoff { animation-play-state: paused !important; }
html.pv-scroll [style*="animation:ns"], html.pv-scroll [style*="animation: ns"] { animation-play-state: paused !important; }
[style*="animation:ns"], [style*="animation: ns"] { transform: translateZ(0); }

/* 8. Page sections / cards below the fold. */
.card, .ec, .li, .pcard-r { contain: layout style; }
img { image-rendering: auto; }
img[loading="lazy"] { content-visibility: auto; }

/* 9. Page-level smoothing */
html { scroll-behavior: auto; }
body { text-rendering: optimizeSpeed; -webkit-font-smoothing: antialiased; }
@media (prefers-reduced-motion: reduce) { .dsv, .pfxi { animation: none !important; } }

/* 10. App feel: instant press feedback, soft page enter, no tap delay or highlight flash. */
button, a, [role="button"], .card, .ec, .li, .pcard, .wcx-row { -webkit-user-select: none; user-select: none; }
button, [role="button"], .card, .ec, .li, .wcx-row, .pw, .th > * {
  transition: transform .14s cubic-bezier(.2, .8, .2, 1), background-color .14s ease, opacity .14s ease;
}
@media (hover: none) {
  button:active, [role="button"]:active, .card:active, .ec:active, .li:active, .wcx-row:active, .pw:active { transform: scale(.965); }
}
@keyframes pvEnter { from { opacity: 0; transform: translate3d(0, 10px, 0); } to { opacity: 1; transform: none; } }
#app.pv-enter { animation: pvEnter .22s cubic-bezier(.2, .8, .2, 1) both; }
@media (prefers-reduced-motion: reduce) { #app.pv-enter { animation: none; } button:active, .card:active { transform: none !important; } }
input, textarea, select, [contenteditable] { -webkit-user-select: text; user-select: text; }
input, textarea { font-size: max(16px, 1em); } /* no iOS zoom jump when focusing */
.hs, .ab, .th, #wcx-list, .wcx-sh-in { -webkit-overflow-scrolling: touch; scroll-behavior: auto; }
