.ec-popups {
    position: fixed;
    right: 2rem;
    bottom: 6.5rem;
    width: calc(100% - 4rem);
    display: none;
    justify-items: end;
    gap: 2rem;
    z-index: 8;

    &:has(.ec-popup.visible) {
        display: grid;
    }
}

@media (min-width: 32em) {
    .ec-popups {
        width: 18rem;
    }
}

@media (min-width: 60em) {
    .ec-popups {
        bottom: 2rem;
    }
}

@keyframes ec-popups-list-appear {
    from {
        opacity: 0;
        translate: 0 1rem;
        scale: 0.75;
    }

    to {
        opacity: 1;
        translate: 0 0;
        scale: 1;
    }
}

.ec-popups-box {
    background-color: #fff;
    position: relative;
    width: 100%;
    box-shadow: 0 0.5rem 0.5rem 0 color-mix(in srgb, #000 10%, transparent);
    animation: ec-popups-list-appear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: 0.2s;
    transform-origin: right bottom;
    opacity: 0;

    .ec-popups:has(.ec-popups-image) &::after {
        content: '';
        display: block;
        position: absolute;
        right: 1.5rem;
        top: 100%;
        width: 0; height: 0;
        border-style: solid;
        border-width: 1.5rem 0px 0px 1.5rem;
        border-color: #fff transparent transparent transparent;
        transform: rotate(0deg);
    }
}

.ec-popups-list {
    max-height: calc(100dvh - 20rem);
    overflow-y: auto;
}

.ec-popup {
    display: grid;
    gap: 0.75rem;
    padding: 1.5rem;
    font-size: 1rem;
    border-top: 1px solid #e0e0e0;

    &:not(.visible) {
        display: none;
    }

    /* Selects the FIRST element with the class 'visible' */
    &:nth-child(1 of .visible) {
        border-top: 0;
    }

    /* Selects the LAST element with the class 'visible' */
    &:nth-last-child(1 of .visible) {
        border-bottom-left-radius: 1.5rem;
    }
}

.ec-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.ec-popup-title {
    font-weight: 600;
    font-size: 1.125em;
}

.ec-popup-close {
    opacity: 0.5;
    transition: opacity 0.2s ease;
    color: #777;
    position: relative;
    top: -0.75rem;
    right: -0.75rem;
    flex-shrink: 0;

    &:hover,
    &:focus-visible {
        opacity: 1;
    }

    svg {
        width: 1.25rem;
    }
}

.ec-popup-buttons {
    padding-top: 0.25rem;
}

@keyframes ec-popups-image-appear {
    from {
        opacity: 0;
        scale: 0.5;
    }

    to {
        opacity: 1;
        scale: 1;
    }
}

.ec-popups-image {
    width: 5rem;
    animation: ec-popups-image-appear 0.4s ease forwards;
    transform-origin: center bottom;
}