/*
 * Липкая панель покупки в карточке товара, раскладка v2: блок товара
 * растягивается, количество, цена и кнопка прижаты вправо, иконки
 * «Избранное» и «Поделиться». Разметка — views/product/_body.php,
 * поведение — web/js/product-sticky-bar.js (в бандле —
 * web/src/js/components/product-sticky-bar.js). Базовые стили панели
 * собираются из web/src/scss/components/_product.scss.
 *
 * Файл подключает сам _body.php, поэтому раскладка одна и на витрине,
 * и в личном кабинете. Раньше блок жил в custom.css, которого нет в ЛК,
 * и там панель оставалась в старой раскладке, прижатой влево.
 */
.product__sticky-bar {
    padding: 12px 0 !important;
}

.product__sticky-bar-content {
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 24px !important;
}

.product__sticky-bar-product {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 260px;
    gap: 14px;
}

.product__sticky-bar-img {
    width: 64px !important;
    height: 64px !important;
    min-width: 64px;
}

.product__sticky-bar-info {
    order: initial !important;
    flex: 1 1 auto !important;
    min-width: 0;
}

.product__sticky-bar-title {
    margin: 0;
    font-size: 15px !important;
    line-height: 1.35 !important;
    -webkit-line-clamp: 2 !important;
}

.product__sticky-bar-article {
    margin-top: 4px;
    color: var(--color-gray);
    font-size: 13px;
    line-height: 1.35;
}

.product__sticky-bar-actions {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end;
    flex: 0 0 auto !important;
    gap: 16px !important;
}

.product__sticky-bar-availability {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 14px;
    line-height: 1.3;
    white-space: nowrap;
}

.product__sticky-bar-tools {
    display: flex;
    align-items: center;
    gap: 4px;
}

.product__sticky-bar-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    padding: 4px !important;
    border-radius: 5px;
    text-decoration: none;
}

.product__sticky-bar-tool img {
    width: 24px;
    height: 24px;
    opacity: .66;
    transition: opacity .2s ease, transform .2s ease;
}

.product__sticky-bar-tool:hover img,
.product__sticky-bar-tool:focus-visible img {
    opacity: 1;
    transform: scale(1.08);
}

/* Вид иконок задаёт .cart-tool-btn из custom.css — класс общий с корзиной
   витрины, поэтому он остаётся там, а для панели значения повторены здесь:
   в ЛК custom.css нет, и «Поделиться» выглядела системной кнопкой. */
.product__sticky-bar-tool {
    border: 0;
    background: transparent;
    color: #aaa8b8;
    cursor: pointer;
    font-size: 25px;
    line-height: 1;
}

.product__sticky-bar-tool:hover {
    color: var(--color-primary);
}

/* Сердечко избранного: серое — товара нет в избранном, фирменный цвет —
   есть (как активные сердечки в каталоге). Иконка inline-SVG с currentColor,
   чтобы цвет задавался классом. */
.product__sticky-bar-tool--favorite svg {
    width: 24px;
    height: 24px;
    opacity: .66;
    transition: opacity .2s ease, transform .2s ease;
}

.product__sticky-bar-tool--favorite:hover svg,
.product__sticky-bar-tool--favorite:focus-visible svg,
.product__sticky-bar-tool--favorite.is-active svg {
    opacity: 1;
}

.product__sticky-bar-tool--favorite:hover svg,
.product__sticky-bar-tool--favorite:focus-visible svg {
    transform: scale(1.08);
}

.product__sticky-bar-tool--favorite.is-active {
    color: var(--color-primary);
}

/* На сенсорных экранах :hover «залипает» после касания, и снятое сердечко
   оставалось бы фирменного цвета, будто товар ещё в избранном. */
@media (hover: none) {
    .product__sticky-bar-tool--favorite:not(.is-active):hover {
        color: #aaa8b8;
    }

    .product__sticky-bar-tool--favorite:not(.is-active):hover svg {
        opacity: .66;
        transform: none;
    }

    /* Сердечки карточек в слайдере под карточкой товара (views/partials/_favorite_heart.php). */
    .product-card__favorive[data-product-favorite]:not(.active):hover {
        background-color: var(--color-pink);
    }
}

.product__sticky-bar-tool--favorite[aria-busy="true"] {
    pointer-events: none;
    opacity: .6;
}

.product__sticky-bar-tool .cart-tool-btn__share {
    display: inline-block;
    transform: rotate(0deg);
    font-weight: 600;
}

.product__sticky-bar-price {
    min-width: 105px !important;
    font-size: 22px !important;
    text-align: right;
}

.product__sticky-bar-price span {
    font-size: 17px !important;
}

.product__sticky-bar-cart {
    min-width: 132px;
}

@media (max-width: 1280px) {
    .product__sticky-bar-content {
        gap: 14px !important;
    }

    .product__sticky-bar-actions {
        gap: 10px !important;
    }

    .product__sticky-bar-product {
        min-width: 220px;
    }
}

