/* ══════════════════════════════════════════════════════════════
   PRADUMNA_FX — PERFORMANCE OPTIMIZATION LAYER v2
   Loaded AFTER styles.css — nukes every scroll-jank source
   Target: 60fps mobile, 120fps desktop, ZERO frame drops
   ══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────
   1. BODY — Kill background-attachment: fixed EVERYWHERE
      This single property causes a FULL PAGE REPAINT on every
      scroll pixel. Not just mobile — desktop too.
   ───────────────────────────────────────────────────────────── */

body {
  background-attachment: scroll !important;
  font-display: swap;
}

/* ─────────────────────────────────────────────────────────────
   2. BODY OVERLAYS — Kill fixed pseudo-elements
      body::before (noise grain) and body::after (vignette)
      are FIXED POSITION covering the entire viewport.
      Every scroll frame repaints them. KILL on all devices.
   ───────────────────────────────────────────────────────────── */

body::before {
  display: none !important;  /* SVG noise grain — massive repaint cost */
}

body::after {
  display: none !important;  /* Radial gradient vignette — repaint cost */
}

/* ─────────────────────────────────────────────────────────────
   3. NAVBAR — Reduce blur, GPU isolate
      backdrop-filter is the #1 scroll jank cause globally.
      20px is the max tolerable. Solid fallback on mobile.
   ───────────────────────────────────────────────────────────── */

.site-header {
  transform: translateZ(0);
  will-change: auto;
  contain: layout style;
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
}

/* ─────────────────────────────────────────────────────────────
   4. DASHBOARD PANEL — Kill 44px blur (the frame destroyer)
   ───────────────────────────────────────────────────────────── */

.dashboard-panel {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: rgba(10, 12, 24, 0.92) !important;
}

/* Kill infinite border shimmer animation — constant GPU cost */
.dashboard-panel::after {
  animation: none !important;
  background: none !important;
}

/* ─────────────────────────────────────────────────────────────
   5. HERO CARD — Kill 28px blur
   ───────────────────────────────────────────────────────────── */

.hero-card {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: rgba(255, 255, 255, 0.03) !important;
}

/* ─────────────────────────────────────────────────────────────
   6. GLOW ORBS — Kill completely
      filter: blur(75px) on animating elements = catastrophic
      Each orb is a 220x220 element with 75px gaussian blur
      AND an infinite 18s animation. This alone kills FPS.
   ───────────────────────────────────────────────────────────── */

.glow-orb {
  display: none !important;
}

/* ─────────────────────────────────────────────────────────────
   7. RESOURCE SECTION — Kill 22px blur
      Every .resource-section on resource pages has a 22px
      backdrop-filter. With 4+ sections per page, that's
      4 blur layers being composited during scroll.
   ───────────────────────────────────────────────────────────── */

.resource-section {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: rgba(10, 13, 26, 0.95) !important;
}

/* ─────────────────────────────────────────────────────────────
   8. PILL — Kill backdrop-filter
   ───────────────────────────────────────────────────────────── */

.pill {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* ─────────────────────────────────────────────────────────────
   9. CARD OVERLAY ICON — Kill backdrop-filter
   ───────────────────────────────────────────────────────────── */

.card-image-overlay-icon {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: rgba(255, 255, 255, 0.18) !important;
}

/* ─────────────────────────────────────────────────────────────
   10. CARDS — Fix will-change (remove box-shadow, it's not
       compositor-accelerated and wastes GPU memory)
   ───────────────────────────────────────────────────────────── */

.card,
.resource-card {
  will-change: transform;  /* ONLY transform, not box-shadow */
  contain: layout style paint;
  transform: translateZ(0);
}

.cat-tile {
  will-change: transform;
  contain: layout style paint;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Release will-change when not hovering — saves GPU memory */
.cat-tile:hover {
  will-change: auto;
}

/* ─────────────────────────────────────────────────────────────
   11. STAGGER ANIMATIONS — GPU-only, snappy
   ───────────────────────────────────────────────────────────── */

.stagger-item {
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  transition:
    opacity 0.35s ease,
    transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
  transition-delay: var(--stagger-delay, 0ms);
  will-change: opacity, transform;
}

.stagger-item.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  will-change: auto;
}

/* ─────────────────────────────────────────────────────────────
   12. IMAGE PERFORMANCE
   ───────────────────────────────────────────────────────────── */

img[loading="lazy"] {
  opacity: 0;
  transition: opacity 0.3s ease;
  transform: translateZ(0);
  content-visibility: auto;
}

img[loading="lazy"].loaded,
img:not([loading="lazy"]).loaded {
  opacity: 1;
}

img {
  image-rendering: auto;
}

/* ─────────────────────────────────────────────────────────────
   13. SCROLL CONTAINMENT — Critical layout isolation
   ───────────────────────────────────────────────────────────── */

.hero {
  contain: layout style;
  will-change: auto;
}

.section,
.page-hero,
main {
  contain: layout style;
}

/* Sections with pseudo-element separators: paint contain */
.section::before {
  contain: strict;
}

/* ─────────────────────────────────────────────────────────────
   14. SEARCH OVERLAY — GPU isolation, reduced blur
   ───────────────────────────────────────────────────────────── */

.search-overlay,
.pfx-search-overlay {
  transform: translateZ(0);
  contain: layout style paint;
}

/* ─────────────────────────────────────────────────────────────
   15. SCROLL PROGRESS BAR — Always compositor layer
   ───────────────────────────────────────────────────────────── */

#scroll-progress {
  contain: strict;
  transform: translateZ(0);
}

/* ─────────────────────────────────────────────────────────────
   16. CURSOR GLOW — Ensure compositor-only
   ───────────────────────────────────────────────────────────── */

