.hm-popup {
    position: fixed;
    inset: 0;
    z-index: var(--hm-popup-z-index, 9999);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: var(--hm-popup-text, #333333);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity .24s ease, visibility .24s ease;
    box-sizing: border-box;
}

.hm-popup *,
.hm-popup *::before,
.hm-popup *::after {
    box-sizing: border-box;
}

.hm-popup.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.hm-popup__overlay {
    position: absolute;
    inset: 0;
    background: var(--hm-popup-overlay-color, #000000);
    opacity: var(--hm-popup-overlay-opacity, .55);
}

.hm-popup__dialog {
    position: relative;
    width: min(100%, var(--hm-popup-max-width, 560px));
    max-height: min(90vh, 900px);
    overflow: hidden auto;
    background: var(--hm-popup-bg, #ffffff);
    border-radius: var(--hm-popup-radius, 24px);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
    transform: translateY(16px) scale(.98);
    transition: transform .24s ease;
}

.hm-popup.is-visible .hm-popup__dialog {
    transform: translateY(0) scale(1);
}

.hm-popup__close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .92);
    color: #111111;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

.hm-popup__close:hover,
.hm-popup__close:focus-visible {
    background: #ffffff;
    outline: 2px solid var(--hm-popup-accent, #4016B3);
    outline-offset: 2px;
}

.hm-popup__media {
    width: 100%;
    background: #f4f4f4;
    overflow: hidden;
}

.hm-popup__media--ratio {
    aspect-ratio: var(--hm-popup-image-ratio, auto);
}

.hm-popup__image {
    display: block;
    width: 100%;
    height: auto;
    max-height: var(--hm-popup-image-max-height, 340px);
    object-fit: var(--hm-popup-image-fit, cover);
    object-position: var(--hm-popup-image-position, center center);
}

.hm-popup__media--ratio .hm-popup__image {
    height: 100%;
    max-height: none;
}

.hm-popup__content {
    padding: clamp(22px, 4vw, 36px);
}

.hm-popup__subtitle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: var(--hm-popup-accent, #4016B3);
    font-size: 13px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.hm-popup__title {
    margin: 0 0 12px;
    color: var(--hm-popup-title, #151515);
    font-size: clamp(26px, 4vw, 38px);
    line-height: 1.06;
    font-weight: 850;
}

.hm-popup__body {
    color: var(--hm-popup-text, #333333);
    font-size: 16px;
    line-height: 1.58;
}

.hm-popup__body > :first-child {
    margin-top: 0;
}

.hm-popup__body > :last-child {
    margin-bottom: 0;
}

.hm-popup__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.hm-popup__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 12px 20px;
    border-radius: 999px;
    font-weight: 800;
    line-height: 1.2;
    text-decoration: none;
    transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.hm-popup__button:hover,
.hm-popup__button:focus-visible {
    transform: translateY(-1px);
    text-decoration: none;
}

.hm-popup__button--primary {
    background: var(--hm-popup-accent, #4016B3);
    color: var(--hm-popup-button-text, #ffffff);
    box-shadow: 0 12px 28px rgba(64, 22, 179, .28);
}

.hm-popup__button--primary:hover,
.hm-popup__button--primary:focus-visible {
    color: var(--hm-popup-button-text, #ffffff);
    box-shadow: 0 16px 34px rgba(64, 22, 179, .34);
}

.hm-popup__button--secondary {
    background: transparent;
    color: var(--hm-popup-accent, #4016B3);
    border: 1px solid color-mix(in srgb, var(--hm-popup-accent, #4016B3) 35%, transparent);
}

.hm-popup__button--secondary:hover,
.hm-popup__button--secondary:focus-visible {
    color: var(--hm-popup-accent, #4016B3);
    background: color-mix(in srgb, var(--hm-popup-accent, #4016B3) 8%, transparent);
}

.hm-popup--slide_right {
    align-items: stretch;
    justify-content: flex-end;
    padding: 18px;
}

.hm-popup--slide_right .hm-popup__dialog {
    height: auto;
    max-height: calc(100vh - 36px);
    align-self: center;
    transform: translateX(28px);
}

.hm-popup--slide_right.is-visible .hm-popup__dialog {
    transform: translateX(0);
}

.hm-popup--bottom_bar {
    align-items: flex-end;
    padding: 16px;
}

.hm-popup--bottom_bar .hm-popup__dialog {
    width: min(100%, 1120px);
    max-height: min(70vh, 520px);
    border-radius: var(--hm-popup-radius, 24px);
    transform: translateY(30px);
}

.hm-popup--bottom_bar .hm-popup__dialog {
    display: grid;
    grid-template-columns: minmax(0, 320px) 1fr;
}

.hm-popup--bottom_bar .hm-popup__media {
    min-height: 100%;
}

.hm-popup--bottom_bar .hm-popup__media--ratio {
    aspect-ratio: auto;
}

.hm-popup--bottom_bar .hm-popup__image {
    height: 100%;
    max-height: none;
    object-fit: cover;
}

.hm-popup--bottom_bar.is-visible .hm-popup__dialog {
    transform: translateY(0);
}

body.hm-popup-open {
    overflow: hidden;
}

@media (max-width: 767px) {
    .hm-popup {
        padding: 12px;
    }

    .hm-popup__dialog,
    .hm-popup--slide_right .hm-popup__dialog,
    .hm-popup--bottom_bar .hm-popup__dialog {
        width: 100%;
        max-height: calc(100dvh - 24px);
        border-radius: min(var(--hm-popup-radius, 24px), 20px);
    }

    .hm-popup--bottom_bar .hm-popup__dialog {
        display: block;
    }

    .hm-popup__content {
        padding: 22px;
    }

    .hm-popup__image {
        max-height: min(var(--hm-popup-image-max-height, 340px), 220px);
    }

    .hm-popup__media--ratio .hm-popup__image {
        max-height: none;
    }

    .hm-popup__actions {
        flex-direction: column;
    }

    .hm-popup__button {
        width: 100%;
    }
}

@supports not (color: color-mix(in srgb, red 50%, transparent)) {
    .hm-popup__button--secondary {
        border-color: rgba(64, 22, 179, .28);
    }

    .hm-popup__button--secondary:hover,
    .hm-popup__button--secondary:focus-visible {
        background: rgba(64, 22, 179, .08);
    }
}


.hm-popup--image-only .hm-popup__dialog {
    background: transparent;
    box-shadow: none;
    overflow: visible;
}

.hm-popup--image-only .hm-popup__media {
    background: transparent;
    border-radius: var(--hm-popup-radius, 24px);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
}

.hm-popup--image-only .hm-popup__image {
    border-radius: var(--hm-popup-radius, 24px);
}

.hm-popup--image-only .hm-popup__close {
    top: 14px;
    right: 14px;
}


/* v1.0.6: stronger image-only mode */
.hm-popup--image-only {
    padding: 12px;
}

.hm-popup--image-only .hm-popup__dialog {
    width: auto;
    max-width: min(calc(100vw - 24px), 920px);
    max-height: calc(100vh - 24px);
    background: transparent;
    box-shadow: none;
    overflow: visible;
    transform: translateY(0) scale(.98);
}

.hm-popup--image-only.is-visible .hm-popup__dialog {
    transform: translateY(0) scale(1);
}

.hm-popup--image-only .hm-popup__media {
    display: block;
    width: auto;
    max-width: 100%;
    background: transparent;
    overflow: visible;
    border-radius: var(--hm-popup-radius, 24px);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
    line-height: 0;
}

.hm-popup--image-only .hm-popup__image {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: calc(100vh - 24px);
    margin: 0;
    border-radius: var(--hm-popup-radius, 24px);
}

.hm-popup--image-only .hm-popup__close {
    top: 10px;
    right: 10px;
}

@media (max-width: 767px) {
    .hm-popup--image-only {
        padding: 8px;
    }

    .hm-popup--image-only .hm-popup__dialog {
        width: auto;
        max-width: calc(100vw - 16px);
        max-height: calc(100dvh - 16px);
    }

    .hm-popup--image-only .hm-popup__media {
        width: auto;
        max-width: calc(100vw - 16px);
    }

    .hm-popup--image-only .hm-popup__image {
        width: 100%;
        max-width: calc(100vw - 16px);
        max-height: calc(100dvh - 16px);
    }

    .hm-popup--image-only .hm-popup__close {
        top: 8px;
        right: 8px;
    }
}


/* v1.0.7: respect image max height and popup max width in image-only mode */
.hm-popup--image-only .hm-popup__dialog {
    max-width: min(calc(100vw - 24px), var(--hm-popup-max-width, 920px));
    max-height: min(calc(100vh - 24px), var(--hm-popup-image-max-height, 700px));
}

.hm-popup--image-only .hm-popup__media {
    max-width: min(calc(100vw - 24px), var(--hm-popup-max-width, 920px));
    max-height: min(calc(100vh - 24px), var(--hm-popup-image-max-height, 700px));
}

.hm-popup--image-only .hm-popup__image {
    max-width: min(calc(100vw - 24px), var(--hm-popup-max-width, 920px));
    max-height: min(calc(100vh - 24px), var(--hm-popup-image-max-height, 700px));
    object-fit: contain;
}

@media (max-width: 767px) {
    .hm-popup--image-only .hm-popup__dialog {
        max-width: calc(100vw - 16px);
        max-height: min(calc(100dvh - 16px), var(--hm-popup-image-max-height, 700px));
    }

    .hm-popup--image-only .hm-popup__media {
        max-width: calc(100vw - 16px);
        max-height: min(calc(100dvh - 16px), var(--hm-popup-image-max-height, 700px));
    }

    .hm-popup--image-only .hm-popup__image {
        width: auto;
        max-width: calc(100vw - 16px);
        max-height: min(calc(100dvh - 16px), var(--hm-popup-image-max-height, 700px));
    }
}


/* v1.0.8: clickable image when main link is provided */
.hm-popup__media--link {
    display: block;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.hm-popup__media--link:hover,
.hm-popup__media--link:focus-visible {
    color: inherit;
    text-decoration: none;
}

.hm-popup__media--link:focus-visible {
    outline: 3px solid var(--hm-popup-accent, #4016B3);
    outline-offset: 4px;
}

.hm-popup--image-only .hm-popup__media--link {
    display: block;
    line-height: 0;
}
