.project-modal {

    position: fixed;
    overscroll-behavior: contain;
    inset: 0;

    background:
        rgba(0, 0, 0, .55);

    backdrop-filter: blur(14px);

    display: flex;

    align-items: center;

    justify-content: center;

    padding: 30px;

    z-index: 99999;

    opacity: 0;

    visibility: hidden;

    transition:
        opacity .45s ease,
        visibility .45s ease;
}

.project-modal.active {

    opacity: 1;

    visibility: visible;
}

.modal-overlay {

    position: absolute;

    inset: 0;
}

/* ====================== */
/* MODAL CONTENT */
/* ====================== */

.modal-content {

    width: 100%;

    max-width: 1180px;

    max-height: 92vh;

    background:
        linear-gradient(135deg,
            rgba(255, 255, 255, .08),
            rgba(255, 255, 255, .03));

    border:
        1px solid var(--border);

    backdrop-filter: blur(35px);

    border-radius: 38px;

    overflow: hidden;

    position: relative;

    z-index: 2;

    display: grid;

    grid-template-columns: 430px 1fr;

    transform:
        scale(.85) translateY(40px);

    opacity: 0;

    transition:
        transform .7s cubic-bezier(.19, 1, .22, 1),
        opacity .7s ease;

    box-shadow:
        0 40px 80px rgba(0, 0, 0, .35);
}

.project-modal.active .modal-content {

    transform:
        scale(1) translateY(0);

    opacity: 1;
}

/* ====================== */
/* LEFT IMAGE */
/* ====================== */

.modal-image-wrap {

    position: relative;

    height: 100%;

    min-height: 550px;

    overflow: hidden;
}

.modal-image-wrap::after {

    content: "";

    position: absolute;

    inset: 0;

    background:
        linear-gradient(to top,
            rgba(0, 0, 0, .45),
            transparent 40%);

    pointer-events: none;
}

.modal-image-wrap img {

    width: 100%;

    height: 100%;

    min-height: 550px;

    object-fit: cover;

    display: block;

    transform: scale(1.15);

    opacity: 0;

    transition:
        transform 1.4s cubic-bezier(.19, 1, .22, 1),
        opacity 1s ease;
}

.project-modal.active .modal-image-wrap img {

    transform: scale(1);

    opacity: 1;
}

/* ====================== */
/* DETAIL */
/* ====================== */

.modal-detail {

    padding: 55px;

    overflow-y: auto;

    max-height: 92vh;

    display: flex;

    flex-direction: column;

    position: relative;

    scrollbar-width: none;
}

.modal-detail::-webkit-scrollbar {

    display: none;
}

.modal-detail h2 {

    font-size: 46px;

    color: var(--text);

    line-height: 1.15;

    margin-bottom: 22px;

    letter-spacing: -.5px;
}

.modal-detail p {

    color: var(--text-secondary);

    line-height: 2;

    margin-bottom: 30px;

    font-size: 15px;
}

/* ====================== */
/* STACK */
/* ====================== */

.modal-stack {

    display: flex;

    flex-wrap: wrap;

    gap: 12px;

    margin-top: 10px;

    margin-bottom: 40px;
}

.stack-badge {

    padding: 10px 16px;

    border-radius: 999px;

    background:
        rgba(255, 255, 255, .06);

    border:
        1px solid var(--border);

    color: var(--secondary);

    font-size: 13px;

    font-weight: 600;

    backdrop-filter: blur(20px);

    transition: .35s ease;
}

.stack-badge:hover {

    transform:
        translateY(-3px);

    background:
        rgba(255, 255, 255, .12);
}

/* ====================== */
/* GALLERY */
/* ====================== */

.modal-gallery {

    display: grid;

    grid-template-columns:
        repeat(2, 1fr);

    gap: 16px;

    margin-top: 10px;

    margin-bottom: 40px;
}

.gallery-image {

    width: 100%;

    height: 150px;

    object-fit: cover;

    border-radius: 22px;

    cursor: pointer;

    transition:
        transform .45s ease,
        box-shadow .45s ease,
        filter .45s ease;

    filter: brightness(.92);
}

.gallery-image:hover {

    transform:
        scale(1.04) translateY(-4px);

    filter: brightness(1);

    box-shadow:
        0 25px 45px rgba(0, 0, 0, .25);
}

/* ====================== */
/* ACTION BUTTONS */
/* ====================== */

.modal-actions {

    display: flex;

    gap: 18px;

    margin-top: auto;

    padding-top: 35px;

    border-top:
        1px solid var(--border);

    flex-wrap: wrap;
}

.modal-btn {

    flex: 1;

    min-height: 62px;

    padding: 18px 24px;

    border-radius: 22px;

    text-decoration: none;

    color: var(--text);

    display: flex;

    align-items: center;

    justify-content: center;

    gap: 12px;

    transition:
        transform .35s ease,
        background .35s ease,
        border .35s ease,
        box-shadow .35s ease;

    font-weight: 600;

    letter-spacing: .3px;

    position: relative;

    overflow: hidden;
}

.modal-btn::before {

    content: "";

    position: absolute;

    inset: 0;

    background:
        linear-gradient(135deg,
            rgba(255, 255, 255, .15),
            transparent);

    opacity: 0;

    transition: .35s ease;
}

.modal-btn:hover::before {

    opacity: 1;
}

