/* ===========================================================
 * J'VIS — Шапка v2 (Figma node 173:21 / 174:43 / 174:61)
 * Глобальный CSS — грузится на всех страницах сайта.
 * Все стили scoped под .jvis-h2 чтобы не задеть Tilda-контент.
 * =========================================================== */

/* На страницах с активной шапкой v2 — обнуляем body-margin (браузерный дефолт 8px)
 * чтобы шапка прижималась к самому верху и левому краю окна, как в Figma. */
body.jvis-v2-header {
    margin: 0;
}

/* На страницах с активной шапкой v2 — скрываем старую Tilda-шапку из post_content.
 * Срабатывает через body-class .jvis-v2-header, который добавляется в functions.php
 * только когда jvis_v2_header_active() === true. */
body.jvis-v2-header [data-tilda-page-alias="header"] {
    display: none !important;
}

/* На страницах без хлебных крошек (главная) — добавляем отступ под шапкой
 * чтобы контент не сливался с меню. */
body.jvis-v2-header:not(.jvis-v2-crumbs) .jvis-h2 {
    margin-bottom: 50px;
}

/* Подвал Tilda — облегчение шрифта (300 → 200) чтобы соответствовать Figma.
 * Tilda inline-CSS имеет высокую специфичность, поэтому !important. */
body.jvis-v2-header [data-tilda-page-alias="footer"] a,
body.jvis-v2-header [data-tilda-page-alias="footer"] span,
body.jvis-v2-header [data-tilda-page-alias="footer"] p {
    font-weight: 200 !important;
}

/* Scoped resets — только внутри шапки v2 */
.jvis-h2,
.jvis-h2 * {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: geometricPrecision;
}

.jvis-h2 {
    width: 100%;
    font-family: 'Onest', sans-serif;
    color: #000;
}

/* Верхняя полоса — точно по Figma:
 * outer wrapper: full width, белый с тонким разделителем снизу
 * inner: 1200px, height 41px, padding 12/0/5/0 (Figma) */
.jvis-h2__topbar {
    background: #ffffff;
    width: 100%;
    border-bottom: 1px solid #d9d9d9;
    font-family: 'Onest', sans-serif;
    font-size: 10px;
    color: #000;
}
.jvis-h2__topbar-inner {
    max-width: 1200px;
    width: 100%;
    height: 41px;
    margin: 0 auto;
    padding: 12px 0 5px 0;
    box-sizing: border-box;
    position: relative;
}
.jvis-h2__topbar-item {
    color: #000;
    text-decoration: none;
    position: absolute;
    top: 12px;
    line-height: normal;
    white-space: nowrap;
}
/* Точные позиции по Figma (node 174:61) */
.jvis-h2__topbar-item--left   { left: 418px; }
.jvis-h2__topbar-item--center { left: 774px; }
.jvis-h2__topbar-item--right  { left: 1069px; }

/* Основная шапка — точно по Figma (node 174:43):
 * background #fffdfd, gap топбар→шапка = 59px,
 * box 1200x40 с border-left/right 40px (трюк чтобы абсолютные дети учитывали отступ). */
.jvis-h2__main {
    background: #fffdfd;
    margin-top: 59px;
}
.jvis-h2__main-inner {
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
    position: relative;
    height: 40px;
    padding: 0 40px;
    display: flex;
    align-items: center;
}
/* Лого — точно по Figma:
 * width: 115.805px; height: 34.538px; aspect-ratio: 57/17;
 * background: url(...) -22.348px -24.309px / 139.355% 235.305% no-repeat; */
.jvis-h2__logo {
    position: relative;
    flex-shrink: 0;
    width: 115.805px;
    height: 34.538px;
    aspect-ratio: 57/17;
    background-repeat: no-repeat;
    background-position: -22.348px -24.309px;
    background-size: 139.355% 235.305%;
    overflow: hidden;
}
.jvis-h2__logo:hover { opacity: 0.8; }

