/*
 * Services submenu for the LEGACY header (Work, Us, Careers, Resources,
 * Contact, blog). Loaded by gd-core/inc/functions/legacy.php on non-gd-core
 * pages only. DELETE ON MIGRATION with that file.
 *
 * Mirrors gd-core's header dropdown (layout/_header.scss) and mobile accordion
 * (components/_mobile-menu.scss) on the legacy markup: the default WP walker's
 * <li class="has-submenu"> + <button class="subnav-toggle"> + <ul class="sub-menu">.
 * Plain CSS on purpose - the legacy library/scss build is not reproduced here.
 */

/* ---------- Desktop (.desktop-nav shows from 40em) ---------- */

.desktop-nav .has-submenu {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.desktop-nav .subnav-toggle,
.main-nav-wrapper .subnav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: none;
  color: #f5f4f0; /* the legacy header links' colour on every legacy page */
  cursor: pointer;
}

.desktop-nav .subnav-toggle {
  width: 1.5rem;
  height: 1.5rem;
  margin-left: -0.125rem;
}

.desktop-nav .subnav-toggle svg,
.main-nav-wrapper .subnav-toggle svg {
  transition: transform 0.3s ease;
}

.desktop-nav .sub-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  z-index: 2;
  min-width: 16rem;
  margin: 0;
  padding: 0.5rem;
  list-style: none;
  text-align: left;
  background-color: #1d1d1d;
  border-radius: 4px 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35), 0 0 15px rgba(243, 243, 243, 0.08);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, 0.25rem);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0.25s;
}

/* the brand hairline, never a fill */
.desktop-nav .sub-menu::before {
  content: "";
  position: absolute;
  top: 0;
  left: 1rem;
  right: 1rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, #F04B51, transparent);
}

/* bridge the gap to the item so the pointer can travel down without closing */
.desktop-nav .sub-menu::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 0.75rem;
}

.desktop-nav .sub-menu li {
  display: block;
  margin: 0;
  padding: 0;
}

.desktop-nav .sub-menu a {
  display: block;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  line-height: 1.3;
  letter-spacing: 0.02rem;
  color: #fff;
  white-space: nowrap;
  background: none;
  border-radius: 4px 12px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.desktop-nav .sub-menu a:hover,
.desktop-nav .sub-menu a:focus-visible {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.06);
}

.desktop-nav .sub-menu .current-menu-item > a {
  color: #F04B51;
}

.desktop-nav .has-submenu:hover > .sub-menu,
.desktop-nav .has-submenu:focus-within > .sub-menu,
.desktop-nav .has-submenu.is-expanded > .sub-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, 0.75rem);
  transition-delay: 0s;
}

.desktop-nav .has-submenu:hover > .subnav-toggle svg,
.desktop-nav .has-submenu:focus-within > .subnav-toggle svg,
.desktop-nav .has-submenu.is-expanded > .subnav-toggle svg {
  transform: rotate(180deg);
}

/* ---------- Mobile panel (.main-nav-wrapper.open, full screen) ---------- */

.main-nav-wrapper .has-submenu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.main-nav-wrapper .subnav-toggle {
  width: 2.75rem;
  height: 2.75rem;
  margin-left: 0.25rem;
}

.main-nav-wrapper .subnav-toggle svg {
  width: 1.5rem;
  height: 1.5rem;
}

.main-nav-wrapper .sub-menu {
  flex-basis: 100%;
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  visibility: hidden;
  transition: max-height 0.3s ease, visibility 0s linear 0.3s;
}

.main-nav-wrapper .sub-menu li {
  display: block;
  margin: 0;
  padding: 0 0 0 0.25rem;
  line-height: 1.2;
}

.main-nav-wrapper .sub-menu a {
  display: block;
  padding: 0.3rem 0;
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.25;
  color: rgba(245, 244, 240, 0.85) !important; /* legacy forces link colour with !important */
}

.main-nav-wrapper .sub-menu .current-menu-item > a {
  color: #F04B51 !important;
}

.main-nav-wrapper .has-submenu.is-expanded > .sub-menu {
  max-height: 40rem;
  visibility: visible;
  margin-bottom: 0.5rem;
  transition: max-height 0.3s ease, visibility 0s;
}

.main-nav-wrapper .has-submenu.is-expanded > .subnav-toggle svg {
  transform: rotate(180deg);
}

/* the expanded list can push the panel past a short phone screen */
.main-nav-wrapper.open {
  overflow-y: auto;
}
