/* E2-C: листинг каталога v2 по Figma «Каталог + PDP» (брейкпоинты 1920 / 640 / 320; планшет 1024/768 собран от 640 и 1920).
   Подключается расширением sp.catalog (Local\Project\Ui\CatalogList::boot) только при sp_e2_list = canary / new. Цвета, обводки, шрифты - токены
   (закрытая палитра: #6667AB, #F4F4FF / #F6F6F9, розовый цен). Радиусы - факт Figma: плитка подраздела 8, поле сортировки 8, номера страниц full.
   Фильтр (боковая колонка, панель на телефоне) - прежний, здесь не стилизуется (E2-D). */

/* ---- шапка страницы: H1 и крошки (Figma: крошки 14 px с «•», на 640 и 320 - «‹ Главная»; H1 24 / 32 / 40) ---- */
.sp-cl-head {
    margin-bottom: 16px;
}

.sp-cl-head .catalog-new__title {
    margin-bottom: 16px;
    font-size: 24px;
    line-height: 28px;
    font-weight: 600;
    letter-spacing: 0;
}

@media (min-width: 640px) {
    .sp-cl-head .catalog-new__title {
        font-size: 32px;
        line-height: 36px;
        margin-bottom: 24px;
    }
}

@media (min-width: 1280px) {
    .sp-cl-head .catalog-new__title {
        font-size: 40px;
        line-height: 48px;
        margin-bottom: 24px;
    }

    .sp-cl-head {
        margin-bottom: 24px;
    }

    /* без быстрых тегов (оборудование): от H1 до плиток 40 px, как в Figma */
    .sp-cl-head:not(:has(.catalog-new__head-tags)) {
        margin-bottom: 16px;
    }
}

/* ---- плитки подразделов ---- */
.sp-cl__subs {
    margin-bottom: 24px;
}

.sp-cl__subs-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sp-cl__subs-item,
.sp-cl__subs-more {
    min-width: 0;
    margin: 0;
}

.sp-cl__sub {
    position: relative;
    display: block;
    box-sizing: border-box;
    height: 110px;
    padding: 8px 6px;
    overflow: hidden;
    border-radius: 8px;
    background: var(--main-light-blue);
    color: var(--text-black);
    text-decoration: none;
}

.sp-cl__sub:hover,
.sp-cl__sub.is-active {
    box-shadow: inset 0 0 0 1px var(--main-blue);
}

.sp-cl__sub:focus-visible,
.sp-cl__more:focus-visible {
    outline: 2px solid var(--stroke-focused);
    outline-offset: 2px;
}

.sp-cl__sub-name {
    position: relative;
    display: block;
    font-size: 10px;
    line-height: 12px;
    font-weight: 600;
    text-transform: uppercase;
    overflow-wrap: anywhere;
    hyphens: auto;
}

/* фото вытекает за правый и нижний край плитки (Figma) */
.sp-cl__sub-photo {
    position: absolute;
    right: -10px;
    bottom: -10px;
    width: 85%;
    height: 66%;
    background-repeat: no-repeat;
    background-position: right bottom;
    background-size: contain;
}

.sp-cl__more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-sizing: border-box;
    height: 110px;
    padding: 8px;
    border: 1px solid var(--main-blue);
    border-radius: 4px;
    background: var(--bg-white);
    color: var(--main-blue);
    font-size: 10px;
    line-height: 12px;
    font-weight: 600;
    text-transform: uppercase;
    text-align: center;
    text-decoration: none;
}

