/* Famarket-style mega menu — DSK */

#mega-menu-wrap-primary {
  background: transparent;
}

#mega-menu-wrap-primary #mega-menu-primary {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
}

#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item {
  position: static;
}

#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item > a.mega-menu-link {
  color: #fff !important;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.85rem 1rem !important;
  height: auto !important;
  line-height: 1.3 !important;
  background: transparent !important;
}

#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item > a.mega-menu-link:hover,
#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item.mega-toggle-on > a.mega-menu-link {
  background: #e65100 !important;
  color: #fff !important;
}

/* АКЦИЯ! */
#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item-sale > a.mega-menu-link {
  color: #ffab40 !important;
  font-weight: 700;
}

#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item-sale > a.mega-menu-link:hover {
  background: #d84315 !important;
  color: #fff !important;
}

/* Dropdown panels */
#mega-menu-wrap-primary #mega-menu-primary li.mega-menu-megamenu > ul.mega-sub-menu {
  background: #fff !important;
  border: 1px solid #e0e0e0 !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12) !important;
  padding: 1rem 1.25rem !important;
  border-top: 3px solid #e65100 !important;
}

#mega-menu-wrap-primary #mega-menu-primary li.mega-menu-megamenu > ul.mega-sub-menu > li.mega-menu-row {
  max-width: 1100px;
  margin: 0 auto;
}

#mega-menu-wrap-primary #mega-menu-primary li.mega-menu-megamenu > ul.mega-sub-menu .mega-menu-column > ul.mega-sub-menu > li.mega-menu-item > a.mega-menu-link {
  color: #1a2332 !important;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.35rem 0.75rem !important;
  background: #f5f7fa !important;
  border-radius: 4px;
  margin-bottom: 0.25rem;
}

#mega-menu-wrap-primary #mega-menu-primary li.mega-menu-megamenu > ul.mega-sub-menu .mega-menu-column > ul.mega-sub-menu > li.mega-menu-item > a.mega-menu-link:hover {
  background: #fff3e0 !important;
  color: #e65100 !important;
}

#mega-menu-wrap-primary #mega-menu-primary li.mega-menu-megamenu ul.mega-sub-menu li.mega-menu-item li.mega-menu-item > a.mega-menu-link {
  color: #455a64 !important;
  font-weight: 400;
  font-size: 0.875rem;
  padding: 0.3rem 0.75rem !important;
  background: transparent !important;
}

#mega-menu-wrap-primary #mega-menu-primary li.mega-menu-megamenu ul.mega-sub-menu li.mega-menu-item li.mega-menu-item > a.mega-menu-link:hover {
  color: #e65100 !important;
  background: #fafafa !important;
}

/* Flyout submenus (nested) */
#mega-menu-wrap-primary #mega-menu-primary li.mega-menu-flyout ul.mega-sub-menu {
  background: #fff !important;
  border: 1px solid #e8ecef !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1) !important;
}

#mega-menu-wrap-primary #mega-menu-primary li.mega-menu-flyout ul.mega-sub-menu a.mega-menu-link {
  color: #37474f !important;
  padding: 0.45rem 1rem !important;
}

#mega-menu-wrap-primary #mega-menu-primary li.mega-menu-flyout ul.mega-sub-menu a.mega-menu-link:hover {
  color: #e65100 !important;
  background: #fff8f0 !important;
}

/* Header layout: keep Storefront's own float layout (a flex override here broke it). */
.site-header .site-branding .site-title a {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

/* Desktop: Max Mega Menu bar; its own mobile toggle is never needed. */
#mega-menu-wrap-primary .mega-menu-toggle {
  display: none !important;
}

@media (min-width: 768px) {
  .storefront-primary-navigation .main-navigation {
    width: 74%;
  }
  #mega-menu-wrap-primary {
    background: transparent !important;
  }
}

/* Mobile: Storefront's "Меню" button + handheld menu (location "handheld"). */
@media (max-width: 767px) {
  #mega-menu-wrap-primary {
    display: none !important;
  }
}

/* Dropdowns: open under their own item, readable dark text (the white header-link
   rule in style.css was leaking into the white panel). */
@media (min-width: 768px) {
  #mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item {
    position: relative !important;
  }
  #mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item > ul.mega-sub-menu {
    left: 0 !important;
    right: auto !important;
    top: 100% !important;
    width: auto !important;
    min-width: 260px;
    padding: 0.5rem 0 !important;
    background: #fff !important;
    border-top: 3px solid var(--shop-kg-primary, #e65100);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 12px 28px rgba(26, 35, 50, 0.18);
    z-index: 9999;
  }
  #mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item > ul.mega-sub-menu li.mega-menu-item {
    width: 100% !important;
    float: none !important;
    padding: 0 !important;
  }
  .site-header #mega-menu-wrap-primary #mega-menu-primary ul.mega-sub-menu a.mega-menu-link {
    display: block !important;
    padding: 0.55rem 1.25rem !important;
    color: var(--shop-kg-heading, #1a2332) !important;
    font-weight: 500 !important;
    white-space: nowrap;
  }
  .site-header #mega-menu-wrap-primary #mega-menu-primary ul.mega-sub-menu a.mega-menu-link:hover,
  .site-header #mega-menu-wrap-primary #mega-menu-primary ul.mega-sub-menu a.mega-menu-link:focus {
    color: var(--shop-kg-primary, #e65100) !important;
    background: #fff8f0 !important;
  }
}

