/* ============================================
   MEGA-MENU — kelvika.ru (unified v2)
   Replaces: mega-menu.css + header-improvements.css
   ============================================ */

:root {
  --header-h: 152px;
  --mm-max-w: 1140px;
  --mm-accent: #FFC107;
  --mm-accent-hover: #E5A906;
  --mm-text: #0F0F10;
  --mm-text-light: #6B6B73;
  --mm-radius: 12px;
}


/* ============================================
   A. FIXED HEADER (desktop)
   ============================================ */

@media (min-width: 992px) {
  .header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 9999;
    background: #fff;
    border-bottom: 2px solid var(--color-yellow);
  }

  .top-menu {
    position: relative !important;
  }

  body {
    padding-top: var(--header-h) !important;
  }

  /* Floating compact / hidden header — DISABLED (header is pinned in full state)
  body.is-header-floating .header {
    box-shadow: 0 2px 18px rgba(0, 0, 0, 0.10);
  }

  body.is-header-hidden .header {
    transform: translateY(-100%);
  }

  body.is-header-floating .header .top-line {
    display: none;
  }

  body.is-header-floating .header > .container {
    padding-top: 0;
    padding-bottom: 0;
  }

  body.is-header-floating .header .header-container {
    padding: 8px 0;
    transition: padding 0.25s ease;
    align-items: center;
  }

  body.is-header-floating .header .logo {
    width: 130px;
    min-width: 130px;
    max-width: 130px;
    margin-right: 25px;
  }

  body.is-header-floating .header .logo a img {
    height: 44px;
    width: auto;
    transition: height 0.25s ease;
  }

  body.is-header-floating .header .search-form,
  body.is-header-floating .header .header-container .phone {
    display: none;
  }

  body.is-header-floating .header .header-container .order-call {
    height: 40px;
    line-height: 40px;
    width: 180px;
    min-width: 180px;
    max-width: 180px;
    margin-left: auto;
    font-size: 15px;
  }

  body.is-header-floating .top-menu ul a {
    height: 42px;
    line-height: 42px;
    font-size: 17px;
  }

  body.is-header-floating {
    --header-h: 102px;
  }
  */
}


/* ============================================
   B. MEGA-MENU PANEL — Desktop (≥992px)
   ============================================ */

/* Parent li must be static so .mm positions from .top-menu */
li.has-mega-menu,
li.menu-item-has-mega-menu {
  position: static !important;
}

.mm {
  position: absolute;
  top: 50px;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 99999;
  background: #fff;
  border-radius: 0 0 var(--mm-radius) var(--mm-radius);
  box-shadow: 0 16px 24px -8px rgba(15, 15, 16, 0.08), 0 2px 8px rgba(15, 15, 16, 0.04);
  border-top: 3px solid var(--mm-accent);
  padding: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 200ms ease,
              transform 200ms ease,
              visibility 200ms;
}

.mm__inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 32px 0;
}

/* Bridge between trigger link and panel */
.mm::before {
  content: '';
  position: absolute;
  top: -18px;
  left: 0;
  right: 0;
  height: 18px;
}

/* Show on hover (desktop) — JS adds .mm--open for hover-intent */
@media (min-width: 992px) {
  li.has-mega-menu.mm--open > .mm,
  li.menu-item-has-mega-menu.mm--open > .mm,
  li.has-mega-menu:focus-within > .mm,
  li.menu-item-has-mega-menu:focus-within > .mm {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }
}

/* Highlight "Услуги" link when open */
li.has-mega-menu.mm--open > a,
li.menu-item-has-mega-menu.mm--open > a {
  opacity: 0.7;
}

/* Chevron on "Услуги" trigger (desktop) */
@media (min-width: 992px) {
  li.has-mega-menu > a,
  li.menu-item-has-mega-menu > a {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
  }

  li.has-mega-menu > a::after,
  li.menu-item-has-mega-menu > a::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    background: currentColor;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    flex-shrink: 0;
    transition: transform 200ms ease;
  }

  li.has-mega-menu.mm--open > a::after,
  li.menu-item-has-mega-menu.mm--open > a::after {
    transform: rotate(180deg);
  }
}


/* ============================================
   C. GRID LAYOUT — 5 columns
   ============================================ */

.mm__grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 36px;
}


/* ============================================
   D. COLUMN
   ============================================ */

.mm__col {
  display: flex;
  flex-direction: column;
}


/* ============================================
   E. COLUMN HEADER
   ============================================ */

.mm__col-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-decoration: none;
  margin-bottom: 0;
  height: auto !important;
  line-height: normal !important;
}

.mm__col-header:hover {
  opacity: 1 !important;
}

.mm__icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0F0F10;
  margin-bottom: 14px;
}

.mm__icon svg {
  width: 100%;
  height: 100%;
}

