/* ===================================================================
   МОБИЛЬНЫЙ СЛОЙ — Deep Blue Tech.
   Все правила здесь ДВАЖДЫ изолированы от десктопа:
   1) @media (max-width: 767px) — работает только на узких экранах;
   2) html.is-mobile — класс добавляется только из mobile.js, когда
      applyMobileEnhancements() определила мобильный режим.
   Если оба условия не выполняются одновременно — ни одно правило
   из этого файла не применяется, и десктопная вёрстка (styles.css)
   остаётся полностью нетронутой.
   =================================================================== */

@media (max-width: 767px) {
  html.is-mobile {
    --header-height: 64px;
    --category-height: 52px;

    --m-navy: #14283E;
    --m-blue: #2678D9;
    --m-bg: #F3F7FB;
    --m-card: #FFFFFF;
    --m-text: #152333;
    --m-text-muted: #64748B;
    --m-success: #16A34A;
  }

  html.is-mobile body {
    background-color: var(--m-bg);
  }

  html.is-mobile,
  html.is-mobile body {
    overflow-x: hidden;
  }

  /* ========================= Мобильная шапка ========================= */

  html.is-mobile .m-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--m-navy);
    z-index: 100;
  }

  html.is-mobile .m-header-logo {
    display: flex;
    align-items: center;
    height: 70%;
    padding: 4px 10px;
    background-color: #ffffff;
    border-radius: 10px;
  }

  html.is-mobile .m-header-logo img {
    height: 100%;
    width: auto;
    object-fit: contain;
  }

  html.is-mobile .m-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  html.is-mobile .m-header-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
  }

  html.is-mobile .m-header-icon-btn:active {
    background-color: rgba(255, 255, 255, 0.18);
  }

  html.is-mobile .m-header-icon-btn svg {
    width: 20px;
    height: 20px;
  }

  /* ========================= Выезжающее меню ========================= */

  html.is-mobile .m-drawer-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(10, 16, 26, 0.5);
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  html.is-mobile .m-drawer-overlay--open {
    opacity: 1;
    pointer-events: auto;
  }

  html.is-mobile .m-drawer {
    position: absolute;
    top: 0;
    right: 0;
    width: min(84vw, 320px);
    height: 100%;
    background-color: #ffffff;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.15);
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.22s ease;
  }

  html.is-mobile .m-drawer-overlay--open .m-drawer {
    transform: translateX(0);
  }

  html.is-mobile .m-drawer-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  html.is-mobile .m-drawer-logo {
    height: 32px;
    width: auto;
    object-fit: contain;
  }

  html.is-mobile .m-drawer-top .m-header-icon-btn {
    background-color: var(--m-bg);
    color: var(--m-navy);
  }

  html.is-mobile .m-drawer-links {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
  }

  html.is-mobile .m-drawer-link {
    padding: 14px 4px;
    font-size: 16px;
    font-weight: 600;
    color: var(--m-text);
    border-bottom: 1px solid var(--border-color);
  }

  html.is-mobile .m-drawer-link:active {
    color: var(--m-blue);
  }

  html.is-mobile .m-drawer-bottom {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  html.is-mobile .m-drawer-contact-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--m-text-muted);
  }

  html.is-mobile .m-drawer-contact-row svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--m-blue);
  }

  html.is-mobile .m-drawer-contact-row:active {
    color: var(--m-blue);
  }

  html.is-mobile .m-drawer-contact-row--phone {
    font-size: 16px;
    font-weight: 700;
    color: var(--m-navy);
  }

  html.is-mobile .m-drawer-contact-row--phone svg {
    color: var(--m-navy);
  }

  html.is-mobile .m-drawer-schedule {
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
  }

  html.is-mobile .m-drawer-schedule-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--m-text);
  }

  html.is-mobile .m-drawer-schedule-title svg {
    width: 15px;
    height: 15px;
    color: var(--m-blue);
  }

  html.is-mobile .m-drawer-schedule-row {
    margin-top: 6px;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--m-text-muted);
  }

  html.is-mobile .m-drawer-schedule-note {
    margin-top: 6px;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--m-text-muted);
  }

  /* ===================== Главный экран — эмблема ===================== */

  html.is-mobile .m-hero {
    margin-top: var(--header-height);
    padding: 28px 20px 24px;
    text-align: center;
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
  }

  html.is-mobile .m-hero-emblem {
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
    padding: 16px;
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 20px;
  }

  html.is-mobile .m-hero-emblem img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
  }

  html.is-mobile .m-hero-caption {
    margin-top: 18px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--m-text);
  }

  /* Минималистичный указатель «Каталог» вместо прежней залитой кнопки —
     просто подпись и два лёгких шеврона вниз без фона и рамки. */
  html.is-mobile .m-hero-pointer {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin: 18px auto 0;
    padding: 6px 10px;
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
  }

  html.is-mobile .m-hero-pointer-label {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--m-blue);
  }

  html.is-mobile .m-hero-pointer-arrows {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 2px;
  }

  html.is-mobile .m-hero-pointer-chevron {
    width: 18px;
    height: 18px;
    margin-top: -6px;
    color: var(--m-blue);
    animation: mHeroPointerBounce 1.5s ease-in-out infinite;
  }

  html.is-mobile .m-hero-pointer-chevron:first-child {
    margin-top: 0;
    opacity: 0.55;
  }

  html.is-mobile .m-hero-pointer-chevron:last-child {
    animation-delay: 0.15s;
  }

  html.is-mobile .m-hero-pointer:active .m-hero-pointer-chevron {
    color: var(--m-navy);
  }

  @keyframes mHeroPointerBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(4px); }
  }

  /* ===================== Сетки категорий и товаров ===================== */

  html.is-mobile .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 0 16px;
  }

  html.is-mobile .category-card {
    width: 100%;
    min-width: 0;
    padding: 14px;
    border-radius: 20px;
    position: relative;
  }

  html.is-mobile .card-image-placeholder {
    min-width: 0;
  }

  html.is-mobile .card-title {
    width: 100%;
    min-width: 0;
    overflow-wrap: break-word;
  }

  html.is-mobile .category-card::after {
    content: "→";
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--m-blue);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }

  html.is-mobile .category-card:active {
    transform: scale(0.98);
    border-color: var(--m-blue);
  }

  html.is-mobile .card-title {
    font-size: 15px;
  }

  html.is-mobile .main-content {
    padding-left: 0;
    padding-right: 0;
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  html.is-mobile .main-content--after-hero {
    padding-top: 24px;
  }

  /* Товарные сетки (категории) — две карточки в ряд, без десктопных смещений */

  html.is-mobile .product-grid {
    padding: 0 16px;
    gap: 14px;
    justify-content: flex-start;
  }

  html.is-mobile .product-card {
    flex: 0 0 calc(50% - 7px);
    border-radius: 20px;
    margin-left: 0 !important;
  }

  html.is-mobile .product-card:active {
    transform: scale(0.98);
  }

  html.is-mobile .product-name {
    font-size: 13px;
    min-height: 2.6em;
  }

  html.is-mobile .product-price {
    font-size: 16px;
  }

  html.is-mobile .card-overlay-button {
    display: none;
  }

  /* ===================== Панель категорий (чипсы) ===================== */

  html.is-mobile .category-bar-inner {
    overflow-x: auto;
    justify-content: flex-start;
    gap: 8px;
    padding: 0 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  html.is-mobile .category-bar-inner::-webkit-scrollbar {
    display: none;
  }

  html.is-mobile .category-btn {
    flex: 0 0 auto;
    height: 38px;
    padding: 0 16px;
    border-radius: 19px;
    font-size: 13px;
    background-color: #ffffff;
  }

  html.is-mobile .category-btn.active {
    background-color: var(--m-blue);
    border-color: var(--m-blue);
  }

  html.is-mobile .category-page-top {
    padding: 0 16px;
  }

  html.is-mobile .category-page-title {
    padding: 0 16px;
    font-size: 22px;
  }

  /* ===================== Подробная страница товара ===================== */

  html.is-mobile .product-page-content {
    flex-direction: column;
    padding: 0 16px;
    gap: 20px;
  }

  html.is-mobile .product-page-image,
  html.is-mobile .product-page-info {
    flex-basis: auto;
    max-width: 100%;
    width: 100%;
  }

  html.is-mobile .product-page-image .product-image-placeholder {
    border-radius: 20px;
  }

  html.is-mobile .product-page-title {
    font-size: 22px;
  }

  html.is-mobile .product-contact-actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
  }

  html.is-mobile .product-action-btn {
    flex: 1 1 140px;
    height: auto;
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 11px 14px;
    font-size: 13px;
    line-height: 1.25;
    border-radius: 14px;
  }

  html.is-mobile .product-action-btn:active {
    transform: scale(0.98);
  }

  /* ===================== Яндекс Карта ===================== */

  html.is-mobile .map-section {
    padding: 36px 16px;
  }

  html.is-mobile .map-frame-wrap {
    height: 280px;
    border-radius: 18px;
  }

  /* ===================== Footer ===================== */

  html.is-mobile .footer-inner {
    grid-template-columns: 1fr;
    gap: 28px;
    padding: 36px 20px 24px;
  }

  html.is-mobile .footer-col:last-child {
    margin-top: 8px;
    text-align: center;
  }

  html.is-mobile .footer-col:last-child .footer-col-title {
    display: block;
  }

  html.is-mobile .footer-col:last-child .footer-messengers {
    justify-content: center;
    align-items: stretch;
  }

  html.is-mobile .footer-col:last-child .footer-messenger {
    flex: 0 1 auto;
    justify-content: center;
    height: 44px;
  }

  html.is-mobile .site-footer {
    background-color: var(--m-navy);
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }

  html.is-mobile .footer-bottom {
    padding-bottom: 16px;
  }

  /* ===================== Информационные страницы ===================== */

  html.is-mobile .delivery-page {
    padding: 0 16px;
  }

  html.is-mobile .delivery-title {
    font-size: 24px;
  }

  html.is-mobile .delivery-steps,
  html.is-mobile .contacts-cards {
    grid-template-columns: 1fr;
  }

  html.is-mobile .requisites-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  /* Блок «Остались вопросы по доставке?» — кнопка открывает Bottom Sheet
     звонка, полный номер показан отдельной строкой под ней. */

  html.is-mobile .delivery-contact .m-delivery-call-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 6px;
    padding: 13px 28px;
    min-height: 46px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    background-color: var(--m-blue);
    border: none;
    border-radius: 14px;
    cursor: pointer;
  }

  html.is-mobile .delivery-contact .m-delivery-call-btn:active {
    transform: scale(0.98);
  }

  html.is-mobile .delivery-contact .m-delivery-call-phone {
    margin-top: 10px;
    font-size: 16px;
    font-weight: 700;
    color: var(--m-navy);
    word-break: keep-all;
  }

  html.is-mobile .contact-schedule-block {
    flex-direction: column;
  }

  html.is-mobile .page-bottom-back {
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  /* ===================== Нижняя плавающая навигация ===================== */

  html.is-mobile .m-bottom-nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    background-color: #ffffff;
    border-radius: 22px;
    box-shadow: 0 10px 30px rgba(20, 40, 62, 0.18);
    padding: 6px;
    z-index: 200;
  }

  html.is-mobile .m-bottom-nav-item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 2px;
    border-radius: 16px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    color: var(--m-text-muted);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
  }

  html.is-mobile .m-bottom-nav-item svg {
    width: 20px;
    height: 20px;
  }

  html.is-mobile .m-bottom-nav-item--active {
    background-color: rgba(38, 120, 217, 0.12);
    color: var(--m-blue);
  }

  /* ===================== Bottom Sheet ===================== */

  html.is-mobile .sheet-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(10, 16, 26, 0.5);
    z-index: 1000;
    opacity: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: opacity 0.22s ease;
  }

  html.is-mobile .sheet-overlay--open {
    opacity: 1;
  }

  html.is-mobile .sheet-box {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 12px 24px calc(24px + env(safe-area-inset-bottom));
    background-color: #ffffff;
    border-radius: 24px 24px 0 0;
    transform: translateY(100%);
    transition: transform 0.24s ease;
  }

  html.is-mobile .sheet-overlay--open .sheet-box {
    transform: translateY(0);
  }

  html.is-mobile .sheet-handle {
    width: 40px;
    height: 4px;
    margin: 4px auto 14px;
    border-radius: 2px;
    background-color: var(--border-color);
  }

  html.is-mobile .sheet-close {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
    color: var(--m-text-muted);
    background: var(--m-bg);
    border: none;
    border-radius: 50%;
    cursor: pointer;
  }

  html.is-mobile .sheet-content .modal-btn {
    height: 50px;
  }
}

/* prefers-reduced-motion: отключаем декоративные transition/transform,
   оставляя функциональность (открытие/закрытие) мгновенным. */
@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
  html.is-mobile * {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}
