/* Max Mega Menu: main menu (location topnav, and topnav-left / topnav-right, the two halves of the Header Centered
   Logo layout, which show the same menu). Loaded after the plugin's own stylesheet on the front end and in
   the editor (inc/megamenu.php). The plugin settings for this menu (colours, sizes, the phone menu's colours) are
   in inc/megamenu.php and the preset's megamenu.php; this file is for everything those settings can't do. */

/* ==============================================================================
   TOP-LEVEL LINKS: pill buttons whose hover background grows from the centre (hoverEffect "background"; "none"
   below turns it off). The corner radius is theme.json settings.custom.menu.hoverRadius (base 50px, a pill; Modular 0px, square). Font family, size, weight and letter
   spacing are settings.custom.menu too, set per style in each preset's theme.json; the plugin has no letter-spacing
   setting, so that one is here.
   ============================================================================== */

:is(
    #mega-menu-wrap-topnav,
    #mega-menu-wrap-topnav-left,
    #mega-menu-wrap-topnav-right
  )
  :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
  > li
  > a.mega-menu-link {
  position: relative !important;
  padding: 8px 20px !important;
  border-radius: var(--wp--custom--menu--hover-radius, 50px) !important;
  z-index: 1 !important;
  background: transparent !important;
  transition: color 0.3s ease;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  letter-spacing: var(--wp--custom--menu--letter-spacing, normal) !important;
}

:is(
    #mega-menu-wrap-topnav,
    #mega-menu-wrap-topnav-left,
    #mega-menu-wrap-topnav-right
  )
  :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
  > li
  > a.mega-menu-link::before {
  content: "" !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background-color: var(--wp--preset--color--white) !important;
  opacity: 0.1;
  border-radius: var(--wp--custom--menu--hover-radius, 50px) !important;
  z-index: -1 !important;
  transform: scale(0) !important;
  transform-origin: center !important;
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1) !important;
}

:is(
    #mega-menu-wrap-topnav,
    #mega-menu-wrap-topnav-left,
    #mega-menu-wrap-topnav-right
  )
  :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
  > li:hover
  > a.mega-menu-link::before {
  transform: scale(1) !important;
}

:is(
    #mega-menu-wrap-topnav,
    #mega-menu-wrap-topnav-left,
    #mega-menu-wrap-topnav-right
  )
  :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
  > li:hover
  > a.mega-menu-link {
  color: var(--wp--preset--color--white) !important;
}

/* Hover effect "none" (theme.json settings.custom.menu.hoverEffect, body class swiss-menu-hover-none): no
   background, only the link colour changes. */
.swiss-menu-hover-none
  :is(
    #mega-menu-wrap-topnav,
    #mega-menu-wrap-topnav-left,
    #mega-menu-wrap-topnav-right
  )
  :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
  > li
  > a.mega-menu-link::before {
  display: none !important;
}

/* ==============================================================================
   DROPDOWN INDICATOR: a plus that turns into a minus on hover (replaces the plugin's arrow). Indicator "none"
   (settings.custom.menu.indicator, body class swiss-menu-indicator-none) hides it on desktop; the phone menu keeps
   it, since tapping it opens a submenu there.
   ============================================================================== */

@media (min-width: 1024px) {
  .swiss-menu-indicator-none
    :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    li.mega-menu-item-has-children
    > a.mega-menu-link
    .mega-indicator {
    display: none !important;
  }
}

:is(
    #mega-menu-wrap-topnav,
    #mega-menu-wrap-topnav-left,
    #mega-menu-wrap-topnav-right
  )
  :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
  li.mega-menu-item-has-children
  > a.mega-menu-link
  .mega-indicator {
  background: none !important;
  mask-image: none !important;
  -webkit-mask-image: none !important;
  font-family: inherit !important;
  display: inline-block !important;
  vertical-align: middle !important;
  position: relative !important;
  width: 12px !important;
  height: 12px !important;
  margin-left: 8px !important;
  margin-top: 0 !important;
}

:is(
    #mega-menu-wrap-topnav,
    #mega-menu-wrap-topnav-left,
    #mega-menu-wrap-topnav-right
  )
  :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
  li.mega-menu-item-has-children
  > a.mega-menu-link
  .mega-indicator::after,
:is(
    #mega-menu-wrap-topnav,
    #mega-menu-wrap-topnav-left,
    #mega-menu-wrap-topnav-right
  )
  :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
  li.mega-menu-item-has-children
  > a.mega-menu-link
  .mega-indicator::before {
  content: "" !important;
  display: block !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  background-color: var(--wp--preset--color--medium-gray) !important;
  transform: translate(-50%, -50%) !important;
  transition: transform 0.3s ease !important;
}

/* The horizontal line. */
:is(
    #mega-menu-wrap-topnav,
    #mega-menu-wrap-topnav-left,
    #mega-menu-wrap-topnav-right
  )
  :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
  li.mega-menu-item-has-children
  > a.mega-menu-link
  .mega-indicator::after {
  width: 10px !important;
  height: 2px !important;
}

