/* PardisGifts - Perfmatters lazy-image loading state (PARDIS-LAZY-001..004) v1.7.3
   Purpose: every lazy product image shows a SKELETON SHIMMER as its base (resting)
   state for as long as the image slot is empty, then the arriving image fades in.

   v1.7.1 root causes (probed live on pardisgifts.com, evidence dir lazy-load/):
   1. Perfmatters v2.6.9 (vanilla-lazyload) swaps each lazy <img> src to a transparent
      inline SVG and manages classes: initial "perfmatters-lazy" -> "pmloading" ->
      "pmloaded". The pmloading window measured 244-735 ms: shimmer-only-while-pmloading
      is imperceptible for the owner. Fix: shimmer is now the BASE state, not tied to
      pmloading.
   2. Elementor injects an inline perf rule on every page:
        .e-con.e-parent:nth-of-type(n+2):not(.e-lazyloaded):not(.e-no-lazyload),
        .e-con.e-parent:nth-of-type(n+2):not(.e-lazyloaded):not(.e-no-lazyload) * {
          background-image: none !important; }
      (same for n+3 / n+4). Specificity (0,5,0) + !important - it silently erased our
      gradient on most below-fold images, leaving a flat #f1f5f9 box. Fix: our base
      selector is prefixed with :root (0,6,1) and re-declares background-image with
      !important so ours (later in cascade order with equal importance, higher
      specificity) wins deterministically.

   v1.7.2 site-wide audit (audit-v172*.md, 7 page archetypes, raw HTML + DB dump):
   - Bucket A (class perfmatters-lazy + data-src): all lazied images - covered below.
   - Bucket B (data-src present but NO perfmatters-lazy class): 0 occurrences live
     today, BUT Perfmatters manages them via elements_selector "img[data-src]" with
     the same pmloading/pmloaded classes, so they would currently render with NO
     shimmer. Safety net: base + fade-in rules now also match img[data-src].
   - Bucket C (raw src, no lazy): 22+ images across category/search/related grids,
     ALL carrying fetchpriority="high". Root cause traced in the DB dump
     (perfmatters options): Preload -> Fetch Priority rule with selector
     "fetchpriority-1", priority=high. Perfmatters intentionally EXCLUDES
     fetchpriority=high images from lazy loading, so category-grid product images
     stream progressively ("piece by piece"). CSS cannot shimmer a real-src image;
     the fix is an owner action in Perfmatters settings (remove/rename the
     "fetchpriority-1" fetch-priority rule so Perfmatters lazies those grids again).
     Documented in CHANGELOG v1.7.2 - NO code can cover bucket C inside this scope.
   - Bucket D (CSS background-image): only the PhotoSwipe plugin skin icon; no
     content background images - .perfmatters-lazy-css-bg coverage not needed yet.

   Scope contract: `img.perfmatters-lazy` AND fallback `img[data-src]` elements.
   The opt-out class "pm-loaded-done" still excludes an img from every rule below. */

/* ---------- Base (unobserved) + loading state: skeleton shimmer ----------
   One rule pair covers both: img slots start shimmering immediately (perceived
   performance), pmloading needs no extra selector. :root + !important beats the
   Elementor inline background-image:none !important (0,5,0) rule.
   Second selector = bucket-B safety net (data-src without perfmatters-lazy). */
:root img.perfmatters-lazy:not(.pmloaded):not(.pm-loaded-done),
:root img[data-src]:not(.perfmatters-lazy):not(.perfmatters-lazy-css-bg):not(.pmloaded):not(.pm-loaded-done) {
    background-color: #e2e8f0 !important;
    background-image: linear-gradient(
        100deg,
        #e2e8f0 0%,
        #eef2f7 18%,
        rgba(254, 154, 0, 0.10) 48%,
        #f8fafc 58%,
        #eef2f7 82%,
        #e2e8f0 100%
    ) !important;
    background-size: 240% 100% !important;
    background-repeat: no-repeat !important;
    animation: pg-lazy-shimmer 1.2s ease-in-out infinite;
}

@keyframes pg-lazy-shimmer {
    0% { background-position: 240% 0; }
    100% { background-position: -240% 0; }
}

/* ---------- Loaded state: stop the shimmer, 0.4s fade-in on arrival.
   Specificity (0,6,1) replaces Perfmatters' built-in 500ms pmFadeIn instead of
   stacking with it. img.pmloaded matches both bucket A and bucket B images
   (pmloaded is only ever added on lazy-managed imgs). background shorthand
   intentionally left unset here: once pmloaded applies, the base selector stops
   matching and Elementor's rule may wipe the gradient - the real image covers
   the box anyway. */
:root img.pmloaded:not(.pm-loaded-done) {
    animation: pg-lazy-fade-in 0.4s ease-out;
}

@keyframes pg-lazy-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Accessibility: honor reduced-motion preference - static gray, no shimmer/pulse/fade. */
@media (prefers-reduced-motion: reduce) {
    :root img.perfmatters-lazy:not(.pmloaded):not(.pm-loaded-done),
    :root img[data-src]:not(.perfmatters-lazy):not(.perfmatters-lazy-css-bg):not(.pmloaded):not(.pm-loaded-done),
    :root img.pmloaded:not(.pm-loaded-done) {
        animation: none !important;
    }
}
