/* Исправления адаптивности (SRV-15). Подключается в header.php шаблона после style-media.css.
 * Откат: убрать строку подключения в header.php (бэкап header.php.bak_fixes). */

/* 1. Карточка товара на телефоне/планшете: правая колонка шире экрана —
 *    flex-basis 100% + padding 19px при box-sizing: content-box (стр. 409px при экране 375px). */
@media (max-width: 990px) {
    .pcg-right {
        box-sizing: border-box;
        min-width: 0;
        max-width: 100%;
    }
    /* Галерея карточки на телефоне/планшете: слайдер 650px при фото 500px давал пустую полосу.
     * Фото товаров 3:4 — слайдер по высоте фото, фото во всю ширину. */
    .product-slider-mobile,
    .product-slider-mobile .swiper-slide {
        height: auto !important;
    }
    /* селектор весомее, чем .product-detail-page .product-slider-slide img в style-media.css */
    .product-slider.product-slider-mobile .swiper-slide img {
        width: 100%;
        height: auto !important;
        aspect-ratio: 3 / 4;
        object-fit: cover !important;
        display: block;
    }
    /* «Купить в один клик»: в style.css жёсткая ширина 351px + padding 10px */
    .payOneClick {
        width: 100%;
        box-sizing: border-box;
    }
}
/* 2. Лента категорий на телефоне/планшете: без полосы прокрутки, справа затухание и «›»,
 *    пока есть что листать (класс is-end ставит bstil-fixes.js, когда долистали до конца). */
@media (max-width: 990px) {
    .catalog-line-filter { position: relative; }
    /* затухание с обеих сторон: слева — только когда ленту сдвинули (is-start снимается), справа — пока не дошли до конца */
    .catalog-line-filter { --fl: 40px; --fr: 56px; }
    .catalog-line-filter.is-start { --fl: 0px; }
    .catalog-line-filter.is-end { --fr: 0px; }
    .catalog-line-filter-group {
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fl), #000 calc(100% - var(--fr)), transparent 100%);
        mask-image: linear-gradient(to right, transparent 0, #000 var(--fl), #000 calc(100% - var(--fr)), transparent 100%);
    }
    .catalog-line-filter-group::-webkit-scrollbar { display: none; }
    /* лента во всю ширину экрана (была по ширине блока карточек): отступ 20px только у первой/последней категории */
    .catalog-line-filter { padding-left: 0 !important; padding-right: 0 !important; }
    /* «Стиль» в логотипе упирался в низ шапки (сверху у .header-group 10px, снизу 0) — на всех страницах */
    .header-group { padding-bottom: 8px; }
    .catalog-line-filter-group { box-sizing: border-box; padding-left: 20px; padding-right: 20px; }
    .catalog-line-filter::after {
        content: '\203A';
        position: absolute; right: 0; top: 50%; transform: translateY(-50%);
        font: 26px/1 Inter, sans-serif; color: #999;
        pointer-events: none; transition: opacity .2s ease;
    }
    .catalog-line-filter.is-end::after { opacity: 0; }
}

/* Главная: блок «Магазины» width 100% + padding 10px — страница была шире экрана (395 при 375).
 * Панель поиска (90% + padding) при content-box уезжала за левый край — как мобильное меню. */
.shops-page, .search-panel { box-sizing: border-box; }

/* /auth/ регистрация на телефоне: кнопка «Получить код» (158px, стили в атрибуте style) закрывала
 * подсказку «+7 (999) 999-99-99» — кнопка компактнее, поле освобождает под неё меньше места */
@media (max-width: 480px) {
    #reg-phone-send { width: 105px !important; font-size: 13px !important; }
    #register-phone { padding-right: 113px !important; }
}

/* Баннер cookie на телефоне: был столбиком с gap 50px (style-media.css) — 161px высоты при 375.
 * Текст слева, «Принять» справа в одну строку — 85px. */
@media (max-width: 750px) {
    .cookie-banner { flex-direction: row !important; gap: 12px !important; padding: 10px 14px !important; text-align: left !important; }
    .cookie-banner__text { font-size: 12px; line-height: 1.35; }
    .cookie-banner button { padding: 8px 14px; font-size: 13px; flex: 0 0 auto; }
}

