.oip-popup {
    --oip-image-margin: 48px;
    align-items: center;
    bottom: 0;
    display: none;
    justify-content: center;
    left: 0;
    padding: 24px;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 999999;
}

.oip-popup--visible {
    display: flex;
}

.oip-popup__backdrop {
    background: rgba(0, 0, 0, 0.68);
    bottom: 0;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
}

.oip-popup__dialog {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
    max-height: calc(100vh - 48px);
    max-width: min(720px, calc(100vw - 48px));
    overflow: visible;
    position: relative;
    width: min(720px, calc(100vw - 48px));
}

.oip-popup__content {
    max-height: calc(100vh - 48px);
    overflow: auto;
    padding: 32px;
    position: relative;
}

.oip-popup__content--image {
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: center;
    padding: 0;
}

.oip-popup__content--image img {
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    object-fit: contain;
}

.oip-popup__content--html {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.oip-popup__html > :first-child {
    margin-top: 0;
}

.oip-popup__html > :last-child {
    margin-bottom: 0;
}

.oip-popup__html {
    color: #111;
    font-size: 16px;
    line-height: 1.35;
}

.oip-popup__html h1,
.oip-popup__html h2,
.oip-popup__html h3,
.oip-popup__html h4,
.oip-popup__html h5,
.oip-popup__html h6 {
    color: #111;
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 12px;
}

.oip-popup__html h1 {
    font-size: 28px;
}

.oip-popup__html h2 {
    font-size: 22px;
}

.oip-popup__html h3 {
    font-size: 18px;
}

.oip-popup__html p {
    margin: 0 0 10px;
}

.oip-popup__html a {
    color: #1b6199;
    text-decoration: underline;
}

.oip-popup__html a.button {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    color: #1b6199;
    display: inline;
    font-size: inherit;
    line-height: inherit;
    min-height: 0;
    padding: 0;
    text-decoration: underline;
}

.oip-popup__html a.button:hover {
    background: transparent;
    color: #134f80;
}

.oip-popup__dialog img {
    display: block;
    height: auto;
    max-width: 100%;
    width: auto;
}

.oip-popup__content--html img {
    max-height: calc(100vh - 170px);
}

.oip-popup__link {
    display: block;
}

.oip-popup__close {
    align-items: center;
    background: #fff;
    border: 0;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    color: #111;
    cursor: pointer;
    display: flex;
    font-size: 28px;
    height: 40px;
    justify-content: center;
    line-height: 1;
    padding: 0 0 3px;
    position: absolute;
    right: -20px;
    top: -20px;
    width: 40px;
    z-index: 5;
}

.oip-popup-is-open {
    overflow: hidden;
}

@media (max-width: 600px) {
    .oip-popup {
        --oip-image-margin: 32px;
        padding: 16px;
    }

    .oip-popup__dialog {
        max-height: calc(100vh - 32px);
        max-width: calc(100vw - 32px);
        width: calc(100vw - 32px);
    }

    .oip-popup__content {
        max-height: calc(100vh - 32px);
        padding: 24px;
    }

    .oip-popup__dialog img {
        max-height: calc(100vh - 32px);
        max-height: calc(100dvh - 32px);
    }

    .oip-popup__content--image {
        padding: 0;
    }

    .oip-popup__close {
        right: -10px;
        top: -10px;
    }
}

/* Let image popups wrap the image instead of using the HTML dialog's width. */
.oip-popup__dialog:has(.oip-popup__content--image) {
    background: transparent;
    box-shadow: none;
    width: max-content;
    max-width: calc(100vw - var(--oip-image-margin));
    max-height: none;
}

.oip-popup__dialog .oip-popup__content--image {
    max-height: none;
    overflow: visible;
    padding: 0;
}

.oip-popup__dialog .oip-popup__content--image img {
    width: auto;
    height: auto;
    max-width: calc(100vw - var(--oip-image-margin));
    max-height: calc(100vh - var(--oip-image-margin));
    max-height: calc(100dvh - var(--oip-image-margin));
    object-fit: contain;
}

/* Image reveal from animated-popup.html; preserve the selected image's dimensions. */
.oip-popup__dialog .oip-popup__content--animated {
    overflow: hidden;
    background-color: transparent;
}

.oip-popup--visible .oip-popup__content--animated img {
    animation: oip-mist-effect 2.2s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes oip-mist-effect {
    0% {
        opacity: 0;
        filter: blur(40px) brightness(2.5);
        transform: scale(1.15);
    }
    40% {
        opacity: 0.6;
        filter: blur(20px) brightness(1.8);
    }
    100% {
        opacity: 1;
        filter: blur(0px) brightness(1);
        transform: scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .oip-popup--visible .oip-popup__content--animated img {
        animation: none;
    }
}
