section,
header {
    min-width: 0;
}

/* ============================================
   HEADER
   ============================================ */

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.logo-desktop {
    display: block;
}

/* ============================================
   TOP HEADER
   ============================================ */

.top-header {
    margin-top: 80px;
    padding: 40px 20px;
}

.top-header-link {
    font-size: 24px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--color-primary);
}

.top-header-title {
    font-size: 52px;
    font-weight: 600;
    line-height: 1.2;
    margin-top: 20px;
}

.services-description {
    padding: 60px 20px;
    background: var(--color-bg-alt);
}

.services-description-text-container {
    background-color: var(--color-bg);
    padding: 30px 20px;
    border-radius: 20px;
}


.services-description-text {
    font-size: 28px;
    font-weight: 400;
    line-height: 1.2;
    color: var(--color-text);
}

@media (min-width: 768px) and (max-width: 1280px) {
    /* Header адаптация для планшетов */
    .logo-desktop {
        display: none;
    }

    .top-header-link {
        font-size: 20px;
    }

    .top-header-title {
        font-size: 34px;
    }

    .services-description-text {
        font-size: 20px;
    }

    .services-list-item {
        grid-template-columns: repeat(2, 1fr);
        justify-items: center;
    }

    .services-card-text {
        font-size: 16px;
    }
}

/* ============================================
   АДАПТИВНЫЕ СТИЛИ ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ (до 767px)
   ============================================ */

@media (max-width: 767px) { 

    /* Header and Hero компоненты */
    .logo-desktop {
        display: none;
    }

    .hero-title--desktop { display: none; }
    .hero-title--tablet  { display: inline-block; /* или block — в зависимости от места */ }

    .top-header-link {
        font-size: 16px;
    }

    .top-header-title {
        font-size: 28px;
    }

    .services-description-text {
        font-size: 16px;
    }

    .services-list-item {
        grid-template-columns: repeat(1, 1fr);
        justify-items: center;
    }

    .services-card-text {
        font-size: 16px;
    }
}

.services-list {
    padding: 0px 20px;
    padding-bottom: 100px;
    background: var(--color-bg-alt);
}

.services-list-item {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.centered-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    justify-content: center; /* Центрирует 2 карточки в контейнере */
    align-self: center; /* Дополнительно центрирует весь ряд по горизонтали в родителе */
}

.services-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--color-bg);
    border-radius: 20px 20px 0 0;
    padding: 40px;
    margin-top: 60px;
    position: relative;
    width: 100%; /* Обеспечивает одинаковый размер в сетке */
    box-sizing: border-box; /* Чтобы padding не влиял на ширину */
    min-height: 250px; /* Минимальная высота для единообразия на всех экранах */
}

.services-card img {
    width: 80%;
    max-width: 100%;
    height: auto;
    flex-shrink: 0; /* Предотвращает сжатие изображения */
    margin-bottom: 30px;
}

.services-card-text-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background-color: var(--color-primary);
    border-radius: 20px 20px 0 0;
    padding: 20px;
    position: absolute;
    bottom: -60px;
    left: 0;
    width: 100%;
    height: 40%;
    max-width: 100%; /* Предотвращает переполнение */
    cursor: pointer;
}

.services-card-fulltext-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background-color: var(--color-primary);
    border-radius: 20px 20px 0 0;
    padding: 20px;
    position: absolute;
    bottom: -60px;
    left: 0;
    width: 100%;
    height: 120%;
    max-width: 100%; /* Предотвращает переполнение */
    gap: 30px;
}

.services-card-fulltext-title {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--color-bg);
    margin: 0;
}
.services-card-fulltext {
    font-size: 18px;
    font-weight: 400;
    line-height: 1.2;
    color: var(--color-bg);
    margin: 0;
}
.services-card-fulltext-button {
    width: 70%;
    padding: 12px;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    line-height: 1;
}
.services-card-fulltext-button:hover {
    background: var(--color-primary-hover);
    color: var(--color-bg);
    transition: background-color 0.3s ease;
}
.services-card-text-container:hover {
    background-color: var(--color-primary-hover);
    transition: background-color 0.3s ease;
}
.services-card-text {
    font-size: 20px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--color-bg);
    margin: 0; /* Убираем дефолтные отступы */
}

/* Таблет: 2 колонки для всех рядов (1 2 / 3 4 / 5 6 / 7 8) */
@media (min-width: 768px) and (max-width: 1280px) {
    .grid-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .centered-row {
        grid-template-columns: repeat(2, 1fr);
        justify-content: center; /* Остаётся для симметрии, но в 2-колонке это полный ряд */
    }
    .services-card {
        padding: 30px;
        min-height: 220px; /* Адаптируем высоту */
    }
    .services-card-text {
        font-size: 20px;
    }
    .services-card-text-container {
        bottom: -50px;
        padding: 18px;
    }
    .services-card-fulltext-container {
        height: 120%;
        bottom: -50px;
    }
    .services-card-fulltext-title {
        font-size: 16px;
    }
    .services-card-fulltext {
        font-size: 14px;
    }
    .services-card-fulltext-button {
        font-size: 16px;
    }
}

/* Мобильные: 1 колонка для всех, с выравниванием структуры для единообразия */
@media (max-width: 767px) {
    .services-list-item {
        display: grid;
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .grid-row,
    .centered-row {
        display: contents; /* "Расплющивает" обертки, чтобы все карточки стали прямыми детьми в единой колонке */
    }
    .services-card {
        padding: 20px;
        margin-top: 40px;
        min-height: 200px; /* Единообразная минимальная высота для мобильки */
        width: 100%;
        max-width: 100%; /* Предотвращает растяжение за пределы экрана */
    }
    .services-card img {
        width: 70%; /* Немного уменьшаем на мобильке для лучшей пропорции */
        max-width: 70%;
    }
    .services-card-text {
        font-size: 18px;
    }
    .services-card-text-container {
        bottom: -40px;
        padding: 15px;
        width: 100%;
        max-width: 100%;
    }
    .services-card-fulltext-container {
        gap: 10px;
        height: 120%;
        bottom: -40px;
    }
    .services-card-fulltext-title {
        font-size: 16px;
    }
    .services-card-fulltext {
        font-size: 14px;
    }
    .services-card-fulltext-button {
        font-size: 14px;
    }
}

@media (max-width: 400px) {
    .services-card-fulltext-container {
        gap: 10px;
    }
    .services-card-fulltext-title {
        font-size: 14px;
    }
    .services-card-fulltext {
        font-size: 12px;
    }
}