/**
 * IranGlass — GPU-friendly performance + zoom-stable layout
 */

/* ---- Global paint/compositing hygiene ---- */
html {
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    /* fixed backgrounds cause severe jank + zoom glitches on mobile */
    background-attachment: scroll;
}

img,
video {
    content-visibility: auto;
}

/* Prefer compositor-friendly reveals */
.ig-portfolio__item,
.ig-blog__card,
.ig-shop__card,
.ig-services__card,
.ig-about__media,
.ig-home-products .ig-shop__card {
    contain: layout paint style;
    backface-visibility: hidden;
}

.ig-site-header,
.ig-menu,
.ig-portfolio__modal,
.ig-fab,
.ig-chat-widget {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Off-screen sections skip most work until near viewport */
.ig-about,
.ig-services,
.ig-portfolio,
.ig-why,
.ig-process,
.ig-blog,
.ig-faq,
.ig-contact,
.ig-home-products {
    content-visibility: auto;
    contain-intrinsic-size: 1px 720px;
}

/* ---- Kill continuous CPU/GPU burn ---- */
@media (max-width: 1024px) {
    body {
        background-attachment: scroll !important;
    }

    body::before,
    body::after {
        animation: none !important;
        filter: none !important;
        transform: none !important;
        opacity: 0.55;
    }

    body::before {
        inset: 0;
        background:
            radial-gradient(circle at 20% 30%, rgba(199, 168, 105, 0.04) 0%, transparent 42%),
            radial-gradient(circle at 80% 70%, rgba(168, 139, 80, 0.03) 0%, transparent 40%);
    }

    .ig-bg-lines__line {
        animation: none !important;
        opacity: 0.35;
    }

    .ig-topbar,
    .ig-topbar__phone,
    .ig-header__shell,
    .ig-header__action,
    .ig-header__toggle {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    .ig-topbar__accent,
    .ig-topbar__glow,
    .ig-topbar__shine,
    .ig-topbar__mesh,
    .ig-portfolio__orb,
    .ig-shop__accent,
    .ig-404__orb,
    .ig-404__shard {
        animation: none !important;
    }

    .ig-portfolio__orb,
    .ig-404__orb,
    .ig-home-products__orb {
        display: none !important;
    }

    /* Shorter, cheaper transitions */
    .ig-portfolio__item,
    .ig-blog__card,
    .ig-shop__card,
    .ig-header__action,
    .ig-topbar__phone,
    .ig-topbar__social-link,
    .ig-faq__item,
    a,
    button {
        transition-duration: 0.18s !important;
    }

    .ig-portfolio__item {
        transition-delay: 0s !important;
    }

    /* Stable viewport units while zooming */
    .ig-main--404 .ig-404,
    .ig-home-products,
    body {
        min-height: 100dvh;
    }

    .ig-site-header {
        /* prevent zoom from stretching fixed chrome oddly */
        width: 100%;
        max-width: 100%;
        left: 0;
        right: 0;
    }

    .ig-header .ig-container,
    .ig-header__shell,
    .ig-topbar__container {
        max-width: 100%;
    }

    /* Avoid 100vw scrollbar/zoom overflow */
    .ig-main,
    .ig-portfolio,
    .ig-shop,
    .ig-hero,
    .ig-about,
    .ig-services {
        max-width: 100%;
        overflow-x: clip;
    }
}

@media (max-width: 768px) {
    html {
        scroll-behavior: auto;
    }

    /* Reduce shadow layers (expensive on mobile GPUs) */
    .ig-header__shell,
    .ig-portfolio__item,
    .ig-shop__card,
    .ig-blog__card,
    .ig-product__buy-card {
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22) !important;
    }

    .ig-portfolio__grid {
        grid-auto-rows: minmax(140px, auto);
    }

    /* Video posters: don’t force decode of many files */
    .ig-portfolio__card--video video.ig-portfolio__media {
        background: rgba(0, 0, 0, 0.35);
    }
}

/* Desktop: soft effects, but never permanent will-change (GPU memory) */
@media (min-width: 1025px) {
    body {
        background-attachment: fixed;
    }

    body::before {
        /* Cheaper than 48px live blur on large monitors */
        filter: blur(28px);
    }
}

/* Tab hidden → freeze decorative loops */
html.ig-paused body::before,
html.ig-paused body::after,
html.ig-paused .ig-bg-lines__line,
html.ig-paused .ig-topbar__accent,
html.ig-paused .ig-portfolio__orb {
    animation-play-state: paused !important;
}

@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;
    }

    body::before,
    body::after,
    .ig-bg-lines__line {
        animation: none !important;
        filter: none !important;
        will-change: auto !important;
    }
}

/* Low-end / data-saver: strip decorative motion */
@media (max-width: 1024px) and (prefers-reduced-data: reduce),
       (max-width: 1024px) and (update: slow) {
    body::before,
    body::after,
    .ig-bg-lines {
        display: none !important;
    }
}