/* The vertical line. */
:is(
    #mega-menu-wrap-topnav,
    #mega-menu-wrap-topnav-left,
    #mega-menu-wrap-topnav-right
  )
  :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
  li.mega-menu-item-has-children
  > a.mega-menu-link
  .mega-indicator::before {
  width: 2px !important;
  height: 10px !important;
}

:is(
    #mega-menu-wrap-topnav,
    #mega-menu-wrap-topnav-left,
    #mega-menu-wrap-topnav-right
  )
  :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
  li.mega-menu-item-has-children:hover
  > a.mega-menu-link
  .mega-indicator::after {
  transform: translate(-50%, -50%) rotate(180deg) !important;
}

:is(
    #mega-menu-wrap-topnav,
    #mega-menu-wrap-topnav-left,
    #mega-menu-wrap-topnav-right
  )
  :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
  li.mega-menu-item-has-children:hover
  > a.mega-menu-link
  .mega-indicator::before {
  transform: translate(-50%, -50%) scaleY(0) !important;
}

/* ==============================================================================
   DROPDOWNS: open 11px below the link; the transparent top border keeps the hover connected
   ============================================================================== */

:is(
    #mega-menu-wrap-topnav,
    #mega-menu-wrap-topnav-left,
    #mega-menu-wrap-topnav-right
  )
  li.mega-menu-item
  > ul.mega-sub-menu {
  border-top: 11px solid transparent !important;
  background-clip: padding-box !important;
  margin-top: 0 !important;
}

/* Desktop: a top-level dropdown starts at the bottom edge of the header bar, whatever the bar's height (18 Nov
   2026, the user's report: in the full 90px bar the fixed 11px gap opened it 14px inside the bar; it was only right
   in the 64px docked bar). The gap is half of what the bar adds around the 40px link: the header height
   (--swiss-header-height) at full height, the Sticky Header plugin's shrunk height (--bsh-shrink-header-height)
   once docked. 40px is the top-level link row's height on desktop; change it here if that changes. */
@media (min-width: 1024px) {
  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    > li.mega-menu-item
    > ul.mega-sub-menu {
    border-top-width: max(
      11px,
      calc((var(--swiss-header-height, 90px) - 40px) / 2)
    ) !important;
  }

  .bsh-header.bsh-docked.bsh-has-shrink-height
    :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    > li.mega-menu-item
    > ul.mega-sub-menu {
    border-top-width: max(
      11px,
      calc((var(--bsh-shrink-header-height, 64px) - 40px) / 2)
    ) !important;
  }
}

/* ==============================================================================
   DESKTOP SEARCH: a main-menu item (the last one) whose Mega Menu replacement is Search, "Expand to left". Open, it
   covers every menu item, whatever the menu's length (Archway-style): the item, and the wrapper the plugin
   positions the form in, are static, so the form is placed against the whole menu list (which is relative) and
   stretches across it when open; the icon stays where it was. Only Search type, Placeholder text and Hide on
   mobile matter in Appearance > Menus; colours and sizes are set here. Icon colours: --swiss-menu-search-icon
   (closed; the top-level link colour, or Contrast on the light tone's solid bar, style.css LIGHT HEADER) and
   --swiss-menu-search-icon-hover; open, the field is --swiss-menu-search-bg with Contrast text and icon.
   ============================================================================== */

