/* Дополнения v2 к base.css (base.css собран из sass и не правится руками) */

.item-card-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 16px;
}

/* На широких экранах миниатюры под главным фото, в свободной ячейке слева от кнопок */
@media (min-width: 576px) {
    .item-card .item-card-gallery {
        grid-row: 3;
        grid-column: 1;
        align-self: start;
    }
}

/* Селектор длиннее, чем .item-card img в base.css: иначе миниатюры растягиваются на мобильных */
.item-card .item-card-gallery img {
    width: 64px;
    height: 64px;
    max-width: none;
    margin: 0;
    object-fit: contain;
    border: 1px solid #e0e0e0;
    cursor: pointer;
}

/* Модели двигателей в карточке идут строкой, а не столбцом, как остальные ссылки блока */
.item-card-usage .item-card-engines a {
    display: inline;
    margin: 0;
}

/* Описание приходит от завода одним куском, в шаблоне оно разбито на абзацы по предложениям.
   Свернуто до 6 строк, разворачивается стрелкой; селектор длиннее .item-card-usage div, иначе блок получит его фон */
.item-card-usage div.item-card-description {
    position: relative;
    /* 6 строк текста плюс отступы между абзацами */
    max-height: calc(9em + 16px);
    max-height: calc(6lh + 16px);
    margin: 16px 0 0;
    padding: 0;
    overflow: hidden;
    line-height: 1.5;
}

.item-card-usage div.item-card-description p {
    margin: 0 0 8px;
    text-align: left;
}

/* Затухание последней строки подсказывает, что текст обрезан */
.item-card-usage div.item-card-description::after {
    content: '';
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 1em;
    background: linear-gradient(rgba(237, 242, 247, 0), #edf2f7);
}

.description-more {
    display: block;
    margin: 0 0 16px;
    color: #075095;
    font-size: 22px;
    text-align: center;
    cursor: pointer;
}

.description-more i {
    display: inline-block;
    transform: rotate(-90deg);
    transition: transform 0.15s ease-out;
}

.description-more-toggle:checked + .item-card-description {
    max-height: none;
}

.description-more-toggle:checked + .item-card-description::after,
.item-card-usage div.item-card-description-short::after,
.item-card-description-short + .description-more {
    display: none;
}

.item-card-usage div.item-card-description-short {
    margin-bottom: 8px;
}

.description-more-toggle:checked ~ .description-more i {
    transform: rotate(90deg);
}

/* Логотип бренда в строке «Производитель»: селектор длиннее .item-card img, иначе он растягивается как фото */
.item-card .item-card-props .item-card-brand-logo {
    display: block;
    width: auto;
    height: 20px;
    max-width: 120px;
    margin: 0 0 4px auto;
    border: none;
}

/* Карточки марок на главной: светлые, строки категорий слева, количество бейджем справа.
   Сетку раскладки дает .index-browser-inner из base.css, здесь только сама карточка */
.maker-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-top: 3px solid #1d5f9e;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(31, 42, 54, 0.12);
    overflow: hidden;
}

.maker-card-head {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 110px;
    padding: 16px 24px 8px;
    text-decoration: none;
}

.maker-card-head img {
    max-width: 100%;
    max-height: 72px;
}

.maker-card-name {
    font-size: 2.6rem;
    font-weight: 600;
    color: #384450;
    letter-spacing: 0.02em;
    text-align: center;
}

.maker-card-total {
    margin: 0 0 8px;
    text-align: center;
    font-size: 1.4rem;
    color: #6b7a8c;
}

.maker-card-list {
    flex-grow: 1;
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid #e3e9ef;
}

.maker-card-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 20px;
    border-bottom: 1px solid #eef2f6;
    color: #1f2a36;
    font-size: 1.5rem;
    line-height: 1.3;
    text-align: left;
    text-decoration: none;
    transition: background 0.1s ease-out;
}

.maker-card-list a:hover {
    background: #eef4fa;
    color: #1d5f9e;
}

.maker-card-count {
    flex-shrink: 0;
    min-width: 32px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #eef2f6;
    color: #384450;
    font-size: 1.3rem;
    text-align: center;
}

.maker-card-all {
    padding: 12px 20px;
    color: #1d5f9e;
    font-size: 1.4rem;
    text-align: right;
    text-decoration: none;
}

.maker-card-all:hover {
    text-decoration: underline;
}