/* 4. Поиск (bstil_search.js): подсказки с фото и ценой под полем; старый список подсказок шаблона скрыт */
.search-input-group { position: relative; }
.search-input-group .search-suggest { display: none !important; }
.bss-list {
    display: none; position: absolute; left: 0; right: 0; top: 100%; z-index: 50;
    margin-top: 6px; max-height: 70vh; overflow-y: auto;
    background: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.08);
}
.bss-list.is-open { display: block; }
.bss-item {
    display: flex; align-items: center; gap: 12px; padding: 8px 12px;
    font: 14px/1.3 "Inter", sans-serif; color: #414141; text-decoration: none;
}
.bss-item:hover { background: #f5f3ef; }
.bss-item img, .bss-noimg { flex: 0 0 42px; width: 42px; height: 56px; object-fit: cover; background: #f1eee8; }
.bss-name { flex: 1; min-width: 0; }
.bss-price { white-space: nowrap; }
.bss-all, .bss-empty { display: block; padding: 12px; border-top: 1px solid #eee; font: 14px/1.4 "Inter", sans-serif; color: #414141; }
.bss-all { text-decoration: underline; text-underline-offset: 3px; }
.bss-empty a { color: #414141; text-decoration: underline; }

/* 5. «Также рекомендуем» на странице товара (catalog.element/bootstrap_v4, bstilRecommend) */
.bsr-wrap { position: relative; padding-bottom: 48px; } /* отступ под ценой до подвала */
.bsr-slider { overflow: hidden; }
.bsr-slider .swiper-slide { height: auto !important; } /* в style.css у всех слайдов height: 80vh !important */
.bsr-card { display: flex; flex-direction: column; gap: 6px; color: #414141; text-decoration: none; font-family: "Inter", sans-serif; }
.bsr-img { display: block; aspect-ratio: 3 / 4; overflow: hidden; background: #f1eee8; }
.bsr-img img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.bsr-card:hover .bsr-img img { transform: scale(1.03); }
.bsr-name { margin-top: 6px; font-size: 15px; line-height: 1.3; }
.bsr-price { font-size: 16px; font-weight: 500; }
.bsr-nav {
    position: absolute; top: 38%; z-index: 5; width: 42px; height: 42px; padding: 0;
    border: 0; border-radius: 50%; background: rgba(255,255,255,.92); box-shadow: 0 2px 10px rgba(0,0,0,.12);
    color: #414141; font-size: 28px; line-height: 40px; cursor: pointer;
}
.bsr-prev { left: -14px; }
.bsr-next { right: -14px; }
.bsr-nav.swiper-button-disabled { opacity: 0; pointer-events: none; }
@media (max-width: 990px) {
    .bsr-nav { display: none; }
    .bsr-wrap { padding-bottom: 32px; }
    .bsr-name { font-size: 13px; }
    .bsr-price { font-size: 14px; }
}
/* служебные подсказки для экранных чтецов («Всего товаров: 4») — стиль Bootstrap, которого на сайте нет */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* 6. Карусель на главной: вместо тёмной плашки на пол-слайда — подпись внизу на мягком затемнении (вариант А).
 * ПК: заголовок + «Смотреть» слева внизу, круглые стрелки справа внизу. Телефон: без стрелок, точки (bstil-fixes.js), листать пальцем. */
.swiper-akcii-predlozhen .swiper-akcii-predlozhen-slide,
.swiper-akcii-predlozhen-mobile .swiper-akcii-predlozhen-slide { position: relative; }
.swiper-akcii-predlozhen .swiper-akcii-predlozhen-slide::after,
.swiper-akcii-predlozhen-mobile .swiper-akcii-predlozhen-slide::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 50%; z-index: 1; pointer-events: none;
    background: linear-gradient(to top, rgba(0,0,0,.55), rgba(0,0,0,0));
}
.swiper-akcii-predlozhen .akg-slide-content,
.swiper-akcii-predlozhen-mobile .akg-slide-content {
    position: absolute !important; z-index: 2; left: 48px !important; right: 48px !important; bottom: 40px !important; top: auto !important;
    width: auto !important; height: auto !important; max-width: none !important; margin: 0 !important; padding: 0 !important;
    background: none !important; border-radius: 0 !important;
}
.swiper-akcii-predlozhen .akg-slide-title,
.swiper-akcii-predlozhen-mobile .akg-slide-title { max-width: 560px; margin: 0 0 18px !important; font-size: 34px !important; line-height: 1.15 !important; color: #fff !important; }
.swiper-akcii-predlozhen .akg-slider-button-catalog,
.swiper-akcii-predlozhen-mobile .akg-slider-button-catalog { width: auto !important; padding: 10px 30px !important; font-size: 14px !important; letter-spacing: .5px; }
/* стрелки внутри слайдов уезжали вместе с картинкой — вместо них одна пара поверх слайдера (bstil-fixes.js) */
.swiper-akcii-predlozhen .akg-nav-buttons { display: none !important; }
.bs-slider-nav { position: absolute; right: 48px; bottom: 40px; z-index: 5; display: flex; gap: 10px; }
.bs-slider-nav button {
    display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; padding: 0;
    border: 1px solid rgba(255,255,255,.8); border-radius: 50%; background: rgba(0,0,0,.15);
    color: #fff; font-size: 18px; line-height: 1; cursor: pointer; transition: background .2s;
}
.bs-slider-nav button:hover { background: rgba(0,0,0,.35); }
@media (max-width: 990px) { .bs-slider-nav { display: none; } }
.bs-slider-dots { position: absolute; left: 0; right: 0; bottom: 12px; z-index: 3; display: flex; justify-content: center; gap: 8px; pointer-events: none; }
.bs-slider-dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.5); transition: background .2s; }
.bs-slider-dots i.is-active { background: #fff; }
@media (max-width: 990px) {
    .swiper-akcii-predlozhen-mobile .akg-slide-content { left: 16px !important; right: 16px !important; bottom: 34px !important; }
    .swiper-akcii-predlozhen-mobile .akg-slide-title { margin-bottom: 12px !important; font-size: 21px !important; }
    .swiper-akcii-predlozhen-mobile .akg-slider-button-catalog { padding: 8px 22px !important; font-size: 13px !important; }
    .akg-nav-buttons-mob { display: none !important; }
}

/* 7. Магазины (/shops/ и блок на главной): нечётный последний магазин в сетке 2 колонки — по центру, той же ширины */
@media (min-width: 769px) {
    .shops-grid > .shop-card:last-child:nth-child(odd) { grid-column: 1 / -1; justify-self: center; box-sizing: border-box; width: calc((100% - 30px) / 2); }
}
@media (min-width: 769px) and (max-width: 1024px) {
    .shops-grid > .shop-card:last-child:nth-child(odd) { width: calc((100% - 20px) / 2); } /* gap 20px в style.css */
}

/* Лента категорий на ПК: шрифт крупнее (было 14px) */
@media (min-width: 991px) {
    .catalog-line-filter-group { font-size: 16px; }
    /* на странице товара у ленты не было боковых отступов — прилипала к краю окна, а фото с отступом 40px */
    .product-detail-page .catalog-line-filter { padding-left: 40px; padding-right: 40px; }
}

/* 3. Меню (include/bstil_menu.php): мобильное — «Каталог» раскрывается списком категорий, аккаунт по входу, контакты */
/* панель 95% + padding 20px при content-box вылезала за левый край экрана */
.mobile-menu { justify-content: flex-start !important; overflow-y: auto; box-sizing: border-box; }
.bsm { display: flex; flex-direction: column; gap: 18px; margin-top: 20px; padding-bottom: 30px; }
.bsm-link {
    font-family: "Inter", sans-serif; font-weight: 400; font-size: 18px; line-height: 1.5; color: #414141;
    text-decoration: none; background: none; border: 0; padding: 0; text-align: left; cursor: pointer;
}
.bsm-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.bsm-chevron { transition: transform .2s ease; }
.bsm-group.is-open .bsm-chevron { transform: rotate(180deg); }
.bsm-sub { display: none; flex-direction: column; gap: 12px; margin-top: 12px; padding: 2px 0 2px 16px; border-left: 1px solid #e5e2dc; }
.bsm-group.is-open .bsm-sub { display: flex; }
.bsm-sublink { font-family: "Inter", sans-serif; font-size: 16px; line-height: 1.4; color: #777; text-decoration: none; }
.bsm-sublink.is-current { color: #414141; text-decoration: underline; text-underline-offset: 3px; }
.bsm-sep { height: 1px; background: #ece9e3; }
.bsm-count { display: inline-block; min-width: 20px; margin-left: 8px; padding: 0 6px; border-radius: 10px; background: #414141; color: #fff; font-size: 12px; line-height: 20px; text-align: center; }
.bsm-muted { color: #999; }
.bsm-auth { display: flex; align-items: center; gap: 8px; }
.bsm-slash { color: #bbb; }
.bsm-contacts { display: flex; flex-direction: column; gap: 10px; }
.bsm-phone { font-family: "Inter", sans-serif; font-size: 16px; color: #414141; text-decoration: none; }
.bsm-social { display: flex; gap: 20px; margin-top: 6px; }

/* ПК: выпадающий список категорий у «Каталог» (шаблон menu/header-menu-desktop) */
.hn-drop { position: relative; display: inline-flex; }
.hn-drop-panel {
    position: absolute; top: 100%; left: -20px; z-index: 30;
    display: none; flex-direction: column; gap: 10px; min-width: 230px;
    margin-top: 0; padding: 18px 20px; background: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.08);
}
.hn-drop::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 12px; } /* мостик, чтобы панель не закрывалась при переводе мыши */
.hn-drop:hover .hn-drop-panel, .hn-drop:focus-within .hn-drop-panel { display: flex; }
.hn-drop-panel .hn-drop-link { font-family: "Inter", sans-serif; font-size: 15px; line-height: 1.3; color: #414141; text-decoration: none; white-space: nowrap; }
/* подчёркивание — только анимированная линия шапки (.header-nav a::after), без подчёркивания текста */
.hn-drop-panel .hn-drop-link.is-current { color: #d4af37; }
.hn-drop-panel .hn-drop-link.is-current::after { width: 100%; }

/* Планшет: фото 3:4 во всю ширину выше экрана — ограничиваем высоту и центрируем */
@media (min-width: 600px) and (max-width: 990px) {
    .product-slider.product-slider-mobile .swiper-slide img {
        width: auto;
        max-width: 100%;
        height: 70vh !important;
        margin: 0 auto;
    }
}
