/* Database-controlled homepage advert and popup.
   The popup does not depend on Bootstrap, jQuery, sessionStorage or localStorage. */

#madHowItWorksAdvert {
    position: relative;
}

#madHowItWorksAdvert .mad-promotion-ad-link,
#madHowItWorksAdvert .mad-promotion-ad-visual {
    position: relative;
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 330px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: inherit;
    background: #fff;
}

#madHowItWorksAdvert .mad-promotion-ad-image {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 330px;
    max-height: 560px;
    object-fit: contain;
    background: #fff;
}

#madHowItWorksAdvert .mad-promotion-ad-label {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    border-radius: 30px;
    color: #fff;
    background: rgba(13, 107, 45, .92);
    box-shadow: 0 7px 18px rgba(0, 0, 0, .18);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.mad-home-promotion-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    padding:
        max(18px, env(safe-area-inset-top))
        max(14px, env(safe-area-inset-right))
        max(18px, env(safe-area-inset-bottom))
        max(14px, env(safe-area-inset-left));
    overflow: auto;
    overscroll-behavior: contain;
    background: rgba(5, 24, 13, .79);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .22s ease, visibility .22s ease;
}

.mad-home-promotion-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.mad-home-promotion-dialog {
    position: relative;
    width: min(94vw, 850px);
    max-height: calc(100vh - 36px);
    margin: auto;
    overflow: hidden;
    border-radius: 18px;
    background: transparent;
    box-shadow: 0 30px 90px rgba(0, 0, 0, .38);
    transform: translateY(16px) scale(.98);
    transition: transform .22s ease;
}

.mad-home-promotion-overlay.is-visible .mad-home-promotion-dialog {
    transform: translateY(0) scale(1);
}

.mad-home-promotion-link,
.mad-home-promotion-visual {
    display: flex;
    width: 100%;
    max-height: calc(100vh - 36px);
    align-items: center;
    justify-content: center;
    overflow: auto;
    border-radius: 18px;
    background: transparent;
    -webkit-overflow-scrolling: touch;
}

.mad-home-promotion-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 94vw;
    max-height: calc(100vh - 36px);
    object-fit: contain;
    border-radius: 18px;
    background: transparent;
}

.mad-home-promotion-close {
    position: absolute;
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    z-index: 4;
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 3px solid rgba(255, 255, 255, .96);
    border-radius: 50%;
    color: #fff;
    background: rgba(13, 107, 45, .96);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.mad-home-promotion-close:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

body.mad-home-popup-open {
    overflow: hidden !important;
    touch-action: none;
}

@supports (height: 100dvh) {
    .mad-home-promotion-overlay {
        height: 100dvh;
        min-height: 100dvh;
    }

    .mad-home-promotion-dialog,
    .mad-home-promotion-link,
    .mad-home-promotion-visual,
    .mad-home-promotion-image {
        max-height: calc(100dvh - 36px);
    }
}

@media (max-width: 767.98px) {
    #madHowItWorksAdvert .mad-promotion-ad-link,
    #madHowItWorksAdvert .mad-promotion-ad-visual,
    #madHowItWorksAdvert .mad-promotion-ad-image {
        min-height: 250px;
        max-height: 430px;
    }

    .mad-home-promotion-overlay {
        padding:
            max(10px, env(safe-area-inset-top))
            max(8px, env(safe-area-inset-right))
            max(10px, env(safe-area-inset-bottom))
            max(8px, env(safe-area-inset-left));
    }

    .mad-home-promotion-dialog {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 20px);
        border-radius: 14px;
    }

    .mad-home-promotion-link,
    .mad-home-promotion-visual,
    .mad-home-promotion-image {
        max-width: calc(100vw - 16px);
        max-height: calc(100vh - 20px);
        border-radius: 14px;
    }

    .mad-home-promotion-image {
        width: 100%;
        height: auto;
    }

    .mad-home-promotion-close {
        top: max(7px, env(safe-area-inset-top));
        right: max(7px, env(safe-area-inset-right));
        width: 42px;
        height: 42px;
        font-size: 26px;
    }
}
