/* ============================================
   MEGA MENU — kelvika.ru
   Адаптировано под .top-menu ul (flex)
   ============================================ */

/* Навигация — relative для позиционирования мега-меню */
.top-menu {
  position: relative;
}

/* Пункт «Услуги» — static, чтобы mega-menu позиционировался от .top-menu */
li.has-mega-menu {
  position: static !important;
}

/* Контейнер мега-меню */
.mega-menu {
  position: absolute;
  top: 50px; /* высота навигации */
  left: 0;
  right: 0;
  width: 100%;
  z-index: 99999;
  background: #fff;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);
  border-top: 3px solid #FFD000;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 24px 8px;
  padding: 32px 40px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.25s cubic-bezier(0.16,1,0.3,1),
              transform 0.25s cubic-bezier(0.16,1,0.3,1),
              visibility 0.25s;
}

/* Мостик — чтобы курсор не терялся между ссылкой и панелью */
.mega-menu::before {
  content: '';
  position: absolute;
  top: -15px;
  left: 0;
  right: 0;
  height: 15px;
}

/* Показ при наведении */
li.has-mega-menu:hover > .mega-menu,
li.has-mega-menu:focus-within > .mega-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

/* Колонки */
.mega-menu__column {
  padding: 16px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
}
.mega-menu__column:hover {
  background-color: #FFFBEB;
}

/* Заголовок колонки с иконкой */
.mega-menu__column-header {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid #FFD000;
  height: auto !important;
  line-height: normal !important;
}
.mega-menu__column-header:hover {
  opacity: 1 !important;
}

/* Иконка */
.mega-menu__icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1a1a;
}
.mega-menu__icon svg {
  width: 100%;
  height: 100%;
}
.mega-menu__column-header:hover .mega-menu__icon {
  color: #E6BB00;
}

/* Заголовок */
.mega-menu__column-title {
  font-size: 14px;
  font-weight: 700;
  color: #1a1a1a;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.3 !important;
}
.mega-menu__column-header:hover .mega-menu__column-title {
  color: #E6BB00;
}

/* Подпункты */
.mega-menu__items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: block !important;
}
.mega-menu__items li {
  margin-bottom: 2px;
}
.mega-menu__items a {
  display: block;
  font-size: 13.5px;
  line-height: 1.45 !important;
  height: auto !important;
  color: #555;
  text-decoration: none;
  padding: 5px 8px;
  border-radius: 4px;
  transition: color 0.15s ease, background-color 0.15s ease, padding-left 0.15s ease;
}
.mega-menu__items a:hover {
  color: #1a1a1a;
  background-color: rgba(255, 208, 0, 0.08);
  padding-left: 12px;
  opacity: 1 !important;
}

/* Подсветка пункта «Услуги» при открытом меню */
li.has-mega-menu:hover > a {
  opacity: 0.7;
}

/* Stagger-анимация колонок */
.mega-menu__column {
  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:hover .mega-menu__column {
  opacity: 1;
  transform: translateY(0);
}
.mega-menu__column:nth-child(1) { transition-delay: 0.03s; }
.mega-menu__column:nth-child(2) { transition-delay: 0.06s; }
.mega-menu__column:nth-child(3) { transition-delay: 0.09s; }
.mega-menu__column:nth-child(4) { transition-delay: 0.12s; }
.mega-menu__column:nth-child(5) { transition-delay: 0.15s; }
.mega-menu__column:nth-child(6) { transition-delay: 0.18s; }
li.has-mega-menu:not(:hover) .mega-menu__column {
  transition-delay: 0s !important;
}

/* Адаптив */
@media (max-width: 991px) {
  .mega-menu {
    position: static;
    transform: none;
    box-shadow: none;
    border-radius: 0;
    padding: 20px;
    grid-template-columns: repeat(2, 1fr);
    opacity: 1;
    visibility: visible;
    display: none;
  }
  li.has-mega-menu.is-open > .mega-menu {
    display: grid;
    pointer-events: auto;
  }
  .mega-menu__column {
    opacity: 1;
    transform: none;
    transition-delay: 0s !important;
  }
}
@media (max-width: 767px) {
  .mega-menu {
    grid-template-columns: 1fr;
    padding: 16px;
  }
}