/* ==========================================================================
   Калаж "Наши работы" (Сетка + Галерея)
   ========================================================================== */

.portfolio {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.portfolio-item {
    position: relative;
    background: var(--soft);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Первая карточка большая */
.portfolio-item.featured {
    grid-row: span 2;
}

/* --- Сетка картинок (БЕЗ СЕРЫХ РАМОК) --- */
.portfolio-gallery {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 0;
    height: 290px;
    overflow: hidden;
}

/* Первая картинка на 2 колонки */
.portfolio-gallery .portfolio-img-wrap:first-child {
    grid-column: span 2;
}

/* Логика для 3 картинок: первая большая слева, две маленькие справа */
.portfolio-gallery .portfolio-img-wrap:first-child:nth-last-child(3) {
    grid-column: 1;
    grid-row: 1 / span 2;
}
.portfolio-gallery .portfolio-img-wrap:nth-child(2):nth-last-child(2) {
    grid-column: 2;
    grid-row: 1;
}
.portfolio-gallery .portfolio-img-wrap:nth-child(3):last-child {
    grid-column: 2;
    grid-row: 2;
}

/* Если картинка одна — она растягивается на всю ширину */
.portfolio-gallery .portfolio-img-wrap:only-child {
    grid-column: span 2;
    grid-row: span 2;
}

/* В больших карточках (featured) галерея растягивается на всю высоту */
.portfolio-item.featured .portfolio-gallery {
    height: 100%;
    flex-grow: 1;
    min-height: 500px;
}

/* Обертка картинки */
.portfolio-img-wrap {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

/* Сама картинка */
.portfolio-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: saturate(0.7);
    transition: transform 0.5s ease, filter 0.5s ease;
}

.portfolio-item:hover .portfolio-img-wrap img {
    transform: scale(1.03);
    filter: saturate(1);
}

/* Плашка "+X фото" */
.portfolio-more {
    position: absolute;
    inset: 0;
    background: rgba(18, 36, 42, 0.7);
    color: #fff;
    font-family: Oswald, sans-serif;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    transition: background 0.3s ease;
}
.portfolio-img-wrap:hover .portfolio-more {
    background: rgba(18, 36, 42, 0.85);
}

/* ==========================================================================
   ТЕКСТОВАЯ ЧАСТЬ (Обновленная типографика)
   ========================================================================== */
.portfolio-info {
    padding: 25px 30px;
    background: var(--soft);
    z-index: 2;
    position: relative;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Тег (Расточка · Наплавка) */
.portfolio-info small {
    color: #5d6b00; /* Более темный и насыщенный оливковый для читаемости */
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    display: block;
    margin-bottom: 8px;
}

/* Заголовок */
.portfolio-info h3 {
    font-size: 26px;
    text-transform: uppercase;
    margin: 0 0 12px 0;
    line-height: 1.2;
    color: var(--ink);
    transition: color 0.3s ease;
}

/* Описание */
.portfolio-info p {
    font-size: 14px;
    line-height: 1.6;
    color: #4a5a60; /* Сделали темнее для контраста */
    margin: 0;
}

.portfolio-item:hover h3 {
    color: #748400;
}

/* ==========================================================================
   ЛАЙТБОКС (МОДАЛЬНОЕ ОКНО)
   ========================================================================== */
.lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    inset: 0;
    background: rgba(9, 23, 27, 0.95);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox-img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.lightbox.active .lightbox-img {
    transform: scale(1);
}

.lightbox-caption {
    color: #fff;
    margin-top: 20px;
    font-family: Oswald, sans-serif;
    font-size: 20px;
    text-transform: uppercase;
    text-align: center;
}

.lightbox-close {
    position: absolute;
    top: 30px;
    right: 40px;
    color: #fff;
    font-size: 40px;
    font-weight: 300;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 10;
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 40px;
    cursor: pointer;
    padding: 20px;
    transition: color 0.2s;
    z-index: 10;
    user-select: none;
}

.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    color: var(--lime);
}

/* Адаптив */
@media (max-width: 760px) {
    .portfolio {
        grid-template-columns: 1fr;
    }
    .portfolio-item.featured {
        grid-row: auto;
    }
    .portfolio-item.featured .portfolio-gallery {
        height: 300px;
        min-height: auto;
    }
    .lightbox-prev, .lightbox-next {
        font-size: 30px;
        padding: 10px;
    }
}