/*
 * Navigation on scroll.
 * The theme adds .scroll-menu after 100px of scroll. It replayed a 2s slide-in animation
 * (opacity 0, top -100%) that made the whole nav vanish for a moment.
 *
 * Desktop: the logo + buttons row slides up out of view (up to the divider line) and the
 *          menu row stays pinned to the top.
 * Tablet and below: the bar is always visible.
 */
.menu-fixed.scroll-menu {
  animation: none;
  opacity: 1;
}

@media (min-width: 992px) {
  .menu-fixed.menu-top-logo {
    transition: top .3s ease;
  }

  /* keep the top row in place and slide the whole nav up by its height (100px) */
  .menu-fixed.scroll-menu.menu-top-logo {
    top: -100px;
    padding-top: 100px;
    transition: top .3s ease;
  }

  .menu-fixed.scroll-menu.menu-top-logo .menu-brand,
  .menu-fixed.scroll-menu.menu-top-logo .menu-right {
    display: flex;
  }
}

/*
 * Tablet and below: the opened menu must always be fully reachable, whatever the scroll position.
 * The theme sets the menu's max-height once on page load (inline style) and lets the page scroll
 * behind it, so long menus (e.g. with "What We Do" expanded) were cut off.
 */
@media (max-width: 991.98px) {
  :root {
    --nav-h: 95px;
  }

  body > nav.menu-fixed .menu-cnt {
    max-height: calc(100vh - var(--nav-h)) !important;
    max-height: calc(100dvh - var(--nav-h)) !important;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* don't let the page scroll behind the open menu */
  html:has(nav.menu-fixed.active),
  body:has(nav.menu-fixed.active) {
    overflow: hidden;
  }
}

/* Phones: smaller logo and slightly tighter menu rows so the whole menu fits more often. */
@media (max-width: 767.98px) {
  :root {
    --nav-h: 72px;
  }

  body > nav .menu-brand img {
    height: 52px;
    width: auto;
  }

  body > nav .menu-brand {
    padding: 10px 0;
    height: auto;
  }

  body > nav .menu-brand a {
    height: 52px;
  }

  body > nav.menu-fixed > .container {
    height: var(--nav-h);
    min-height: 0;
  }

  body > nav.menu-fixed .menu-cnt li > a {
    height: 44px;
    line-height: 44px;
  }
}
