/* ==========================================================================
   InSono — Modal / Dialog
   Based on Dawn details-modal + product-media-modal, in the InSono look
   ========================================================================== */

.modal {
    position: fixed;
    z-index: 1300;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.is-open {
    display: flex;
}

.modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(30, 33, 29, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal__dialog {
    position: relative;
    z-index: 1;
    display: flex;
    width: min(560px, 100%);
    max-height: calc(100vh - 32px);
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
    animation: modal-in 260ms var(--ease-out);
}

.modal--wide .modal__dialog {
    width: min(920px, 100%);
}

.modal--full .modal__dialog {
    width: min(1200px, 100%);
    height: calc(100vh - 32px);
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.98);
    }
}

.modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px 0;
}

.modal__title {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.035em;
}

.modal__subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 14px;
}

.modal__close {
    display: grid;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    place-items: center;
    border-radius: 50%;
    color: var(--muted);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.modal__close:hover {
    background: rgba(30, 33, 29, 0.06);
    color: var(--text);
}

.modal__close svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.modal__body {
    flex: 1;
    padding: 20px 24px 24px;
    overflow-y: auto;
}

.modal__footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px 22px;
    border-top: 1px solid var(--line);
}

/* While a modal is open, do not scroll the background (see js/common/modal.js) */
body.has-modal-open {
    overflow: hidden;
}

/* ---- Lightbox for the product gallery ----------------------------------- */

.modal--lightbox .modal__dialog {
    width: min(1100px, 100%);
    background: #14140f;
    border-color: transparent;
}

.modal--lightbox .modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    background: rgba(255, 255, 255, 0.9);
    color: #14140f;
}

.modal--lightbox .modal__body {
    display: grid;
    padding: 0;
    place-items: center;
}

.modal--lightbox img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

@media screen and (max-width: 749px) {
    .modal {
        align-items: flex-end;
        padding: 0;
    }

    .modal__dialog {
        width: 100%;
        max-height: 92vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    @keyframes modal-in {
        from {
            transform: translateY(100%);
        }
    }
}
