/* ==========================================================
   Nine3 Designs — Portfolio (Balkan-style gallery)
   Tile grid + click-to-open project panels.
   Load AFTER portfolio.css so these rules win.
========================================================== */





/* ==========================================================
   GALLERY GRID
========================================================== */

main section.gallery {
    padding: 0 0 var(--space-xl);
}

main section.gallery .row {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 24px;
}

main section.gallery .row ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

main section.gallery .row ul::after {
    content: "";
    display: table;
    clear: both;
}

main section.gallery .row ul li {
    float: left;
    width: 31.3333%;
    margin: 1%;
    position: relative;
}


/* --- Tiles ------------------------------------------------ */

main section.gallery .row ul li a {
    display: block;
    position: relative;
    overflow: hidden;
    margin: 0;
    padding: 0;
    line-height: 0;
    cursor: pointer;
    border-radius: var(--radius-sm);
    background: var(--primary);
}

main section.gallery .row ul li a img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    transition: transform .45s ease, opacity .3s ease;
}

main section.gallery .row ul li a:hover img {
    transform: scale(1.05);
}


/* --- Fullscreen icon on hover (Balkan signature) ---------- */

main section.gallery .row ul li a::before {
    position: absolute;
    width: 32px;
    height: 32px;
    top: 40%;
    left: 50%;
    margin: -14px 0 0 -16px;
    background: url(data:image/svg+xml;utf8,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%3F%3E%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20x%3D%220px%22%20y%3D%220px%22%20viewBox%3D%220%200%20960%20560%22%20enable-background%3D%22new%200%200%20960%20560%22%20xml%3Aspace%3D%22preserve%22%3E%3Cg%3E%3Crect%20x%3D%22220%22%20y%3D%22260%22%20fill%3D%22%23FFFFFF%22%20width%3D%22536%22%20height%3D%2224%22/%3E%3C/g%3E%3Cg%3E%3Crect%20x%3D%22476%22%20y%3D%224%22%20fill%3D%22%23FFFFFF%22%20width%3D%2224%22%20height%3D%22556%22/%3E%3C/g%3E%3C/svg%3E) no-repeat;
    content: "";
    opacity: 0;
    z-index: 1;
    transition: all .3s linear;
}

main section.gallery .row ul li a:hover::before {
    top: 50%;
    opacity: 1;
}

main section.gallery .row ul li a::after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    content: "";
    opacity: 0;
    background: rgba(51, 60, 48, .55);
    transition: opacity .3s linear;
}

main section.gallery .row ul li a:hover::after {
    opacity: 1;
}


/* --- Graceful placeholder while images are not yet uploaded */

main section.gallery .tile-fallback {
    display: none;
    aspect-ratio: 4 / 3;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--off-white);
}

main section.gallery .tile-fallback .tile-name {
    font-family: var(--font-signature);
    font-size: 2.2rem;
    color: var(--accent-light);
    line-height: 1.2;
}

main section.gallery .row ul li.img-missing a img {
    display: none;
}

main section.gallery li.img-missing .tile-fallback {
    display: flex;
}


/* ==========================================================
   CLOSE BUTTON
========================================================== */

main section.gallery .close {
    position: fixed;
    top: 1.6em;
    right: 1.6em;
    display: none;
    width: 44px;
    height: 44px;
    z-index: 5;
    cursor: pointer;
    border-radius: 50%;
    background: var(--primary-dark);
}

main section.gallery .close::before,
main section.gallery .close::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 2px;
    background: var(--accent);
    transition: transform .3s ease;
}

main section.gallery .close::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

main section.gallery .close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

main section.gallery .close:hover::before,
main section.gallery .close:hover::after {
    transform: translate(-50%, -50%) rotate(0deg);
}

main section.gallery .row ul.item_open .close {
    display: block;
}


/* ==========================================================
   PROJECT PANELS
========================================================== */

main section.gallery .port {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 4;
    background: var(--off-white);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

main section.gallery .port.item_open {
    display: block;
    animation: portIn .35s ease;
}

@keyframes portIn {
    from {
        opacity: 0;
        transform: translateY(-14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

main section.gallery .port:focus {
    outline: none;
}

.port-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 96px 32px 80px;
}

.port-number {
    display: block;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: .5rem;
}

.port-category {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--text-light);
    margin-bottom: 2rem;
}

.port-inner h2 {
    font-size: clamp(2.2rem, 4vw, 3.2rem);
    font-weight: 800;
    color: var(--primary-dark);
    line-height: 1.05;
    margin: 0 0 1.25rem;
}

.port-inner h2 span {
    color: var(--accent);
}

.port-intro {
    font-size: 1.15rem;
    color: var(--text);
    max-width: 640px;
    margin: 0 0 2.5rem;
}

.port-main {
    margin-bottom: 20px;
}

.port-main img,
.port-side img {
    width: 100%;
    display: block;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

.port-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 2.5rem;
}

.port-copy {
    font-size: 1rem;
    color: var(--text);
    max-width: 640px;
    margin: 0 0 2rem;
}

.port-link {
    display: inline-block;
    font-weight: 700;
    font-size: .95rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--primary-dark);
    text-decoration: none;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--accent);
    transition: color .3s ease;
}

.port-link:hover {
    color: var(--accent);
}

.port-link span {
    margin-left: 6px;
}


/* --- Panel image fallback --------------------------------- */

.port-main.img-missing img,
.port-side .img-missing img {
    display: none;
}

.port-main.img-missing::before,
.port-side .img-missing::before {
    content: "Image coming soon";
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4 / 3;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--accent-light);
    font-size: .9rem;
    letter-spacing: .15em;
    text-transform: uppercase;
}


/* ==========================================================
   RESPONSIVE
========================================================== */

@media (max-width: 900px) {

    main section.gallery .row ul li {
        width: 48%;
    }

    .port-side {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {

    main section.gallery .row ul li {
        width: 100%;
        margin: 0 0 20px;
    }

    .port-inner {
        padding: 80px 20px 60px;
    }
}


/* ==========================================================
   REDUCED MOTION
========================================================== */

@media (prefers-reduced-motion: reduce) {

    main section.gallery .row ul li a img,
    main section.gallery .row ul li a::before,
    main section.gallery .row ul li a::after,
    main section.gallery .close::before,
    main section.gallery .close::after,
    main section.gallery .port-link {
        transition: none;
    }

    main section.gallery .row ul li a:hover img {
        transform: none;
    }

    main section.gallery .port.item_open {
        animation: none;
    }
}
