.p5g-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.p5g-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 20px;
}

/* Стили для первой четверки проектов (1-4) */
.p5g-card:nth-child(4n+1) {
    grid-column: span 1;
    grid-row: span 2;
}

.p5g-card:nth-child(4n+2),
.p5g-card:nth-child(4n+3) {
    grid-column: span 1;
    grid-row: span 1;
}

.p5g-card:nth-child(4n+4) {
    grid-column: span 2;
    grid-row: span 1;
}

/* Стили для второй четверки проектов (5-8) */
.p5g-card:nth-child(n+5):nth-child(-n+6) {
    grid-column: span 1;
    grid-row: span 1;
}

.p5g-card:nth-child(7) {
    grid-column: span 1;
    grid-row: span 2;
}

.p5g-card:nth-child(8) {
    grid-column: span 2;
    grid-row: span 1;
}

.p5g-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    height: 100%;
    min-height: 250px;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.p5g-card:hover {
    transform: translateY(-10px);
}

.p5g-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

.p5g-image-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.5s ease;
}

.p5g-card:hover .p5g-image-wrapper img {
    filter: brightness(0.7);
    transition: all 0.5s ease;
}

/* Оверлей при наведении */
.p5g-overlay {
    position: absolute;
    bottom: 0;
    right: 0;
    opacity: 0;
    z-index: 2;
    transition: all 0.5s ease;
}

.p5g-card:hover .p5g-overlay {
    opacity: 1;
    transition: all 0.5s ease;
}

.p5g-details-button {
    width: 234px;
    height: 55px;
    background: #FFD332;
    border: none;
    color: #000 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    font-family: 'Inter Tight' !important;
    cursor: pointer;
    border-radius: 12px;
    text-transform: capitalize !important;
    transition: all 0.5s ease;
}

.p5g-details-button:hover {
    background: #FFD332;
    transition: all 0.5s ease;
}

/* Скрываем информацию о проекте, она будет только в модальном окне */
.p5g-info {
    display: none;
}

/* Модальное окно */
.p5g-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.5s ease;
}

/* Стили для открытого модального окна */
.p5g-modal.active {
    visibility: visible;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.8);
    opacity: 1;
}

.p5g-modal-content {
    position: relative;
    background: #F0F0F0;
    width: 90%;
    max-width: 1000px;
    padding: 118px 40px 55px;
    border-radius: 8px;
    margin: 20px;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: all 0.5s ease;
}

/* Анимация для контента при открытом модальном окне */
.p5g-modal.active .p5g-modal-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.p5g-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: stretch;
}

.p5g-modal-image {
    position: relative;
    height: 100%;
    min-height: 100%;
}

.p5g-modal-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px !important;
    display: block;
}

.p5g-modal-info {
    height: 100%;
}

.p5g-close-button {
    position: absolute;
    right: 26px !important;
    top: 26px !important;
    width: 39px !important;
    height: 39px !important;
    cursor: pointer;
    border: none;
    padding: 0;
    font-size: 0;
    background: none !important;
}

.p5g-close-button::before,
.p5g-close-button::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: contain !important;
    transition: opacity 0.3s ease !important;
}

.p5g-close-button::before {
    background-image: url('https://plan5.infodevelopmentpreview.ru/wp-content/uploads/2025/02/close.svg') !important;
    opacity: 1;
}

.p5g-close-button::after {
    background-image: url('https://plan5.infodevelopmentpreview.ru/wp-content/uploads/2025/02/close__hover.svg') !important;
    opacity: 0;
}

.p5g-close-button:hover::before {
    opacity: 0;
}

.p5g-close-button:hover::after {
    opacity: 0.8;
}

.p5g-details {
    margin-top: 40px;
}

.p5g-detail {
    margin: 0 0 15px;
    color: #666;
    display: grid;
    grid-template-columns: 140px 1fr;
    align-items: baseline;
}

.p5g-label {
    font-weight: normal;
    color: #999;
}

/* Стили для текстового контента */
#modalTitle {
    font-size: 24px;
    color: #333;
    margin-bottom: 20px;
    font-weight: normal;
}

#modalDescription {
    color: #666;
    margin-bottom: 30px;
    line-height: 1.5;
}

/* Адаптивность */
@media (max-width: 800px) {
    .p5g-container {
        padding: 15px;
        width: 100%;
        margin: 0 auto;
    }

    .p5g-grid {
        gap: 10px;
    }

    /* Уменьшаем только высоту */
    .p5g-card {
        min-height: 125px;
    }

    /* Адаптив модального окна */
    .p5g-modal-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .p5g-modal-content {
        padding: 80px 20px 40px;
    }

    .p5g-modal-image {
        min-height: 300px;
    }

    .p5g-close-button {
        width: 39px !important;
        height: 39px !important;
        right: 22px !important;
        top: 22px !important;
    }

    /* Размер текста для планшетов */
    .p5g-modal-item span,
    .p5g-modal-item .p5g-label,
    .p5g-modal-item span:last-child,
    .p5g-value-wrapper,
    #modalTitle,
    #modalDescription,
    #modalClient,
    #modalDate,
    #modalMeters {
        font-size: 16px !important;
    }

    .p5g-title-main {
        font-size: 48px !important;
    }

    .p5g-details-button {
        width: 142px !important;
        height: 50px !important;
        font-size: 16px !important;
    }
}

