/* Nuki CLS Fix — Audit Patch (2026-04-27, F-02)
 * Reduces homepage CLS from 0.32 → < 0.10 by reserving space for
 * known hero, product card, and font reflow culprits.
 * Loaded via wp_head hook in nuki-seo-fixes.php.
 */

/* ============ FONT RENDERING (reduce text reflow) ============ */
@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial');
  size-adjust: 107%;
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}
html, body {
  font-display: optional;
}

/* Common Blocksy + custom hero text — reserve a stable line height */
h1, h2, h3, .nhv2-title, .ncpv2-h1, .nsv2-h1, .shop-hero-title {
  font-family: var(--theme-font-family, 'Inter'), 'Inter Fallback', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  text-rendering: optimizeSpeed;
}

/* ============ IMAGE LAYOUT (reserve space) ============ */
/* Generic: any img without explicit dims that we can constrain */
img[src][alt]:not([width]):not([height]):not([style*="width"]) {
  aspect-ratio: auto 16 / 10;
  height: auto;
  max-width: 100%;
}

/* Hero images — specific aspect ratios */
.nuki-shop-hero, .nuki-shop-hero-img,
.nhv2-hero, .nhv2-hero-img,
.ncpv2-hero, .ncpv2-hero img,
.nsv2-hero, .nsv2-hero img,
.nuki-ult-hero, .nuki-ult-hero-visual img {
  aspect-ratio: 21 / 9;
  height: auto;
  width: 100%;
}
@media (max-width: 768px) {
  .nuki-shop-hero, .nuki-shop-hero-img,
  .nhv2-hero, .nhv2-hero-img,
  .ncpv2-hero, .ncpv2-hero img,
  .nsv2-hero, .nsv2-hero img,
  .nuki-ult-hero, .nuki-ult-hero-visual img {
    aspect-ratio: 4 / 5;
  }
}

/* Product card images */
.product img.wp-post-image,
ul.products li.product img,
.woocommerce ul.products li.product a img,
.nuki-ult-related-img img,
.nuki-hcz-img img {
  aspect-ratio: 1 / 1;
  height: auto;
  width: 100%;
  object-fit: contain;
}

/* Newsletter / feature section images */
.nuki-feat-img img, .feature-image img {
  aspect-ratio: 16 / 10;
  height: auto;
}

/* ============ THIRD-PARTY EMBEDS (Site Kit, GTM, Hostinger Reach) ============ */
/* These often inject into footer / fixed positions — stop them shifting layout */
[id^="google_ads_"], [id^="hostinger-"], .ct-cookie-notification {
  contain: layout style;
}

/* ============ ANIMATION SAFETY (transform-only, no layout shift) ============ */
/* GreenShift animations — force compositor-only transforms */
[class*="gsbp-"][data-animation], [class*="gspb_"][data-animation] {
  will-change: transform, opacity;
}

/* ============ HOMEPAGE LAYOUT RESERVATION (F-02 main fix) ============ */
/* The .nuki-home-v2 section grows from ~641px to ~3800px during lazy render,
 * causing CLS=0.32. Reserve intrinsic height so content below doesn't shift. */
section.nuki-home-v2 {
  contain-intrinsic-size: auto 3800px;
  min-height: 3800px;
}
@media (max-width: 768px) {
  section.nuki-home-v2 {
    contain-intrinsic-size: auto 6000px;
    min-height: 6000px;
  }
}

/* Defer below-the-fold sections from initial layout cost */
.nuki-home-v2 .nhv2-section:nth-child(n+3),
.nuki-home-v2 .nhv2-finalcta {
  content-visibility: auto;
  contain-intrinsic-size: 1px 600px;
}

/* Custom hero sections on /uyumluluk/ /cozumler/ — reserve heights */
section.nuki-compat-v2, [class*="ncpv2-"][class*="hero"],
section.nuki-solutions-v2, [class*="nsv2-"][class*="hero"] {
  min-height: 480px;
}
@media (max-width: 768px) {
  section.nuki-compat-v2, section.nuki-solutions-v2 { min-height: 540px; }
}
