/* Hydroposhan — site-wide performance optimizations (load last in global stack) */

/* GPU-friendly compositing for fixed chrome */
html.ha-unified .ha-scroll-progress,
html.ha-unified .ha-back-to-top {
    contain: layout style;
}

html.ha-unified header {
    contain: style;
    overflow: visible !important;
}

@media (prefers-reduced-motion: reduce) {
    html.ha-unified *,
    html.ha-unified *::before,
    html.ha-unified *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Defer paint for below-fold sections (keep hero/header immediate) */
html.ha-unified .section-padding:not(.hero):not(.programs-hero):not(.page-hero):not(.program-hero),
html.ha-unified .content-card:not(.programs-page__card),
html.ha-unified .program-section,
html.ha-unified .category-section,
html.ha-unified .policy-section,
html.ha-unified .legal-content,
html.ha-unified footer {
    content-visibility: auto;
    contain-intrinsic-size: auto 220px;
}

/* Images: stable layout + async decode */
html.ha-unified main img:not([width]):not([height]) {
    height: auto;
}

html.ha-unified main img[loading="lazy"] {
    content-visibility: auto;
}

html.ha-unified img[decoding="async"] {
    decoding: async;
}

/* Font loading: reduce invisible text flash */
html.ha-unified {
    text-rendering: optimizeLegibility;
}

/* Mobile: skip expensive hover/tilt effects */
@media (max-width: 768px) {
    html.ha-unified .ha-tilt-card,
    html.ha-unified .program-card:hover,
    html.ha-unified .infra-card:hover,
    html.ha-unified .article-card:hover,
    html.ha-unified .testimonial-card:hover,
    html.ha-unified .value-item:hover,
    html.ha-unified .diff-badge:hover {
        transform: none !important;
        box-shadow: none !important;
    }

    html.ha-unified .ha-magnetic-btn {
        transform: none !important;
    }
}

/* Reduce layout thrash from wide tables */
.table-responsive,
.program-compare-scroll,
.programs-compare-wrap,
.infra-compare-wrap {
    contain: layout style;
}

/* Legal / policy pages — lighter paint on mobile */
@media (max-width: 768px) {
    html.ha-unified .policy-summary__card,
    html.ha-unified .policy-notice {
        contain: layout style paint;
    }
}

/* Faster first paint — skip rendering off-screen sections until needed */
html.ha-unified body:not(.page-home) main > section:not(:first-of-type) {
    content-visibility: auto;
    contain-intrinsic-size: auto 180px;
}

/* Homepage — defer below-fold sections */
html.ha-unified body.page-home .section-padding:not(.hero):not(:first-of-type) {
    content-visibility: auto;
    contain-intrinsic-size: auto 200px;
}

/* Lazy images — reduce decode cost on scroll */
html.ha-unified main img[loading="lazy"] {
    content-visibility: auto;
    contain-intrinsic-size: auto 120px;
}

/* Preconnect hints are in HTML; reduce layout shift for lazy images */
html.ha-unified main img[loading="lazy"]:not([width]) {
    min-height: 1px;
}

/* Single scroll listener — pages should not add duplicate header scripts */
html.ha-unified header {
    will-change: box-shadow;
}

/* Section eyebrows removed — hide any cached markup */
html.ha-unified .section-eyebrow,
html.ha-unified .programs-section__eyebrow {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Legacy .reveal — inner pages must never stay invisible (how-to-enroll, etc.) */
html.ha-unified body:not(.page-home) .reveal {
    opacity: 1 !important;
    transform: none !important;
}
