/* Three-bar menu button. Sites set color via currentColor.
   The disclosure itself is display:contents so it does not take a
   grid/flex cell; only the summary (the bars) participates in layout.
   Put nav-bar on the row that holds the logo, optional mobile CTA, and
   details.nav-menu so the button stays trailing on small screens. */

.nav-menu { display: contents; }

.nav-toggle {
  display: none;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: inherit;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  line-height: 1;
  list-style: none;
  touch-action: manipulation;
  margin-left: auto;
  justify-self: end;
  grid-column: -1;
  grid-row: 1;
}
.nav-toggle:focus {
  outline: none;
}
.nav-toggle:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}
.nav-toggle:active {
  opacity: 0.7;
}
.nav-toggle::-webkit-details-marker,
.nav-toggle::marker {
  display: none;
  content: none;
}

.nav-toggle-bars {
  display: block;
  position: relative;
  width: 18px;
  height: 12px;
}
.nav-toggle-bars span {
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.2s ease, opacity 0.2s ease, top 0.2s ease;
}
.nav-toggle-bars span:nth-child(1) { top: 0; }
.nav-toggle-bars span:nth-child(2) { top: 5px; }
.nav-toggle-bars span:nth-child(3) { top: 10px; }

.nav-toggle[aria-expanded="true"] .nav-toggle-bars span:nth-child(1),
details.nav-menu[open] .nav-toggle-bars span:nth-child(1) {
  top: 5px;
  transform: rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bars span:nth-child(2),
details.nav-menu[open] .nav-toggle-bars span:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bars span:nth-child(3),
details.nav-menu[open] .nav-toggle-bars span:nth-child(3) {
  top: 5px;
  transform: rotate(-45deg);
}

@media (prefers-reduced-motion: reduce) {
  .nav-toggle-bars span { transition: none; }
}

/* Mobile nav row: logo left, optional CTA, menu button flush right. */
@media (max-width: 1040px) {
  :is(.nav .wrap, .masthead-top, .masthead__inner, .nav-min .nav-row, .bar).nav-bar:has(.nav-menu) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    column-gap: 0.75rem;
  }
  :is(.nav .wrap, .masthead-top, .masthead__inner, .nav-min .nav-row, .bar).nav-bar:has(.nav-menu) > :is(.nav-logo, .wordmark, a.wordmark, .logo) {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }
  :is(.nav .wrap, .masthead-top, .masthead__inner, .nav-min .nav-row, .bar).nav-bar:has(.nav-menu) > :is(.nav-cta, .nav-phone, .nav-book, .bar-cta, .masthead__call) {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    margin-left: 0;
  }
}

/* Restore desktop nav layout once the menu button is hidden. */
@media (min-width: 641px) {
  .nav-min .nav-row.nav-bar:has(.nav-menu) { display: flex; }
}
@media (min-width: 861px) {
  :is(.masthead-top, .bar, .masthead__inner).nav-bar:has(.nav-menu) { display: flex; }
}
