/*
 * Shared layout for the real ad-provider placements.
 *
 * The provider may render an iframe, image, or video inside its <ins> marker.
 * Center the slot itself and neutralize old creative-specific offsets without
 * changing the provider scripts, zone IDs, or creative dimensions.
 */
:is(
    .ad-placement,
    #top-dirty-stuff,
    #top-dirty-stuff2,
    #mid-dirty-stuff,
    #dirty-stuff,
    #dirty-stuff2
) {
    position: relative;
    inset: auto;
    clear: both;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-right: auto;
    margin-left: auto;
    text-align: center;
}

/* The provider can leave the <ins> marker in place and inject the visible
   creative as a sibling. Keep every rendered child on its own centered row. */
:is(
    .ad-placement,
    #top-dirty-stuff,
    #top-dirty-stuff2,
    #mid-dirty-stuff,
    #dirty-stuff,
    #dirty-stuff2
) > :not(script) {
    position: static !important;
    inset: auto !important;
    align-self: center !important;
    float: none !important;
    max-width: 100% !important;
    margin-right: auto !important;
    margin-left: auto !important;
    text-align: center !important;
}

/* These are the legacy footer/content hosts called out by the templates.
   Use explicit high-priority rules so their old video offsets cannot win. */
#dirty-stuff,
#dirty-stuff2 {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-right: auto !important;
    margin-left: auto !important;
    text-align: center !important;
}

/* Add breathing room only when a real zone marker is present. Empty legacy
   placeholders therefore remain collapsed. */
:is(
    #top-dirty-stuff,
    #top-dirty-stuff2
):has(ins[data-zoneid]) {
    margin-top: 18px;
    margin-bottom: 22px;
}

#mid-dirty-stuff:has(ins[data-zoneid]) {
    margin-top: 24px;
    margin-bottom: 24px;
}

:is(
    #dirty-stuff,
    #dirty-stuff2
):has(ins[data-zoneid]) {
    margin-top: 28px;
    margin-bottom: 18px;
}

.ad-placement--sitewide {
    margin-top: 24px;
    margin-bottom: 24px;
}

:is(
    .ad-placement,
    #top-dirty-stuff,
    #top-dirty-stuff2,
    #mid-dirty-stuff,
    #dirty-stuff,
    #dirty-stuff2
) ins[data-zoneid] {
    position: static !important;
    inset: auto !important;
    display: block !important;
    flex: 0 1 auto;
    float: none !important;
    max-width: 100%;
    margin: 0 auto !important;
    text-align: center;
}

/* Override legacy bottom offsets and accommodate each creative type the ad
   provider currently emits. Width/height are left to the provider. */
:is(
    .ad-placement,
    #top-dirty-stuff,
    #top-dirty-stuff2,
    #mid-dirty-stuff,
    #dirty-stuff,
    #dirty-stuff2
) :is(iframe, img, video) {
    position: static !important;
    inset: auto !important;
    display: block !important;
    float: none !important;
    max-width: 100% !important;
    margin-right: auto !important;
    margin-left: auto !important;
}

@media (max-width: 480px) {
    :is(
        .ad-placement,
        #top-dirty-stuff,
        #top-dirty-stuff2,
        #mid-dirty-stuff,
        #dirty-stuff,
        #dirty-stuff2
    ) {
        padding-right: 6px;
        padding-left: 6px;
    }
}