/* Каталог: остальные марки скрыты, пока не нажали «Еще марки» */
.category-more-toggle:not(:checked) + .category-makers .category-makers-extra,
.category-more-toggle:not(:checked) + .category-makers .category-more-hide,
.category-more-toggle:checked + .category-makers .category-more-show {
    display: none;
}

.items .categories .category-more label {
    display: block;
    margin: 0 0 4px;
    padding: 14px 20px;
    background: #fff;
    color: #1d5f9e;
    font-size: 1.5rem;
    text-align: right;
    cursor: pointer;
    box-shadow: -1px -1px 2px 0 rgba(0, 0, 0, 0.09), 2px 2px 1px -2px rgba(0, 0, 0, 0.09), 2px 2px 1px 0 rgba(0, 0, 0, 0.1);
}

.items .categories .category-more label:hover {
    text-decoration: underline;
}

/* Плитки категорий на десктопе: ширина по тексту, подпись в одну строку, лишние плитки уходят в следующий ряд.
   В base.css ширина подписи ограничена 110px под короткие названия классов v1 */
@media (min-width: 992px) {
    .items .category-classes {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 4px;
    }

    .items .category-classes li {
        margin: 0;
    }

    .items .category-classes li a {
        height: 100%;
    }

    .items .category-classes li a span {
        max-width: none;
        padding-right: 16px;
        white-space: nowrap;
    }

    .items .category-classes li a i {
        font-size: 24px;
        margin: 12px 12px 12px 14px;
    }
}

/* Плитки категорий на планшете и телефоне: в v1 у классов были разные иконки и подписи скрывались,
   у категорий завода иконки одинаковые, поэтому подписи нужны. Лента прокручивается вбок */
@media (max-width: 991px) {
    .items .category-classes {
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .items .category-classes li {
        flex-shrink: 0;
    }

    .items .category-classes li a span {
        display: inline;
        max-width: none;
        padding-right: 14px;
        white-space: nowrap;
    }

    .items .category-classes li a i {
        font-size: 22px;
        margin: 10px 10px 10px 12px;
    }
}

/* Марки на телефоне: компактные чипы в несколько строк вместо столбца на весь экран */
@media (max-width: 767px) {
    .items .categories > .category-group > .category-makers {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin-bottom: 6px;
    }

    .items .categories > .category-group > .category-makers a {
        margin: 0;
        padding: 0 14px;
    }

    .items .categories > .category-group > .category-makers a div {
        display: none;
    }

    .items .categories > .category-group > .category-makers a span {
        line-height: 36px;
    }

    .items .categories > .category-group > .category-makers a.category-makers-current {
        background: #075095;
        color: #fff;
    }

    .items .categories > .category-group > .category-makers a.category-makers-current:after,
    .items .categories > .category-group > .category-makers a:hover:after {
        display: none;
    }

    .items .categories .category-more label {
        margin: 0;
        padding: 0 14px;
        line-height: 36px;
    }
}

/* Хлебные крошки в одну строку: длинные звенья обрезаются многоточием, полное название во всплывающей подсказке.
   Без этого длинный путь до товара переносился по словам и вылезал из полосы шапки */
#header-bottom .breadcrumbs {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}

/* Ссылка на главную не сжимается: иначе она уже значка дома, и первая стрелка наезжает на него */
#header-bottom .breadcrumbs > a:first-child {
    flex-shrink: 0;
    min-width: auto;
}

/* Промежуточные звенья не сжимаются (длинные ограничены шириной ссылки), сжимается последнее: название товара */
#header-bottom .breadcrumbs > span {
    flex: 0 0 auto;
}

#header-bottom .breadcrumbs > span:last-child {
    flex: 1 1 auto;
    min-width: 100px;
}

#header-bottom .breadcrumbs a {
    min-width: 0;
    max-width: 160px;
}

#header-bottom .breadcrumbs .breadcrumbs-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 1199px) {
    #header-bottom .breadcrumbs a {
        max-width: 110px;
    }
}

/* Карточка товара: характеристики шире за счет фото, иначе артикул и значения переносятся по слогам */
@media (min-width: 1200px) {
    .item-card {
        grid-template-columns: 300px 380px auto;
    }
}

@media (min-width: 992px) and (max-width: 1199px) {
    .item-card {
        grid-template-columns: 260px 360px auto;
    }
}

/* Фото с галереей в одной обертке, чтобы миниатюры стояли сразу под фото, а не под всей строкой сетки.
   На узких экранах обертка прозрачна для сетки: фото и галерею раскладывают правила base.css */
.item-card-media {
    display: contents;
}

