/* DGR News: prevent homepage-top ad from appearing above the header */
body.home .dgram-placement-homepage_top,
body.front-page .dgram-placement-homepage_top,
body.home .dgram-homepage-top,
body.front-page .dgram-homepage-top {
    display: none !important;
}

/* Allow the homepage-top ad inside the popup */
#dgram-home-popup .dgram-placement-homepage_top,
.dgram-homepage-popup .dgram-placement-homepage_top {
    display: block !important;
}

/* Popup styles matching the PHP class names */
#dgram-home-popup {
    display: none;
}

#dgram-home-popup.dgram-home-popup-visible {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

#dgram-home-popup .dgram-home-popup-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .78);
}

#dgram-home-popup .dgram-home-popup-dialog {
    position: relative;
    z-index: 1;
    width: min(560px, 100%);
    max-height: 90vh;
    overflow: auto;
    padding: 34px 16px 16px;
    background: #fff;
    border-radius: 8px;
    box-sizing: border-box;
}

#dgram-home-popup .dgram-home-popup-close {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: #111;
    color: #fff;
    font-size: 26px;
    cursor: pointer;
}

#dgram-home-popup .dgram-home-popup-body .dgram-placement,
#dgram-home-popup .dgram-home-popup-body .dgram-ad-link {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

#dgram-home-popup .dgram-home-popup-body img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

html.dgram-popup-open,
body.dgram-home-popup-open {
    overflow: hidden;
}

/* Homepage-middle banner */
.dgram-placement-homepage_grid {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 24px auto;
    box-sizing: border-box;
}

.dgram-placement-homepage_grid img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

@media (max-width: 600px) {
    #dgram-home-popup.dgram-home-popup-visible {
        padding: 12px;
    }

    #dgram-home-popup .dgram-home-popup-dialog {
        width: 100%;
        padding: 34px 10px 10px;
    }
}