/* Ad places. Markup is emitted by the engine (_AdSlot): .ad-slot > .ad-slot__label + .ad-slot__frame.
   An unsold slot renders no element, so spacing lives on the slot itself, never on a wrapper or a rule. */
@layer components {
  .ad-slot { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: var(--space-2); margin-block: var(--space-6); min-inline-size: 0; }
  .ad-slot__label {
    font-size: var(--fs-2xs);
    font-stretch: var(--stretch-label);
    letter-spacing: 0.12em;
    line-height: 1;
    text-transform: uppercase;
    color: var(--ink-muted);
  }
  /* the frame reserves the space (no layout shift); a banner scales down in proportion inside it */
  .ad-slot__frame {
    inline-size: 100%;
    min-inline-size: 0;
    min-block-size: var(--ad-min-h-mobile, 0);
    max-inline-size: var(--ad-w, 100%);
    display: grid;
    justify-items: center;
    align-content: start;
    overflow-x: clip; /* Revive banners wider than the frame are scaled by the engine script (/_r.js) */
  }
  .ad-slot__frame :is(img, svg, video, iframe) { max-inline-size: 100%; block-size: auto; }
  .ad-slot__frame img { inline-size: 100%; }
  .ad-slot__frame iframe { inline-size: 100%; border: 0; }
  @media (min-width: 64em) {
    .ad-slot__frame { min-block-size: var(--ad-min-h-desktop, 0); }
  }

  /* widths per place (px of the banner) */
  .ad-slot[data-slot="top_billboard"], .ad-slot[data-slot="home_row"], .ad-slot[data-slot="listing_row"],
  .ad-slot[data-slot^="footer_"] { --ad-w: 728px; }
  .ad-slot[data-slot="top_left"], .ad-slot[data-slot="top_right"] { --ad-w: 468px; }
  .ad-slot[data-slot^="sidebar_"] { --ad-w: 336px; }
  .ad-slot[data-slot^="in_article_"] { --ad-w: 468px; }
  .ad-slot[data-slot="in_article_2"] { --ad-w: 336px; }

  /* header group: one label for three banners; the pair stacks on narrow screens */
  .l-adgroup > .ad-slot { margin-block: 0; flex: 1 1 100%; }
  .l-adgroup > .ad-slot[data-slot="top_billboard"] { flex-basis: 100%; }
  @media (min-width: 48em) {
    .l-adgroup > .ad-slot[data-slot="top_left"], .l-adgroup > .ad-slot[data-slot="top_right"] { flex: 0 1 calc(50% - var(--space-3)); max-inline-size: 468px; }
  }
  .l-adgroup > .ad-slot ~ .ad-slot .ad-slot__label {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .l-adgroup > .ad-slot ~ .ad-slot { gap: 0; }

  /* slots in the main column */
  .l-main > .ad-slot { margin-block: var(--space-2); }
  .l-article > .ad-slot { margin-block: var(--space-8); }
  .c-body .ad-slot { margin-block: var(--space-8); max-inline-size: none; }
  .l-rail > .ad-slot { margin-block: 0; justify-items: stretch; }
  .l-rail > .ad-slot .ad-slot__label { justify-self: center; }
  .l-rail > .ad-slot .ad-slot__frame { max-inline-size: none; }
  /* optional: keep the last unit of the rail in view while the rail scrolls (not used by default) */
  .ad-slot--sticky { position: sticky; inset-block-start: var(--space-4); }

  /* placeholder state (admin "show placeholders"): same footprint as a banner, drawn as a dashed plate */
  .ad-slot__ph {
    inline-size: min(100%, var(--ph-w-m, 100%));
    block-size: var(--ph-h-m, 4rem);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    align-content: center;
    gap: var(--space-1) var(--space-3);
    padding: var(--space-2);
    border: 1px dashed var(--ad-line);
    background: var(--surface-alt);
    color: var(--ink-muted);
    font-size: var(--fs-xs);
    text-align: center;
  }
  .ad-slot__ph-size { font-size: var(--fs-sm); font-weight: var(--fw-strong); color: var(--ink); }
  .ad-slot__ph-code { font-family: var(--font-mono); font-size: 0.75rem; }
  .ad-slot__ph-alt { flex-basis: 100%; font-size: var(--fs-2xs); }
  .ad-slot__ph-d { display: none; }
  @media (min-width: 64em) {
    .ad-slot__ph { inline-size: min(100%, var(--ph-w-d, 100%)); block-size: var(--ph-h-d, 4rem); }
    .ad-slot__ph-m { display: none; }
    .ad-slot__ph-d { display: inline; }
  }
}