@media (max-width: 1024px) {
    .product__sticky-bar-content {
        flex-wrap: wrap !important;
    }

    .product__sticky-bar-product {
        flex: 1 1 420px;
    }

    .product__sticky-bar-actions {
        flex: 1 1 100% !important;
        justify-content: flex-end;
    }
}


/* Мобильная раскладка. Раньше панель разворачивалась на четыре строки и
   вместе с липкой шапкой занимала почти половину экрана (390×844: шапка
   132px + панель 257px = 46% высоты). Теперь строки две: «товар + иконки»
   и «покупка», панель — около 100px.
   Из панели убраны артикул и цена за штуку: и то, и другое видно в самой
   карточке, а в панели это две лишние строки.
   Вложенность важна: .product__sticky-bar-availability и -tools лежат
   внутри -info, а не в -actions (см. views/product/_body.php), поэтому
   вторую колонку строки задаёт грид на -info. Прежние правила расставляли
   их как ячейки грида -actions и ни на что не влияли.
   Условие по высоте — для телефона в альбомной ориентации: там ширина 844px,
   раскладка бралась планшетная (четыре строки, 214px) и вместе с шапкой
   закрывала 89% экрана высотой 390px. */
@media (max-width: 700px), (max-height: 520px) {
    .product__sticky-bar {
        padding: 8px 0 !important;
    }

    .product__sticky-bar-content {
        gap: 8px !important;
    }

    .product__sticky-bar-product {
        flex-basis: 100%;
        min-width: 0;
        align-items: center;
        gap: 10px;
    }

    .product__sticky-bar-img {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px;
    }

    .product__sticky-bar-info {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "title tools"
            "availability tools";
        align-items: center;
        column-gap: 8px;
        row-gap: 0 !important;
    }

    .product__sticky-bar-title {
        grid-area: title;
        font-size: 14px !important;
        line-height: 1.3 !important;
        -webkit-line-clamp: 1 !important;
    }

    .product__sticky-bar-article,
    .product__sticky-bar-price-unit {
        display: none !important;
    }

    .product__sticky-bar-availability {
        grid-area: availability;
        margin: 0;
        font-size: 12px;
        line-height: 1.3;
    }

    .product__sticky-bar-tools {
        grid-area: tools;
        gap: 0;
    }

    .product__sticky-bar-tool {
        flex: 0 0 34px;
        width: 34px;
        height: 34px;
    }

    .product__sticky-bar-tool img,
    .product__sticky-bar-tool--favorite svg {
        width: 20px;
        height: 20px;
    }

    .product__sticky-bar-actions {
        display: flex !important;
        flex-wrap: wrap;
        align-items: center;
        width: 100%;
        gap: 8px !important;
    }

    .product__sticky-bar-quantity-box {
        flex: 0 0 auto;
    }

    .product__sticky-bar-actions .quantity {
        gap: 4px;
    }

    .product__sticky-bar-actions .quantity__btn {
        height: 38px;
        padding: 6px 8px;
        font-size: 20px;
    }

    .product__sticky-bar-actions .quantity__input {
        width: 46px;
        height: 38px;
        font-size: 15px;
    }

    .product__sticky-bar-price-box {
        flex: 0 1 auto;
        min-width: 0;
    }

    .product__sticky-bar-price {
        min-width: 0 !important;
        font-size: 18px !important;
        line-height: 1.2 !important;
    }

    .product__sticky-bar-price span {
        font-size: 14px !important;
    }

    .product__sticky-bar-cart {
        flex: 1 1 110px;
        min-width: 0;
        width: auto;
        height: 38px !important;
        padding: 0 10px !important;
        font-size: 14px !important;
    }

    /* «Уведомить о наличии» длиннее «В корзину» и рядом с количеством не
       помещается — этой кнопке отдаём отдельную строку. */
    .product__sticky-bar-cart.product-card__buy--request {
        flex: 1 1 100%;
    }
}

/* Узкие экраны (360px и меньше): без этого количество, цена и кнопка не
   помещаются в одну строку и кнопка переносится, возвращая панели третью
   строку. */
@media (max-width: 374px) {
    .product__sticky-bar-actions .quantity__btn {
        padding: 6px 4px;
    }

    .product__sticky-bar-actions .quantity__input {
        width: 40px;
    }

    .product__sticky-bar-cart {
        flex-basis: 96px;
        padding: 0 8px !important;
        font-size: 13px !important;
    }
}

/* Низкий, но широкий экран (телефон лёжа): места по горизонтали хватает —
   собираем панель в одну строку. */
@media (min-width: 701px) and (max-height: 520px) {
    .product__sticky-bar-content {
        flex-wrap: nowrap !important;
    }

    .product__sticky-bar-product {
        flex: 1 1 auto;
        flex-basis: auto;
    }

    .product__sticky-bar-actions {
        flex: 0 0 auto !important;
        width: auto;
    }

    .product__sticky-bar-cart {
        flex: 0 0 auto;
        min-width: 132px;
    }
}
