/*
 * Новая шапка (макет 26.11.2026). Разметка - local/templates/desktop/include/zn-header2.php,
 * поведение - local/js/zn-header2.js. Пока включается только администраторам.
 *
 * Цвета нового стиля: красный #d32f2f, наведение #b71c1c, подложка #ffebee,
 * тёмный логотипа #1e242b, текст #2b3038, иконки #4a525b, зелёный часов #10b981.
 * Десктоп - от 1024px, уже - мобильный вид с нижней панелью.
 */

.zn-h2-spacer,
.zn-h2,
.zn-h2-cat,
.zn-h2-tabbar {
    --zn-red: #d32f2f;
    --zn-red-h: #b71c1c;
    --zn-red-bg: #ffebee;
    --zn-dark: #1e242b;
    --zn-text: #2b3038;
    --zn-ico: #4a525b;
    --zn-muted: #5a6169;
    --zn-line: #e6e8eb;
    font-family: Manrope, sans-serif;
    color: var(--zn-text);
}

.zn-h2-spacer { position: relative; z-index: 1000; flex: 0 0 auto; }

.zn-h2 {
    background: #fff;
    border-bottom: 1px solid var(--zn-line);
    position: relative;
    z-index: 1000;
}
.zn-h2.is-fixed {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--zn-h2-top, 0px);
}
.zn-h2 a,
.zn-h2-cat a,
.zn-h2-tabbar a { color: var(--zn-text); text-decoration: none; }
.zn-h2 a:hover,
.zn-h2-cat a:hover { color: var(--zn-red-h); text-decoration: none; }
.zn-h2-tabbar a:hover { text-decoration: none; }

/* прежняя шапка на телефоне давала body отступ сверху под себя - у новой своя распорка */
body.zn-h2-on { padding-top: 0 !important; }
.zn-h2 button,
.zn-h2-tabbar button {
    font: inherit;
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    cursor: pointer;
    color: inherit;
}

.zn-h2-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.zn-h2-wrap {
    max-width: 1376px;
    margin: 0 auto;
    padding: 0 32px;
    box-sizing: content-box;
}

/* логотип */
.zn-h2-logo {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 7px;
    line-height: 1;
}
.zn-h2-logo__a {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--zn-dark);
}
.zn-h2-logo__b {
    background: var(--zn-red);
    color: #fff;
    font-size: 20px;
    font-weight: 800;
    padding: 4px 7px 3px;
    border-radius: 4px;
}
.zn-h2 a.zn-h2-logo:hover .zn-h2-logo__a { color: var(--zn-dark); }
.zn-h2-logo--m { flex-direction: column; align-items: flex-start; gap: 3px; }
.zn-h2-logo--m .zn-h2-logo__a { font-size: 15px; letter-spacing: -0.3px; }
.zn-h2-logo--m .zn-h2-logo__b { font-size: 15px; padding: 3px 6px 2px; }