/* cursor-glow element removed from phase4.js — rule no longer needed */


/* ─────────────────────────────────────────────────────────────
   17. PULSE DOT — Remove box-shadow from animation
       box-shadow is repainted every frame during animation
   ───────────────────────────────────────────────────────────── */

.pulse-dot {
  box-shadow: none;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.55); opacity: 0.55; }
}

/* ─────────────────────────────────────────────────────────────
   18. AD WRAPPER — CLS prevention + paint isolation
   ───────────────────────────────────────────────────────────── */

.ad-wrapper {
  min-height: 100px;
  contain: layout style;
  overflow: hidden;
}

.ad-wrapper ins.adsbygoogle {
  min-height: 90px;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE — NUCLEAR PERFORMANCE MODE
   Kill EVERYTHING that isn't transform/opacity
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* ── Navbar: solid background, zero blur ── */
  .site-header {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(3, 5, 14, 0.96) !important;
  }

  /* ── Mobile nav dropdown: zero blur ── */
  .nav-links {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(7, 9, 22, 0.98) !important;
  }

  /* ── Kill page-entry animation ── */
  body {
    animation: none !important;
  }

  /* ── Kill ALL card transforms on mobile ── */
  .card, .cat-tile, .sg-card {
    transform: none !important;
    will-change: auto !important;
  }

  /* ── Simplify card shadows (single shadow vs 4-layer) ── */
  .card {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35) !important;
  }
  .card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45) !important;
    transform: none !important;
  }

  /* ── Simplify btn shadows ── */
  .btn {
    box-shadow: 0 4px 12px rgba(124, 92, 255, 0.22) !important;
  }

  /* ── Kill dashboard panel heavy shadow ── */
  .dashboard-panel {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4) !important;
  }

  /* ── Kill resource-section shadow ── */
  .resource-section {
    box-shadow: none !important;
  }

  /* ── Kill resource-preview heavy shadow ── */
  .resource-preview {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5) !important;
  }

  /* ── Simplify hero::before radial gradients ── */
  .hero::before {
    background: radial-gradient(ellipse at 42% 45%, rgba(124, 92, 255, 0.10) 0%, transparent 60%) !important;
  }

  /* ── Kill card image hover zoom ── */
  .card:hover .card-image img,
  .resource-card:hover img {
    transform: none !important;
  }

  /* ── Kill card hover pseudo-element transitions ── */
  .card::before, .card::after,
  .resource-card::before, .resource-card::after {
    display: none !important;
  }

  /* ── Kill cat-tile hover pseudo-elements ── */
  .cat-tile::before, .cat-tile::after {
    display: none !important;
  }

  /* ── Kill section separator pseudo-element blur ── */
  .section-sep::before {
    display: none !important;
  }

  /* ── Ad wrapper: smaller reserve ── */
  .ad-wrapper {
    min-height: 60px;
  }
  .ad-wrapper ins.adsbygoogle {
    min-height: 50px;
  }

  /* ── Kill metric-item hover effects ── */
  .metric-item {
    will-change: auto !important;
  }
  .metric-item:hover {
    transform: none !important;
    box-shadow: none !important;
  }
  .metric-item::before {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   TABLET — Kill medium-expensive effects
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  /* border-shine animation already killed globally in styles.css */
  .card-image-overlay {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════════════
   TOUCH DEVICES — Kill all hover-only effects
   ═══════════════════════════════════════════════════════════════ */

body.is-touch .card:hover,
body.is-touch .cat-tile:hover,
body.is-touch .sg-card:hover {
  transform: none !important;
}

body.is-touch .btn:hover {
  transform: none !important;
  filter: none !important;
}

body.is-touch .metric-item:hover {
  transform: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   REDUCED MOTION — Kill everything animated
   ═══════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .stagger-item {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  body {
    animation: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   ACCESSIBILITY
   ═══════════════════════════════════════════════════════════════ */

:focus-visible {
  outline: 2px solid rgba(0, 224, 255, 0.7);
  outline-offset: 3px;
}

.skip-link:focus {
  z-index: 99999;
  top: 8px;
  outline: 2px solid rgba(0, 224, 255, 0.7);
  outline-offset: 2px;
}

.card-body > p,
.cat-desc,
.footer-links a,
.footer-bottom p {
  color: rgba(180, 195, 230, 0.68);
}

.nav-links a:focus-visible,
.btn:focus-visible,
.cat-tile:focus-visible,
.card:focus-visible,
.menu-toggle:focus-visible,
.search-trigger:focus-visible {
  outline: 2px solid rgba(0, 224, 255, 0.7);
  outline-offset: 3px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ═══════════════════════════════════════════════════════════════
   FONT OPTIMIZATION
   ═══════════════════════════════════════════════════════════════ */

body {
  text-rendering: optimizeSpeed;
}

@media (min-width: 769px) {
  body {
    text-rendering: optimizeLegibility;
  }
}

/* ═══════════════════════════════════════════════════════════════
   SEARCH OVERLAY — Reduce blur on mobile
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .pfx-search-overlay {
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   ADSENSE CONTAINERS (Anti-CLS & Responsive)
   ═══════════════════════════════════════════════════════════════ */

/* Enforce height reservation so page layout does not jump */
.ad-horizontal {
  width: 100%;
  min-height: 90px;
  margin: 32px 0;
  text-align: center;
  contain: layout style;
  border-radius: 4px;
}

.ad-vertical {
  width: 100%;
  min-height: 600px;
  margin: 20px 0;
  contain: layout style;
  border-radius: 4px;
}

@media (max-width: 900px) {
  .desktop-only {
    display: none !important;
  }
}