/* Mega Menu default theme uppercases panel headings; keep normal case. */
#mega-menu-wrap-primary #mega-menu-primary ul.mega-sub-menu a.mega-menu-link {
  text-transform: none !important;
  font-size: 0.95rem !important;
}

/* Service links appended to the mobile menu */
.handheld-navigation .shop-kg-handheld-service a {
  font-weight: 400 !important;
  color: #cfd8dc !important;
}
.handheld-navigation .shop-kg-handheld-service-first {
  margin-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 0.5rem;
}

/* Tablets / small laptops (768–1099px): compact main menu so it stays on one line.
   Lives here (not style.css) because this file loads later and must override the rules above. */
@media (min-width: 768px) and (max-width: 1099px) {
  #mega-menu-wrap-primary #mega-menu-primary {
    display: flex !important;
    flex-wrap: nowrap;
  }
  #mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item > a.mega-menu-link {
    padding: 0.85rem 0.5rem !important;
    font-size: 0.85rem !important;
    white-space: nowrap;
  }
}

@media (min-width: 768px) and (max-width: 860px) {
  #mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item > a.mega-menu-link {
    padding: 0.85rem 0.35rem !important;
    font-size: 0.8rem !important;
  }
}

@media (min-width: 768px) and (max-width: 800px) {
  #mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item > a.mega-menu-link {
    padding: 0.85rem 0.28rem !important;
    font-size: 0.76rem !important;
  }
}

/* ===== "Каталог" button + panel (desktop) ===== */
.shop-kg-catalog {
  display: none;
}
@media (min-width: 768px) {
  #masthead .storefront-primary-navigation > .col-full {
    position: relative; /* panel spans the whole row */
  }
  .shop-kg-catalog {
    display: block;
    flex: 0 0 auto;
  }
  .shop-kg-catalog-toggle {
    display: inline-flex !important;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7em 1.1em !important;
    margin: 0 !important;
    border-radius: 6px !important;
    font-weight: 700 !important;
    white-space: nowrap;
  }
  .shop-kg-catalog-icon,
  .shop-kg-catalog-icon::before,
  .shop-kg-catalog-icon::after {
    display: block;
    width: 16px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    position: relative;
    content: "";
  }
  .shop-kg-catalog-icon::before { position: absolute; top: -5px; }
  .shop-kg-catalog-icon::after { position: absolute; top: 5px; }
  .shop-kg-catalog.is-open .shop-kg-catalog-icon { background: transparent; }
  .shop-kg-catalog.is-open .shop-kg-catalog-icon::before { top: 0; transform: rotate(45deg); }
  .shop-kg-catalog.is-open .shop-kg-catalog-icon::after { top: 0; transform: rotate(-45deg); }

  .shop-kg-catalog-panel {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 10000;
    padding: 1.5rem 1.75rem 1rem;
    background: #fff;
    border-top: 3px solid var(--shop-kg-primary, #e65100);
    border-radius: 0 0 10px 10px;
    box-shadow: 0 18px 40px rgba(26, 35, 50, 0.22);
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 1.25rem 2rem;
  }
  /* hover bridge so the panel does not close while the pointer travels down to it */
  .shop-kg-catalog-panel::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -18px;
    height: 18px;
  }
  .shop-kg-catalog:hover .shop-kg-catalog-panel,
  .shop-kg-catalog:focus-within .shop-kg-catalog-panel,
  .shop-kg-catalog.is-open .shop-kg-catalog-panel {
    display: grid;
  }
  .shop-kg-catalog-head {
    display: block;
    font-weight: 700;
    color: var(--shop-kg-heading, #1a2332) !important;
    margin-bottom: 0.5rem;
    text-decoration: none;
  }
  .shop-kg-catalog-col ul {
    list-style: none;
    margin: 0;
  }
  .shop-kg-catalog-col li a {
    display: block;
    padding: 0.25rem 0;
    color: #546e7a !important;
    text-decoration: none;
    font-size: 0.92rem;
  }
  .shop-kg-catalog-head:hover,
  .shop-kg-catalog-col li a:hover {
    color: var(--shop-kg-primary, #e65100) !important;
  }
  .shop-kg-catalog-all {
    grid-column: 1 / -1;
    justify-self: start;
    border-top: 1px solid #eceff1;
    padding-top: 0.75rem;
    width: 100%;
    font-weight: 600;
    color: var(--shop-kg-primary, #e65100) !important;
    text-decoration: none;
  }
}

/* "АКЦИЯ!" quick link keeps its accent */
#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item-sale > a.mega-menu-link {
  color: var(--shop-kg-primary-light, #ff9800) !important;
}
