/* —— Boczne reklamy w szarych marginesach viewportu —— */
:root {
    --pm-rail-width: 160px;
    --pm-rail-gap: 18px;
    --pm-rail-col-gap: 12px;
}

.pm-ad-rail {
    position: fixed;
    z-index: 40;
    top: 92px;
    width: var(--pm-rail-width);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    max-height: calc(100vh - 108px);
    overflow: hidden;
}

/* Jedna kolumna boczna */
@media (min-width: 1536px) {
    .pm-ad-rail--col1 {
        display: flex;
    }
}

.pm-ad-rail--left.pm-ad-rail--col1 {
    left: max(
        8px,
        calc((100vw - var(--site-content-max)) / 2 - var(--pm-rail-width) - var(--pm-rail-gap))
    );
}

.pm-ad-rail--right.pm-ad-rail--col1 {
    right: max(
        8px,
        calc((100vw - var(--site-content-max)) / 2 - var(--pm-rail-width) - var(--pm-rail-gap))
    );
}

/* Druga kolumna — od Full HD (1920px) w górę */
@media (min-width: 1880px) {
    .pm-ad-rail--col2 {
        display: flex;
    }
}

.pm-ad-rail--left.pm-ad-rail--col2 {
    left: max(
        8px,
        calc(
            (100vw - var(--site-content-max)) / 2 - var(--pm-rail-width) * 2 - var(--pm-rail-gap) -
                var(--pm-rail-col-gap)
        )
    );
}

.pm-ad-rail--right.pm-ad-rail--col2 {
    right: max(
        8px,
        calc(
            (100vw - var(--site-content-max)) / 2 - var(--pm-rail-width) * 2 - var(--pm-rail-gap) -
                var(--pm-rail-col-gap)
        )
    );
}

/* —— Leaderboard pod nagłówkiem (728×90) —— */
.pm-ad-leaderboard {
    display: none;
    justify-content: center;
    padding: 10px 16px 4px;
    max-width: var(--site-content-max);
    margin: 0 auto;
}

@media (min-width: 769px) {
    .pm-ad-leaderboard {
        display: flex;
    }
}

/* —— Pasek mobilny (320×50) —— */
.pm-ad-mobile-bar {
    display: flex;
    justify-content: center;
    padding: 8px 12px;
    background: var(--header-bg, rgba(255, 254, 251, 0.92));
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-soft, #e7e5e4);
}

[data-theme='dark'] .pm-ad-mobile-bar {
    background: rgba(12, 10, 9, 0.92);
}

@media (min-width: 769px) {
    .pm-ad-mobile-bar:not(.pm-ad-mobile-bar--bottom) {
        display: none;
    }
}

/* —— Przyklejony pasek na dole (mobile) —— */
.pm-ad-mobile-bar--bottom {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 120;
    margin: 0;
    padding: 6px 12px calc(6px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-soft, #e7e5e4);
    border-bottom: none;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}

@media (max-width: 768px) {
    .pm-ad-mobile-bar--bottom {
        display: flex;
    }

    body.pm-ads-mobile-bottom {
        padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px));
    }
}

/* —— Panel reklam nad stopką —— */
.pm-ad-footer-strip {
    max-width: var(--site-content-max);
    margin: 0 auto 24px;
    padding: 0 clamp(10px, 2.5vw, 24px);
}

.pm-ad-footer-strip__inner {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 20px clamp(12px, 2vw, 20px) 24px;
    border-radius: var(--radius-lg, 12px);
    border: 1px dashed var(--border, #e7e5e4);
    background: rgba(255, 255, 255, 0.4);
    min-height: 200px;
}

[data-theme='dark'] .pm-ad-footer-strip__inner {
    background: rgba(28, 25, 23, 0.35);
    border-color: rgba(255, 255, 255, 0.08);
}

/* Górny rząd — native / ECPM (4 miniatury + baner) */
.pm-ad-footer-strip__row--ecpm {
    width: 100%;
}

.pm-ad-footer-strip__row--ecpm .pm-ad-slot--ecpm-invoke {
    width: 100%;
    max-width: none;
    min-height: 300px;
}

.pm-ad-footer-strip__row--ecpm #container-658eec4fdcf15651f91c6d8adbe4f016 {
    width: 100%;
    min-height: 260px;
    overflow: hidden;
}

/* Dolny rząd — banery HPF w siatce */
.pm-ad-footer-strip__row--hpf {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    justify-items: center;
    align-items: start;
    width: 100%;
}

.pm-ad-footer-strip__row--hpf .pm-ad-slot--728x90 {
    grid-column: 1 / -1;
}

@media (min-width: 900px) {
    .pm-ad-footer-strip__inner {
        min-height: 420px;
        gap: 22px;
        padding: 24px 20px 28px;
    }

    .pm-ad-footer-strip__row--ecpm .pm-ad-slot--ecpm-invoke {
        min-height: 340px;
    }

    .pm-ad-footer-strip__row--ecpm #container-658eec4fdcf15651f91c6d8adbe4f016 {
        min-height: 300px;
    }

    .pm-ad-footer-strip__row--hpf {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* —— Sloty wg formatu —— */
.pm-ad-slot {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: hidden;
    max-width: 100%;
    line-height: 0;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 6px;
    flex-shrink: 0;
}

[data-theme='dark'] .pm-ad-slot {
    background: rgba(255, 255, 255, 0.05);
}

.pm-ad-slot--728x90 {
    width: 728px;
    max-width: 100%;
    min-height: 90px;
}

.pm-ad-slot--468x60 {
    width: 468px;
    max-width: 100%;
    min-height: 60px;
}

.pm-ad-slot--320x50 {
    width: 320px;
    max-width: 100%;
    min-height: 50px;
}

.pm-ad-slot--300x250 {
    width: 300px;
    max-width: 100%;
    min-height: 250px;
}

.pm-ad-slot--160x300 {
    width: 160px;
    min-height: 300px;
}

.pm-ad-slot--160x600 {
    width: 160px;
    min-height: 600px;
}

.pm-ad-slot--ecpm-invoke {
    width: 100%;
    max-width: none;
    min-height: 50px;
}

/* —— Mobile —— */
@media (max-width: 768px) {
    .pm-ad-leaderboard {
        display: none;
    }

    .pm-ad-footer-strip {
        margin-bottom: 16px;
    }

    .pm-ad-footer-strip__inner {
        gap: 14px;
        padding: 14px 10px 18px;
        min-height: 360px;
    }

    .pm-ad-footer-strip__row--ecpm .pm-ad-slot--ecpm-invoke {
        min-height: 280px;
    }

    .pm-ad-footer-strip__row--ecpm #container-658eec4fdcf15651f91c6d8adbe4f016 {
        min-height: 240px;
    }

    .pm-ad-footer-strip__row--hpf {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .pm-ad-footer-strip__row--hpf .pm-ad-slot {
        width: 100%;
        max-width: 320px;
    }

    .pm-ad-footer-strip .pm-ad-slot--728x90 {
        display: none;
    }

    .pm-ad-footer-strip__row--ecpm iframe {
        max-width: 100% !important;
    }

    .pm-ad-slot--728x90,
    .pm-ad-slot--468x60,
    .pm-ad-slot--300x250 {
        width: 100%;
        max-width: 320px;
    }
}

@media print {
    .pm-ad-leaderboard,
    .pm-ad-mobile-bar,
    .pm-ad-footer-strip,
    .pm-ad-rail {
        display: none !important;
    }
}
