/* ═══════════════════════════════════════════════════════════════════════════
   ADSENSE MONETIZATION CSS — ads/adsense.css
   ─ Responsive, CLS-safe ad containers
   ─ Auto-collapse for unfilled slots
   ─ AdBlock blur gate styling
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1. AD WRAPPER BASE ────────────────────────────────────────────────────── */
/* ⚑ CANARY: this custom property is the AdBlock detection signal.
   If adsense.css is blocked by AdBlock, --ad-loaded will be missing.
   The JS in app-validator.js reads this value to detect AdBlock. */
:root {
    --ad-loaded: 1;
}

.ad-wrapper {
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    transition: min-height 0.3s ease, opacity 0.3s ease;
    background: transparent;
}

/* Disclosure label — required by Google AdSense policy */
.ad-label {
    display: block;
    text-align: center;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted, #94a3b8);
    margin-bottom: 4px;
    font-weight: 600;
    position: absolute;
    top: 4px;
    left: 0;
    right: 0;
    pointer-events: none;
}

/* ── 2. SLOT-SPECIFIC LAYOUTS ──────────────────────────────────────────────── */

/* Leaderboard (Top banner) — stays above the fold on desktop, stacks on mobile */
.ad-wrapper--leaderboard {
    max-width: 728px;
    margin: 0 auto 1rem auto;
}

/* Below Hero — appears right after generator, safe mobile clearance */
.ad-wrapper--below_hero {
    max-width: 728px;
    margin: 1.5rem auto;
}

/* Sidebar unit — standard 300×250, glass card style */
.ad-wrapper--sidebar {
    max-width: 336px;
    width: 100%;
    border-radius: 16px;
    /* Subtle inner border consistent with glass-morphism */
    border: 1px solid rgba(255,255,255,0.08);
    padding: 8px 0 0;
}

/* Infeed unit — blends between signature cards */
.ad-wrapper--infeed {
    width: 100%;
    border-radius: 16px;
    border: 1px dashed rgba(99,102,241,0.15);
    background: rgba(99,102,241,0.03);
    padding: 4px;
}

/* Footer leaderboard */
.ad-wrapper--footer {
    max-width: 728px;
    margin: 0 auto;
}

/* Modal unit */
.ad-wrapper--modal {
    max-width: 336px;
    margin: 0 auto;
    border-radius: 12px;
}

/* ── 3. AUTO-COLLAPSE — Unfilled Slots ─────────────────────────────────────── */

/* CSS fallback: hide completely when <ins> is empty (no ad rendered) */
.ad-wrapper ins.adsbygoogle:empty,
.ad-slot-container:empty,
.ad-container:empty,
.adsbygoogle:empty {
    display: none !important;
}

/* When AdSense sets data-ad-status="unfilled" via JS observer (backup) */
.ad-wrapper ins[data-ad-status="unfilled"],
.adsbygoogle[data-ad-status="unfilled"] {
    display: none !important;
}

/* Collapse parent wrapper too — eliminates white gaps */
.ad-wrapper:has(ins[data-ad-status="unfilled"]),
.ad-slot-container:not(:has(ins[data-ad-status="filled"])),
.ad-container:not(:has(ins[data-ad-status="filled"])),
.leaderboard-top:not(:has(ins[data-ad-status="filled"])),
.ad-container:empty {
    display: none !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 0 !important;
}

/* Ensure filled ads have some breathing room */
.ad-slot-container:has(ins[data-ad-status="filled"]),
.ad-container:has(ins[data-ad-status="filled"]) {
    padding: 20px 0;
    min-height: 100px;
}

/* AdBlock Blur Effect */
#signature-generator.adblock-active {
    filter: blur(8px) grayscale(50%);
    pointer-events: none;
    user-select: none;
    transition: filter 0.5s ease;
}

/* AdBlock Modal */
.adblock-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.adblock-content {
    background: white;
    padding: 40px;
    border-radius: 24px;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    animation: slideUp 0.4s ease;
}

[data-theme="dark"] .adblock-content {
    background: #1a1a2e;
    color: white;
    border: 1px solid rgba(255,255,255,0.1);
}

.adblock-icon {
    font-size: 4rem;
    color: #ef4444;
    margin-bottom: 20px;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.btn-whitelist {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 50px;
    font-weight: 600;
    margin-top: 20px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.btn-whitelist:hover {
    transform: scale(1.05);
}

/* Dynamic Ad & Preview Backgrounds */
.ad-preview-bg {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    transition: background 0.3s ease;
}

[data-theme="dark"] .ad-preview-bg {
    background: rgba(30, 30, 45, 0.6) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
}

.ad-container-bg {
    background: #f8fafc;
    border-radius: 12px;
}

[data-theme="dark"] .ad-container-bg {
    background: rgba(255, 255, 255, 0.05) !important;
}

/* ── 4. MOBILE SAFETY — No Above-Fold Ads on Small Screens ─────────────────── */
@media (max-width: 767px) {
    /* Leaderboard becomes full-width on mobile */
    .ad-wrapper--leaderboard,
    .ad-wrapper--below_hero,
    .ad-wrapper--footer {
        max-width: 100%;
    }

    /* Never let ads push generator below 100vh on mobile */
    .ad-wrapper--leaderboard {
        min-height: 50px !important; /* Reduced reservation on mobile */
        max-height: 100px;
    }

    /* Sidebar unit moves inline — same safe max */
    .ad-wrapper--sidebar {
        max-width: 100%;
    }
}


/* ── 5. DARK / LIGHT MODE ADJUSTMENTS ─────────────────────────────────────── */
[data-theme="light"] .ad-wrapper--sidebar,
[data-theme="light"] .ad-wrapper--infeed {
    border-color: rgba(0,0,0,0.06);
    background: rgba(0,0,0,0.02);
}

[data-theme="light"] .ad-label {
    color: #94a3b8;
}
