/* Canonical site nav (pairs with js/nav.js).
   Owns: the .nav-toggle button, the <=880px full-height sheet, accordion
   submenus, and the scroll lock. Desktop nav styling stays with each page's
   existing stylesheets; this file only hides the toggle there.
   Load AFTER the page's other stylesheets on every page with the shared header. */

:root {
  --nav-header-h: 60px;
  color-scheme: dark;
}

/* scroll lock while the sheet is open */
html.nav-open,
html.nav-open body { overflow: hidden; }

/* ---------- toggle button ---------- */
body > header .nav-toggle {
  display: none;
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  margin-left: auto;
  cursor: pointer;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  color: #f4f6fb;
  z-index: 130;
}
body > header .nav-toggle .bars,
body > header .nav-toggle .cross { display: block; }
body > header .nav-toggle .cross { display: none; }
body > header .nav-toggle[aria-expanded="true"] .bars { display: none; }
body > header .nav-toggle[aria-expanded="true"] .cross { display: block; }
body > header .nav-toggle:focus-visible {
  outline: 2px solid #ED166C;
  outline-offset: 3px;
  border-radius: 6px;
}

@media (max-width: 880px) {
  /* Solid header on mobile: the 85%-alpha blur let content ghost through.
     backdrop-filter must ALSO go: it turns the header into the containing
     block for fixed descendants, which would pin the sheet to the header's
     scrolled position instead of the viewport. */
  body > header {
    background: #0a0e1a;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  /* While the sheet is open the scroll lock (overflow:hidden) de-activates
     position:sticky, which would let the header (and its ✕) sit off-screen
     at any scroll depth. Pin it for the duration. */
  html.nav-open body > header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 130;
  }
  body > header .nav-toggle { display: inline-flex; }

  /* header row: logo left, toggle right, regardless of legacy flex rules */
  body > header .container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  body > header .logo { order: 0; }
  body > header .nav-toggle { order: 2; }

  /* ---------- the sheet ---------- */
  body > header nav {
    display: block;
    max-height: none; /* stale cached pre-rollout CSS set 80vh; a max-height would cap the sheet */
    position: fixed;
    top: var(--nav-header-h);
    left: 0;
    right: 0;
    height: calc(100vh - var(--nav-header-h));
    height: calc(100dvh - var(--nav-header-h));
    background: #0a0e1a;
    border-top: 1px solid rgba(120, 130, 160, 0.18);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    z-index: 120;
    padding: 0.5rem 0 3rem;
    /* hidden state */
    visibility: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
  }
  html.nav-open body > header nav {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
  }
  @media (prefers-reduced-motion: reduce) {
    body > header nav { transition: none; }
  }

  body > header nav ul {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
  }
  body > header nav ul li { width: 100%; margin: 0; text-align: left; }
  body > header nav ul li > a {
    display: block;
    padding: 0.95rem clamp(1rem, 5vw, 1.5rem);
    min-height: 44px;
    font-size: 1rem;
    line-height: 1.3;
    color: #e8ecf3;
    text-decoration: none;
    border-bottom: 1px solid rgba(120, 130, 160, 0.12);
  }
  body > header nav ul li > a:active { background: rgba(237, 22, 108, 0.08); }

  /* accordion parents */
  body > header nav ul li.dropdown > a { position: relative; }
  body > header nav ul li.dropdown > a::after {
    content: '';
    position: absolute;
    right: clamp(1rem, 5vw, 1.5rem);
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid #8a93a8;
    border-bottom: 2px solid #8a93a8;
    transform: translateY(-70%) rotate(45deg);
    transition: transform 0.15s ease;
  }
  body > header nav ul li.dropdown.active > a::after {
    transform: translateY(-30%) rotate(225deg);
  }

  /* submenus: closed by default, accordion on .active; kill hover behavior */
  body > header nav ul .submenu {
    display: none;
    position: static;
    margin: 0;
    padding: 0;
    background: #0f1424;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  body > header nav ul li.dropdown:hover > .submenu,
  body > header nav ul li.dropdown:focus-within > .submenu { display: none; }
  body > header nav ul li.dropdown.active > .submenu { display: block; }
  body > header nav ul .submenu li a {
    padding-left: clamp(1.75rem, 9vw, 2.5rem);
    font-size: 0.95rem;
    color: #b9c1d4;
  }

  /* highlighted pill (Hosting) renders as a plain sheet item on mobile */
  body > header nav ul li > a.highlight-nav {
    display: block;
    margin: 0;
    background: none;
    border: 0;
    border-bottom: 1px solid rgba(120, 130, 160, 0.12);
    border-radius: 0;
    color: #e8ecf3;
    padding: 0.95rem clamp(1rem, 5vw, 1.5rem);
  }

  /* promoted CTA at the sheet bottom (mobile only) */
  body > header nav ul li.nav-cta-mobile { padding: 1rem clamp(1rem, 5vw, 1.5rem); }
  body > header nav ul li.nav-cta-mobile > a {
    display: block;
    text-align: center;
    background: #ED166C;
    color: #fff;
    border: 0;
    border-radius: 8px;
    font-weight: 700;
    padding: 0.95rem 1rem;
  }
}

/* desktop: the mobile-only CTA row stays out of the horizontal menu */
@media (min-width: 881px) {
  body > header nav ul li.nav-cta-mobile { display: none; }
}

/* While the nav sheet is open, page-level floating buttons (e.g. the docs
   sidebar FAB, z-index 1000000) must not sit above it or open competing
   layers that hide the header. */
html.nav-open .mobile-nav-toggle { display: none !important; }
