/* === Адаптация под планшеты и маленькие ноутбуки (до 1024px) === */
@media (max-width: 1024px) {
    .news-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    .products-grid {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    .product-card-link {
        flex-basis: calc(50% - 1rem);
        margin: 0.6rem 0;
    }
    .resources-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    .page-container {
        margin-top: 6rem; /* чуть меньше отступ для хедера */
    }
    .card-frame {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* === Планшеты в портретной ориентации и телефоны (до 768px) === */
@media (max-width: 768px) {
    /* Шапка и меню */
    .top-menu-frame {
        flex-direction: column;
        /* align-items: center; */
        gap: 0.5rem;
    }
    .main-menu {
        /* justify-content: center; */
        gap: 0.5rem;
    }
    .theme-switcher {
        margin-left: 0;
        margin-top: 0.5rem;
    }
    .page-container {
        margin-top: 8rem; /* увеличенный отступ из-за более высокой шапки */
        padding: 0 0.5rem;
    }
    .card-frame {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Сетки */
    .news-grid {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }
    .news-card {
        height: auto;
        min-height: 200px;
    }
    .products-grid {
        flex-direction: column;
        align-items: stretch;
    }
    .product-card-link {
        flex-basis: auto;
        width: 100%;
        margin: 0.6rem 0;
    }
    .product-card {
        flex-direction: column;
        margin: 1rem;
    }
    .product-card-text {
        margin-top: 0.5rem;
    }

    /* Таблицы (общие) */
    table:not([class]) {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    .product-specs {
        padding: 0.75rem;
        row-gap: 0.75rem;
    }

    /* Библиография */
    .resources-row {
        gap: 0.25rem;
        padding: 0.5rem 0;
    }
    .resources-docs ul {
        padding-left: 0.5rem;
    }
    .doc-thumbnail {
        max-width: 4rem;
        max-height: 5rem;
        margin: 0.25rem;
    }

    /* Отступы и размеры */
    h1 {
        font-size: 1.5rem;
    }
    h2 {
        font-size: 1.25rem;
    }
    .breadcrumbs {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }
    .footer {
        padding: 1rem 0 0.6rem;
    }
    .footer-table {
        flex-direction: column;
        /* text-align: center; */
    }
    .footer-table-map {
        width: 320px;
        height: auto;
    }
    .footer-table-contacts-frame {
        margin-left: 0.5rem;
    }
    .sub-footer {
        flex-direction: column;
        /* align-items: center; */
        gap: 0.5rem;
    }
    .sub-footer-menu {
        gap: 0.5rem;
        flex-wrap: wrap;
        /* justify-content: center; */
    }
    .copyright-frame {
        justify-content: right;
    }
}

/* === Телефоны (до 480px) === */
@media (max-width: 480px) {
    body {
        font-size: 0.875rem;
    }
    .main-menu a {
        font-size: 0.875rem;
        padding: 0.3rem;
    }
    .news-card {
        padding: 0.75rem;
    }
    .news-card a {
        font-size: 1rem;
    }
    .news-thumbnail {
        height: 120px;
    }
    .product-card {
        margin: 0.75rem;
    }
    .product-card-text h2 {
        font-size: 1.1rem;
    }
    .product-specs {
        font-size: 0.75rem;
        padding: 0.5rem;
    }
    .product-specs th,
    .product-specs td {
        padding: 0.3rem;
    }
    .resources-docs li {
        margin-bottom: 0.3rem;
    }
    .doc-thumbnail {
        max-width: 3rem;
        max-height: 4rem;
    }
    .chapter-dark,
    .block-quote {
        padding: 1rem;
        margin: 1rem 0;
    }
    .footer-table-map {
        max-width: 480px;
    }
    .card-frame {
        grid-template-columns: 1fr;
    }
    :root {
        --price-font-size: 70%;
        --product-select-width: 12rem;
        --price-result-width: 85%;
    }   
    .dark {
        --price-font-size: 70%;
        --product-select-width: 12rem;
        --price-result-width: 85%;
    }
}