@media (max-width: 480px) {
    .p5g-container {
        padding: 10px;
        width: 100%;
    }

    .p5g-grid {
        gap: 8px;
    }

    /* Дополнительные стили для модального окна на мобильных */
    .p5g-modal-content {
        padding: 60px 15px 30px;
        margin: 10px;
    }

    .p5g-modal-image {
        min-height: 250px;
    }

    /* Размер текста для телефонов */
    .p5g-modal-item span,
    .p5g-modal-item .p5g-label,
    .p5g-modal-item span:last-child,
    .p5g-value-wrapper,
    #modalTitle,
    #modalDescription,
    #modalClient,
    #modalDate,
    #modalMeters {
        font-size: 14px !important;
    }

    .p5g-title-main {
        font-size: 26px !important;
    }

    .p5g-details-button {
        width: 90px !important;
        height: 31px !important;
        font-size: 10px !important;
        border-radius: 8px !important;
    }

    .p5g-card {
        border-radius: 8px !important;
    }

    .p5g-close-button {
        width: 30px !important;
        height: 30px !important;
        right: 20px !important;
        top: 20px !important;
    }
}

.p5g-title-main {
    color: #FFD332 !important;
    text-transform: uppercase !important;
    font-size: 64px !important;
    margin-bottom: 40px;
}

.p5g-modal-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.p5g-modal-item {
    padding: 27px 0;
    border-top: 1px solid rgba(28, 28, 27, 0.5);
    border-bottom: 1px solid rgba(28, 28, 27, 0.5);
    display: grid;
    grid-template-columns: 140px 1fr;
    align-items: baseline;
    gap: 10px;
}

/* Общие стили для всех span в списке */
.p5g-modal-item span {
    margin: 0;
    padding: 0;
    font-size: 24px !important;
    font-family: 'Inter Tight' !important;
}

/* Стили для меток (Название:, Описание: и т.д.) */
.p5g-modal-item .p5g-label {
    color: #000000 !important;
    line-height: 140% !important;
    font-weight: 500 !important;
}

/* Стили для данных проекта */
.p5g-modal-item span:last-child {
    color: #1C1C1B !important;
    line-height: 150% !important;
    font-weight: 400 !important;
    opacity: 0.6 !important;
    text-transform: lowercase !important;
}

.p5g-modal-item span:last-child::first-letter {
    text-transform: uppercase !important;
}

/* Стили для значения площади и единиц измерения */
.p5g-value-wrapper {
    display: flex !important;
    align-items: baseline !important;
    gap: 4px !important;
    color: #1C1C1B !important;
    line-height: 150% !important;
    font-weight: 400 !important;
    opacity: 0.6 !important;
    font-size: 24px !important;
    text-transform: lowercase !important;
}

.p5g-value {
    display: inline-block !important;
}

.p5g-unit {
    display: inline-block !important;
    white-space: nowrap !important;
    text-transform: lowercase !important;
}

/* Удаляем старые стили */
.p5g-value-wrapper,
.p5g-value,
.p5g-unit,
.p5g-modal-item #modalMeters,
.p5g-modal-item #modalMeters .value,
.p5g-modal-item #modalMeters .unit,
.p5g-modal-item span:last-child .unit {
    display: none !important;
}

/* Удаляем двойные бордеры между элементами */
.p5g-modal-item + .p5g-modal-item {
    border-top: none;
    margin-top: -1px;
}

/* Удаляем ненужные стили */
#modalTitle,
#modalDescription,
#modalClient,
#modalDate,
#modalMeters {
    all: unset;
}

/* Удаляем старые стили */
.p5g-details,
.p5g-detail {
    display: none;
}

.p5g-details-button {
    color: #000 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    text-transform: capitalize !important;
}

/* Стили для фильтров */
.p5g-filters {
    margin-bottom: 40px;
}

.p5g-categories-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.p5g-category-link {
    display: inline-block;
    padding: 10px 20px;
    background: #F0F0F0;
    border-radius: 8px;
    color: #1C1C1B !important;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.p5g-category-link:hover,
.p5g-category-link.active {
    background: #FFD332;
    color: #000 !important;
}

/* Адаптивность для фильтров */
@media (max-width: 800px) {
    .p5g-filters {
        margin-bottom: 30px;
    }

    .p5g-categories-list {
        gap: 10px;
    }

    .p5g-category-link {
        padding: 8px 16px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .p5g-filters {
        margin-bottom: 20px;
    }

    .p5g-categories-list {
        gap: 8px;
    }

    .p5g-category-link {
        padding: 6px 12px;
        font-size: 12px;
    }
}

.p5g-modal-item:nth-child(2) {
  display: none !important;
}