.mm__col-header:hover .mm__icon {
  color: var(--mm-accent-hover);
}

.mm__col-title {
  font-size: 16px;
  font-weight: 700;
  color: #0F0F10;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.3 !important;
  margin-bottom: 8px;
  min-height: 2.6em;
  display: flex;
  align-items: flex-start;
}

.mm__col-header:hover .mm__col-title {
  color: var(--mm-accent-hover);
}

/* Yellow bar after column header (icon + title) — desktop only */
@media (min-width: 992px) {
  .mm__col-header::after {
    content: '';
    display: block;
    width: 32px;
    height: 2px;
    background: #FFC107;
    margin-top: 6px;
    margin-bottom: 14px;
  }
}


/* ============================================
   F. SUB-GROUPS
   ============================================ */

.mm__groups {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 10px;
  margin-right: -6px;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--mm-accent) transparent;
}

.mm__groups::-webkit-scrollbar {
  width: 6px;
}

.mm__groups::-webkit-scrollbar-track {
  background: transparent;
}

.mm__groups::-webkit-scrollbar-thumb {
  background: var(--mm-accent);
  border-radius: 3px;
}

.mm__group-title {
  font-size: 15px;
  font-weight: 600;
  color: #1A1A1D;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0;
  padding: 0;
  line-height: 1.3;
  border-bottom: none;
}

/* Yellow bar after group title */
.mm__group-title::after {
  content: '';
  display: block;
  width: 20px;
  height: 2px;
  background: #FFC107;
  margin-top: 6px;
  margin-bottom: 14px;
}

/* ============================================
   G. ITEMS
   ============================================ */

.mm__items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: block !important;
}

.mm__items li {
  margin-bottom: 1px;
}

.mm__items a,
.top-menu .mm__items a,
.mm .mm__items a {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 17px !important;
  font-weight: 400 !important;
  line-height: 1.5 !important;
  height: auto !important;
  color: #1A1A1D;
  text-decoration: none;
  padding: 5px 0;
  transition: color 120ms ease;
}

.mm__items a:hover,
.top-menu .mm__items a:hover,
.mm .mm__items a:hover {
  color: #E5A906;
  opacity: 1 !important;
}


/* ============================================
   H. BADGES
   ============================================ */