.sp-cl__more::after {
    content: '';
    flex: none;
    width: 16px;
    height: 16px;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8h10M9 4l4 4-4 4'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8h10M9 4l4 4-4 4'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* свернуто: на 320/390 5 плиток + «Все категории», на 640 - 8 + «Все категории», на 1024+ - 9 + «Все категории»; ссылки остаются в HTML */
.sp-cl__subs.is-collapsed:not(.is-open) .sp-cl__subs-item:nth-child(n + 6) {
    display: none;
}

.sp-cl__subs.is-open .sp-cl__subs-more {
    display: none;
}

@media (min-width: 640px) {
    .sp-cl__subs-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .sp-cl__sub,
    .sp-cl__more {
        height: 150px;
    }

    .sp-cl__sub {
        padding: 12px;
    }

    .sp-cl__sub-name,
    .sp-cl__more {
        font-size: 12px;
        line-height: 14px;
    }

    .sp-cl__subs.is-collapsed:not(.is-open) .sp-cl__subs-item:nth-child(n + 6) {
        display: block;
    }

    .sp-cl__subs.is-collapsed:not(.is-open) .sp-cl__subs-item:nth-child(n + 9) {
        display: none;
    }
}

@media (min-width: 1024px) {
    .sp-cl__subs-list {
        grid-template-columns: repeat(var(--sp-subs-cols, 5), minmax(0, 1fr));
    }

    .sp-cl__sub,
    .sp-cl__more {
        height: 180px;
    }

    .sp-cl__sub {
        padding: 16px;
    }

    .sp-cl__subs.is-collapsed:not(.is-open) .sp-cl__subs-item:nth-child(n + 9) {
        display: block;
    }

    .sp-cl__subs.is-collapsed:not(.is-open) .sp-cl__subs-item:nth-child(n + 10) {
        display: none;
    }
}

@media (min-width: 1280px) {
    .sp-cl__subs {
        margin-bottom: 36px;
    }
}

/* ---- панель: сортировка, вид, «Фильтры» ---- */
.sp-cl__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 16px;
}

.sp-cl__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.sp-cl__sort {
    position: relative;
    min-width: 0;
}

.sp-cl__sort::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 0;
    width: 10px;
    height: 6px;
    margin-top: -3px;
    pointer-events: none;
    background-color: var(--text-black);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0h10L5 6z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0h10L5 6z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.sp-cl__sort-select {
    -webkit-appearance: none;
    appearance: none;
    max-width: 100%;
    height: 32px;
    padding: 0 20px 0 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-black);
    font: inherit;
    font-size: 16px;
    line-height: 24px;
    cursor: pointer;
}

.sp-cl__sort-select:focus-visible {
    outline: 2px solid var(--stroke-focused);
    outline-offset: 2px;
}

.sp-cl__tools {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sp-cl__views {
    display: flex;
    gap: 8px;
}

.sp-cl__view {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    background-color: var(--text-gray);
    cursor: pointer;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
}

.sp-cl__view.is-active {
    background-color: var(--text-black);
}

.sp-cl__view:hover:not(.is-active) {
    background-color: var(--main-blue);
}

.sp-cl__view:focus-visible {
    outline: 2px solid var(--stroke-focused);
    outline-offset: 2px;
}

.sp-cl__view--plate {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.6'%3E%3Crect x='3' y='3' width='7.5' height='7.5' rx='1.5'/%3E%3Crect x='13.5' y='3' width='7.5' height='7.5' rx='1.5'/%3E%3Crect x='3' y='13.5' width='7.5' height='7.5' rx='1.5'/%3E%3Crect x='13.5' y='13.5' width='7.5' height='7.5' rx='1.5'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.6'%3E%3Crect x='3' y='3' width='7.5' height='7.5' rx='1.5'/%3E%3Crect x='13.5' y='3' width='7.5' height='7.5' rx='1.5'/%3E%3Crect x='3' y='13.5' width='7.5' height='7.5' rx='1.5'/%3E%3Crect x='13.5' y='13.5' width='7.5' height='7.5' rx='1.5'/%3E%3C/svg%3E");
}

.sp-cl__view--list {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.6' stroke-linecap='round'%3E%3Crect x='3' y='3.5' width='4.5' height='4.5' rx='1'/%3E%3Cpath d='M11 5.8h10'/%3E%3Crect x='3' y='9.75' width='4.5' height='4.5' rx='1'/%3E%3Cpath d='M11 12h10'/%3E%3Crect x='3' y='16' width='4.5' height='4.5' rx='1'/%3E%3Cpath d='M11 18.2h10'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.6' stroke-linecap='round'%3E%3Crect x='3' y='3.5' width='4.5' height='4.5' rx='1'/%3E%3Cpath d='M11 5.8h10'/%3E%3Crect x='3' y='9.75' width='4.5' height='4.5' rx='1'/%3E%3Cpath d='M11 12h10'/%3E%3Crect x='3' y='16' width='4.5' height='4.5' rx='1'/%3E%3Cpath d='M11 18.2h10'/%3E%3C/svg%3E");
}

/* кнопка «Фильтры» - прежняя (панель текущего фильтра), на компьютере её скрывает стиль фильтра; здесь только выравнивание */
.sp-cl__bar .sp-cl__filter {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-black);
    font-size: 16px;
    line-height: 24px;
}

