/* Template Central owns the space around promotions. Leave creative padding,
   ad/iframe dimensions and loading behaviour to the provider. Load after the
   template styles; the scoped !important margins also replace legacy provider
   overrides. No changes to header, reading rhythm or Listen/station spacing. */
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main) {
 --nas-tc-placement-gap:24px;
}
@media(max-width:600px) {
 :is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main) {
  --nas-tc-placement-gap:20px;
 }
}

/* An existing slot already supplies its surrounding margin. Strip only the
   outside edges of its content, including unfamiliar Google-ad/CTA wrappers.
   Ignore script/style nodes so late-inserted creatives get the same treatment. */
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main)
 :is(.nas-tc-slot,.nas-tc-article-slot,.nas-tc-ar-slot,.nas-sc-home-display-slot,[data-nas-template-section="ad_top"],[data-nas-template-section="cta_top"],[data-nas-template-section="ad_middle"],[data-nas-template-section="ad_bottom"],[data-nas-template-section="partner_box"],[data-nas-template-section="sponsor_spotlight"])
 > :nth-child(1 of :not(script,style,link,template,[hidden])) {
 margin-top:0!important;
}
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main)
 :is(.nas-tc-slot,.nas-tc-article-slot,.nas-tc-ar-slot,.nas-sc-home-display-slot,[data-nas-template-section="ad_top"],[data-nas-template-section="cta_top"],[data-nas-template-section="ad_middle"],[data-nas-template-section="ad_bottom"],[data-nas-template-section="partner_box"],[data-nas-template-section="sponsor_spotlight"])
 > :nth-last-child(1 of :not(script,style,link,template,[hidden])) {
 margin-bottom:0!important;
}



/* Sponsor Central may add a separate "next sponsor" line after the creative.
   Keep a small gap to that line instead of adding the creative's 30px margin
   to the line's own margin and the surrounding slot. Preserve horizontal
   centring and all internal card styles. */
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main)
 :is(.nas-tc-slot,.nas-tc-article-slot,.nas-tc-ar-slot,.nas-sc-home-display-slot,[data-nas-template-section="ad_top"],[data-nas-template-section="cta_top"],[data-nas-template-section="ad_middle"],[data-nas-template-section="ad_bottom"],[data-nas-template-section="partner_box"],[data-nas-template-section="sponsor_spotlight"])
 > :is(.nas-exclusive-sponsor-display,.nas-local-partner-box,.nas-house-sponsor-promotion) {
 margin-top:0!important;
 margin-bottom:0!important;
}
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main)
 :is(.nas-tc-slot,.nas-tc-article-slot,.nas-tc-ar-slot,.nas-sc-home-display-slot,[data-nas-template-section="ad_top"],[data-nas-template-section="cta_top"],[data-nas-template-section="ad_middle"],[data-nas-template-section="ad_bottom"],[data-nas-template-section="partner_box"],[data-nas-template-section="sponsor_spotlight"])
 > .nas-sc-next-sponsor {
 margin-top:8px!important;
 margin-bottom:0!important;
}

/* The template's existing top padding is the header-to-promotion gap. Do not
   add another slot margin above it. The rule is independent of provider. */
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main)
 [data-nas-tc-slot="placement_below_header"] {
 display:flow-root;
 margin-top:0!important;
 margin-bottom:var(--nas-tc-placement-gap)!important;
}

/* Composer top sections can also receive a CTA/ad directly, without an ad
   slot. One shell owns the gap, even when a slot is nested inside that shell.
   A section moved farther down the article keeps separation above it. */
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main)
 :is([data-nas-template-section="ad_top"],[data-nas-template-section="cta_top"]) {
 display:flow-root;
 margin-top:var(--nas-tc-placement-gap);
 margin-bottom:var(--nas-tc-placement-gap);
}
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main)
 :is([data-nas-template-section="ad_top"],[data-nas-template-section="cta_top"]):first-child {
 margin-top:0!important;
}
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main)
 :is([data-nas-template-section="ad_top"],[data-nas-template-section="cta_top"])
 > [data-nas-tc-slot="placement_below_header"] {
 margin-top:0!important;
 margin-bottom:0!important;
}

/* Legacy/theme page templates may receive an unwrapped top placement. Keep
   its own small top gap where no Template Central slot supplies the spacing. */
body.nas-tc-custom-header :is(
 .nas-exclusive-sponsor-display[data-nas-sponsor-placement="placement_below_header"],
 .nas-local-partner-box[data-nas-placement="placement_below_header"],
 .nas-google-ad-wrap[data-nas-placement="placement_below_header"],
 .nas-outside-ad[data-nas-outside-placement="placement_below_header"]
):not(:is(.nas-tc-slot,.nas-tc-article-slot,.nas-tc-ar-slot,[data-nas-template-section="ad_top"],[data-nas-template-section="cta_top"]) *) {
 margin-top:16px!important;
 margin-bottom:var(--nas-tc-placement-gap,24px)!important;
}