.mm__badge {
  display: inline-block;
  background: #FFC107;
  color: #0F0F10;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 4px;
  margin-left: auto;
  vertical-align: middle;
  letter-spacing: 0.5px;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.mm__badge--hit {
  background: var(--mm-accent);
  color: var(--mm-text);
}

.mm__badge--new {
  background: #22c55e;
  color: #fff;
}


/* ============================================
   I. STAGGER ANIMATION (desktop)
   ============================================ */

@media (min-width: 992px) {
  .mm__col {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                background-color 0.2s ease;
  }

  li.has-mega-menu.mm--open .mm__col,
  li.menu-item-has-mega-menu.mm--open .mm__col {
    opacity: 1;
    transform: translateY(0);
  }

  .mm__col:nth-child(1) { transition-delay: 0.03s; }
  .mm__col:nth-child(2) { transition-delay: 0.06s; }
  .mm__col:nth-child(3) { transition-delay: 0.09s; }
  .mm__col:nth-child(4) { transition-delay: 0.12s; }
  .mm__col:nth-child(5) { transition-delay: 0.15s; }

  li.has-mega-menu:not(.mm--open) .mm__col,
  li.menu-item-has-mega-menu:not(.mm--open) .mm__col {
    transition-delay: 0s !important;
  }
}


/* ============================================
   J. MESSENGERS (hidden on desktop, shown in mobile)
   ============================================ */

.mm__messengers {
  display: none;
}


/* ============================================
   K. CONTACTS BLOCK (mobile-only)
   ============================================ */

@media (min-width: 992px) {
  .mm-contacts { display: none !important; }
}


/* ============================================
   L. MOBILE MEGA-MENU PANEL (≤991px)
   Body scroll lock via JS (position: fixed).
   Panel uses 100dvh for correct height on iOS.
   ============================================ */

@media (max-width: 991px) {
  /* Body scroll lock — applied by JS */
  body.mm-body-locked {
    position: fixed;
    width: 100%;
    overflow: hidden;
  }

  /* Mobile menu container — full-screen panel (Claude Design panel bg) */
  .top-menu {
    background: #0E0E10;
  }

  .top-menu.open {
    display: flex !important;
    flex-direction: column;
    height: 100dvh;
    height: 100vh; /* fallback */
    max-height: 100dvh;
    overflow: hidden;
    background: #0E0E10;
  }

  @supports (height: 100dvh) {
    .top-menu.open {
      height: 100dvh;
      max-height: 100dvh;
    }
  }

  /* Sticky top area of mobile menu (nav items) — full-width, no side padding */
  .top-menu.open > .container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 0 80px !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  /* ── L1: root menu rows (Главная, Услуги, Доставка, Контакты) ── */
  .top-menu .nav {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .top-menu .nav > li {
    display: block;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .top-menu .nav > li > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    height: auto;
    padding: 0 20px;
    line-height: 1.4;
    font-size: 17px;
    font-weight: 500;
    color: #fff;
    text-decoration: none;
    background: transparent;
  }

  /* Samsung Internet greys out :visited / :focus by default — pin white for all states. */
  .top-menu .nav > li > a,
  .top-menu .nav > li > a:link,
  .top-menu .nav > li > a:visited,
  .top-menu .nav > li > a:hover,
  .top-menu .nav > li > a:active,
  .top-menu .nav > li > a:focus {
    color: #fff;
  }

  /* Override desktop .top-menu ul a:hover { opacity: 0.7 } — on touch devices
     the hover state sticks after a tap and dims the L1 label. */
  .top-menu .nav > li > a:hover {
    opacity: 1;
  }

  /* Chevron — right by default, down for mega-menu trigger, up when open */
  .top-menu .nav > li > a::after {
    content: '';
    display: block;
    width: 10px;
    height: 10px;
    border-right: 2px solid rgba(255, 255, 255, 0.5);
    border-bottom: 2px solid rgba(255, 255, 255, 0.5);
    transform: rotate(-45deg);
    transition: transform 200ms ease;
    flex-shrink: 0;
  }

  .top-menu .nav > li.has-mega-menu,
  .top-menu .nav > li.menu-item-has-mega-menu {
    position: relative !important;
  }

  .top-menu .nav > li.has-mega-menu > a::after,
  .top-menu .nav > li.menu-item-has-mega-menu > a::after {
    transform: rotate(45deg);
  }

  .top-menu .nav > li.has-mega-menu.is-open > a::after,
  .top-menu .nav > li.menu-item-has-mega-menu.is-open > a::after {
    transform: rotate(-135deg);
  }

  /* Active / open row — yellow tint on background, 3px yellow bar on the left.
     Both effects MUST sit on the <a> (the 56px row), not the <li>, because the <li>
     also contains the expanded mega-menu when .is-open. */
  .top-menu .nav > li.current-menu-item > a,
  .top-menu .nav > li.current_page_item > a,
  .top-menu .nav > li.is-open > a {
    background: rgba(255, 193, 7, 0.08);
  }

  .top-menu .nav > li.current-menu-item > a::before,
  .top-menu .nav > li.current_page_item > a::before,
  .top-menu .nav > li.is-open > a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 12px;
    bottom: 12px;
    width: 3px;
    background: var(--mm-accent);
    border-radius: 2px;
    z-index: 1;
  }

  /* Anchor must be a positioning context for the ::before bar */
  .top-menu .nav > li > a {
    position: relative;
  }

  /* Mega-menu inside mobile — vertical accordion, transparent (panel bg shows through) */
  .top-menu .mm {
    position: static !important;
    transform: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    border-top: none !important;
    background: transparent !important;
    padding: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    display: none;
  }

  .top-menu li.has-mega-menu.is-open > .mm,
  .top-menu li.menu-item-has-mega-menu.is-open > .mm {
    display: block;
  }

  /* Override grid to single column */
  .top-menu .mm__grid {
    display: block !important;
  }

  /* Column in mobile — flat row, no card */
  .top-menu .mm__col {
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    max-height: none;
    overflow: visible;
  }

  .top-menu .mm__col:hover {
    background: transparent !important;
  }

  /* L2: category row — 24px left padding, icon + CAPS title + chevron right.
     Separator between categories lives on this row's bottom border. */
  .top-menu .mm__col-header {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 14px;
    min-height: 56px;
    padding: 0 20px 0 24px !important;
    margin: 0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: transparent;
    position: relative;
    color: #fff !important;
    transition: background 200ms ease;
  }

  .top-menu .mm__col.is-col-open .mm__col-header {
    background: rgba(255, 255, 255, 0.03);
  }

  /* Chevron — white default, yellow when column is open */
  .top-menu .mm__col--has-children .mm__col-header::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 18px;
    width: 9px;
    height: 9px;
    border-right: 2px solid rgba(255, 255, 255, 0.5);
    border-bottom: 2px solid rgba(255, 255, 255, 0.5);
    transform: translateY(-75%) rotate(45deg);
    transition: transform 0.25s ease, border-color 0.2s ease;
  }

  .top-menu .mm__col.is-col-open .mm__col-header::after {
    transform: translateY(-25%) rotate(-135deg);
    border-right-color: var(--mm-accent);
    border-bottom-color: var(--mm-accent);
  }

  /* Icon 20px, white default, yellow when column is open */
  .top-menu .mm__icon {
    width: 20px;
    height: 20px;
    color: #fff;
    margin-bottom: 0;
    transition: color 0.2s ease;
  }

  .top-menu .mm__col.is-col-open .mm__icon {
    color: var(--mm-accent);
  }

  /* Title: compact single-line — overrides desktop min-height/display:flex */
  .top-menu .mm__col-title {
    flex: 1;
    display: inline !important;
    min-height: 0 !important;
    margin-bottom: 0 !important;
    color: #fff !important;
    font-size: 15px !important;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    line-height: 1.3 !important;
    transition: color 0.2s ease;
  }

  /* ── Sub-groups: column-level toggle (display only — no grid trick) ── */
  .top-menu .mm__groups {
    display: none;
    padding: 0;
    max-height: none;
    overflow: visible;
  }

  .top-menu .mm__col.is-col-open > .mm__groups {
    display: block;
  }

  /* L3: subgroup — slightly darker than category, no border inside */
  .top-menu .mm__group {
    background: rgba(0, 0, 0, 0.15);
    border: none;
    padding: 0;
  }

  /* Subgroup title — 48px row, padding 24px left / 20px right.
     Yellow text + yellow 20×2px rule below (via block ::after), chevron right (span). */
  .top-menu .mm__group-title {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    position: relative;
    min-height: 48px;
    cursor: pointer;
    color: var(--mm-accent);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    padding: 20px 20px 0 24px;
    margin: 0;
    line-height: 1.3;
  }

  /* Yellow rule 20×2px under title text — block flow, 6px gap below text */
  .top-menu .mm__group-title::after {
    content: '';
    display: block;
    width: 20px;
    height: 2px;
    background: var(--mm-accent);
    margin-top: 6px;
  }

  /* Chevron — its own span; size/position matches L2 chevron for visual alignment */
  .top-menu .mm__chevron {
    display: block;
    position: absolute;
    right: 18px;
    top: 50%;
    width: 9px;
    height: 9px;
    border-right: 2px solid rgba(255, 255, 255, 0.4);
    border-bottom: 2px solid rgba(255, 255, 255, 0.4);
    transform: translateY(-75%) rotate(45deg);
    transition: transform 200ms ease;
  }

  .top-menu .mm__group.is-open .mm__chevron {
    transform: translateY(-25%) rotate(-135deg);
  }

  /* L4: sub-items — hidden by default, revealed when group is open */
  .top-menu .mm__group .mm__items {
    display: none !important;
  }

  .top-menu .mm__group.is-open .mm__items {
    display: block !important;
    padding-bottom: 8px;
  }

  .top-menu .mm__items {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .top-menu .mm__items li {
    border-bottom: none;
    margin: 0;
  }

  .top-menu .mm__items a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 20px 0 24px !important;
    color: rgba(255, 255, 255, 0.85) !important;
    font-size: 17px !important;
    font-weight: 400 !important;
    line-height: 1.5 !important;
    background: transparent !important;
    border-radius: 0 !important;
    text-decoration: none;
  }

  .top-menu .mm__items a:hover,
  .top-menu .mm__items a:active,
  .top-menu .mm__items a:focus {
    color: var(--mm-accent) !important;
    background: transparent !important;
    padding-left: 24px !important;
  }

  .top-menu .mm__badge {
    font-size: 12px;
    padding: 4px 6px;
  }


  /* ── Contacts block (address / hours / email) — sits above messengers ── */
  .mm-contacts {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px 16px;
    margin-bottom: 8px;
  }
  .mm-contacts__item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: #ffffff;
    text-decoration: none;
    font-size: 16px;
    line-height: 1.4;
  }
  .mm-contacts__item svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: #FECE15;
    margin-top: 1px;
  }
  a.mm-contacts__item:hover span {
    color: #FECE15;
  }

  /* ── Messengers block (sits at the bottom of the mobile panel — pinned by
     flex column on .top-menu.open + .container being flex:1). Brand-coloured
     circular SVGs render at their full 48px — no extra wrapper circle. ── */
  .mm__messengers {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 32px 20px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
  }

  .mm__messengers-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: #9A9A9A;
    margin-bottom: 18px;
  }

  .mm__messengers-buttons {
    display: flex;
    gap: 24px;
    justify-content: center;
    align-items: center;
  }

  .mm__messenger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    text-decoration: none;
    transition: opacity 0.2s ease;
  }

  .mm__messenger-btn:hover {
    background: transparent !important;
    opacity: 0.85;
  }

  .mm__messenger-btn img,
  .mm__messenger-btn svg {
    width: 48px !important;
    height: 48px !important;
  }
}


/* ============================================
   M. PREFERS-REDUCED-MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .mm,
  .mm__col,
  .header,
  .top-menu .mm__groups,
  .mm__items a,
  .mm__col-header::after {
    transition: none !important;
    animation: none !important;
  }
}