.modal-btn.primary {

    background:
        linear-gradient(135deg,
            var(--primary),
            var(--secondary));

    box-shadow:
        0 15px 35px rgba(108, 92, 231, .35);
}

.modal-btn.secondary {

    background:
        rgba(255, 255, 255, .06);

    border:
        1px solid var(--border);

    backdrop-filter: blur(15px);
}

.modal-btn:hover {

    transform:
        translateY(-5px) scale(1.02);

    box-shadow:
        0 20px 40px rgba(0, 0, 0, .25);
}

/* ====================== */
/* CLOSE */
/* ====================== */

.modal-close {

    position: absolute;

    top: 22px;

    right: 22px;

    width: 52px;
    height: 52px;

    border: none;

    border-radius: 50%;

    background:
        rgba(255, 255, 255, .1);

    color: white;

    cursor: pointer;

    z-index: 10;

    transition:
        transform .35s ease,
        background .35s ease;
}

.modal-close:hover {

    transform:
        rotate(90deg) scale(1.08);

    background:
        rgba(255, 255, 255, .18);
}

.project-card {

    cursor: pointer;
}

#modalImage {

    cursor: zoom-in;
}

/* ====================== */
/* IMAGE VIEWER */
/* ====================== */

.image-viewer {

    position: fixed;

    inset: 0;

    background:
        rgba(0, 0, 0, .82);

    backdrop-filter: blur(14px);

    display: flex;

    align-items: center;

    justify-content: center;

    z-index: 999999;

    opacity: 0;

    visibility: hidden;

    transition: .45s ease;
}

.image-viewer.active {

    opacity: 1;

    visibility: visible;
}

.image-viewer img {

    max-width: 90%;

    max-height: 90vh;

    border-radius: 30px;

    transform:
        scale(.82);

    transition:
        transform .45s ease;
}

.image-viewer.active img {

    transform:
        scale(1);
}

.image-viewer-overlay {

    position: absolute;

    inset: 0;
}

.viewer-close {

    position: absolute;

    top: 28px;

    right: 28px;

    width: 58px;
    height: 58px;

    border-radius: 50%;

    border: none;

    background:
        rgba(255, 255, 255, .1);

    color: white;

    cursor: pointer;

    font-size: 18px;

    z-index: 3;

    transition: .35s ease;
}

.viewer-close:hover {

    transform:
        rotate(90deg) scale(1.08);
}

/* ====================== */
/* LIGHT MODE */
/* ====================== */

[data-theme="light"] .modal-content {

    background:
        linear-gradient(135deg,
            rgba(255, 255, 255, .75),
            rgba(255, 255, 255, .55));

    box-shadow:
        0 30px 60px rgba(0, 0, 0, .08);
}

[data-theme="light"] .modal-close,
[data-theme="light"] .viewer-close {

    background:
        rgba(255, 255, 255, .8);

    color: #111827;
}

[data-theme="light"] .modal-actions {

    border-top:
        1px solid rgba(0, 0, 0, .08);
}

/* ====================== */
/* MOBILE */
/* ====================== */

@media(max-width:768px) {

    .project-modal {

        padding: 12px;

        align-items: flex-end;
    }

    .modal-content {

        width: 100%;

        height: 92vh;

        max-height: 92vh;

        border-radius: 32px;

        grid-template-columns: 1fr;

        overflow: hidden;

        animation:
            mobileModalUp .55s cubic-bezier(.19, 1, .22, 1);
    }

    .modal-image-wrap {

        min-height: unset;

        height: 260px;
    }

    .modal-image-wrap img {

        min-height: unset;

        height: 260px;
    }

    .modal-detail {

        padding:
            28px 22px 35px;

        max-height:
            calc(92vh - 260px);
    }

    .modal-detail::before {

        content: "";

        width: 65px;

        height: 5px;

        border-radius: 999px;

        background:
            rgba(255, 255, 255, .18);

        position: absolute;

        top: 12px;

        left: 50%;

        transform:
            translateX(-50%);
    }

    .modal-detail h2 {

        font-size: 30px;

        margin-bottom: 16px;
    }

    .modal-detail p {

        font-size: 14px;

        line-height: 1.9;
    }

    .modal-gallery {

        gap: 12px;
    }

    .gallery-image {

        height: 110px;

        border-radius: 16px;
    }

    .modal-actions {

        position: sticky;

        bottom: 0;

        display: flex;

        flex-direction: column;

        gap: 12px;

        margin-top: 24px;

        padding-top: 20px;

        background: transparent;

        backdrop-filter: none;

        border-top: none;

        width: 100%;

        margin-left: 0;

        margin-right: 0;
    }

    .modal-btn {

        min-height: 56px;

        border-radius: 18px;

        font-size: 13px;
    }

    .modal-close {

        top: 16px;

        right: 16px;

        width: 44px;
        height: 44px;
    }

    .viewer-close {

        top: 18px;

        right: 18px;

        width: 46px;
        height: 46px;
    }

    .image-viewer {

        padding: 20px;
    }

    .image-viewer img {

        width: 100%;

        max-width: 100%;

        border-radius: 22px;
    }

    [data-theme="light"] .modal-actions {

        background:
            rgba(255, 255, 255, .92);
    }
}

@keyframes mobileModalUp {

    from {

        transform:
            translateY(120px);

        opacity: 0;
    }

    to {

        transform:
            translateY(0);

        opacity: 1;
    }
}