/* ==========================================================================
   TechX Ad Container & CLS Safety System (Modular Architecture)
   Prevents empty black rectangles, collapses unfilled ads, stops CLS
   ========================================================================== */

/* 1. Dynamic Collapse for Empty, Unfilled, or Blocked Ads */
.a-wrap:empty,
.a-wrap.techx-ad-unfilled,
.a-wrap:has(ins[data-ad-status="unfilled"]),
.a-wrap:not(:has(ins)):not(:has(iframe)),
.techx-ad-slot:empty,
.techx-ad-slot.techx-ad-unfilled,
.techx-ad-slot:has(ins[data-ad-status="unfilled"]),
.techx-ad-slot:not(:has(iframe)):not(:has(ins[data-adsbygoogle-status="done"])),
.elementor-widget-smartmag-codes:has(.techx-ad-unfilled),
.elementor-widget-smartmag-codes:has(.techx-ad-slot:empty),
.elementor-widget-smartmag-codes:has(ins[data-ad-status="unfilled"]) {
    display: none !important;
    min-height: 0 !important;
    max-height: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    visibility: hidden !important;
    overflow: hidden !important;
}

/* 2. Active Filled Ad Styling & Soft Bento Frame */
.a-wrap:has(ins[data-ad-status="filled"]),
.a-wrap:has(iframe),
.a-wrap.techx-ad-filled,
.techx-ad-slot:has(ins[data-ad-status="filled"]),
.techx-ad-slot:has(iframe),
.techx-ad-slot.techx-ad-filled {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    margin: 32px auto !important;
    min-height: 250px;
    background: rgba(255, 255, 255, 0.02) !important;
    border-radius: 12px !important;
    border: 1px dashed rgba(255, 255, 255, 0.08) !important;
    position: relative !important;
    overflow: hidden !important;
}

/* Light Mode Active Ad Frame */
html:not(.site-s-dark) .a-wrap:has(ins[data-ad-status="filled"]),
html:not(.site-s-dark) .a-wrap:has(iframe),
html:not(.site-s-dark) .a-wrap.techx-ad-filled,
html:not(.site-s-dark) .techx-ad-slot:has(ins[data-ad-status="filled"]),
html:not(.site-s-dark) .techx-ad-slot:has(iframe),
html:not(.site-s-dark) .techx-ad-slot.techx-ad-filled {
    background: rgba(0, 0, 0, 0.02) !important;
    border: 1px dashed rgba(0, 0, 0, 0.08) !important;
}

/* Small Subtle Ad Label */
.a-wrap:has(ins[data-ad-status="filled"])::before,
.a-wrap:has(iframe)::before,
.a-wrap.techx-ad-filled::before,
.techx-ad-slot:has(ins[data-ad-status="filled"])::before,
.techx-ad-slot:has(iframe)::before,
.techx-ad-slot.techx-ad-filled::before {
    content: "ADVERTISEMENT";
    position: absolute;
    top: 6px;
    right: 12px;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.25);
    font-weight: 600;
    font-family: inherit;
    text-transform: uppercase;
}

html:not(.site-s-dark) .a-wrap:has(ins[data-ad-status="filled"])::before,
html:not(.site-s-dark) .a-wrap:has(iframe)::before,
html:not(.site-s-dark) .a-wrap.techx-ad-filled::before,
html:not(.site-s-dark) .techx-ad-slot:has(ins[data-ad-status="filled"])::before,
html:not(.site-s-dark) .techx-ad-slot:has(iframe)::before,
html:not(.site-s-dark) .techx-ad-slot.techx-ad-filled::before {
    color: rgba(0, 0, 0, 0.35);
}

/* 3. AdSense Dark Mode Harmonization (Discover More / Related Content / Auto-Ads) */
html.site-s-dark {
    color-scheme: dark;
}

html.site-s-dark iframe[id^="aswift_"],
html.site-s-dark iframe[name^="google_ads_"] {
    color-scheme: dark;
    background: transparent !important;
}

html.site-s-dark .google-auto-placed,
html.site-s-dark .adsbygoogle {
    background: transparent !important;
}

ins.adsbygoogle {
    background: transparent !important;
}

@media (max-width: 768px) {
    .a-wrap:has(ins[data-ad-status="filled"]),
    .a-wrap:has(iframe),
    .a-wrap.techx-ad-filled,
    .techx-ad-slot:has(ins[data-ad-status="filled"]),
    .techx-ad-slot:has(iframe),
    .techx-ad-slot.techx-ad-filled {
        min-height: 250px !important;
        margin: 20px auto !important;
    }
}


/* AdSense Related Content & Discover More units in Dark Mode */
html.site-s-dark .goog-rentries,
html.site-s-dark .goog-rentry,
html.site-s-dark .google-aiuf,
html.site-s-dark div[id^="aswift_"] {
    background-color: #0f131f !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #e2e8f0 !important;
}

html.site-s-dark .goog-rentries *,
html.site-s-dark .google-aiuf * {
    color: #cbd5e1 !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

html.site-s-dark .goog-rentries div,
html.site-s-dark .google-aiuf div {
    background-color: #0f131f !important;
}
