/* ============================================================
   Мега-меню «Каталог» (десктоп). Часть 9 плана.
   Самодостаточные стили с префиксом dk- (не завязаны на тему,
   чтобы не ловить конфликты специфичности). На мобильном (<=860px)
   весь блок скрыт — там работает штатная модалка/мобильный sheet.
   Высота шапки берётся из --dk-header-h (её выставляет script.js).
   ============================================================ */

/* Контейнер десктопной навигации в полоске header. На мобильном (<=860px) скрыт —
   там штатный бургер -> модалка. */
.dk-desktop-nav{
    display: flex;
    align-items: center;
    gap: 32px;
    height: 100%;
    margin-left: 40px;
}
@media (max-width: 860px){
    .dk-desktop-nav{ display: none !important; }
}

/* На десктопе старый бургер не нужен — навигация в полоске шапки.
   На мобильном бургер остаётся и открывает новую шторку (dkm-sheet). */
@media (min-width: 861px){
    header .header-menu-burger{ display: none !important; }
}

.dk-nav-item{
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 100%;
}

.dk-nav-trigger{
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    letter-spacing: 0.08em;
    color: inherit;
    cursor: pointer;
    padding: 8px 2px;
    white-space: nowrap;
}
.dk-nav-item.dk-open .dk-nav-trigger,
.dk-nav-item:hover .dk-nav-trigger{ color: var(--dk-accent, #6E6E6E); }

.dk-desktop-nav,
.dk-mega-panel{ font-family: "Montserrat", Arial, sans-serif; }

.dk-caret{ width: 8px; height: 8px; transition: transform 150ms ease; }
.dk-nav-item.dk-open .dk-caret{ transform: rotate(180deg); }

/* мостик, чтобы не закрывалось при переходе курсора к панели */
.dk-nav-item::before{
    content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 12px;
}

/* панель — фиксированная, на всю ширину экрана.
   +15px к top, чтобы не наезжала на полоску шапки. */
.dk-mega-panel{
    position: fixed;
    top: calc(var(--dk-header-h, 72px) + 15px);
    left: 0; right: 0;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0,0,0,0.10);
    border-top: 1px solid #eee;
    z-index: 1200;
    max-height: calc(100vh - var(--dk-header-h, 72px) - 15px);
    overflow-y: auto;
    opacity: 0; visibility: hidden; pointer-events: none;
    transform: translateY(8px);
    transition: opacity 120ms ease-out, transform 120ms ease-out, visibility 0s linear 120ms;
}
.dk-nav-item.dk-open .dk-mega-panel,
.dk-nav-item:hover .dk-mega-panel{
    opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0);
    transition: opacity 120ms ease-out, transform 120ms ease-out, visibility 0s linear 0s;
}

.dk-mega-inner{ max-width: 1440px; margin: 0 auto; padding: 40px 80px 48px; }

/* сброс наследия темы (header a { color/… }) внутри панели */
.dk-mega-panel a{ text-decoration: none; }
.dk-mega-panel ul{ list-style: none; margin: 0; padding: 0; }

/* группы в 3 колонки, группа не разрывается между колонками */
.dk-mega-groups{ column-count: 3; column-gap: 48px; }
.dk-group{
    -webkit-column-break-inside: avoid; page-break-inside: avoid; break-inside: avoid;
    margin-bottom: 36px;
}
.dk-group_standalone{ margin-bottom: 0; }

