/* components/ad-slot.css — layout for partials/ad-banner-*.hbs and
   ad-placeholder.hbs.
   .ad-slot is the wrapper (width only). .ad-slot__frame is what GPT fills
   and hides (collapseEmptyDivs) when unsold, so every visible property —
   height, spacing, the "Advertisement" label — goes on the frame so it
   disappears with the slot. The label is a pseudo-element for the same
   reason (so it can't be translated).
   Creatives scale down to fit the frame, keeping their aspect ratio.
   The placeholder shares these rules and mirrors GPT's size mappings from
   default.hbs (960px / 640px viewport, ad ops' numbers; 1024px for the
   tag archives' rail, whose 320px column is in tag-feed.css — change them
   together). */

.ad-slot,
.ad-preview {
  width: 100%;
  margin-inline: auto;
}

.ad-slot__frame,
.ad-preview__frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  /* Shortest creative's height, so the page doesn't jump. Matches live. */
  min-height: 360px;

  margin-block: var(--space-12);
  padding-block: var(--space-8);
}

/* Live: default.hbs sets --ad-scale (at most 1) and --ad-height when a
   creative renders. A transform doesn't change layout, so the negative
   margin gives back the height the scaled creative no longer fills. The div
   is GPT's own container, the frame's only div child. */
.ad-slot__frame > div {
  transform: scale(var(--ad-scale, 1));
  transform-origin: top center;
  margin-block-end: calc(var(--ad-height, 0px) * (var(--ad-scale, 1) - 1));
}

/* The reset's max-width: 100% would squash the creative instead. */
.ad-slot__frame iframe {
  max-width: none;
}

/* .ad-break — hyp-5 above the footer. body is a flex column, so margins
   don't collapse; zero the frame's bottom margin and let the footer's
   margin own the gap. No spacing on .ad-break itself. */
.ad-break > .ad-slot > .ad-slot__frame,
.ad-break > .ad-preview > .ad-preview__frame {
  margin-block-end: 0;
}

.ad-slot__frame::before,
.ad-preview__frame::before {
  content: "Advertisement";
  padding-block-end: var(--space-4);
  color: var(--color-fg-tone);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
}

/* Placeholder creative: the requested size, shrunk to the frame with its
   aspect ratio kept, as the live creative is. */
.ad-preview__creative {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);

  width: 320px;
  max-width: 100%;
  aspect-ratio: 320 / 480;

  border: var(--border-width) dashed var(--color-border-soft);
  background-color: var(--color-bg);
  color: var(--color-fg-tone);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
}

/* Only CSS knows which size applies at this viewport. */
.ad-preview__creative::after {
  content: "320 \00d7  480";
}

@media (width >= 640px) {
  .ad-preview__creative {
    width: 640px;
    aspect-ratio: 640 / 360;
  }

  .ad-preview__creative::after {
    content: "640 \00d7  360";
  }
}

@media (width >= 960px) {
  .ad-preview__creative {
    width: 960px;
    aspect-ratio: 960 / 540;
  }

  .ad-preview__creative::after {
    content: "960 \00d7  540";
  }
}

/* The tag archives' rail (partials/ad-rail.hbs). The rail's own spacing
   places it, so the frame drops its margins and top padding. */
.tag-feed__rail .ad-slot__frame,
.tag-feed__rail .ad-preview__frame {
  margin-block: 0;
  padding-block-start: 0;
}

/* Beside the feed, the rail slots ask for the portrait size only. */
@media (width >= 64rem) {
  .tag-feed__rail .ad-preview__creative {
    width: 320px;
    aspect-ratio: 320 / 480;
  }

  .tag-feed__rail .ad-preview__creative::after {
    content: "320 \00d7  480";
  }
}
