/* /public/css/ad.css */

.ad-sidebar {
    position: absolute;
    right: 15px;
    top: 50px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: clamp(165px, calc(50vw - 430px), 325px);
    z-index: 100;
}

.ad-slot {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: rgba(143, 164, 210, 0.08);
    border-radius: 17px;
    overflow: hidden;
    border: 2.5px solid #8fa4d2;
    box-shadow:
        0 4px 24px 0 #7a90be26,
        0 1px 6px 0 #5973b229;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Placeholder label — visible until AdSense fills the slot */
.ad-slot::after,
.ad-slot-inline::after {
    content: "Advertisement";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-family: inherit;
    color: #8fa4d2;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    pointer-events: none;
    white-space: nowrap;
}

/* Hide placeholder once AdSense ins has content */
.ad-slot:has(ins.adsbygoogle[data-ad-status="filled"])::after,
.ad-slot-inline:has(ins.adsbygoogle[data-ad-status="filled"])::after {
    display: none;
}

/* ─── Below 1200px — hide sidebar, show inline banner ───────────────────── */
@media (max-width: 1200px) {
    .ad-sidebar {
        display: none;
    }

    /* Outer container — styled like .vocab-box-wrapper to match the page.
       flex-shrink: 0 prevents the flex body from collapsing it.
       Height is set explicitly so AdSense inline-style overrides on children
       cannot affect the outer box dimensions.                                 */
    .ad-slot-inline {
        display: block;
        position: relative;
        flex-shrink: 0;
        box-sizing: border-box;
        width: 95%;
        max-width: 800px;
        height: 100px;
        margin: 16px auto;
        background: rgba(143, 164, 210, 0.08);
        border: 2px solid #8fa4d2;
        border-radius: 8px;
        box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
        overflow: hidden;
    }

    /* Inner wrapper is absolutely positioned — AdSense sets height/min-height
       on THIS element; the outer container's height is unaffected.           */
    .ad-slot-inner {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        overflow: hidden;
    }
}

/* ─── Fallback: single vertical rectangle ────────────────────────────────── */
.ad-slot--vertical {
    aspect-ratio: auto;
    height: 150px;
}

/* ─── Flowmap override (full-screen canvas page) ─────────────────────────── */
body.flowmap-page .ad-sidebar {
    position: fixed;
    right: 16px;
    top: 80px;
}

/* Flowmap adaptive — fixed at bottom center, doesn't disrupt canvas */
@media (max-width: 1200px) {
    body.flowmap-page .ad-slot-inline {
        position: fixed;
        bottom: 48px;
        left: 16px;
        right: 16px;
        width: auto;
        max-width: 100%;
        margin: 0;
        z-index: 999;
        transform: none;
    }
}

#ad-inline-1.ad-slot-inline {
    margin-top: 0px;
    margin-bottom: 0px;
}
