.ed-real-ad {
    box-sizing: border-box;
    max-width: min(100% - 24px, var(--ed-ad-maximum));
    margin: clamp(1rem, 3vw, 2.25rem) auto !important;
    text-align: center;
}
.ed-real-ad img, .wp-block-post-content [class*="endur-entity-placement"] img {
    max-inline-size: 100%;
    block-size: auto;
}
.ed-real-ad:empty { display: none; }
.ed-real-ad--parallax {
    --ed-ad-maximum: 450px;
    --ed-ad-travel: 34px;
    margin-block: clamp(1.5rem, 4vw, 3rem) !important;
}
@media (min-width: 768px) {
    .ed-real-ad--parallax { --ed-ad-travel: 64px; }
}
.ed-real-ad--parallax a:has(img) {
    display: block;
    width: 100%;
    overflow: hidden;
    padding-block: calc(var(--ed-ad-travel) + 4px);
}
.ed-real-ad--parallax img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: min(620px, 80svh);
    margin-inline: auto;
    transform: translate3d(0, calc(var(--ed-ad-progress, 0) * var(--ed-ad-travel)), 0);
}
@media (prefers-reduced-motion: reduce) {
    .ed-real-ad--parallax { --ed-ad-travel: 0px; }
    .ed-real-ad--parallax img { transform: none; }
}

/* Sitewide partners and compact units above the footer. */
.ed-real-ad--croatia-wide,
.ed-real-ad--maxxis-wide,
.ed-real-ad--travel { --ed-ad-maximum: 560px; }
.ed-real-ad--desktop-content,
.ed-real-ad--whatsapp-text { --ed-ad-maximum: 100%; }
.ed-real-ad--branding { --ed-ad-maximum: 210px; }
.ed-real-ad--sturm, .ed-real-ad--partners { --ed-ad-maximum: 300px; }
.ed-real-ad--compact { --ed-ad-maximum: 320px; }

.ed-ad-partners { padding-block: 0.5rem 1rem; }
.ed-ad-partners__compact {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    gap: 1.5rem;
    padding-inline: 12px;
}
.ed-ad-partners__compact .ed-real-ad {
    flex: 0 1 var(--ed-ad-maximum);
    max-width: 100%;
    min-width: 0;
    margin: 0 !important;
}

.ed-real-ad .endur-entity-placement,
.ed-real-ad .endur-entity-ad {
    max-inline-size: 100%;
}
.ed-real-ad--whatsapp-text a { text-decoration: underline; }
/* Fit the existing logo into the 300 × 60 slot without trimming it. */
.ed-real-ad--sturm img { max-block-size: 60px; width: auto; }

/* The default placement stays in the document flow on narrow or unfamiliar templates. */
.ed-real-ad--branding {
    margin-inline-end: max(12px, calc((100% - 1340px) / 2)) !important;
}

/* These pages use the same wide content measure as the service directories. */
.ed-standard-page .wp-site-blocks > main {
    --wp--style--global--content-size: var(--wp--style--global--wide-size);
    overflow-wrap: anywhere;
}

/* Balance the right branding rail with a matching space on the left. */
@media (min-width: 1740px) and (min-height: 700px) {
    .wp-site-blocks:has(> header + .ed-real-ad--croatia-wide + main + .ed-ad-partners + .ed-real-ad--branding + footer:last-child),
    .ed-standard-page .wp-site-blocks:has(> header + main + .ed-real-ad--branding + footer:last-child) {
        display: grid;
        --ed-branding-gutter: min(332px, calc((100% - var(--wp--style--global--wide-size, 1340px) - 96px) / 2));
        grid-template-columns: var(--ed-branding-gutter) minmax(0, 1fr) var(--ed-branding-gutter);
        grid-template-areas:
            "header header header"
            ". leader rail"
            ". main rail"
            ". partners rail"
            "footer footer footer";

        > header { grid-area: header; }
        > footer { grid-area: footer; }
        > .ed-real-ad--croatia-wide { grid-area: leader; }

        > main {
            grid-area: main;
            min-inline-size: 0;
            overflow-x: clip;
        }

        > .ed-ad-partners {
            grid-area: partners;
            min-inline-size: 0;
        }

        > .ed-real-ad--branding {
            --ed-ad-maximum: min(300px, calc(100% - 32px), calc((100svh - 120px) / 2));
            grid-area: rail;
            align-self: start;
            justify-self: center;
            position: sticky;
            top: 56px;
            width: var(--ed-ad-maximum);
            margin-inline: 0 !important;
        }
    }

    .ed-standard-page .wp-site-blocks:has(> header + main + .ed-real-ad--branding + footer:last-child) {
        grid-template-areas:
            "header header header"
            ". main rail"
            "footer footer footer";
    }
}

/* Keep each banner on its own row between result cards. */
.ed-page-ad-break {
    grid-column: 1 / -1;
    display: flow-root;
    min-inline-size: 0;
    list-style: none;
}
/* The archive applies a column span to each list item, including the ad wrapper. */
.ed-category-feed .wp-block-post-template > li.ed-page-ad-break { grid-column: 1 / -1; }
.ed-page-ad-break:has(> :only-child:empty:not([data-ed-image-rotation])) { display: none; }

/* Reserve the responsive creative and label height before Advanced Ads chooses an image. */
.ed-real-ad[data-ed-image-rotation] { display: block; position: relative; }
.ed-real-ad--travel { --ed-creative-ratio: 565 / 160; }
.ed-real-ad--partners { --ed-creative-ratio: 300 / 150; }
.ed-real-ad[data-ed-image-rotation]::before {
    content: "";
    display: block;
    box-sizing: content-box;
    aspect-ratio: var(--ed-creative-ratio);
    padding-block-start: 1.75rem;
}
.ed-real-ad[data-ed-image-rotation] > div {
    position: absolute;
    inset: 0;
}
