/* ---------- Portfolio page ---------- */

html {
    scroll-behavior: smooth;
}

.portfolio {
    position: relative;
    height: 100dvh;
    overflow: hidden;
    background: linear-gradient(160deg, #11131d 0%, #1b1d29 55%, #14161f 100%);
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* ---------- Heading ---------- */
.heading {
    position: absolute;
    top: 92px;
    left: 0;
    right: 0;
    z-index: 3;
    text-align: center;
    margin: 0;
    padding: 12px 12px 8px;
    flex: 0 0 auto;
}

.animate-head {
    font-family: "Montserrat", sans-serif;
    font-weight: 300;
    font-size: clamp(1.1rem, 2vw, 1.6rem);
    color: #ffffff;
    margin: 0;
}

.animate-head span {
    color: #ffd166;
}

.heading p {
    display: none;
}

/* ---------- Works strip ---------- */
.works {
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: none;
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
}

.work {
    flex: 1 1 0;
    min-width: 0;
    position: relative;
    border-radius: 0;
    overflow: hidden;
    cursor: pointer;
    border: none;
    outline: 2px solid transparent;
    background: #000;
    opacity: 0;
    transform: translateY(40px);
    animation: rise 0.7s ease forwards;
    transition: flex 0.55s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease, filter 0.35s ease;
}

.work:nth-child(1) { animation-delay: 0.05s; }
.work:nth-child(2) { animation-delay: 0.12s; }
.work:nth-child(3) { animation-delay: 0.19s; }
.work:nth-child(4) { animation-delay: 0.26s; }
.work:nth-child(5) { animation-delay: 0.33s; }
.work:nth-child(6) { animation-delay: 0.40s; }
.work:nth-child(7) { animation-delay: 0.47s; }
.work:nth-child(8) { animation-delay: 0.54s; }
.work:nth-child(9) { animation-delay: 0.61s; }
.work:nth-child(10) { animation-delay: 0.68s; }
.work:nth-child(11) { animation-delay: 0.75s; }
.work:nth-child(12) { animation-delay: 0.82s; }
.work:nth-child(13) { animation-delay: 0.89s; }

.work:focus-visible {
    outline: 2px solid #ffd166;
}

/* Enlarge the hovered one, dim the rest */
.work:hover {
    flex: 5 1 0;
    z-index: 2;
}

.works:has(.work:hover) .work:not(:hover) {
    opacity: 0.35;
    filter: saturate(0.5) brightness(0.7);
}

.img-wrap {
    width: 100%;
    height: 100%;
}

.img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    image-rendering: auto;
    transition: transform 0.55s ease;
}

.work:hover .img-wrap img {
    transform: scale(1.06);
}

/* Caption overlay */
.caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 26px 20px 20px;
    background: linear-gradient(transparent, rgba(8, 10, 18, 0.88));
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.35s ease, transform 0.35s ease;
    pointer-events: none;
}

.caption h3 {
    font-family: "Montserrat", sans-serif;
    font-weight: 400;
    font-size: 1rem;
    color: #ffffff;
    margin: 0;
}

.caption span {
    font-size: 0.8rem;
    color: #ffd166;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.work:hover .caption,
.work:focus-visible .caption {
    opacity: 1;
    transform: translateY(0);
}

@keyframes rise {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Modal ---------- */
.project-modal {
    background: #000000;
    border: 5px solid rgba(255, 255, 255, 0.95);
    border-radius: 18px;
    color: #ffffff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    padding: 2px;
}

.btn-close-white {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
    background-color: #000000;
    border: 2px solid rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    padding: 10px;
    opacity: 1;
    box-shadow: none;
}

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.08);
    color: #ffd166;
    font-size: 1.45rem;
    line-height: 1;
    transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
    border-radius: 50%;
    transform-origin: center;
}

.nav-arrow i {
    display: block;
    transform: translateY(-1px);
    color: #ffd166;
}

.nav-arrow:hover {
    background: #ffd166;
    color: #11131d;
    border-color: rgba(255, 209, 102, 0.9);
    transform: translateY(-50%) scale(1.04);
}

.nav-arrow:hover i {
    color: #11131d;
}

.nav-arrow.prev { left: 14px; }
.nav-arrow.next { right: 14px; }

.project-modal .modal-body {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 36px;
    padding: 40px;
    min-height: 60vh;
    align-items: center;
    background: #000000;
}

.modal-img {
    width: 100%;
    max-height: 66vh;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px 22px 20px 18px / 16px 18px 22px 20px;
    overflow: hidden;
    background: #000000;
    border: none;
    box-shadow: none;
    position: relative;
}

.modal-img img {
    max-width: 100%;
    max-height: 66vh;
    object-fit: contain;
    display: block;
    padding: 0;
    position: relative;
    z-index: 1;
}

.modal-info .badge {
    background: rgba(255, 209, 102, 0.18);
    color: #ffe7a3;
    border: 1px solid rgba(255, 209, 102, 0.5);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 6px 12px;
    border-radius: 999px;
    margin-bottom: 16px;
    font-weight: 700;
}

.modal-info .modal-title {
    font-family: "Montserrat", sans-serif;
    font-weight: 400;
    font-size: clamp(1.6rem, 2.6vw, 2.2rem);
    text-align: left;
    margin-bottom: 14px;
    color: #ffffff;
    letter-spacing: 0.02em;
}

.modal-desc {
    color: #edf1ff;
    font-weight: 400;
    line-height: 1.75;
    font-size: 1rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.modal-tags .tag {
    background: rgba(255, 255, 255, 0.08);
    color: #f3f6ff;
    font-size: 0.8rem;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    font-weight: 500;
}

/* ---------- Responsive ---------- */
@media (max-width: 767px) {
    .portfolio {
        height: 100dvh;
        overflow: hidden;
        padding: 0;
    }

    .works {
        flex-wrap: nowrap;
        flex: 1 1 auto;
        height: auto;
        gap: 0;
    }

    .work {
        flex: 1 1 0;
        min-height: 0;
        opacity: 1;
        transform: none;
        animation: none;
    }

    .work:nth-child(odd) { flex: 1 1 0; }

    .work:hover {
        flex: 1 1 0;
    }

    .caption {
        opacity: 1;
        transform: none;
    }
}

@media (max-width: 600px) {
    .work {
        flex: 1 1 100%;
    }

    .work:hover {
        flex: 1 1 100%;
    }

    .project-modal .modal-body {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 24px;
    }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    .work {
        animation: none;
        opacity: 1;
        transform: none;
    }
}