/* ==========================================================================
   «Наш Город» — мобильный слой в духе iOS-приложения (09.09.2026)
   Нижний таб-бар, модалки-шторки снизу, меню-шторка, фильтры в шторке,
   полупрозрачная шапка, тач-отклик, safe-area. Подключается после ng-compat.css.
   ========================================================================== */

:root {
    --ng-tabbar-h: 56px;
    --ng-sheet-radius: 18px;   /* единственное место со скруглением: шторки на мобилке, как в iOS */
    --ng-ease-ios: cubic-bezier(.32, .72, 0, 1);
}

* { -webkit-tap-highlight-color: transparent; }

/* ---------- нижний таб-бар ---------- */
.ng-tabbar { display: none; }

@media (max-width: 767.98px) {
    body { padding-bottom: calc(var(--ng-tabbar-h) + env(safe-area-inset-bottom, 0px)); }

    .ng-tabbar {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 1035;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        height: calc(var(--ng-tabbar-h) + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: rgba(255, 255, 255, .9);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        backdrop-filter: saturate(180%) blur(20px);
        border-top: 1px solid rgba(0, 0, 0, .08);
    }
    .ng-tabbar a,
    .ng-tabbar button {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        border: 0;
        background: none;
        padding: 6px 0 4px;
        font-family: var(--ng-body);
        font-size: 10px;
        line-height: 12px;
        font-weight: 500;
        letter-spacing: .1px;
        color: var(--ng-muted-2, #6B7280);
        cursor: pointer;
        -webkit-user-select: none;
        user-select: none;
        transition: color .2s, transform .15s;
    }
    .ng-tabbar .ng-ico { width: 24px; height: 24px; transition: transform .25s var(--ng-ease-ios); }
    .ng-tabbar a.is-active,
    .ng-tabbar button.is-active { color: var(--ng-red); }
    .ng-tabbar a.is-active .ng-ico { transform: translateY(-1px) scale(1.08); }
    .ng-tabbar a:active .ng-ico,
    .ng-tabbar button:active .ng-ico { transform: scale(.86); }
    .ng-tabbar__badge {
        position: absolute;
        top: 3px;
        left: calc(50% + 6px);
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        border-radius: 8px;
        background: var(--ng-red);
        color: #fff;
        font-size: 10px;
        line-height: 16px;
        font-weight: 700;
        text-align: center;
    }
    .ng-tabbar__badge:empty,
    .ng-tabbar__badge[data-zero="1"] { display: none; }

    /* шапка как iOS navigation bar: полупрозрачная с блюром, бургер не нужен — есть таб «Меню» */
    .ng-header {
        background: rgba(255, 255, 255, .86);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        backdrop-filter: saturate(180%) blur(20px);
    }
    .ng-burger { display: none !important; }

    /* плавающая трубка и рейл — над таб-баром */
    .ng-rail { bottom: calc(var(--ng-tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px); right: 12px; }
    .ng-rail__toggle { width: 50px; height: 50px; }

    /* iOS зумит страницу при фокусе в поле со шрифтом < 16px */
    .ng-field,
    .ng-form__control,
    .ng-sel .ts-control,
    .ng-sel .ts-control > input,
    .ng-sel .ts-control > .item,
    .ng-range__panel input,
    textarea { font-size: 16px !important; }

    /* ---------- все модалки Bootstrap — шторки снизу ---------- */
    .modal.fade { opacity: 1; transition: visibility .42s; } /* длительность читает Bootstrap для transitionend */
    .modal .modal-dialog,
    .modal.fade .modal-dialog {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        width: 100%;
        max-width: none;
        margin: 0;
        display: block;
        min-height: 0;
        transform: translateY(100%);
        transition: transform .42s var(--ng-ease-ios);
        will-change: transform;
    }
    .modal.show .modal-dialog { transform: translateY(0); }
    .modal .modal-dialog.is-dragging { transition: none; }
    .modal-content,
    .modal-content.ng-modal,
    .ng-modal .modal-content {
        display: flex;
        flex-direction: column;
        border: 0;
        border-top: 0;
        border-radius: var(--ng-sheet-radius) var(--ng-sheet-radius) 0 0;
        max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-shadow: 0 -12px 40px rgba(0, 0, 0, .18);
        overflow: hidden;
    }
    .modal-content::before {
        content: '';
        flex: none;
        width: 38px;
        height: 5px;
        margin: 8px auto 2px;
        border-radius: 3px;
        background: #D1D5DB;
    }
    .modal-header { padding: 10px 20px 14px; border-bottom: 1px solid var(--ng-line); }
    .modal-title { font-size: 17px; }
    .modal-body { padding: 16px 20px 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
    .ng-modal .modal-body { padding: 16px 20px 24px; }
    .modal-footer { padding: 12px 20px; gap: 8px; }
    .modal-footer .ng-btn { flex: 1 1 auto; }
    .modal-backdrop { background: #000; }
    .modal-backdrop.show { opacity: .45; }

    /* ---------- меню (бывший дровер) — шторка снизу со списком как в iOS ---------- */
    .ng-drawer {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: calc(100dvh - 48px - env(safe-area-inset-top, 0px));
        padding: 0 0 calc(env(safe-area-inset-bottom, 0px) + 12px);
        border-radius: var(--ng-sheet-radius) var(--ng-sheet-radius) 0 0;
        box-shadow: 0 -12px 40px rgba(0, 0, 0, .18);
        transform: translateY(100%);
        transition: transform .42s var(--ng-ease-ios);
        z-index: 1041;
    }
    .ng-drawer.is-open { transform: translateY(0); }
    .ng-drawer::before {
        content: '';
        display: block;
        width: 38px;
        height: 5px;
        margin: 8px auto 6px;
        border-radius: 3px;
        background: #D1D5DB;
    }
    .ng-drawer__nav { padding: 0 16px; }
    .ng-drawer__nav a {
        position: relative;
        padding: 15px 36px 15px 16px;
        border: 0;
        border-bottom: 1px solid var(--ng-line);
        font-size: 16px;
        font-weight: 600;
        background: #fff;
    }
    .ng-drawer__nav a::after {
        content: '';
        position: absolute;
        right: 16px;
        top: 50%;
        width: 8px;
        height: 8px;
        border-right: 1.5px solid var(--ng-muted-2, #9CA3AF);
        border-bottom: 1.5px solid var(--ng-muted-2, #9CA3AF);
        transform: translateY(-50%) rotate(-45deg);
    }
    .ng-drawer__nav a:last-child { border-bottom: 0; }
    .ng-drawer__nav a:active { background: var(--ng-bg-soft); }
    .ng-drawer__contacts { margin: 16px 16px 0; padding: 0 16px; gap: 0; background: var(--ng-bg-soft); }
    .ng-drawer__contacts > a,
    .ng-drawer__contacts > span { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--ng-line); font-size: 15px; color: var(--ng-text); }
    .ng-drawer__contacts .ng-ico { display: inline-block; width: 18px !important; height: 18px !important; padding: 0; border: 0; flex: none; color: var(--ng-red); }
    .ng-drawer__contacts > :last-child { border-bottom: 0; }
    .ng-drawer-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1040;
        background: rgba(0, 0, 0, .45);
        opacity: 0;
        pointer-events: none;
        transition: opacity .3s;
    }
    .ng-drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }

    /* ---------- фильтры каталога/карты: панель уезжает в шторку, в баре остаётся кнопка ---------- */
    .ng-catalog-bar { padding: 12px 0; }
    .ng-catalog-bar .ng-tabs-pill { margin-bottom: 10px; width: 100%; }
    .ng-catalog-bar .ng-tabs-pill > * { flex: 1 1 auto; text-align: center; padding: 8px 10px; font-size: 13px; }
    .ng-catalog-bar__top { flex-direction: column; align-items: stretch; gap: 0; }
    .ng-catalog-bar__count { margin: 0 0 10px; font-size: 13px; }
    .ng-filters-open {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        height: 46px;
        border: 1px solid var(--ng-line);
        background: #fff;
        font-family: var(--ng-body);
        font-size: 14px;
        font-weight: 600;
        color: var(--ng-text);
        cursor: pointer;
    }
    .ng-filters-open:active { background: var(--ng-bg-soft); }
    .ng-filters-open .ng-ico { color: var(--ng-red); }
    .ng-filters-open__count {
        min-width: 20px;
        height: 20px;
        padding: 0 6px;
        border-radius: 10px;
        background: var(--ng-red);
        color: #fff;
        font-size: 11px;
        line-height: 20px;
        font-weight: 700;
    }
    .ng-filters-open__count:empty { display: none; }
    .ng-filter-sheet .ng-search__panel { background: transparent; }
    .ng-filter-sheet .ng-search__body { padding: 0; }
    .ng-filter-sheet .ng-search__grid { grid-template-columns: 1fr; gap: 10px; }
    .ng-filter-sheet .ng-search__row { flex-wrap: wrap; gap: 10px; padding-top: 10px; }
    .ng-filter-sheet .ng-search__row .ng-suggest-wrap { flex: 1 1 100%; }
    .ng-filter-sheet .ng-search__ghost { display: none; }
    .ng-filter-sheet .ng-search__submit { flex: 1 1 auto; height: 46px; }
    .ng-filter-sheet .ng-search__round { width: 46px; height: 46px; }
    .ng-filter-sheet .ng-field,
    .ng-filter-sheet .ng-sel .ts-control { background: var(--ng-bg-soft); border: 1px solid var(--ng-line); }
    .ng-filter-sheet__extra { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--ng-line); }
    .ng-filter-sheet__extra .ng-tabs-pill { display: none; } /* тип сделки уже выбран в баре */
    .ng-filter-sheet__extra .ng-range.ng-mt-24 { margin-top: 0; }
    .ng-filter-sheet__extra .ng-mt-32 { margin-top: 18px; }
    /* хиро главной: вместо семи селектов — одна кнопка, панель в шторке */
    .ng-hero .ng-filters-open { margin: 0; height: 52px; border: 0; }
    .ng-hero .ng-search__tabs { flex-wrap: wrap; }
    .ng-filter-sheet .ng-grid--2 { grid-template-columns: 1fr; }
    .ng-filter-sheet .modal-footer .filterSearch { display: none; } /* ищем основной кнопкой */
    .ng-map { height: calc(100dvh - var(--ng-header-h) - var(--ng-tabbar-h) - var(--ng-mapbar-h, 120px) - env(safe-area-inset-bottom, 0px)); min-height: 360px; }

    /* ---------- тач-отклик и хвосты от ховеров ---------- */
    .ng-pcard, .ng-scard, .ng-tcard, .ng-bcard, .ng-rcard, .ng-office { transition: transform .15s var(--ng-ease-ios), box-shadow .2s; }
    .ng-pcard:active, .ng-scard:active, .ng-tcard:active, .ng-bcard:active { transform: scale(.985); }
    .ng-btn:active, .ng-pcard__phone:active, .ng-iconbtn:active { transform: scale(.96); }
    .ng-footer { padding-bottom: 8px; }
    .ng-devby { padding-bottom: 20px; }
}

/* на тач-устройствах :hover залипает после тапа — гасим ховер-эффекты, оставляем :active */
@media (hover: none) {
    .ng-btn:hover { transform: none; box-shadow: none; }
    .ng-btn:hover::before { transform: translateX(-112%) skewX(-18deg); }
    .ng-btn:hover::after { opacity: 0; width: 0; height: 0; }
    .ng-btn--primary:hover { color: #fff; }
    .ng-btn--outline:hover { color: var(--ng-text); }
    .ng-btn:hover .ng-ico { animation: none; transform: none; }
    .ng-link:hover .ng-ico { animation: none; }
    .ng-link:hover::after { transform: scaleX(0); }
    .ng-pcard:hover, .ng-scard:hover { transform: none; box-shadow: none; }
    .ng-pcard:hover .ng-pcard__media img, .ng-scard:hover .ng-scard__media img { transform: none; }
    .ng-iconbtn:hover { transform: none; box-shadow: none; }
    .ng-iconbtn:hover .ng-ico { transform: none; }
    .ng-rail a:hover { transform: none; filter: none; }
    .ng-rail__toggle:hover { transform: none; }
    .ng-pcard__phone:hover { color: var(--ng-text-2); }
    .ng-pcard__phone:hover::before { transform: translateY(101%); }
}

@media (prefers-reduced-motion: reduce) {
    .modal .modal-dialog, .ng-drawer, .ng-tabbar .ng-ico { transition: none; }
}

/* соцсети в мобильной шторке (15.09.2026) */
@media (max-width: 767px) {
    .ng-drawer__soc { margin: 16px 16px 0; padding: 14px 16px; background: var(--ng-bg-soft); }
    .ng-drawer__soc-label { margin-bottom: 10px; }
    .ng-drawer__soc-links { gap: 12px; }
    .ng-drawer__soc-links a { width: 46px; height: 46px; background: #fff; }
}