/* 1.30.3: middle/end-of-article displays may be supplied directly to a
   composer section, with no ad-slot wrapper. Give these shells the same single
   spacing budget as the top. Only outer margins change; the top and rails keep
   their existing rules, and creative/ad dimensions remain provider-owned. */
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main)
 :is([data-nas-template-section="ad_middle"],[data-nas-template-section="ad_bottom"],[data-nas-template-section="partner_box"],[data-nas-template-section="sponsor_spotlight"]) {
 display:flow-root;
 clear:both;
 margin-top:var(--nas-tc-placement-gap)!important;
 margin-bottom:var(--nas-tc-placement-gap)!important;
}
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main)
 :is([data-nas-tc-slot="placement_inline"],[data-nas-tc-slot="placement_below_share_and_comment"],[data-nas-tc-slot="placement_above_footer"],.nas-sc-home-display-slot) {
 margin-top:var(--nas-tc-placement-gap)!important;
 margin-bottom:var(--nas-tc-placement-gap)!important;
}

/* A bottom section can contain several ad slots. Keep one gap between occupied
   slots, rather than adding a slot's margins to the section's margins. Empty
   slots can still initialise asynchronously without reserving a margin. */
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main)
 :is([data-nas-template-section="ad_middle"],[data-nas-template-section="ad_bottom"],[data-nas-template-section="partner_box"],[data-nas-template-section="sponsor_spotlight"]) > :is([data-nas-tc-slot="placement_inline"],[data-nas-tc-slot="placement_below_share_and_comment"],[data-nas-tc-slot="placement_above_footer"],.nas-sc-home-display-slot) {
 margin-top:0!important;
 margin-bottom:0!important;
}
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main)
 :is([data-nas-template-section="ad_middle"],[data-nas-template-section="ad_bottom"],[data-nas-template-section="partner_box"],[data-nas-template-section="sponsor_spotlight"]) > :is([data-nas-tc-slot="placement_inline"],[data-nas-tc-slot="placement_below_share_and_comment"],[data-nas-tc-slot="placement_above_footer"],.nas-sc-home-display-slot):has(> :not(script,style,link,template,[hidden],.nas-sponsor-auto-hidden)) ~ :is([data-nas-tc-slot="placement_inline"],[data-nas-tc-slot="placement_below_share_and_comment"],[data-nas-tc-slot="placement_above_footer"],.nas-sc-home-display-slot):has(> :not(script,style,link,template,[hidden],.nas-sponsor-auto-hidden)) {
 margin-top:var(--nas-tc-placement-gap)!important;
}

/* A related/popular heading normally starts a new editorial section with a
   48px margin. Immediately after a lower promotion, reuse the promotion gap.
   Its border, heading padding and spacing elsewhere remain unchanged. */
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main)
 :is([data-nas-template-section="ad_middle"],[data-nas-template-section="ad_bottom"],[data-nas-template-section="partner_box"],[data-nas-template-section="sponsor_spotlight"]):has(> :not(script,style,link,template,[hidden],.nas-sponsor-auto-hidden)) + [data-nas-template-section] > .nas-tc-reading-section {
 margin-top:var(--nas-tc-placement-gap)!important;
}

/* At the end of an archive/homepage, avoid adding the final slot's bottom
   margin to the main container's footer padding. */
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main):has(> [data-nas-tc-slot="placement_above_footer"]:last-child) {
 padding-bottom:var(--nas-tc-placement-gap);
}
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main)
 > [data-nas-tc-slot="placement_above_footer"]:last-child {
 margin-bottom:0!important;
}

/* Comment-only/disabled slots must not leave a blank band. Do not hide or
   resize the slot: an asynchronous ad can still initialise and populate it. */
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main)
 :is(.nas-tc-slot,.nas-tc-article-slot,.nas-tc-ar-slot,.nas-sc-home-display-slot,[data-nas-template-section="ad_top"],[data-nas-template-section="cta_top"],[data-nas-template-section="ad_middle"],[data-nas-template-section="ad_bottom"],[data-nas-template-section="partner_box"],[data-nas-template-section="sponsor_spotlight"]):not(:has(> :not(script,style,link,template,[hidden],.nas-sponsor-auto-hidden))) {
 margin-top:0!important;
 margin-bottom:0!important;
}

/* An otherwise empty lower section may retain asynchronous child slots. Keep
   the section's margins at zero until a slot receives visible content. */
:is(#nas-tc-main,#nas-tc-article-main,#nas-tc-archive-main,#nas-tc-page-main,#nas-tc-sketch-main)
 :is([data-nas-template-section="ad_middle"],[data-nas-template-section="ad_bottom"],[data-nas-template-section="partner_box"],[data-nas-template-section="sponsor_spotlight"]):not(:has(
  > :not([data-nas-tc-slot],script,style,link,template,[hidden],.nas-sponsor-auto-hidden),
  [data-nas-tc-slot] > :not(script,style,link,template,[hidden],.nas-sponsor-auto-hidden)
 )) {
 margin-top:0!important;
 margin-bottom:0!important;
}
