/* ==========================================================================
   mr-66.ru — фиксы мобильной вёрстки (Rubik Media)
   Тема: The7 3.9.x. Всё внутри @media (max-width: 991px) — тот же брейкпоинт,
   на котором The7 включает мобильный липкий хедер. Десктоп не затрагивается.
   Правки только визуальные, тема и functions.php не трогаются.
   ========================================================================== */

@media (max-width: 991px) {

  /* Якорные переходы не должны прятать цель под липкий хедер */
  html { scroll-padding-top: 108px; }

  /* --------------------------------------------------------------------------
     1. ЗАГОЛОВОК СТРАНИЦЫ НЕ УХОДИТ ПОД ЛИПКИЙ ХЕДЕР.
        Причина бага: The7 компенсирует фиксированный мобильный хедер правилом
        `@media (max-width:991px){ .page-title { padding-top: 90px } }`, но
        реальная высота хедера ~125px → h1 налезал на хедер (первые 5-15px под ним).
        Поднимаем распорку до высоты хедера + воздух.
     -------------------------------------------------------------------------- */
  .page-title { padding-top: 96px !important; }

  /* Заголовок и хлебные крошки — по левому краю (было по центру); h1 — жирный */
  .page-title,
  .page-title .wf-wrap,
  .page-title .wf-table,
  .page-title .wf-td,
  .page-title .hgroup,
  .page-title .subtitle {
    text-align: left !important;
  }
  .page-title h1,
  h1.entry-title {
    font-weight: 700 !important;
  }

  /* Хлебные крошки: без серой плашки-подложки, по левому краю */
  .page-title .breadcrumbs,
  .breadcrumbs.text-small,
  .breadcrumbs {
    background: transparent !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    text-align: left !important;
  }
  .breadcrumbs > span,
  .breadcrumbs .breadcrumb_last,
  .breadcrumbs .current {
    background: transparent !important;
  }

  /* --------------------------------------------------------------------------
     2. Компактнее двухэтажный липкий хедер (~125px = ~19% экрана).
        Ужимаем только вертикальные отступы серой полосы (телефон/город) и
        логотипа — без изменения самих элементов.
     -------------------------------------------------------------------------- */
  .masthead > .top-bar.solid-bg {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
  }
  .masthead .mobtop > .top-bar.solid-bg {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
  }
  .mobile-branding > a {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
  }
  .mobile-branding img,
  .mobile-branding svg {
    max-height: 44px !important;
    width: auto !important;
  }

  /* --------------------------------------------------------------------------
     3. Тап-таргеты >= 44px (Apple HIG 44 / Material 48 / WCAG 2.5.8).
     -------------------------------------------------------------------------- */

  /* бургер (был 22px по высоте) */
  .mobile-navigation .dt-mobile-menu-icon {
    min-width: 44px;
    min-height: 44px;
    padding: 10px !important;
    box-sizing: border-box;
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  /* иконка «Избранное» в мобильной шапке (была 30px) */
  .mobile-header-bar .wishlist_products_counter,
  .mobile-header-bar .top_wishlist-heart {
    min-height: 44px;
    min-width: 40px;
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  /* ссылки в списках каталога/фильтра (подкатегории были ~30px) */
  .l-content .sidebar li > a,
  .l-content .widget_product_categories li > a,
  .l-content .product-categories li > a,
  .wpc-filters-ul-list li label,
  .wpc-term-name,
  .l-content .dt-fancy-list li > a,
  .l-content .wpb_widgetised_column li > a {
    display: block;
    padding-top: 9px !important;
    padding-bottom: 9px !important;
  }

  /* кнопка открытия фильтров WPC */
  .wpc-filters-open-button-container .wpc-filters-open-button,
  .wpc-filters-button-text {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* --------------------------------------------------------------------------
     4. Мобильное меню всегда поверх сторонних виджетов.
        Bitrix24 button z-index ~10150, LeadBack (ldiv.lb-*) ~2147483646 —
        меню The7 (z 9602) уходило под них. Поднимаем меню на максимум.
     -------------------------------------------------------------------------- */
  .dt-mobile-header,
  .dt-mobile-header .mobile-header-scrollbar-wrap,
  .dt-mobile-header .mobile-mini-widgets,
  .dt-mobile-header-bg,
  .mobile-menu-icon.active,
  .dt-mobile-menu-icon.active {
    z-index: 2147483647 !important;
  }

  /* --------------------------------------------------------------------------
     5. Плавающие кнопки виджетов не накладываются друг на друга.
        Bitrix24 сидит в правом нижнем углу — поднимаем LeadBack над ним.
     -------------------------------------------------------------------------- */
  ldiv.lb-button__wrapper,
  .lb-button__wrapper,
  .lb-button {
    bottom: 150px !important;
  }

  /* Проактивный поп-ап чата Bitrix24 («Ксения…») перекрывает контент/меню.
     Правильно выключается в кабинете Bitrix24 (виджет → приглашение в чат) —
     доступа к кабинету нет. Раскомментировать, если нужно скрыть его на мобиле
     средствами сайта (кнопка чата остаётся, скрывается только авто-поп-ап): */
  /* .b24-widget-button-popup,
  .b24-widget-button-popup-wrapper { display: none !important; } */

  /* --------------------------------------------------------------------------
     6. Cookie-плашка (.warning) — узкой полосой снизу во всю ширину,
        а не плавающей карточкой на пол-экрана.
     -------------------------------------------------------------------------- */
  .warning.warning--active {
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    inset: auto 0 0 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    padding: 12px 16px 14px !important;
    max-height: 50vh !important;
    overflow-y: auto !important;
    box-shadow: 0 -2px 14px rgba(0, 0, 0, .18) !important;
  }
  .warning.warning--active .warning__text {
    font-size: 12px !important;
    line-height: 1.35 !important;
    margin: 0 0 10px !important;
  }
  .warning.warning--active .warning__apply {
    min-height: 44px !important;
    margin: 0 !important;
  }

  /* --------------------------------------------------------------------------
     7. Читаемость основного текста: The7 ставит 15px, местами 13px.
        Поднимаем абзацы контента до 16px.
     -------------------------------------------------------------------------- */
  .l-content .entry-content,
  .l-content .wpb_text_column,
  .l-content .entry-content p,
  .l-content .wpb_text_column p,
  article .post-content p {
    font-size: 16px;
  }
}

/* Keep the single mobile bar and the phone/city row visible on narrow screens. */
@media (max-width: 991px) {
  .term-description > table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Old cached scripts may still create two bars; the last has one menu handler. */
  .masthead > .mobile-header-bar:has(~ .mobile-header-bar) { display: none !important; }
}
@media (max-width: 767px) {
  .masthead > .mobile-header-bar { display: flex !important; }
  .masthead .top-bar .telmob { flex: 0 0 auto; white-space: nowrap; }
  .masthead .top-bar .telfilials { min-width: 0; margin-left: 10px; }
  .masthead .top-bar .telfilials .gorod-link { max-width: 100%; display: block; }
  .masthead .top-bar .telfilials .gorod { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 480px) {
  .masthead .top-bar .telmob a,
  .masthead .top-bar .telfilials .gorod { font-size: 14px; }
}

/* --------------------------------------------------------------------------
   8. Плашка выбора города (.selectc в .mobtop, гео-подсказка).
      Была absolute с left:-39px и z-index:10: на телефоне уезжала под липкий
      хедер (fixed, z-index:101) и налезала на логотип и H1, на планшете левый
      край уходил за экран, а кнопки «Да» и «Выбрать город» не помещались в
      207px и ломались в три строки. Делаем карточку под хедером во всю ширину,
      кнопки в один ряд, тап-таргеты 44px. Экземпляр в выезжающем меню
      (.mobile-mini-widgets-in-menu) не трогаем.
   -------------------------------------------------------------------------- */
@media (max-width: 991px) {
  html .mobtop .selectc {
    position: fixed !important;
    top: 111px !important;          /* липкий хедер 101px + отступ */
    left: 12px !important;
    right: 12px !important;
    bottom: auto !important;
    width: auto !important;
    max-width: 360px !important;
    box-sizing: border-box !important;
    margin: 0 auto !important;
    z-index: 102 !important;        /* выше липкого хедера */
    padding: 14px 16px 18px !important;
    border-radius: 6px !important;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .18) !important;
    font-size: 16px !important;
    line-height: 1.35 !important;
  }
  html .mobtop .selectc .closex {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
    text-align: center !important;
    font-size: 18px !important;
    color: #888 !important;
  }
  html .mobtop .selectc .btns {
    display: flex !important;
    gap: 10px !important;
    margin-top: 14px !important;
  }
  html .mobtop .selectc .btns > a {
    flex: 1 1 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 44px !important;
    margin: 0 !important;
    padding: 8px 10px !important;
    white-space: nowrap !important;
    font-size: 15px !important;
  }
}
