/* ==========================================================================
   Advertising surfaces
   --------------------------------------------------------------------------
   A slot is invisible unless <html> carries `up-ads-on`, which is only added
   by the <head> snippet that tools/build-ads.mjs writes once a publisher id is
   set in assets/js/ads.js. That keeps the boxes out of the way on a site with
   advertising switched off and gives the layout a reserved height while an ad
   is being requested.

   The label stays hidden until the ad actually fills: during the 6s watchdog
   window in ads.js an "ADVERTISEMENT" caption over nothing reads as a bug.
   ========================================================================== */

.up-ad {
    display: none;
}

html.up-ads-on .up-ad {
    display: grid;
    justify-items: center;
    gap: 8px;
    width: 100%;
    max-width: 970px;
    margin: 36px auto 40px;
    padding-inline: clamp(0px, 2vw, 16px);
}

html.up-ads-on .up-ad[hidden] {
    display: none !important;
}

/* Inside an article the column is already capped at 42rem, so the slot should
   just fill it instead of asking for 970px. */
html.up-ads-on .article-content .up-ad {
    max-width: none;
    margin: 32px auto;
    padding-inline: 0;
}

.up-ad-label {
    font-family: var(--font-mono, ui-monospace, "Cascadia Mono", Consolas, monospace);
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--fg-4, #4a525d);
    visibility: hidden;
}

.up-ad.is-filled .up-ad-label {
    visibility: visible;
}

.up-ad-frame {
    display: block;
    width: 100%;
    overflow: hidden;
}

/* Reserve room only while the request is in flight, so a filled ad decides its
   own height (auto format) instead of being padded to our guess. */
html.up-ads-on .up-ad[data-ad-state="loading"] .up-ad-frame {
    min-height: 100px;
}

@media (min-width: 768px) {
    html.up-ads-on .up-ad[data-ad-state="loading"] .up-ad-frame {
        min-height: 250px;
    }
}

@media print {
    .up-ad {
        display: none !important;
    }
}