.dk-group-title{
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: #999999;
    margin: 0 0 18px; padding-bottom: 15px; border-bottom: 1px solid #ededed;
}
.dk-group-title a{ color: inherit; }
.dk-group_now .dk-group-title{ color: var(--dk-accent, #6E6E6E); }

.dk-group-list li a{
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    height: 36px; font-size: 14px; font-weight: 400; color: #1a1a1a;
    letter-spacing: 0.01em; line-height: 1.2;
    transition: color 150ms ease, transform 150ms ease;
}
.dk-group-list li a:hover{ color: var(--dk-accent, #6E6E6E); transform: translateX(4px); }
.dk-group-list li a.active{ color: var(--dk-accent, #6E6E6E); }

/* Первая буква заглавная, остальное строчными — единый вид независимо от того,
   как набрано в файле меню (СУМКИ / рубашки -> Сумки / Рубашки). */
.dk-group-list li a .dk-txt{
    display: inline-block; min-width: 0;
    text-transform: lowercase;
}
.dk-group-list li a .dk-txt::first-letter{ text-transform: uppercase; }

/* Стрелка — как в прототипе: скрыта, появляется на hover (крупная, акцент) */
.dk-group-list li a .dk-arrow{
    flex: 0 0 auto;
    font-size: 16px; line-height: 1; color: var(--dk-accent, #6E6E6E);
    opacity: 0; transform: translateX(-4px);
    transition: opacity 150ms ease, transform 150ms ease;
}
.dk-group-list li a:hover .dk-arrow{ opacity: 1; transform: translateX(0); }

/* на мобильном мега-меню не используется */
@media (max-width: 860px){
    .dk-nav-item{ display: none !important; }
}

/* ============================================================
   Иконки шапки (стадия 4): размер/толщина как в прототипе (компактнее),
   бейдж количества на корзине — красный кружок.
   ============================================================ */
header .header-buttons svg{ width: 23px; height: 23px; }

/* ЕДИНАЯ обёртка иконки шапки (.dk-icon-wrap) — общая для избранного, профиля и корзины.
   Структура одинаковая у всех: div[data-href] > span.dk-icon-wrap > svg > i(бейдж).
   inline-flex + line-height:0 => коробка обёртки точно по иконке 23×23, поэтому бейдж
   (top/right:-6px) у ВСЕХ иконок встаёт одинаково в правый верхний угол. */
header .header-buttons .dk-icon-wrap{
    position: relative; display: inline-flex; align-items: center;
    line-height: 0; vertical-align: middle;
}
/* иконка при наведении не перекрывает бейдж */
header .header-buttons .dk-icon-wrap svg{ position: relative; z-index: 1; }

/* Бейдж — маленький красный кружок в ПРАВОМ ВЕРХНЕМ углу иконки. Один набор правил
   для корзины и избранного => полностью идентичный вид.
   ВАЖНО: !important + сброс left/bottom/margin — чтобы перебить СТАРОЕ правило темы
   (dist/main.min.css:8470 и медиа-версии): position:absolute; top:13px; left:0; right:0;
   margin:auto — оно центрировало счётчик ВНУТРИ иконки и мешало позиционированию. */
header .header-buttons .dk-icon-wrap .set_count_items_to_basket,
header .header-buttons .dk-icon-wrap .count_items_wishlist{
    position: absolute !important; z-index: 5;
    top: -6px !important; right: -6px !important;
    left: auto !important; bottom: auto !important;
    width: 15px !important; height: 15px !important; min-width: 0 !important;
    padding: 0 !important; margin: 0 !important; box-sizing: border-box;
    background: #C8102E !important; color: #fff;
    font-size: 9px !important; font-weight: 700; font-style: normal; line-height: 15px !important;
    text-align: center; border-radius: 50%; overflow: hidden;
    pointer-events: none;
}
header .header-buttons .dk-icon-wrap .set_count_items_to_basket:empty,
header .header-buttons .dk-icon-wrap .count_items_wishlist:empty{ display: none; }

/* Внутри ОБОИХ бейджей число оборачивается в <p> с инлайновыми стилями:
   - избранное: JS темы даёт <p style="margin-left:2px;margin-top:-2px;">, плюс тема
     .count_items_wishlist p { margin-top:-5px !important };
   - корзина: JS пишет <p style="opacity:0.5;">N</p> (common.js и catalog.element scripts),
     из-за чего цифра шла полупрозрачной и смещённой.
   Перебиваем оба <p> одним правилом (opacity:1 !important гасит инлайн корзины),
   чтобы цифры в корзине и избранном были ИДЕНТИЧНЫ: чёткие, по центру. */
header .header-buttons .dk-icon-wrap .count_items_wishlist p,
header .header-buttons .dk-icon-wrap .set_count_items_to_basket p{
    margin: 0 !important; padding: 0 !important;
    display: block; width: 100%;
    font: inherit; line-height: 15px !important; text-align: center;
    opacity: 1 !important;
}

/* Больше боковых отступов у шапки на десктопе.
   ВАЖНО: без max()/calc() — Bitrix-минификатор CSS их портит и ломает весь бандл стилей. */
@media (min-width: 861px){
    body header{ padding-left: 48px; padding-right: 48px; }
}
@media (min-width: 1600px){
    body header{ padding-left: 80px; padding-right: 80px; }
}
