/* Editor submenus. Click or tap opens them. Hover does not.
   Phone (the hamburger breakpoint) keeps the group in the drawer. */

.nav-sub {
  position: relative;
  list-style: none;
}

.nav-sub__bar {
  display: inline-flex;
  align-items: center;
  gap: 0.15em;
}

.nav-sub__toggle {
  font: inherit;
  font-family: inherit;
  font-weight: 500;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-align: left;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  appearance: none;
  -webkit-appearance: none;
  white-space: nowrap;
  vertical-align: middle;
  box-sizing: border-box;
}

.nav-sub__toggle::after {
  content: "▾";
  font-size: 0.75em;
  line-height: 1;
  opacity: 0.75;
  margin-left: 0.2em;
}

.nav-sub__toggle[aria-expanded="true"]::after {
  content: " ▴";
}

.nav-sub__toggle:hover,
.nav-sub__toggle:focus {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.nav-sub__menu[hidden] {
  display: none !important;
}

.nav-sub__menu {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.35rem 0 0;
  padding: 0.45rem 0.65rem;
  list-style: none;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(57, 255, 20, 0.28);
  box-shadow: 0 0 12px rgba(57, 255, 20, 0.12);
}

.nav-sub__menu a {
  font-size: 14px !important;
  color: #c8f5c8 !important;
  text-decoration: none !important;
  padding: 0.2rem 0;
}

.nav-sub__menu a:hover,
.nav-sub__menu a:focus {
  color: #39ff14 !important;
  text-decoration: underline !important;
}

@media (min-width: 769px) {
  .nav-sub__menu {
    position: absolute;
    top: calc(100% + 0.45rem);
    right: 0;
    min-width: 11rem;
    z-index: 1200;
  }

  /* Linked parent: the empty arrow button kept a 44px min-width and
     centered the caret, which left a gap after the label (My story on
     iPad landscape). Keep the 44px hit target, but put the caret at
     the start of the button, right next to the label. */
  .nav-sub__bar > a + .nav-sub__toggle {
    justify-content: flex-start;
  }

  .nav-sub__bar > a + .nav-sub__toggle::after {
    margin-left: 0;
  }
}

@media (max-width: 768px) {
  .nav-sub__toggle {
    display: block;
    padding: 0.65rem 1.25rem;
  }

  .nav-sub__bar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 0;
    position: relative;
  }

  /* A linked parent (label link + arrow button) keeps the arrow on the
     link's row. Without this the empty arrow button took its own row
     and showed as a stray caret under the label. */
  .nav-sub__bar > a + .nav-sub__toggle {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: inline-flex;
    width: auto;
    padding: 0 1.25rem;
  }

  .nav-sub__menu {
    position: static;
    margin: 0 1.25rem 0.35rem;
  }

  .nav-sub__menu a {
    display: block;
    padding: 0.45rem 0.25rem !important;
  }

  .site-nav.is-open:has(.nav-sub__toggle[aria-expanded="true"]) {
    max-height: 80vh;
    overflow: auto;
  }
}