/* Правая колонка (описание, применяемость) растет вниз через строки 2-4, а цена стоит строкой 3
   сразу под характеристиками. Строка 4 гибкая: высоту правой колонки забирает она, а не строки 2-3 */
@media (min-width: 992px) {
    .item-card {
        grid-template-rows: auto auto auto 1fr auto;
        row-gap: 24px;
    }

    .item-card .item-card-media {
        display: block;
        grid-row: 2 / 4;
        grid-column: 1;
    }

    .item-card .item-card-usage {
        grid-row: 2 / 5;
    }

    .item-card .item-card-kit {
        grid-row: 5;
    }

    /* В колонку характеристик три кнопки в ряд не помещаются: цена и наличие строкой, «Подробнее» под ними */
    .item-card .item-card-actions {
        grid-row: 3;
        grid-column: 2;
        grid-template-columns: 1fr 1fr;
        grid-template-areas: 'price instock' 'buy buy';
        gap: 8px;
        align-self: start;
        margin: 0;
    }

    .item-card .item-card-actions span {
        height: 44px;
        border-radius: 5px;
    }

    .item-card .item-card-actions span.item-card-actions-price {
        grid-area: price;
    }

    .item-card .item-card-actions span.item-card-actions-instock {
        grid-area: instock;
        gap: 6px;
    }

    .item-card .item-card-actions span.item-card-actions-buy {
        grid-area: buy;
    }

    /* Растягивание кнопки на всю тройку из base.css в этой раскладке ломает ряд */
    .item-card .item-card-actions span.item-card-actions-buy:hover {
        width: auto;
        padding: 2px 0;
        transform: none;
        background: #174d80;
    }

    .item-card .item-card-usage {
        grid-row: 2 / 5;
    }

    .item-card .item-card-kit {
        grid-row: 5;
    }
}

.item-card .item-card-props li i {
    font-size: 40px;
}

/* base.css ставит каждый ряд в одну ячейку (строка 2), и «Аналоги» с соседним рядом накладываются друг на друга.
   Без явной строки ряды встают в колонке по очереди */
.item .item-related {
    grid-row: auto;
}

/* Ряды «Аналоги» и «Другие детали каталога»: карточки одной высоты, фото и цена на одном уровне во всех карточках.
   Колонок столько, сколько карточек base.css оставляет на этой ширине, чтобы одна карточка не растягивалась */
.item .item-related > .item-related-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
}

