/* AS Category Mega Menu v1.0.5 */

.et-l--header .as-category-menu-host {
  position: relative !important;
  overflow: visible !important;
  z-index: 10020;
}

.et-l--header .as-category-menu-trigger[aria-expanded="true"] {
  filter: brightness(.94);
}

.as-category-mega-menu,
.as-category-mega-menu *,
.as-mobile-categories-item,
.as-mobile-categories-item * {
  box-sizing: border-box;
}

.as-category-mega-menu[hidden],
.as-category-mega-menu__panel[hidden],
.as-mobile-categories-panel[hidden],
.as-mobile-category-children[hidden] {
  display: none !important;
}

/* Desktop + tablet mega menu. */
@media (min-width: 768px) {
  .et-l--header .as-category-mega-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1280px;
    margin: 8px 0 0;
    padding: 0;
    color: #2f3440;
    background: #ffffff;
    border: 1px solid #e3e7ed;
    border-radius: 14px;
    box-shadow: 0 18px 42px rgba(47, 52, 64, .16);
    font-family: Inter, Arial, sans-serif;
    z-index: 10030;
    overflow: hidden;
  }

  .et-l--header .as-category-mega-menu__inner {
    display: grid;
    grid-template-columns: minmax(210px, 260px) minmax(0, 1fr);
    min-height: 340px;
    max-height: min(68vh, 620px);
  }

  .et-l--header .as-category-mega-menu__roots {
    margin: 0;
    padding: 10px;
    background: #f7f8fa;
    border-right: 1px solid #e8ebef;
    overflow-y: auto;
  }

  .et-l--header .as-category-mega-menu__root {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 46px;
    margin: 0 0 4px;
    padding: 10px 12px;
    color: #2f3440;
    background: transparent;
    border: 0;
    border-radius: 9px;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
  }

  .et-l--header .as-category-mega-menu__root:hover,
  .et-l--header .as-category-mega-menu__root:focus-visible,
  .et-l--header .as-category-mega-menu__root.is-active {
    color: #4c78d3;
    background: #ffffff;
    outline: none;
  }

  .et-l--header .as-category-mega-menu__root:focus-visible {
    box-shadow: inset 0 0 0 2px rgba(76, 120, 211, .28);
  }

  .et-l--header .as-category-mega-menu__chevron {
    flex: 0 0 auto;
    color: #7a828e;
    font-size: 22px;
    line-height: 1;
  }

  .et-l--header .as-category-mega-menu__panels {
    min-width: 0;
    overflow-y: auto;
    background: #ffffff;
  }

  .et-l--header .as-category-mega-menu__panel {
    padding: 24px 28px 28px;
  }

  .et-l--header .as-category-mega-menu__panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid #edf0f3;
  }

  .et-l--header .as-category-mega-menu__title {
    margin: 0;
    padding: 0;
    color: #2f3440;
    font-family: Inter, Arial, sans-serif;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.25;
  }

  .et-l--header .as-category-mega-menu__all {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 auto;
    color: #4c78d3;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
  }

  .et-l--header .as-category-mega-menu__all:hover,
  .et-l--header .as-category-mega-menu__all:focus-visible {
    color: #b64a9a;
    text-decoration: underline;
  }

  .et-l--header .as-category-mega-menu__children {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px 18px;
  }

  .et-l--header .as-category-mega-menu__child {
    display: flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 10px;
    color: #3f4652;
    background: transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.35;
    text-decoration: none;
  }

  .et-l--header .as-category-mega-menu__child:hover,
  .et-l--header .as-category-mega-menu__child:focus-visible {
    color: #4c78d3;
    background: #f7f8fa;
    outline: none;
  }

  .et-l--header .as-category-mega-menu__empty {
    margin: 4px 0 0;
    color: #69717d;
    font-size: 14px;
    line-height: 1.5;
  }
}

/* Tablet: keep the panel generous, but reduce the category grid to two columns. */
@media (min-width: 768px) and (max-width: 980px) {
  .et-l--header .as-category-mega-menu {
    width: calc(100% - 28px);
    max-width: none;
  }

  .et-l--header .as-category-mega-menu__inner {
    grid-template-columns: 220px minmax(0, 1fr);
    max-height: 66vh;
  }

  .et-l--header .as-category-mega-menu__panel {
    padding: 22px 22px 24px;
  }

  .et-l--header .as-category-mega-menu__children {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 12px;
  }

  .et-l--header .as-category-mega-menu__title {
    font-size: 20px;
  }
}