/* Меню — центр grid-колонок. Равные gap между пунктами через flex. */
.jvis-h2__nav {
    position: relative;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    gap: 56px;
    align-items: center;
    font-family: 'Onest', sans-serif;
    font-weight: 200;
    font-size: 18px;
    line-height: normal;
    letter-spacing: 0;
    color: #000;
}
.jvis-h2__nav a {
    color: #000;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.2s;
}
.jvis-h2__nav a:hover { color: #C19099; }

/* Иконки — конец grid-колонок, компактная группа лупа+корзина. */
.jvis-h2__icons {
    position: relative;
    flex-shrink: 0;
    width: 48.86px;
    height: 24px;
}
.jvis-h2__icon {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
}
.jvis-h2__search {
    left: 0;
    top: 3.87px;
    width: 20.126px;
    height: 20.126px;
}
.jvis-h2__cart {
    left: 30.68px; /* было 50.68 — сдвинули ближе к лупе */
    top: 0;
    width: 18.182px;
    height: 24px;
    text-decoration: none;
}
.jvis-h2__icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.jvis-h2__cart-count {
    position: absolute;
    top: -6px;
    right: -8px;
    min-width: 16px;
    height: 16px;
    background: #C19099;
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    padding: 0 4px;
}

/* ---------- Поисковый overlay (открывается по клику на лупу) ---------- */
.jvis-h2__search-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 140px;
    font-family: 'Onest', sans-serif;
}
.jvis-h2__search-overlay[hidden] { display: none; }
.jvis-h2__search-form {
    background: #fff;
    width: 100%;
    max-width: 720px;
    margin: 0 40px;
    padding: 24px 28px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-sizing: border-box;
}
.jvis-h2__search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: 'Onest', sans-serif;
    font-weight: 200;
    font-size: 20px;
    color: #000;
    padding: 8px 0;
    border-bottom: 1px solid #d9d9d9;
}
.jvis-h2__search-input::placeholder { color: #8c8888; font-weight: 200; }
.jvis-h2__search-input:focus { border-bottom-color: #000; }
.jvis-h2__search-submit {
    background: none; border: none; cursor: pointer;
    padding: 8px; width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
}
.jvis-h2__search-submit img { width: 20px; height: 20px; object-fit: contain; }
.jvis-h2__search-close {
    background: none; border: none; cursor: pointer;
    width: 36px; height: 36px;
    font-size: 28px; font-weight: 200; color: #000; line-height: 1;
}
.jvis-h2__search-close:hover { color: #C19099; }
@media (max-width: 640px) {
    .jvis-h2__search-overlay { padding-top: 100px; }
    .jvis-h2__search-form { margin: 0 16px; padding: 20px; gap: 12px; }
    .jvis-h2__search-input { font-size: 18px; }
}

/* ---------- Хлебные крошки v2 (универсальные — для всех внутренних страниц) ----------
 * На главной не выводятся (control в functions.php / partial).
 * На journal — собственные .jvis-journal__crumbs.
 * Здесь — для остальных Tilda-страниц и WC. */
.jvis-crumbs-v2-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 50px 40px 0; /* по Figma: 50px gap шапка → крошки */
    font-family: 'Onest', sans-serif;
    box-sizing: border-box;
}
.jvis-crumbs-v2 {
    font-weight: 200;
    font-size: 13px;
    color: #8c8888;
    display: flex;
    align-items: center;
    gap: 12px;
}
.jvis-crumbs-v2 a {
    color: #8c8888;
    text-decoration: none;
}
.jvis-crumbs-v2 a:hover { color: #000; }

/* visually-hidden utility (для a11y labels) */
.jvis-h2 .visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
}

/* Бургер — скрыт на десктопе, показывается на мобильном (через media query ниже) */
.jvis-h2__burger { display: none; }

/* ============================================
 * Корзина-drawer (боковая панель справа)
 * ============================================ */
.jvis-drawer {
    position: fixed;
    inset: 0;
    z-index: 10000;
    font-family: 'Onest', sans-serif;
    pointer-events: none;
}
.jvis-drawer[hidden] { display: none; }
.jvis-drawer__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: auto;
}
.jvis-drawer.is-open .jvis-drawer__overlay { opacity: 1; }
.jvis-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 480px;
    max-width: 90vw;
    background: #fff;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}
.jvis-drawer.is-open .jvis-drawer__panel { transform: translateX(0); }

.jvis-drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 28px 32px 18px;
    border-bottom: 1px solid #eaeaea;
}
.jvis-drawer__title {
    font-family: 'Onest', sans-serif;
    font-weight: 300;
    font-size: 22px;
    line-height: 1;
    margin: 0;
    color: #000;
}
.jvis-drawer__close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
    color: #000;
    padding: 0;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.jvis-drawer__close:hover { color: #C19099; }

.jvis-drawer__content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 32px;
}
.jvis-drawer__loading,
.jvis-drawer__empty {
    text-align: center;
    color: #8c8888;
    font-weight: 200;
    font-size: 16px;
    padding: 60px 0;
}