.sp-cl__filter-text {
    display: none;
}

@media (min-width: 640px) {
    .sp-cl__filter-text {
        display: block;
    }
}

@media (min-width: 1280px) {
    .sp-cl__bar .sp-cl__filter {
        display: none;
    }
}

@media (min-width: 1024px) {
    .sp-cl__bar {
        margin-bottom: 24px;
    }

    /* Figma 1920: поле сортировки 282 x 48, обводка, радиус 8, шеврон справа */
    .sp-cl__sort {
        width: 282px;
        max-width: 100%;
    }

    .sp-cl__sort::after {
        right: 20px;
    }

    .sp-cl__sort-select {
        width: 100%;
        height: 48px;
        padding: 0 44px 0 20px;
        border: 1px solid var(--stroke-gray-light);
        border-radius: 8px;
        background: var(--bg-white);
        color: var(--dark-gray-2);
    }

    .sp-cl__sort-select:hover {
        border-color: var(--field-stroke-hover);
    }
}

/* ---- сетка списка ---- */
.sp-cl__list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.sp-cl__list--list {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
}

.sp-cl__item {
    min-width: 0;
}

.sp-cl__empty {
    grid-column: 1 / -1;
    margin: 0;
    padding: 48px 0;
    color: var(--text-dark-gray);
    text-align: center;
}

@media (min-width: 640px) {
    .sp-cl__list--plate {
        gap: 24px;
    }
}

@media (min-width: 1024px) {
    .sp-cl__list--plate {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ---- постраничная навигация ---- */
.sp-pg {
    margin: 32px 0;
}

.sp-pg__list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sp-pg__li {
    margin: 0;
}

.sp-pg__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--text-black);
    font-size: 14px;
    line-height: 20px;
    font-weight: 600;
    text-decoration: none;
}

.sp-pg__link:hover {
    border-color: var(--main-blue);
    color: var(--main-blue);
}

.sp-pg__link:focus-visible {
    outline: 2px solid var(--stroke-focused);
    outline-offset: 2px;
}

.sp-pg__item.is-current {
    background: var(--btn-violet-default);
    color: var(--text-white);
}

.sp-pg__item--prev,
.sp-pg__item--next {
    border-color: var(--stroke-gray-light);
}

.sp-pg__item.is-disabled {
    color: var(--text-gray);
}

/* до 640 «Назад» / «Вперёд» - стрелки (текст остаётся для чтения с экрана) */
@media (max-width: 639px) {
    .sp-pg__txt {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .sp-pg__item--prev,
    .sp-pg__item--next {
        min-width: 40px;
        padding: 0;
    }

    .sp-pg__item--prev::before,
    .sp-pg__item--next::before {
        content: '';
        width: 16px;
        height: 16px;
        background-color: currentColor;
        -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 3 5 8l5 5'/%3E%3C/svg%3E") center / contain no-repeat;
        mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 3 5 8l5 5'/%3E%3C/svg%3E") center / contain no-repeat;
    }

    .sp-pg__item--next::before {
        transform: scaleX(-1);
    }
}
