/* =============================================================================
   Ad zone — wraps AdSense / sponsor units in a labeled, height-reserved
   container. Reserving height prevents the async ad fill from pushing content
   down (Cumulative Layout Shift is a Core Web Vitals ranking signal, and the
   organic traffic it protects IS the business).

   Loaded in base.html after main.css so design tokens resolve. Uses tokens
   only — no hardcoded colors (see CLAUDE.md CSS conventions).
   ============================================================================= */

.ad-zone {
    /* Centered block with breathing room above/below the surrounding content. */
    display: block;
    margin: var(--space-8) auto;
    text-align: center;
    /* Contain the responsive <ins> to the readable column width. */
    max-width: 100%;
}

.ad-zone__label {
    display: block;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-light, var(--color-text-muted));
    margin-bottom: var(--space-2);
}

.ad-zone .adsbygoogle {
    display: block;
    margin: 0 auto;
}

/* --- Reserved heights per format (kills CLS during load) --------------------
   Heights match the most common fill for each placement. If Google returns a
   taller creative the residual shift is minor; if it returns nothing the zone
   collapses (see :has() rule below) so no empty gap is left. */

.ad-zone--leaderboard {
    min-height: 100px; /* mobile/most common banner fill */
}

.ad-zone--in-content,
.ad-zone--in_content {
    min-height: 280px; /* 300x250 / responsive rectangle */
}

.ad-zone--sidebar {
    min-height: 600px; /* half-page / vertical unit */
    margin-top: 0;
}

@media (min-width: 1024px) {
    .ad-zone--leaderboard {
        min-height: 100px;
    }
}

/* Collapse a zone whose ad came back unfilled — Google stamps
   data-ad-status="unfilled" on the <ins> when no ad is served. :has() lets us
   hide the reserved box AND its "Advertisement" label so an unfilled slot
   leaves neither a gap nor an orphan label. Height is still reserved during
   the load window, so this does not reintroduce CLS. */
.ad-zone:has(ins[data-ad-status="unfilled"]) {
    display: none;
}

/* --- Dismissible sticky bottom anchor --------------------------------------
   Fixed to the viewport bottom, dismissible. Centered, above page content but
   below modals. Hidden on print. */
.ad-anchor {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--space-2) var(--space-4);
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    min-height: 60px;
}

.ad-anchor[hidden] {
    display: none;
}

.ad-anchor .ad-zone {
    margin: 0;
    min-height: 50px;
    flex: 1;
    max-width: 970px;
}

.ad-anchor .ad-zone__label {
    margin-bottom: var(--space-1);
}

.ad-anchor__close {
    position: absolute;
    top: -32px;
    right: var(--space-3);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: var(--text-lg);
    line-height: 1;
    transition: color var(--transition-fast);
}

.ad-anchor__close:hover {
    color: var(--color-text);
}

@media print {
    .ad-zone,
    .ad-anchor {
        display: none !important;
    }
}
