/* Empty inventory must never render user-visible placeholder copy. Configured
   slots keep their dimensions while loading, but their surface stays clear. */
.network-ad-unit:not(.network-ad-unit--monetag),
.adsense-shell,
.timeline-faves-banner-ad,
.timeline-faves-banner-ad__media {
  position: relative;
}

[data-ad-placeholder],
.profile-page-ad-placeholder,
.profile-home-ad-placeholder,
.adsense-placeholder,
.adsense-slot-placeholder,
.timeline-story-bottom-ad__placeholder,
.timeline-faves-banner-ad__placeholder,
.google-adsense-banner-placeholder,
.ms-doc-access-ad-placeholder {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.network-ad-unit:not(.network-ad-unit--monetag),
.adsense-shell {
  border: 0 !important;
  border-radius: 0 !important;
  outline: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.network-ad-unit--right-rail {
  width: 300px !important;
  max-width: 100% !important;
  min-height: 250px !important;
}

.network-ad-unit--banner .network-ad-unit__frame {
  width: min(728px, 100%);
  height: 90px;
}

.network-ad-unit--right-rail .network-ad-unit__frame {
  width: min(300px, 100%);
  height: 250px;
}

.network-ad-unit--vast,
.network-ad-unit--vast .network-ad-unit__frame {
  width: min(640px, 100%);
  aspect-ratio: 16 / 9;
  height: auto;
}

.ad-placement-slot {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-width: 0;
  margin: 18px 0;
  grid-column: 1 / -1;
  background: transparent;
}

.ad-placement-slot > .network-ad-unit {
  width: 100%;
  max-width: 100%;
}

.ad-placement-slot:has(.network-ad-unit.is-ad-empty),
.ad-placement-slot:has(.network-ad-unit.is-ad-unconfigured) {
  display: none !important;
  min-height: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

@media (max-width: 640px) {
  .network-ad-unit--banner:not(.network-ad-unit--right-rail) .network-ad-unit__frame {
    width: min(320px, 100%);
    height: 50px;
  }
}

.adsense-shell > .adsense-unit {
  position: relative;
  z-index: 0;
  display: block;
  width: 100%;
  min-height: inherit;
}

[data-ad-loaded="true"] > [data-ad-placeholder],
.has-ad > [data-ad-placeholder],
[data-ad-loaded="true"] .profile-page-ad-placeholder,
.has-ad .profile-page-ad-placeholder,
[data-ad-loaded="true"] .adsense-placeholder,
.has-ad .adsense-placeholder,
[data-ad-loaded="true"] .timeline-story-bottom-ad__placeholder,
.has-ad .timeline-story-bottom-ad__placeholder,
[data-ad-loaded="true"] .timeline-faves-banner-ad__placeholder,
.has-ad .timeline-faves-banner-ad__placeholder,
[data-ad-loaded="true"] .ms-doc-access-ad-placeholder,
.has-ad .ms-doc-access-ad-placeholder {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.network-ad-unit.is-ad-empty[data-ad-fallback="collapse"],
.is-ad-empty {
  display: none !important;
  min-height: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

.timeline-responsive-network-banner:has(.network-ad-unit.is-ad-empty) {
  display: none !important;
  min-height: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* The right rail is part of the same slot-state chain as its provider unit.
   Once that unit is confirmed empty, release both the rail and its grid
   column instead of leaving a blank 300px gutter. */
.right-rail.is-ad-empty,
.right-rail.is-ad-unconfigured {
  display: none !important;
  width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

@media (min-width: 1200px) {
  body.app-content-with-ads .main-grid:not(:has(> .right-rail)),
  body.app-content-with-ads .main-grid:has(> .right-rail.is-ad-empty),
  body.app-content-with-ads .main-grid:has(> .right-rail.is-ad-unconfigured) {
    grid-template-columns: minmax(0, var(--app-social-content-column-max));
  }

  /* The social pages normally place their content in the middle track so a
     live desktop ad can occupy the right track. When that rail is absent or
     collapsed, return the content to column one and center the single track.
     Leaving it on column two creates an implicit column and shifts the page. */
  body.centered-social-layout .main-grid:not(:has(> .right-rail)),
  body.centered-social-layout .main-grid:has(> .right-rail.is-ad-empty),
  body.centered-social-layout .main-grid:has(> .right-rail.is-ad-unconfigured) {
    grid-template-columns: minmax(0, min(100%, 800px));
    justify-content: center;
  }

  body.centered-social-layout .main-grid:not(:has(> .right-rail)) > .main-inner,
  body.centered-social-layout .main-grid:has(> .right-rail.is-ad-empty) > .main-inner,
  body.centered-social-layout .main-grid:has(> .right-rail.is-ad-unconfigured) > .main-inner {
    grid-column: 1;
  }
}

/* Placeholder-only shells are not inventory. Hide them immediately when no
   iframe, AdSense unit, direct creative, or provider zone is configured. The
   JS class is a fallback for dynamically inserted slots and older selectors. */
:is(
  .profile-page-ad-slot,
  .profile-home-ad-slot,
  .profile-editorial-detail-ad-slot,
  .app-display-ad,
  .timeline-faves-banner-ad,
  [data-story-ad],
  [aria-label="Advertisement"]
):not(.network-ad-unit):not(.adsense-shell):not(:has(
  .network-ad-unit__frame,
  ins.adsbygoogle,
  img[src]:not([src=""]),
  video[src]:not([src=""]),
  object[data],
  embed[src],
  canvas,
  [data-network-ad-zone]
)),
.is-ad-unconfigured {
  display: none !important;
  min-height: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

/* A confirmed creative owns the slot surface. Remove every piece of fallback
   chrome while retaining the slot's normal outer margin in the page flow. */
:is(
  .network-ad-unit,
  .adsense-shell,
  .profile-page-ad-slot,
  .app-display-ad,
  .timeline-faves-banner-ad,
  [data-story-ad],
  [aria-label="Advertisement"]
)[data-ad-loaded="true"],
:is(
  .network-ad-unit,
  .adsense-shell,
  .profile-page-ad-slot,
  .app-display-ad,
  .timeline-faves-banner-ad,
  [data-story-ad],
  [aria-label="Advertisement"]
).has-ad {
  min-height: 0 !important;
  height: auto !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  outline: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
