/*
 * Navigation refinement (WaveLocal). Loaded after header.css and mega.css so it wins where they overlap.
 *  1. Navigation typography: clean, mixed-case, semibold sans-serif for the desktop header, the mega menu and the
 *     mobile menu. Oswald stays for hero and section headings and for the primary button.
 *  2. The mobile menu: left-aligned rows with separators, an enquiry panel, a dimmed backdrop, a fade and slide.
 * The menu content and markup come from config/nav.php, app/components/navigation.php and app/components/header.php.
 */
:root {
  /* Navigation uses the body font: the stack is set once, in base.css. */
  --navFont: var(--bodyFont);
}

/* ------------------------------------------------------------------ desktop */
@media only screen and (min-width: 1024px) {
  /* Logo | Services  Case Studies  About  Insights | Let's Talk + theme switch. The links are a flex item that
     fills the space between the logo and the call to action, so they are centred in that space. */
  #cs-navigation .cs-logo {
    margin-right: 0;
  }
  #cs-navigation .cs-nav {
    display: flex;
    flex: 1 1 auto;
    align-self: stretch;
    justify-content: center;
    min-width: 0;
  }
  #cs-navigation .cs-ul-wrapper {
    position: static;
    transform: none;
    width: auto;
    height: 100%;
  }
  #cs-navigation .cs-ul {
    width: auto;
    gap: clamp(1.75rem, 2.2vw, 2rem);
  }
  #cs-navigation .cs-li-link {
    text-transform: none;
    font-family: var(--navFont);
    font-size: 1.0625rem;
    line-height: 1.4em;
    font-weight: 600;
    letter-spacing: 0;
  }
  #cs-navigation .cs-li-link.cs-active {
    font-weight: 600;
  }
  /* Light mode: the brand cyan fails contrast on white at this size, so hover, open and current states use the
     darker link blue already used for links elsewhere. Dark mode keeps its cyan (rules in header.css and mega.css). */
  #cs-navigation .cs-li-link:hover,
  #cs-navigation .cs-li-link.cs-active,
  #cs-navigation .cs-mega.is-open .cs-mega__trigger {
    color: var(--linkOnLight, #0a74b5);
  }
  /* The links are shorter than the header now, so give the mega menu's hover bridge a little more reach. */
  #cs-navigation .cs-mega:after {
    height: 3.25rem;
  }
  /* Let's Talk is the only way to Contact from the desktop header, so it shows at every desktop width. */
  #cs-navigation > .cs-container > .cs-button-solid {
    display: block;
    flex: none;
    min-width: 0;
    padding: 0 2.25rem;
    font-size: 1.0625rem;
    line-height: 3.125rem;
    right: 0;
  }
  /* Mobile-only pieces. */
  #cs-navigation .cs-nav-chev,
  #cs-navigation .cs-enquiry,
  .cs-backdrop {
    display: none;
  }
}
/* ------------------------------------------------------------------ mobile menu */
@media only screen and (max-width: 1023px) {
  /* Home and Contact stay in the desktop header only: the logo goes home and the panel below leads to Contact. */
  #cs-navigation .cs-li--desktop {
    display: none;
  }

  /* The menu container: fades and slides down from under the floating header. It scrolls on its own. */
  #cs-navigation .cs-ul-wrapper {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.625rem);
    border-radius: 1.5rem;
    background-color: #fff;
    max-height: calc(100vh - 3rem);
    max-height: calc(100dvh - 3rem);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0;
    box-shadow: 0 1.25rem 3rem rgba(0, 20, 40, 0.22);
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0.22s;
  }
  #cs-navigation.cs-active .cs-ul-wrapper {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition-delay: 0s;
  }
  /* The header's own panel no longer grows when the menu opens: the menu container lines up with it instead. */
  #cs-navigation.cs-active:before {
    transform: translateX(-50%);
  }

  /* Primary links: left-aligned, mixed case, semibold, with separators. */
  #cs-navigation .cs-ul {
    display: block;
    margin: 0;
    padding: 4.75rem 1.25rem 0.25rem;
    max-height: none;
    overflow: visible;
  }
  #cs-navigation .cs-li,
  #cs-navigation.cs-active .cs-li {
    opacity: 1;
    transform: none;
    transition: none;
    margin: 0;
    width: 100%;
    text-align: left;
  }
  #cs-navigation .cs-li:not(.cs-li--desktop) ~ .cs-li:not(.cs-li--desktop) {
    border-top: 1px solid rgba(0, 31, 63, 0.1);
  }
  #cs-navigation .cs-li-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0;
    min-height: 3.5rem;
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0;
    text-transform: none;
    text-align: left;
    font-family: var(--navFont);
    font-size: 1.1875rem;
    line-height: 1.25em;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--headerColor);
  }
  #cs-navigation .cs-li-link.cs-active {
    color: var(--linkOnLight, #0a74b5);
  }
  #cs-navigation .cs-nav-chev {
    flex: none;
    opacity: 0.5;
  }

  /* The enquiry panel: part of the menu, not a banner. */
  #cs-navigation .cs-enquiry {
    margin: 0.75rem 1.25rem 1.25rem;
    border: 1px solid rgba(67, 183, 255, 0.3);
    border-radius: 1.25rem;
    background-color: #eaf5fd;
    padding: 1.25rem 1.25rem 0.9rem;
    text-align: left;
  }
  #cs-navigation .cs-enquiry__title {
    margin: 0 0 0.35rem;
    font-family: var(--navFont);
    font-size: 1.25rem;
    line-height: 1.2em;
    font-weight: 700;
    color: var(--headerColor);
  }
  #cs-navigation .cs-enquiry__text {
    margin: 0 0 1rem;
    font-family: var(--navFont);
    font-size: 1rem;
    line-height: 1.5em;
    color: var(--bodyTextColor);
  }
  #cs-navigation .cs-enquiry .cs-button-solid {
    display: block;
    min-width: 0;
    width: 100%;
    padding: 0 1rem;
    line-height: 3.25rem;
  }
  #cs-navigation .cs-enquiry__mail {
    display: block;
    margin-top: 0.15rem;
    padding: 0.7rem 0 0.4rem;
    text-align: center;
    text-decoration: none;
    overflow-wrap: anywhere;
    font-family: var(--navFont);
    font-size: 0.9375rem;
    line-height: 1.3em;
    font-weight: 600;
    color: var(--linkOnLight, #0a74b5);
  }
  #cs-navigation .cs-enquiry__mail:hover {
    text-decoration: underline;
  }

  /* Dim the page behind the open menu. Tapping it closes the menu (see main.js). */
  .cs-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9990;
    opacity: 0;
    visibility: hidden;
    background-color: rgba(0, 16, 32, 0.42);
    transition: opacity 0.22s ease, visibility 0s linear 0.22s;
  }
  body.cs-open .cs-backdrop {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
  }
  /* No background scrolling while the menu is open (body is locked in base.css; this covers the root too). */
  html:has(body.cs-open) {
    overflow: hidden;
  }

  /* Dark mode: the space theme is kept, with softer separators and a blue-tinted enquiry panel. */
  html.dark-mode #cs-navigation .cs-ul-wrapper {
    border: 1px solid rgba(255, 255, 255, 0.08);
    background-color: var(--dark);
    box-shadow: rgba(67, 183, 255, 0.16) 0 0 28px, rgba(0, 0, 0, 0.6) 0 1.25rem 3rem;
  }
  html.dark-mode #cs-navigation .cs-li:not(.cs-li--desktop) ~ .cs-li:not(.cs-li--desktop) {
    border-top-color: rgba(255, 255, 255, 0.12);
  }
  html.dark-mode #cs-navigation .cs-li-link {
    color: #fff;
  }
  html.dark-mode #cs-navigation .cs-li-link.cs-active {
    color: var(--secondary);
  }
  html.dark-mode #cs-navigation .cs-enquiry {
    border-color: rgba(67, 183, 255, 0.3);
    background-color: rgba(67, 183, 255, 0.1);
  }
  html.dark-mode #cs-navigation .cs-enquiry__title {
    color: #fff;
  }
  html.dark-mode #cs-navigation .cs-enquiry__text {
    color: rgba(255, 255, 255, 0.8);
  }
  html.dark-mode #cs-navigation .cs-enquiry__mail {
    color: var(--secondary);
  }
  html.dark-mode .cs-backdrop {
    background-color: rgba(0, 4, 12, 0.62);
  }
}

@media (prefers-reduced-motion: reduce) {
  #cs-navigation .cs-ul-wrapper,
  .cs-backdrop {
    transition: none !important;
  }
}
