/* ============================================ */
/* ПРЕМИУМ СЕТКА ПОРТФОЛИО (АВТОМАТИЧЕСКАЯ) */
/* ============================================ */

/* ОБЩИЙ КОНТЕЙНЕР СЕТКИ */
.portfolio-projects-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 450px 220px; /* Паттерн: высокая строка + низкая строка */
    gap: 24px;
    margin-bottom: 60px;
}

/* ===================================== */
/* ПАТТЕРН: Каждые 5 карточек */
/* 1 = БОЛЬШОЙ (2 строки, левая колонка) */
/* 2 = СРЕДНИЙ (верх, центр) */
/* 3 = СРЕДНИЙ (верх, справа) */
/* 4 = МАЛЕНЬКИЙ (низ, центр) */
/* 5 = МАЛЕНЬКИЙ (низ, справа) */
/* ===================================== */

/* Карточка 1, 6, 11, 16... — БОЛЬШОЙ (левая колонка, 2 строки) */
.portfolio-projects-grid .portfolio-item:nth-child(5n+1) {
    grid-column: 1 / 2;
    grid-row: span 2;
}

/* Карточка 2, 7, 12, 17... — СРЕДНИЙ (верх, центр) */
.portfolio-projects-grid .portfolio-item:nth-child(5n+2) {
    grid-column: 2 / 3;
    grid-row: span 1;
}

/* Карточка 3, 8, 13, 18... — СРЕДНИЙ (верх, справа) */
.portfolio-projects-grid .portfolio-item:nth-child(5n+3) {
    grid-column: 3 / 4;
    grid-row: span 1;
}

/* Карточка 4, 9, 14, 19... — МАЛЕНЬКИЙ (низ, центр) */
.portfolio-projects-grid .portfolio-item:nth-child(5n+4) {
    grid-column: 2 / 3;
    grid-row: span 1;
}

/* Карточка 5, 10, 15, 20... — МАЛЕНЬКИЙ (низ, справа) */
.portfolio-projects-grid .portfolio-item:nth-child(5n) {
    grid-column: 3 / 4;
    grid-row: span 1;
}

/* ===================================== */
/* ОБЩИЕ СТИЛИ ДЛЯ ВСЕХ КАРТОЧЕК */
/* ===================================== */

.portfolio-item {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    text-decoration: none;
}

.portfolio-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    text-decoration: none;
}

.portfolio-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.portfolio-item:hover img {
    transform: scale(1.05);
}

/* Оверлей с градиентом */
.portfolio-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 30px 24px 24px 24px;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 70%, transparent 100%);
    color: #FFFFFF;
    z-index: 2;
}

.portfolio-item-content {
    position: relative;
    z-index: 3;
}

.portfolio-item-title {
    font-size: 20px;
    font-weight: 600;
    color: #FFFFFF;
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.portfolio-item-subtitle {
    font-size: 14px;
    font-weight: 400;
    color: rgba(255,255,255,0.85);
    margin: 0;
    line-height: 1.4;
}

/* ===================================== */
/* АДАПТИВ ДЛЯ ПЛАНШЕТОВ */
/* ===================================== */

@media (max-width: 991px) {
    .portfolio-projects-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 350px 280px;
        gap: 20px;
    }
    
    /* На планшетах упрощаем: чередуем большой-маленькие */
    .portfolio-projects-grid .portfolio-item:nth-child(3n+1) {
        grid-column: 1 / 2;
        grid-row: span 2;
    }
    
    .portfolio-projects-grid .portfolio-item:nth-child(3n+2) {
        grid-column: 2 / 3;
        grid-row: span 1;
    }
    
    .portfolio-projects-grid .portfolio-item:nth-child(3n) {
        grid-column: 2 / 3;
        grid-row: span 1;
    }
}

/* ===================================== */
/* АДАПТИВ ДЛЯ МОБИЛЬНЫХ */
/* ===================================== */

@media (max-width: 767px) {
    .portfolio-projects-grid {
        grid-template-columns: 1fr;
        grid-auto-rows: 320px;
        gap: 16px;
    }
    
    /* На мобильных все карточки одинаковые */
    .portfolio-projects-grid .portfolio-item {
        grid-column: 1 / 2;
        grid-row: span 1;
    }
    
    .portfolio-item-title {
        font-size: 18px;
    }
    
    .portfolio-item-subtitle {
        font-size: 13px;
    }
}
