/* ===========================================================================
   Нижнее меню для телефонов
   ---------------------------------------------------------------------------
   Что учтено:
   · показывается до 992 px — там, где Bootstrap прячет меню в гамбургер;
     сам гамбургер на этой ширине скрывается, чтобы не было двух меню;
   · внутренняя ширина ограничена — на планшете пять пунктов не растягиваются
     на весь экран;
   · у body появляется отступ снизу, иначе подвал уезжает под панель;
   · учитывается safe-area у айфонов с вырезом;
   · плавающая кнопка квиза на этой ширине убрана: её роль берёт на себя
     центральная кнопка, иначе они наложились бы в правом нижнем углу;
   · высота пунктов 58 px — не меньше рекомендованных 44 px для пальца.
   =========================================================================== */

.mnav { display: none; }
.mnav-sheet { display: none; }

@media (max-width: 991.98px) {

    .mnav {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1035;
        display: block;
        background: rgba(255, 255, 255, .96);
        backdrop-filter: blur(10px);
        border-top: 1px solid #e8edf3;
        box-shadow: 0 -4px 20px rgba(16, 30, 54, .07);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .mnav-inner {
        display: flex;
        align-items: flex-end;
        justify-content: space-between;
        max-width: 520px;   /* чтобы на планшете пункты не разъезжались */
        margin: 0 auto;
        padding: 0 6px;
    }

    .mnav-item,
    .mnav-fab {
        position: relative;
        display: flex;
        flex: 1 1 0;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-width: 0;
        height: 58px;
        padding: 0 2px;
        border: none;
        background: none;
        font-family: inherit;
        font-size: .68rem;
        font-weight: 600;
        line-height: 1.1;
        color: #6c7a90;
        text-align: center;
        text-decoration: none;
        cursor: pointer;
        transition: color .15s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .mnav-item i { font-size: 1.18rem; }

    .mnav-item span,
    .mnav-fab span {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mnav-item:active { color: var(--brand); }
    .mnav-item.is-active { color: var(--brand); }

    /* Полоска над активным пунктом — понятнее, чем только цвет */
    .mnav-item.is-active::before {
        content: '';
        position: absolute;
        top: 0;
        width: 28px;
        height: 3px;
        border-radius: 0 0 3px 3px;
        background: var(--brand);
    }

    /* Центральная кнопка — приподнята над панелью */
    .mnav-fab { color: var(--brand); }

    .mnav-fab-circle {
        display: grid;
        place-items: center;
        width: 48px;
        height: 48px;
        margin-top: -22px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--brand), var(--brand-mid));
        color: #fff;
        font-size: 1.15rem;
        box-shadow: 0 6px 18px rgba(70, 82, 7, .42);
        transition: transform .15s ease;
    }

    .mnav-fab:active .mnav-fab-circle { transform: scale(.93); }

    /* Место под панель, чтобы подвал не уезжал под неё */
    body { padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px)); }

    /* Два меню сразу не нужны */
    .navbar-toggler { display: none !important; }

    /* Плавающая кнопка квиза уступает место центральной кнопке */
    .quiz-trigger { display: none !important; }

    /* --- Шторка «Ещё» --- */

    /* Селектор из двух классов не случаен: у Bootstrap правило записано как
       .offcanvas.offcanvas-bottom и весит больше одиночного .mnav-sheet —
       его height: 30vh побеждал, и шторка обрезалась на трети экрана
       независимо от того, сколько в ней пунктов. */
    .offcanvas.mnav-sheet {
        display: block;
        height: auto;                      /* по содержимому */
        max-height: min(86vh, 620px);      /* но не во весь экран */
        border-radius: 20px 20px 0 0;
    }

    /* Если пунктов станет больше, чем влезает, список прокручивается
       внутри шторки, а не уезжает за край экрана. */
    .offcanvas.mnav-sheet .offcanvas-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Полоска-ухватка: сразу читается, что шторку можно закрыть смахиванием */
    .mnav-sheet .offcanvas-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        width: 38px;
        height: 4px;
        margin-left: -19px;
        border-radius: 99px;
        background: #d7dde6;
    }

    .mnav-sheet .offcanvas-header { position: relative; }

    .mnav-sheet .offcanvas-header {
        padding: 20px 20px 8px;
        border-bottom: 1px solid #eef2f7;
    }

    .mnav-sheet .offcanvas-title { font-weight: 700; }

    .mnav-sheet .offcanvas-body {
        padding: 8px 12px calc(20px + env(safe-area-inset-bottom, 0px));
    }

    .mnav-sheet-link {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 14px 12px;
        border-radius: 12px;
        color: #1a2b45;
        font-weight: 600;
        font-size: .96rem;
        text-decoration: none;
    }

    .mnav-sheet-link i {
        width: 22px;
        color: var(--brand);
        text-align: center;
        font-size: 1.02rem;
    }

    .mnav-sheet-link:active { background: #f2f6fc; }

    .mnav-sheet-contacts {
        margin-top: 10px;
        padding: 14px 12px 4px;
        border-top: 1px solid #eef2f7;
        font-size: .86rem;
        color: #6c7a90;
    }

    .mnav-sheet-contacts a {
        display: block;
        margin-bottom: 4px;
        color: var(--brand);
        font-weight: 700;
        font-size: 1.05rem;
        text-decoration: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mnav-fab-circle { transition: none; }
}

/* Сноска про Meta в шторке меню */
.mnav-sheet-contacts small {
    display: block;
    margin-top: .6rem;
    font-size: .68rem;
    line-height: 1.4;
    color: var(--ink-soft);
}