.jvis-drawer__item {
    display: grid;
    grid-template-columns: 80px 1fr auto 24px;
    gap: 16px;
    align-items: start;
    padding: 22px 0;
    border-bottom: 1px solid #eaeaea;
}
.jvis-drawer__item-img {
    width: 80px;
    height: 100px;
    object-fit: cover;
    background: #f5f5f5;
    display: block;
}
.jvis-drawer__item-img--placeholder { background: #f5f5f5; }
.jvis-drawer__item-info { min-width: 0; }
.jvis-drawer__item-title {
    font-weight: 300;
    font-size: 15px;
    line-height: 1.3;
    color: #000;
    margin-bottom: 6px;
}
.jvis-drawer__item-meta,
.jvis-drawer__item-sku,
.jvis-drawer__item-qty {
    font-weight: 200;
    font-size: 12px;
    line-height: 1.4;
    color: #8c8888;
    margin-top: 2px;
}
.jvis-drawer__item-price {
    font-weight: 300;
    font-size: 15px;
    color: #000;
    white-space: nowrap;
    align-self: start;
    padding-top: 0;
}
.jvis-drawer__item-remove {
    background: none;
    border: 1px solid #d9d9d9;
    border-radius: 50%;
    cursor: pointer;
    width: 24px;
    height: 24px;
    font-size: 14px;
    line-height: 1;
    color: #8c8888;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, border-color 0.2s;
    align-self: start;
}
.jvis-drawer__item-remove:hover {
    color: #000;
    border-color: #000;
}

.jvis-drawer__footer {
    padding: 24px 32px 32px;
    border-top: 1px solid #eaeaea;
    background: #fff;
}
.jvis-drawer__total {
    font-weight: 300;
    font-size: 16px;
    color: #8c8888;
    text-align: right;
    margin-bottom: 18px;
}
.jvis-drawer__total span {
    color: #000;
    font-weight: 300;
    font-size: 18px;
    margin-left: 4px;
}
.jvis-drawer__pay {
    display: block;
    width: 100%;
    background: #000;
    color: #fff;
    border: none;
    padding: 18px 24px;
    font-family: 'Onest', sans-serif;
    font-weight: 300;
    font-size: 15px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s;
    box-sizing: border-box;
    border-radius: 0;
}
.jvis-drawer__pay:hover { background: #C19099; }
.jvis-drawer__pay.is-disabled {
    background: #d9d9d9;
    pointer-events: none;
}

/* Бейдж счётчика корзины */
.jvis-h2__cart-count.is-hidden { display: none; }

/* Когда drawer открыт — фиксируем скролл body */
body.jvis-drawer-open { overflow: hidden; }

/* Адаптив drawer */
@media (max-width: 600px) {
    .jvis-drawer__panel { width: 100%; }
    .jvis-drawer__head { padding: 22px 20px 14px; }
    .jvis-drawer__content { padding: 8px 20px; }
    .jvis-drawer__footer { padding: 20px; }
    .jvis-drawer__item {
        grid-template-columns: 64px 1fr 24px;
        gap: 12px;
    }
    .jvis-drawer__item-img { width: 64px; height: 80px; }
    .jvis-drawer__item-price {
        grid-column: 2 / span 1;
        margin-top: 8px;
    }
}

/* ---------- Адаптив ----------
 * Базовая стратегия: десктоп — абсолютное позиционирование по Figma,
 * меньше 1200px — переход на flex/flow с автоматической раскладкой,
 * мобильный — компактный стек с бургер-меню. */

/* === Tablet и компактный десктоп (1199-901) === */
@media (max-width: 1199px) {
    .jvis-h2__topbar-inner {
        padding: 12px 20px 5px;
        height: 41px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
    }
    .jvis-h2__topbar-item {
        position: static;
        left: auto !important;
    }
    .jvis-h2__main {
        margin-top: 30px;
    }
    .jvis-h2__main-inner {
        padding: 0 20px;
        border-left: 0;
        border-right: 0;
        height: 50px;
        display: flex;
        align-items: center;
        gap: 24px;
    }
    .jvis-h2__logo {
        position: static;
        flex-shrink: 0;
    }
    .jvis-h2__nav {
        position: static;
        flex: 1;
        display: flex;
        gap: 20px;
        justify-content: center;
        font-size: 15px;
    }
    .jvis-h2__nav a { position: static; left: auto !important; }
    .jvis-h2__icons {
        position: static;
        flex-shrink: 0;
        display: flex;
        gap: 16px;
        width: auto;
    }
    .jvis-h2__icon {
        position: static;
        left: auto;
        top: auto;
    }
    .jvis-h2__search { top: 0; }
    .jvis-h2__cart { left: auto; top: 0; }
}

/* === Mobile (≤700px) — бургер-меню === */
@media (max-width: 700px) {
    .jvis-h2__topbar { font-size: 11px; }
    .jvis-h2__topbar-inner {
        padding: 10px 16px;
        height: auto;
    }
    .jvis-h2__topbar-item--center { display: none; }
    .jvis-h2__topbar-item--left { font-size: 11px; }

    .jvis-h2__main { margin-top: 16px; }
    .jvis-h2__main-inner {
        padding: 0 16px;
        gap: 12px;
        flex-wrap: nowrap;
    }
    .jvis-h2__logo {
        width: 92px;
        height: 28px;
    }
    /* Скрываем меню — заменяем бургером */
    .jvis-h2__nav {
        order: 99;
        display: none;
    }
    /* Бургер показывается через JS — пока скрыт */
    .jvis-h2__icons { gap: 12px; }
    .jvis-h2__search { width: 22px; height: 22px; }
    .jvis-h2__search img { width: 22px; height: 22px; }
    .jvis-h2__cart { width: 18px; height: 24px; }

    /* Меню в раскрытом мобильном режиме */
    .jvis-h2.is-mobile-open .jvis-h2__nav {
        display: flex;
        flex-direction: column;
        gap: 18px;
        position: fixed;
        top: 0; left: 0; right: 0;
        background: #fffdfd;
        padding: 80px 24px 32px;
        z-index: 9998;
        font-size: 20px;
        align-items: flex-start;
    }
    .jvis-h2.is-mobile-open .jvis-h2__nav a {
        position: static;
        font-size: 20px;
        font-weight: 200;
    }

    /* Бургер-кнопка */
    .jvis-h2__burger {
        display: inline-flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;
        width: 24px;
        height: 24px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0;
        position: relative;
        z-index: 9999;
    }
    .jvis-h2__burger span {
        display: block;
        width: 20px;
        height: 1px;
        background: #000;
        transition: transform 0.2s, opacity 0.2s;
    }
    .jvis-h2.is-mobile-open .jvis-h2__burger span:nth-child(1) {
        transform: translateY(6px) rotate(45deg);
    }
    .jvis-h2.is-mobile-open .jvis-h2__burger span:nth-child(2) {
        opacity: 0;
    }
    .jvis-h2.is-mobile-open .jvis-h2__burger span:nth-child(3) {
        transform: translateY(-6px) rotate(-45deg);
    }

    /* Хлебные крошки на мобильном */
    .jvis-crumbs-v2-wrap { padding: 30px 16px 0; }
    .jvis-crumbs-v2 { font-size: 12px; gap: 8px; flex-wrap: wrap; }
}