@media (min-width: 1024px) {
  /* The last item keeps no spacing on its right, so the menu (and the open search) ends at its last item. */
  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    > li.mega-menu-item:last-child {
    margin-right: 0 !important;
  }

  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    > li.mega-menu-item:has(> .mega-search-wrap .expand-to-left),
  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    > li.mega-menu-item
    > .mega-search-wrap:has(.expand-to-left) {
    position: static !important;
  }

  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    > li.mega-menu-item
    > .mega-search-wrap:has(.expand-to-left) {
    width: 40px !important;
    height: 40px !important;
  }

  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    li.mega-menu-item
    .mega-search.expand-to-left {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    left: auto !important;
    z-index: 3 !important;
    display: flex !important;
    justify-content: flex-end !important;
    height: 40px !important;
  }

  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    li.mega-menu-item
    .mega-search.expand-to-left.mega-search-open {
    left: 0 !important;
  }

  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    li.mega-menu-item
    .mega-search.expand-to-left
    input[type="text"] {
    width: 100% !important;
    height: 40px !important;
    margin: 0 !important;
    padding: 0 44px 0 20px !important;
    border: 0 !important;
    border-radius: var(--wp--custom--menu--hover-radius, 50px) !important;
    background-color: var(
      --swiss-menu-search-bg,
      var(--wp--preset--color--extra-light-gray)
    ) !important;
    color: var(--wp--preset--color--contrast) !important;
    font-family: var(--wp--custom--menu--font-family) !important;
    font-size: var(--wp--custom--menu--font-size, 1rem) !important;
    line-height: 40px !important;
    transition:
      width 0.6s,
      background-color 0.6s !important;
  }

  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    li.mega-menu-item
    .mega-search.expand-to-left.mega-search-closed
    input[type="text"] {
    width: 40px !important;
    padding: 0 !important;
    background-color: transparent !important;
  }

  /* Placeholder: the same font and size as the menu links. */
  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    li.mega-menu-item
    .mega-search.expand-to-left
    input[type="text"]::placeholder {
    color: var(--wp--preset--color--dark-gray) !important;
    font-family: var(--wp--custom--menu--font-family) !important;
    font-size: var(--wp--custom--menu--font-size, 1rem) !important;
    opacity: 1 !important;
  }

  /* The icon: 24px (the plugin's dashicon is 20px), in a 40px box at the right. */
  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    li.mega-menu-item
    .mega-search.expand-to-left
    .search-icon {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    width: 40px !important;
    height: 40px !important;
  }

  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    li.mega-menu-item
    .mega-search.expand-to-left
    .search-icon::before {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    font-size: 24px !important;
    color: var(
      --swiss-menu-search-icon,
      var(--wp--custom--menu--link-color, var(--wp--preset--color--light-gray))
    ) !important;
    transition: color 0.3s ease !important;
  }

  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    li.mega-menu-item
    .mega-search.expand-to-left.mega-search-closed
    .search-icon:hover::before {
    color: var(
      --swiss-menu-search-icon-hover,
      var(--wp--custom--menu--link-hover-color, var(--wp--preset--color--white))
    ) !important;
  }

  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    li.mega-menu-item
    .mega-search.expand-to-left.mega-search-open
    .search-icon::before {
    color: var(--wp--preset--color--contrast) !important;
  }
}

/* ==============================================================================
   PHONE MENU
   ============================================================================== */

/* No close button in the slide-out panel. */
@media (max-width: 1023px) {
  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    .mega-close {
    display: none !important;
  }
}

/* No pill hover background on the phone menu's links (desktop keeps it); the plus/minus indicator stays. */
@media (max-width: 1023px) {
  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    > li
    > a.mega-menu-link::before {
    display: none !important;
  }

  /* Dropdowns open just under their parent: no desktop gap border, 3px extra space above and below. */
  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    li.mega-menu-item
    > ul.mega-sub-menu {
    border-top: 0 !important;
    padding-top: 3px !important;
    padding-bottom: 3px !important;
  }

  /* Dropdown links sit 10px in from the top-level links (20px, the pill padding above) in 37px rows, slightly
     tighter than the 40px top-level rows, so the indent and the minus sign are what mark the submenu. */
  :is(
      #mega-menu-wrap-topnav,
      #mega-menu-wrap-topnav-left,
      #mega-menu-wrap-topnav-right
    )
    :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
    li.mega-menu-item
    > ul.mega-sub-menu
    a.mega-menu-link {
    padding-left: 30px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    height: 37px !important;
    line-height: 37px !important;
  }
}

/* Search bar at the top of the panel: a menu item with the CSS class "mobile-search" whose Mega Menu
   replacement is Search (static), hidden on desktop. Leave its colour and size settings in Appearance > Menus at
   their defaults; this sets them. The caption under it is written per site. */
:is(
    #mega-menu-wrap-topnav,
    #mega-menu-wrap-topnav-left,
    #mega-menu-wrap-topnav-right
  )
  :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
  li.mega-mobile-search
  .mega-search
  input[type="text"] {
  color: var(--wp--preset--color--white) !important;
  background-color: rgb(255 255 255 / 0.1) !important;
  height: 30px !important;
  border-radius: 2px !important;
}

:is(
    #mega-menu-wrap-topnav,
    #mega-menu-wrap-topnav-left,
    #mega-menu-wrap-topnav-right
  )
  :is(#mega-menu-topnav, #mega-menu-topnav-left, #mega-menu-topnav-right)
  li.mega-mobile-search
  .mega-search
  .search-icon::before {
  color: var(--wp--preset--color--white) !important;
}

@media (max-width: 1023px) {
  .mega-menu-wrap .mega-menu li .mega-search-wrap {
    margin: 5px 0 50px !important;
    display: block !important;
  }

  li.mega-mobile-search .mega-search-wrap {
    position: relative !important;
    height: 60px;
  }

  .mega-menu-wrap
    .mega-menu
    li
    .mega-search.mega-search-open
    input::placeholder {
    color: rgb(68, 68, 68);
    font-size: var(--wp--custom--menu--mobile-font-size);
  }

  li.mega-mobile-search .mega-search-wrap::after {
    content: "Swiss Theme";
    display: block;
    width: 100%;
    color: #fff;
    text-align: center;
    padding-top: 14px;
    font-size: 1rem;
  }

  .mega-menu-wrap .mega-menu li.mega-mobile-search {
    border-bottom: 1px solid #fff;
  }
}
