/* ==========================================================================
   Ads_terra/ads.css
   --------------------------------------------------------------------------
   WHY THIS IS SO PLAIN — read before "improving" it.

   The first version hid each slot until a fill was confirmed (display:none when
   idle, visibility:hidden and parked off-screen while loading). That gave a
   perfect no-blank-space guarantee and ZERO ads, because the network refuses to
   render into a hidden container. Its loader walks the container's ancestor
   chain and bails out if any of them has visibility:hidden or opacity below
   0.9 — a standard anti-fraud check, since a hidden ad is an unviewable
   impression.

   So the slot must be genuinely visible and in normal flow from the start.
   The no-blank-space guarantee is achieved a different way: an empty div with
   no height, no padding, no border and no margin is a self-collapsing block.
   It occupies exactly zero pixels, and neighbouring margins collapse straight
   through it, so a slot that never fills is invisible anyway.

   Spacing is added ONLY once real content is confirmed inside it.

   Do NOT add to the idle state: display:none, visibility:hidden, opacity,
   transform, filter, clip-path, position:absolute, or overflow:hidden.
   overflow:hidden is not a visibility problem but it establishes a block
   formatting context, which stops neighbouring margins collapsing through the
   empty slot — measured at 160px of stray gap on /methodology/.
   ========================================================================== */

.adslot {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  /* No height declaration at all: an empty block is 0px tall by itself. */
}

/* Rhythm containers (.prose, .stack) space their children with `> * + *`. A
   collapsed slot paints nothing but is still a SIBLING for selector matching, so
   if it lands first, the element after it starts matching `* + *` and gains a top
   margin it never had. Measured at 15px per occurrence. Neutralise that case only. */
.prose > .adslot:not(.is-filled):first-child + *,
.stack > .adslot:not(.is-filled):first-child + * {
  margin-block-start: 0;
}

/* Confirmed fill — the ONLY rule that introduces space. */
.adslot.is-filled {
  margin-block: clamp(1.75rem, 4vw, 2.75rem);
  margin-inline: auto;
  max-inline-size: 100%;
  text-align: center;
}

/* Contain creatives that ship fixed pixel widths, so an ad can never be the thing
   that breaks the site's zero-horizontal-overflow guarantee at 320px. */
.adslot > div,
.adslot iframe,
.adslot img {
  max-inline-size: 100%;
}

.adslot iframe {
  border: 0;
  display: block;
  margin-inline: auto;
}

/* The slot above the related-tools grid takes the card treatment once filled, so it
   reads as part of that row rather than as something dropped between blocks. */
.adslot--grid.is-filled {
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  padding: 0.75rem;
}

@media print {
  .adslot { display: none !important; }
}
