/* EM2026 — Navigation — mobile-first */

/* =============================================
   BASE (mobile)
   ============================================= */

.em-nav {
  display: flex;
  align-items: center;
  order: 1;
}

.em-header__logo { order: 2; }
.em-header__cta  { order: 3; }

/* Hamburger button */
.em-nav__toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--em-color-text);
  flex-shrink: 0;
}

.em-nav__toggle svg {
  width: 28px;
  height: 28px;
}

/* Full-screen overlay panel */
.em-nav__panel {
  display: none;
  position: fixed;
  top: calc(var(--em-header-height) + var(--em-admin-bar));
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--em-color-page);
  overflow-y: auto;
  z-index: 99;
  padding-bottom: 2rem;
}

.em-nav--open .em-nav__panel {
  display: block;
}

/* Nav list */
.em-nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Nav items */
.em-nav__item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  border-top: 1px solid rgba(var(--em-color-main-rgb), 0.2);
  position: relative;
}

/* Links */
.em-nav__link {
  flex: 1;
  display: block;
  padding: 1rem;
  color: var(--em-color-text);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease;
}

.em-nav__link:hover,
.em-nav__item--current > .em-nav__link {
  color: var(--em-color-main);
}

/* Sub-toggle button */
.em-nav__sub-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--em-color-text);
  flex-shrink: 0;
}

.em-nav__sub-toggle svg {
  width: 1.25rem;
  height: 1.25rem;
  transition: transform 0.2s ease;
}

.em-nav__item--open > .em-nav__sub-toggle svg {
  transform: rotate(180deg);
}

/* Sub-list */
.em-nav__sub-list {
  display: none;
  width: 100%;
  list-style: none;
  margin: 0;
  padding: 0 0 0.25rem 1.25rem;
}

.em-nav__item--open > .em-nav__sub-list {
  display: block;
}

.em-nav__sub-list .em-nav__item {
  border-top-color: rgba(var(--em-color-main-rgb), 0.1);
}

/* =============================================
   DESKTOP (≥1200px)
   ============================================= */

@media (min-width: 1200px) {
  /* Reset flex order — natural DOM order: logo, nav, cta */
  .em-nav          { order: 0; }
  .em-header__logo { order: 0; }
  .em-header__cta  { order: 0; }

  /* Hide hamburger */
  .em-nav__toggle { display: none; }

  /* Panel: always visible, inline */
  .em-nav__panel {
    display: flex;
    align-items: center;
    position: static;
    background: none;
    overflow: visible;
    z-index: auto;
    padding-bottom: 0;
  }

  .em-header__inner {
    gap: 2rem;
  }

  /* Keep panel visible regardless of open state */
  .em-nav--open .em-nav__panel { display: flex; }

  /* Horizontal list */
  .em-nav__list {
    display: flex;
    gap: 2rem;
    align-items: center;
  }

  /* Reset item to inline */
  .em-nav__item {
    display: block;
    border-top: none;
    position: static;
  }

  .em-nav__item--has-children {
    position: relative;
  }

  /* Reset link */
  .em-nav__link {
    flex: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.3em;
  }

  /* Chevron on parent links */
  .em-nav__item--has-children > .em-nav__link::after {
    content: '';
    display: inline-block;
    width: 0.45em;
    height: 0.45em;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-0.1em);
    flex-shrink: 0;
  }

  /* Hide mobile-only controls */
  .em-nav__sub-toggle { display: none; }

  /* Dropdown submenu */
  .em-nav__sub-list {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    width: max-content;
    background: var(--em-color-page);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    list-style: none;
    margin: 0;
    padding: .5rem 0;
    z-index: 200;
  }

  /* Transparent bridge fills the 0.5rem gap so hover stays active */
  .em-nav__sub-list::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    height: 0.5rem;
  }

  .em-nav__item--has-children:hover > .em-nav__sub-list {
    display: block;
  }

  /* 2-column layout when submenu has more than 10 items */
  .em-nav__sub-list:has(> .em-nav__item:nth-child(11)) {
    display: none;
    grid-template-columns: max-content max-content;
    width: auto;
  }

  .em-nav__item--has-children:hover > .em-nav__sub-list:has(> .em-nav__item:nth-child(11)) {
    display: grid;
    padding: 1rem 0;
  }
  
  .em-nav__item--has-children:hover > .em-nav__sub-list:has(> .em-nav__item:nth-child(11)) .em-nav__link {
    margin-top: .5rem;
    margin-bottom: .5rem;
  }

  .em-nav__sub-list .em-nav__item {
    border-top: none;
  }

  .em-nav__sub-list .em-nav__link {
    display: block;
    padding: 0;
    white-space: nowrap;
    text-align: left;
    margin: 1rem 1.5rem;
  }

  .em-nav__sub-list .em-nav__link:hover {
    text-decoration: underline;
  }

  .em-header {
    padding: 1rem;
  }
}
