/* ==========================================================================
   AdSense slot chrome
   --------------------------------------------------------------------------
   Shared by both layout families:
     · the classic shell (head.html, light/dark through data-theme)
     · the reading shell (space-head.html, always dark)

   Keeps the unit inside the page's own column, reserves height so a late-filling
   ad cannot shove the article down (CLS), labels it as advertising the way
   Google's policies ask, and removes the block entirely when Google reports the
   unit unfilled so no empty frame is left behind.
   ========================================================================== */

.ad-slot {
  --ad-line: rgba(20, 18, 15, .14);
  --ad-fg: rgba(20, 18, 15, .44);
  --ad-bg: rgba(20, 18, 15, .02);

  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(100%, 880px);
  margin: clamp(28px, 4vw, 48px) auto;
  padding: 0 clamp(18px, 3vw, 32px);
}

html[data-theme="dark"] .ad-slot,
html.sp-flat .ad-slot,
.sp-body .ad-slot {
  --ad-line: rgba(255, 255, 255, .15);
  --ad-fg: rgba(255, 255, 255, .42);
  --ad-bg: rgba(255, 255, 255, .03);
}

.ad-slot__label {
  font: 500 10px/1 var(--f-mono, ui-monospace, "SF Mono", Consolas, monospace);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ad-fg);
}

.ad-slot__unit {
  display: block;
  width: 100%;
  /* reserved height: the usual responsive banner floor, so text below does not
     jump when the creative paints */
  min-height: 100px;
}

/* Google sets data-ad-status on the <ins> once it decides.
   unfilled → collapse the unit and, via :has(), the label with it. */
.ad-slot ins.adsbygoogle[data-ad-status="unfilled"] {
  display: none !important;
}

.ad-slot:has(ins.adsbygoogle[data-ad-status="unfilled"]) {
  display: none;
}

/* inside the reading column the prose width already applies */
.rd-prose .ad-slot {
  width: 100%;
  max-width: 100%;
  margin: calc(var(--rd-gap, 1.45em) * 1.5) 0;
  padding: 0;
}

/* local `jekyll serve` only — replaced by the real unit on a production build */
.ad-slot--preview {
  min-height: 100px;
  padding: 20px clamp(18px, 3vw, 32px);
  border: 1px dashed var(--ad-line);
  border-radius: 10px;
  background: var(--ad-bg);
  color: var(--ad-fg);
  text-align: center;
}

.ad-slot--preview .ad-slot__label {
  color: var(--ad-fg);
}

.ad-slot__note {
  font: 400 11px/1.5 var(--f-cjk, "PingFang SC", "Noto Sans SC", sans-serif);
  color: var(--ad-fg);
}

/* the last block before a footer should not add a second gap */
.ad-slot--footer {
  margin-bottom: clamp(10px, 2vw, 18px);
}

@media (prefers-reduced-data: reduce) {
  .ad-slot {
    margin-block: 18px;
  }
}