/* Mobile accordion injected into the existing Divi hamburger menu. */
@media (max-width: 767px) {
  .et-l--header .as-category-mega-menu {
    display: none !important;
  }

  .et-l--header .as-mobile-nav-menu .et_mobile_menu .as-mobile-categories-item {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    border-bottom: 1px solid #e9edf1 !important;
  }

  .et-l--header .as-mobile-categories-toggle,
  .et-l--header .as-mobile-category-root {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 12px 18px !important;
    color: #2f3440 !important;
    background: #ffffff !important;
    border: 0 !important;
    border-radius: 0 !important;
    font-family: Inter, Arial, sans-serif !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
    text-align: left !important;
    cursor: pointer !important;
    box-shadow: none !important;
  }

  .et-l--header .as-mobile-categories-toggle {
    color: #b64a9a !important;
    font-weight: 700 !important;
  }

  .et-l--header .as-mobile-categories-toggle:hover,
  .et-l--header .as-mobile-categories-toggle:focus-visible,
  .et-l--header .as-mobile-category-root:hover,
  .et-l--header .as-mobile-category-root:focus-visible,
  .et-l--header .as-mobile-category-root.is-open {
    color: #4c78d3 !important;
    background: #f7f8fa !important;
    outline: none !important;
  }

  .et-l--header .as-mobile-categories-toggle__icon,
  .et-l--header .as-mobile-category-root__icon {
    flex: 0 0 auto !important;
    font-size: 20px !important;
    font-weight: 400 !important;
    line-height: 1 !important;
    transition: transform .18s ease !important;
  }

  .et-l--header .as-mobile-categories-toggle[aria-expanded="true"] .as-mobile-categories-toggle__icon,
  .et-l--header .as-mobile-category-root[aria-expanded="true"] .as-mobile-category-root__icon {
    transform: rotate(45deg) !important;
  }

  .et-l--header .as-mobile-categories-panel {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 0 6px !important;
    background: #f7f8fa !important;
  }

  .et-l--header .as-mobile-category-group {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border-top: 1px solid #edf0f3 !important;
  }

  .et-l--header .as-mobile-category-root {
    padding-left: 24px !important;
    background: #f7f8fa !important;
    font-size: 15px !important;
  }

  .et-l--header .as-mobile-category-children {
    width: 100% !important;
    margin: 0 !important;
    padding: 4px 0 8px !important;
    background: #ffffff !important;
  }

  .et-l--header .as-mobile-nav-menu .et_mobile_menu .as-mobile-category-children a,
  .et-l--header .as-mobile-nav-menu .et_mobile_menu .as-mobile-category-direct {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 10px 24px 10px 34px !important;
    color: #3f4652 !important;
    background: #ffffff !important;
    border: 0 !important;
    border-bottom: 1px solid #f0f2f5 !important;
    font-family: Inter, Arial, sans-serif !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    line-height: 1.35 !important;
    text-align: left !important;
    text-decoration: none !important;
  }

  .et-l--header .as-mobile-nav-menu .et_mobile_menu .as-mobile-category-direct {
    padding-left: 24px !important;
    background: #f7f8fa !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    border-top: 1px solid #edf0f3 !important;
  }

  .et-l--header .as-mobile-nav-menu .et_mobile_menu .as-mobile-category-children a:hover,
  .et-l--header .as-mobile-nav-menu .et_mobile_menu .as-mobile-category-children a:focus-visible,
  .et-l--header .as-mobile-nav-menu .et_mobile_menu .as-mobile-category-direct:hover,
  .et-l--header .as-mobile-nav-menu .et_mobile_menu .as-mobile-category-direct:focus-visible {
    color: #4c78d3 !important;
    background: #f7f8fa !important;
    outline: none !important;
  }

  .et-l--header .as-mobile-nav-menu .et_mobile_menu .as-mobile-category-all {
    color: #4c78d3 !important;
    font-weight: 600 !important;
  }
}

/* v1.0.2: robust mobile disclosure indicators.
 * Divi can suppress the text glyph spans inside injected buttons, so the
 * arrows are drawn with pseudo-elements instead. This makes it obvious which
 * roots expand and which entries are direct links.
 */
@media (max-width: 767px) {
  .et-l--header .as-mobile-categories-toggle__icon,
  .et-l--header .as-mobile-category-root__icon {
    display: none !important;
  }

  .et-l--header .as-mobile-categories-toggle::after,
  .et-l--header .as-mobile-category-root::after {
    content: "›" !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 22px !important;
    width: 22px !important;
    height: 22px !important;
    margin-left: auto !important;
    color: #7a828e !important;
    font-size: 22px !important;
    font-weight: 400 !important;
    line-height: 1 !important;
    transform: rotate(0deg) !important;
    transition: transform .18s ease, color .18s ease !important;
  }

  .et-l--header .as-mobile-categories-toggle[aria-expanded="true"]::after,
  .et-l--header .as-mobile-category-root[aria-expanded="true"]::after {
    color: #4c78d3 !important;
    transform: rotate(90deg) !important;
  }

  .et-l--header .as-mobile-category-direct > span:last-child {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 22px !important;
    width: 22px !important;
    color: #7a828e !important;
    font-size: 18px !important;
    line-height: 1 !important;
  }
}

/* v1.0.5: active state for the current WooCommerce category context. */
@media (min-width: 768px) {
  .et-l--header .as-category-mega-menu__root.is-current {
    font-weight: 700;
    box-shadow: inset 3px 0 0 #4c78d3;
  }

  .et-l--header .as-category-mega-menu__child.is-current,
  .et-l--header .as-category-mega-menu__all.is-current {
    color: #4c78d3;
    background: #eef4ff;
    font-weight: 700;
  }

  .et-l--header .as-category-mega-menu__all.is-current {
    padding: 7px 10px;
    border-radius: 8px;
    text-decoration: none;
  }
}

@media (max-width: 767px) {
  .et-l--header .as-mobile-category-root.is-current {
    color: #4c78d3 !important;
    background: #eef4ff !important;
    box-shadow: inset 3px 0 0 #4c78d3 !important;
    font-weight: 700 !important;
  }

  .et-l--header .as-mobile-nav-menu .et_mobile_menu .as-mobile-category-children a.is-current,
  .et-l--header .as-mobile-nav-menu .et_mobile_menu .as-mobile-category-direct.is-current {
    color: #4c78d3 !important;
    background: #eef4ff !important;
    box-shadow: inset 3px 0 0 #4c78d3 !important;
    font-weight: 700 !important;
  }
}