@media (max-width: 1199px) {
    .item .item-related > .item-related-row {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 991px) {
    .item .item-related > .item-related-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .item .item-related > .item-related-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* display у ссылок не задается: им base.css скрывает лишние карточки на узких экранах */
.item .item-related > .item-related-row > a {
    text-decoration: none;
}

.item .item-related h2 {
    font-size: 2.6rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.item .item-related .item-related-card {
    box-sizing: border-box;
    height: 100%;
    min-width: 0;
    justify-content: flex-start;
}

.item .item-related .item-related-card img {
    width: 100%;
    height: 180px;
    max-height: none;
    margin: 12px 0;
}

/* Категория одной строкой и тише названия: в ряду она обычно у всех одна и та же */
.item .item-related .item-related-card p:first-child {
    height: auto;
    overflow: hidden;
    color: #6b7a8c;
    font-size: 1.3rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Название до трех строк, чтобы длинные названия не растягивали карточку. Обрезка на span внутри абзаца:
   overflow абзаца режет по краю его отступа, и из-под многоточия выглядывала четвертая строка */
.item .item-related .item-related-card p:last-child {
    font-size: 1.5rem;
    font-weight: 500;
    line-height: 1.4;
}

/* Селектор длиннее .item-related-card span:last-child из base.css: там цвет и отступы для цены */
.item .item-related .item-related-card .item-related-name {
    display: -webkit-box;
    padding: 0;
    color: inherit;
    font-weight: inherit;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

/* Окно заявки на звонок (React-виджет Callback). В base.css шапка окна на сетке с жесткой высотой строк:
   длинное название вылезает из строки, а фото на все три строки наезжает на цену и наличие.
   Здесь строки по содержимому: название и фото сверху, цена и наличие на всю ширину под ними */
.overlay .overlay-callback {
    box-sizing: border-box;
    width: calc(100% - 32px);
    max-width: 440px;
    height: auto;
    max-height: calc(100% - 32px);
}

.overlay .overlay-callback-context {
    box-sizing: border-box;
    max-height: 100%;
    margin: 0;
    padding: 24px;
    overflow-y: auto;
}

.overlay .overlay-callback-context-item {
    grid-template-columns: minmax(0, 1fr) 96px;
    grid-template-rows: auto auto auto;
    column-gap: 16px;
    justify-items: stretch;
    align-items: start;
}

.overlay .overlay-callback-context-item h2 {
    display: -webkit-box;
    grid-row: 1;
    grid-column: 1;
    align-self: center;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    font-size: 2rem;
    font-weight: 400;
    line-height: 1.3;
}

.overlay .overlay-callback-context-item img {
    box-sizing: border-box;
    grid-row: 1;
    grid-column: 2;
    width: 96px;
    height: 96px;
    object-fit: contain;
}

.overlay .overlay-callback-context-item p:nth-child(2),
.overlay .overlay-callback-context-item p:nth-child(3) {
    box-sizing: border-box;
    grid-column: 1 / 3;
    align-self: stretch;
    margin: 0;
    padding: 10px 0;
    font-size: 1.6rem;
}

.overlay .overlay-callback-context-item p:nth-child(2) {
    margin-top: 16px;
    border-top: 1px solid #c3c3c3;
}

.overlay .overlay-callback-context-item p span {
    padding: 0;
}

.overlay .overlay-callback-context-form p {
    margin: 20px 0 12px;
    font-size: 1.5rem;
}

/* Поля и кнопка во всю ширину, как строки цены и наличия над ними */
.overlay .overlay-callback-context-form div input {
    box-sizing: border-box;
    width: 100%;
    margin: 5px 0;
}

.overlay .overlay-callback-context-form div i {
    right: 16px;
}

.overlay .overlay-callback-context-form-button {
    margin: 5px 0;
}

/* Страница «О нашей продукции»: раздел на каждую верхнюю категорию каталога.
   Сверху фото и ссылки на все подкатегории с товарами, ниже блоки подкатегорий с описанием из админки */
.classes .overview-section {
    grid-column: 2;
    padding: 24px 32px 32px;
    background: #fff;
    box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.09), 3px 3px 1px -2px rgba(0, 0, 0, 0.09), 0 1px 5px 0 rgba(0, 0, 0, 0.1);
}

.overview-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid gainsboro;
}

.overview-head h2 {
    margin: 0;
    font-size: 2.6rem;
    font-weight: 400;
}

.overview-head h2 a {
    color: #1f2a36;
    text-decoration: none;
}

.overview-head h2 a:hover {
    color: #1d5f9e;
}

.overview-all {
    flex-shrink: 0;
    color: #1d5f9e;
    font-size: 1.5rem;
    text-decoration: none;
    white-space: nowrap;
}

.overview-all i {
    margin-left: 6px;
    font-size: 1rem;
}

.overview-all:hover {
    text-decoration: underline;
}

.overview-intro,
.overview-feature {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 32px;
    align-items: start;
    margin-top: 24px;
}

.overview-intro img,
.overview-feature img {
    width: 100%;
    height: 220px;
    object-fit: contain;
}

/* Без картинки текст и ссылки занимают всю ширину раздела */
.overview-intro > div:only-child,
.overview-feature > div:only-child {
    grid-column: 1 / -1;
}

.overview-feature {
    padding-top: 24px;
    border-top: 1px solid #eef2f6;
}

.overview-feature h3 {
    margin: 0 0 12px;
    font-size: 2rem;
    font-weight: 400;
}

.overview-feature h3 a {
    color: #1f2a36;
    text-decoration: none;
}

.overview-feature h3 a:hover {
    color: #1d5f9e;
}

.overview-about {
    margin: 0 0 16px;
    font-size: 1.5rem;
    line-height: 1.6;
}

.overview-links-title {
    margin: 0 0 10px;
    color: #6b7a8c;
    font-size: 1.4rem;
}

.overview-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.overview-links a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 4px;
    background: #eef2f6;
    color: #1f2a36;
    font-size: 1.4rem;
    text-decoration: none;
    transition: background 0.1s ease-out;
}

.overview-links a:hover {
    background: #dde7f1;
    color: #1d5f9e;
}

.overview-links a span {
    padding: 1px 7px;
    border-radius: 10px;
    background: #fff;
    color: #6b7a8c;
    font-size: 1.2rem;
}

@media (max-width: 767px) {
    .classes .overview-section {
        padding: 20px 16px 24px;
    }

    .overview-head {
        flex-direction: column;
        gap: 4px;
    }

    .overview-intro,
    .overview-feature {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .overview-intro img,
    .overview-feature img {
        height: 180px;
    }
}
