/* ============================================================================
   optimize.css — Performance overrides (loaded last)

   - Slower/removed infinite animations
   - overflow: clip where a scroll container is unnecessary
   - GPU promotion for animated elements
   - Lighter animations on low-refresh-rate and mobile devices
   ============================================================================ */

/* ---------------------------------------------------------------------------
   1. Infinite animations — slower, subtler versions of the effects.css defaults
   --------------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .eyebrow-dot {
    animation: pulse-dot var(--duration-infinite-medium) var(--ease-smooth) infinite;
  }

  .contact-glow {
    animation: pulse-glow calc(var(--duration-infinite-medium) * 2) var(--ease-smooth) infinite;
  }

  .hero-grid {
    animation: pan-grid var(--duration-infinite-slow) var(--ease-smooth) infinite alternate;
  }

  /* orbit-two is a redundant dashed circle — skip its rotation */
  .orbit-two {
    animation: none;
  }
}

/* ---------------------------------------------------------------------------
   2. Overflow — clip avoids creating a scroll container
   --------------------------------------------------------------------------- */

.approach-art {
  overflow: clip;
}

.contact-map {
  overflow: clip;
}

/* ---------------------------------------------------------------------------
   3. GPU promotion — REMOVED.

   `transform: translateZ(0)` on these five was inert. Every one of them carries
   an entrance `animation: … both`, and a CSS animation's filled end state
   outranks a normal author declaration, so the promotion never applied during
   the animation — which is the only period it was wanted for. On .hero-visual
   it never applied at all, because its `float` animation is `infinite`. After
   the animation ended it promoted four elements that then never moved again,
   costing four compositor layers for nothing.
   --------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------
   4. will-change — only on continuously animated elements
   --------------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .visual-core,
  .eyebrow-dot {
    will-change: transform, opacity;
  }

  .visual-orbit {
    will-change: transform;
  }
}

/* ---------------------------------------------------------------------------
   5. Low-refresh-rate devices — disable infinite animations
   --------------------------------------------------------------------------- */

@media (update: slow) {
  /* .hero-visual belongs here: its `float` animation is `infinite`, so the
     0.01ms duration below would otherwise spin it roughly 100,000 times a
     second, forever — the exact cost this block exists to avoid. */
  .visual-core,
  .visual-orbit,
  .eyebrow-dot,
  .contact-glow,
  .hero-grid,
  .hero-visual,
  .approach-feature {
    animation: none;
  }

  /* Snap the entrance animations to their end state. This is the ONLY place
     entrance timing is compressed, and it is a device-capability query rather
     than a width one, so it cannot make phones disagree with desktops. */
  .hero-copy > *,
  .hero-visual,
  .section-heading,
  .hero-bottom,
  .visual-label,
  .trust-inner li,
  .service-card,
  .approach-art,
  .approach-copy,
  .contact-copy,
  .contact-details,
  .contact-details dl > div,
  .contact-form,
  .footer-main,
  /* Was missing, so the panel animated its full 0.25s entrance on these devices
     while every other entrance snapped — the exact two-speeds drift the
     `update: slow` block exists to prevent. */
  .js .primary-nav.is-open {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
  }

  /* Backdrop blur is the most expensive paint on the page and this block exists
     to cut cost on exactly this hardware. Measured regions: ~460x649px at a
     500px viewport and ~1150x650px (750k px) at 1200px for the contact form
     alone. `max-width: 760px` relieves phones; a 1024px tablet at 30Hz got
     neither. 8px is the same radius the phone gate uses, so the two gates
     agree. `.js .primary-nav` is (0,2,0) so glass.css cannot undo it, and the
     header is listed as `::before` so it is not made a backdrop root again. */
  .site-header::before,
  .js .primary-nav,
  .contact-form {
    backdrop-filter: blur(8px) saturate(140%);
    -webkit-backdrop-filter: blur(8px) saturate(140%);
  }
}

/* ---------------------------------------------------------------------------
   6. Mobile — reduce animation complexity and blur
   --------------------------------------------------------------------------- */

@media (max-width: 760px) {
  /* The ambient loops are killed here, which is where the real mobile
     performance win is. Entrance timings are deliberately NOT touched: they
     used to be forced to --duration-fast with every delay zeroed, which halved
     the duration of the elements listed here and removed the stagger — while
     five other entrance-animated elements were missing from that list and kept
     the desktop 0.5s and their delays. Phones therefore ran a mix of 0.25s and
     0.5s entrances, some staggered and some not. One source of timing
     (effects.css) now applies at every width.

     `.hero-visual` keeps its 6s `float` on mobile deliberately — it is the
     hero's focal element and 6s is gentle enough to read as ambient, and
     `parallax.js` is already off on touch. Every other infinite loop is
     stopped. */
  .visual-core,
  .visual-orbit,
  .eyebrow-dot,
  .contact-glow,
  .hero-grid,
  .approach-feature {
    animation: none !important;
  }

  .service-card:hover,
  .button:hover,
  .nav-cta:hover,
  .approach-art:hover,
  .contact-form:hover,
  /* These three were missing, and on a touch device `:hover` sticks after a
     tap. The nav rows and the theme toggle gain a scale plus a 50%-black pill
     fill that stays put until the visitor taps elsewhere; .approach-feature
     lifts and turns its border red. Note the nav-link scale is applied
     INSTANTLY — glass.css:104 overrides the transition list and drops
     `transform` from it — so a tapped "About" row jumps with no easing at all. */
  .primary-nav > a:not(.nav-cta):hover,
  [data-theme-toggle]:hover,
  .approach-feature:hover,
  /* The card's icon lead and its "Discuss …" link were the last two hover
     moves still on a touch screen: a tapped card left its icon raised and
     enlarged and its link 4px to the right until something else was tapped. */
  .service-card:hover .service-icon img,
  .service-card > a:hover,
  .brand:hover {
    transform: none !important;
    box-shadow: none !important;
    translate: none !important;
    scale: none !important;
    rotate: none !important;
  }

  /* The header's blur is listed as `.site-header::before`, NOT `.site-header`.
     Writing `.site-header` here would re-declare `backdrop-filter` on the
     element the nav panel descends from, turning it back into a backdrop root
     and making the panel's filter inert again on every phone — with no error and
     no visible cause. It was `.site-header` in this block until the panel's blur
     was fixed; keep it on the pseudo-element.

     `.js .primary-nav` was absent from this list. It is the LARGEST filtered
     surface on a phone (measured 358x258 at 390px wide), so the gate most
     needed to cover it — and it only started genuinely blurring once the
     backdrop-root trap was fixed. `.js` keeps it at (0,2,0) so it cannot be
     undone by the (0,2,0) `.js .primary-nav` rule in glass.css. */
.site-header::before,
  .js .primary-nav,
  .contact-form {
    backdrop-filter: blur(8px) saturate(140%);
    -webkit-backdrop-filter: blur(8px) saturate(140%);
  }
}

/* ---------------------------------------------------------------------------
   7. Contain — layout/style isolation for independent blocks
   --------------------------------------------------------------------------- */

.service-grid,
.trust-inner {
  contain: layout style;
}