.zn-h2-time { color: #10b981; font-weight: 600; white-space: nowrap; }
.zn-h2-time::before { content: "\25CF\00a0"; }

/* ───────── десктоп ───────── */
.zn-h2-m { display: none; }

.zn-h2-top { background: #f5f7fa; border-bottom: 1px solid #eef0f3; }
.zn-h2-top__in {
    height: 36px;
    display: flex;
    align-items: center;
    gap: 24px;
    font-size: 13px;
}
.zn-h2-top__nav { display: flex; gap: 20px; }
.zn-h2 .zn-h2-top__nav a { color: var(--zn-muted); }
.zn-h2 .zn-h2-top__nav a:hover { color: var(--zn-red-h); }
.zn-h2-top .zn-h2-time { margin-left: auto; }

.zn-h2-main {
    height: 84px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.zn-h2-search { flex: 1 1 auto; min-width: 0; margin: 0; }
.zn-h2-search__box {
    display: flex;
    align-items: center;
    height: 48px;
    margin: 0;
    border: 1.5px solid #dfe2e6;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}
.zn-h2-search__box:focus-within { border-color: var(--zn-red); }
.zn-h2-search input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    padding: 0 16px;
    border: 0;
    background: none;
    font: inherit;
    font-size: 15px;
    color: var(--zn-text);
    outline: none;
    box-shadow: none;
}
.zn-h2-search input::placeholder { color: #6b717a; }
.zn-h2 .zn-h2-search__btn {
    flex: 0 0 auto;
    width: 52px;
    height: 100%;
    background: #f4f5f7;
    border-left: 1px solid #dfe2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--zn-text);
}
.zn-h2 .zn-h2-search__btn:hover { background: #eceef1; }

.zn-h2-phones {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.25;
}
.zn-h2 .zn-h2-phones__main { font-size: 18px; font-weight: 800; color: var(--zn-dark); white-space: nowrap; }
.zn-h2 .zn-h2-phones__sub { font-size: 13px; color: var(--zn-muted); white-space: nowrap; }

/* пункты действий: общие для строки десктопа и нижней панели */
.zn-h2-acts { flex: 0 0 auto; display: flex; align-items: center; }
.zn-h2-act {
    position: relative;
    width: 68px;
    height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}
.zn-h2 .zn-h2-act,
.zn-h2-tabbar .zn-h2-act { color: var(--zn-ico); }
.zn-h2 .zn-h2-act:hover,
.zn-h2-tabbar .zn-h2-act:hover { color: var(--zn-red-h); }
.zn-h2-act__ico { display: flex; width: 24px; height: 24px; }
.zn-h2-act__avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--zn-red-bg);
    color: var(--zn-red-h);
    font-size: 12px;
    font-weight: 800;
    line-height: 24px;
    text-align: center;
}
.zn-h2-act__count {
    position: absolute;
    top: 2px;
    left: 50%;
    margin-left: 6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    box-sizing: border-box;
    border-radius: 9px;
    background: var(--zn-red);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}
.zn-h2-act__count.is-empty { display: none; }

/* полоса разделов */
.zn-h2-sec { border-top: 1px solid #eef0f3; position: relative; }
.zn-h2-sec__in {
    height: 52px;
    display: flex;
    align-items: center;
    gap: 20px;
}
.zn-h2-sec__nav { display: flex; align-items: center; gap: 20px; min-width: 0; }
.zn-h2 .zn-h2-sec__link {
    height: 52px;
    display: flex;
    align-items: center;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--zn-text);
}
/* наведённый или открытый раздел - только красный текст, без рамок (просьба владельца) */
.zn-h2 .zn-h2-sec__link:hover,
.zn-h2 .zn-h2-sec__link.is-open { color: var(--zn-red-h); }
.zn-h2 .zn-h2-sec__survey {
    margin-left: auto;
    flex: 0 0 auto;
    height: 38px;
    padding: 0 16px;
    border: 1.5px solid var(--zn-red);
    border-radius: 10px;
    display: flex;
    align-items: center;
    color: var(--zn-red);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}
.zn-h2 .zn-h2-sec__survey:hover { background: var(--zn-red); color: #fff; }

/* выпадающая панель раздела */
.zn-h2-mega {
    position: absolute;
    top: 100%;
    left: 50%;
    width: 1376px;
    max-width: calc(100% - 64px);
    transform: translateX(-50%);
    background: #fff;
    border-radius: 0 0 14px 14px;
    box-shadow: 0 16px 40px rgba(30, 36, 43, .18);
    display: grid;
    grid-template-columns: 1fr 300px;
    min-height: 300px;
    max-height: calc(100vh - 200px);
    overflow: auto;
}
.zn-h2-mega[hidden] { display: none; }
.zn-h2-mega__list { padding: 28px 32px; display: flex; flex-direction: column; gap: 20px; }
.zn-h2-mega__head { display: flex; align-items: baseline; gap: 16px; }
.zn-h2 .zn-h2-mega__title { font-size: 22px; font-weight: 800; color: var(--zn-dark); }
.zn-h2 .zn-h2-mega__all { font-size: 14px; color: var(--zn-red); }
.zn-h2-mega__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px 32px;
    align-content: start;
}
.zn-h2 .zn-h2-mega__grid a { font-size: 15px; line-height: 1.35; }
.zn-h2 .zn-h2-mega__grid a.is-current { color: var(--zn-red-h); }
.zn-h2-mega__side { padding: 24px 24px 24px 0; }
.zn-h2-mega__card {
    height: 100%;
    border-radius: 12px;
    background: #f5f7fa;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.zn-h2-mega__card-title { font-size: 17px; font-weight: 800; color: var(--zn-dark); }
.zn-h2-mega__card-text { font-size: 14px; color: var(--zn-muted); line-height: 1.4; }
.zn-h2 .zn-h2-mega__card-btn {
    margin-top: auto;
    height: 44px;
    border-radius: 10px;
    background: var(--zn-red);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
}
.zn-h2 .zn-h2-mega__card-btn:hover { background: var(--zn-red-h); color: #fff; }

/* затемнение страницы под открытой панелью */
.zn-h2-shade {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(30, 36, 43, .45);
}
.zn-h2-shade[hidden] { display: none; }

/* компактная шапка: прокрутка вниз - одна строка 60px.
   Строки не убираются display:none, а схлопываются по высоте с прозрачностью,
   чтобы переход был плавным. Выпадающая панель лежит в .zn-h2-sec, а не в __in,
   поэтому overflow у __in её не обрезает. */
.zn-h2-top__in,
.zn-h2-sec__in { overflow: hidden; }
.zn-h2 .zn-h2-phones__sub,
.zn-h2 .zn-h2-act__label { display: block; max-height: 20px; overflow: hidden; }
.zn-h2.is-compact .zn-h2-top { border-bottom-width: 0; }
.zn-h2.is-compact .zn-h2-sec { border-top-width: 0; }
.zn-h2.is-compact .zn-h2-top__in,
.zn-h2.is-compact .zn-h2-sec__in { height: 0; opacity: 0; }
.zn-h2.is-compact .zn-h2-phones__sub,
.zn-h2.is-compact .zn-h2-act__label { max-height: 0; opacity: 0; }
.zn-h2.is-compact .zn-h2-act { width: 44px; gap: 0; }
.zn-h2.is-compact .zn-h2-main { height: 60px; }
.zn-h2.is-compact .zn-h2-logo--d .zn-h2-logo__a { font-size: 18px; }
.zn-h2.is-compact .zn-h2-logo--d .zn-h2-logo__b { font-size: 15px; }
.zn-h2.is-compact .zn-h2-search__box { height: 40px; }
.zn-h2.is-compact .zn-h2-act__count { top: 4px; }

@media (min-width: 1024px) and (prefers-reduced-motion: no-preference) {
    .zn-h2 { transition: box-shadow .28s ease; }
    .zn-h2-top,
    .zn-h2-sec { transition: border-width .28s ease; }
    .zn-h2-top__in,
    .zn-h2-sec__in,
    .zn-h2-main,
    .zn-h2-search__box { transition: height .28s cubic-bezier(.4, 0, .2, 1), opacity .2s ease; }
    .zn-h2 .zn-h2-phones__sub,
    .zn-h2 .zn-h2-act__label { transition: max-height .28s cubic-bezier(.4, 0, .2, 1), opacity .2s ease; }
    .zn-h2-act { transition: width .28s cubic-bezier(.4, 0, .2, 1), gap .28s ease; }
    .zn-h2-logo--d .zn-h2-logo__a,
    .zn-h2-logo--d .zn-h2-logo__b { transition: font-size .28s cubic-bezier(.4, 0, .2, 1); }
    /* замер высоты шапки - без анимации, иначе прочитается промежуточное значение */
    .zn-h2.is-measuring,
    .zn-h2.is-measuring * { transition: none !important; }
}

.zn-h2-cat,
.zn-h2-tabbar { display: none; }

@media (max-width: 1279px) {
    .zn-h2 .zn-h2-sec__survey { display: none; }
}
@media (max-width: 1199px) {
    .zn-h2-main { gap: 16px; }
    .zn-h2-sec__nav { gap: 16px; }
    .zn-h2 .zn-h2-sec__link { font-size: 14px; }
    .zn-h2-act { width: 60px; }
    .zn-h2-top__nav { gap: 16px; }
}

/* ───────── телефон и планшет ───────── */
@media (max-width: 1023.98px) {
    .zn-h2-d { display: none; }
    .zn-h2-m {
        height: 64px;
        display: flex;
        align-items: center;
        padding: 0 6px 0 14px;
        gap: 2px;
    }
    .zn-h2-m__gap { flex: 1 1 auto; }
    .zn-h2 .zn-h2-m__btn {
        width: 60px;
        height: 52px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        font-size: 11px;
        font-weight: 600;
        color: var(--zn-text);
    }
    .zn-h2 .zn-h2-m__btn--call { width: 62px; color: var(--zn-red); }
    .zn-h2-m__btn svg { width: 22px; height: 22px; flex: 0 0 auto; }
    .zn-h2-m__ico-open,
    .zn-h2-m__ico-close { display: flex; }
    .zn-h2-m__ico-close,
    .zn-h2-m__lbl-close { display: none; }
    .zn-h2.is-cat-open .zn-h2-m__ico-open,
    .zn-h2.is-cat-open .zn-h2-m__lbl-open { display: none; }
    .zn-h2.is-cat-open .zn-h2-m__ico-close,
    .zn-h2.is-cat-open .zn-h2-m__lbl-close { display: flex; }

    /* экран каталога и поиска */
    .zn-h2-cat {
        position: fixed;
        left: 0;
        right: 0;
        top: var(--zn-h2-cat-top, 64px);
        bottom: 64px;
        z-index: 998;
        background: #fff;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        display: flex;
        flex-direction: column;
    }
    .zn-h2-cat[hidden] { display: none; }
    .zn-h2-cat__search { margin: 0; padding: 12px 12px 4px; }
    .zn-h2-cat__box {
        display: flex;
        align-items: center;
        gap: 8px;
        height: 46px;
        margin: 0;
        padding: 0 12px;
        border: 1.5px solid var(--zn-red);
        border-radius: 10px;
        background: #fff;
        color: var(--zn-ico);
    }
    .zn-h2-cat__box input {
        flex: 1 1 auto;
        min-width: 0;
        border: 0;
        background: none;
        font: inherit;
        font-size: 16px; /* 16px - иначе iOS увеличивает страницу при фокусе */
        color: var(--zn-text);
        outline: none;
        box-shadow: none;
        padding: 0;
    }
    .zn-h2-cat__box input::placeholder { color: #6b717a; }
    .zn-h2-cat__chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 12px 4px; }
    .zn-h2-cat .zn-h2-cat__chips a {
        padding: 6px 12px;
        border-radius: 16px;
        background: #f4f5f7;
        font-size: 13px;
    }
    .zn-h2-cat__lists { padding: 4px 16px 0; }
    .zn-h2-cat__level[hidden] { display: none; }
    .zn-h2-cat__level ul { list-style: none; margin: 0; padding: 0; }
    .zn-h2-cat__level li { border-bottom: 1px solid #f1f2f4; }
    .zn-h2-cat .zn-h2-cat__level li a {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: 46px;
        padding: 6px 0;
        box-sizing: border-box;
        font-size: 16px;
        line-height: 1.3;
    }
    .zn-h2-cat__level li a svg { flex: 0 0 auto; color: #8a9099; }
    .zn-h2-cat__back {
        display: flex;
        align-items: center;
        gap: 4px;
        height: 40px;
        padding: 0;
        border: 0;
        background: none;
        font: inherit;
        font-size: 14px;
        color: var(--zn-muted);
        cursor: pointer;
    }
    .zn-h2-cat .zn-h2-cat__title {
        display: block;
        padding: 2px 0 8px;
        font-size: 18px;
        font-weight: 800;
        color: var(--zn-dark);
        border-bottom: 1px solid #f1f2f4;
    }
    .zn-h2-cat__contacts {
        margin-top: auto;
        padding: 16px;
        background: #f4f5f7;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    .zn-h2-cat .zn-h2-cat__contacts > a[href^="tel:"] { font-size: 18px; font-weight: 800; color: var(--zn-dark); }
    .zn-h2-cat__contacts .zn-h2-time { font-size: 13px; }
    .zn-h2-cat__contacts .zn-h2-time::before { content: none; }
    .zn-h2-cat .zn-h2-cat__survey {
        margin-top: 8px;
        height: 44px;
        border: 1.5px solid var(--zn-red);
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--zn-red);
        font-size: 15px;
        font-weight: 700;
    }
    html.zn-h2-locked,
    html.zn-h2-locked body { overflow: hidden; }

    /* нижняя панель */
    .zn-h2-tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 997;
        height: 64px;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: #fff;
        border-top: 1px solid var(--zn-line);
        box-shadow: 0 -2px 12px rgba(43, 48, 56, .06);
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        transition: transform .2s ease;
    }
    .zn-h2-tabbar--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .zn-h2-tabbar .zn-h2-act { width: auto; height: 64px; font-size: 11px; }
    .zn-h2-tabbar .zn-h2-act__count { top: 6px; margin-left: 4px; }
    html.zn-h2-tab-hidden .zn-h2-tabbar { transform: translateY(100%); }

    body.zn-h2-on { padding-bottom: 64px; }

    /* карточка: полоса с ценой стоит над нижней панелью и опускается, когда панель прячется */
    body.zn-h2-on .zn-stickybar { bottom: 64px; transition: bottom .2s ease; }
    html.zn-h2-tab-hidden body.zn-h2-on .zn-stickybar { bottom: 0; }
    body.zn-h2-on .zn-stickybar__cta { background: var(--zn-red); border-color: var(--zn-red); border-radius: 10px; }
}

@media (max-width: 767.98px) {
    /* под полосу с ценой и нижнюю панель вместе */
    body.zn-h2-on.zn-h2-has-bar { padding-bottom: 140px; }
}

@media (max-width: 359px) {
    .zn-h2-m { padding-left: 10px; }
    .zn-h2 .zn-h2-m__btn { width: 52px; }
    .zn-h2 .zn-h2-m__btn--call { width: 56px; }
    .zn-h2-tabbar .zn-h2-act { font-size: 10px; }
}
