/* Site navigation layout and mobile hamburger menu, shared by every page.
   Loaded after each page's own styles; /assets/nav.js adds .has-js to <nav>
   and wires up the buttons.

   Layout: the logo and the menu share one row, with the menu on the right.
     >= 1320px       full-size logo, menu links on the right
     1130-1319px     smaller logo, menu links on the right
     <= 1129px       logo and hamburger button on the right; menu opens below
   (Keep 1129px in sync with the media query in /assets/nav.js, and 1319px in
   sync with the home page's .hero rule.) */

.nav-toggle, .sub-toggle { display: none; }

/* Height of the fixed nav at each layout tier. Pages offset their first
   content by var(--nav-h) so it always starts just below the nav. */
:root { --nav-h: 183px; }
@media (min-width: 1130px) and (max-width: 1319px) { :root { --nav-h: 133px; } }
@media (max-width: 1129px) { :root { --nav-h: 123px; } }
@media (max-width: 900px) { :root { --nav-h: 115px; } }
@media (max-width: 480px) { :root { --nav-h: calc(min(273px, 100vw - 104px) * 150 / 455 + 25px); } }

/* Soft gradient line under the nav in place of the flat border */
nav { border-bottom-color: transparent; }
nav::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, rgba(59, 123, 255, 0) 0%, rgba(59, 123, 255, 0.45) 25%, rgba(0, 229, 255, 0.45) 75%, rgba(0, 229, 255, 0) 100%);
}

/* One row: logo left, everything else pushed right */
nav { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; column-gap: 32px; row-gap: 0; }
nav .nav-bottom { width: auto; margin-left: auto; }
nav .nav-links { justify-content: flex-end; }

/* Nested submenu (IT Legacy inside AI/SI Prompts): a flyout that opens to the
   left, shown only while its own item is hovered or focused. The first rules
   out-rank the pages' ".nav-has-sub:hover .nav-sub", which would otherwise
   reveal every nested level as soon as the parent menu opens. */
.nav-sub .nav-has-sub { padding-bottom: 0; margin-bottom: 0; }
.nav-sub .nav-has-sub > a::after { content: none; }
.nav-sub .nav-has-sub > a::before { content: '‹'; margin-right: 6px; opacity: 0.7; }
.nav-has-sub:hover .nav-sub .nav-sub,
.nav-has-sub:focus-within .nav-sub .nav-sub {
  top: -9px; right: 100%; left: auto; min-width: 170px;
  opacity: 0; visibility: hidden; transform: translateX(-4px);
}
.nav-sub .nav-has-sub:hover > .nav-sub,
.nav-sub .nav-has-sub:focus-within > .nav-sub {
  opacity: 1; visibility: visible; transform: none;
}

@media (min-width: 1130px) and (max-width: 1319px) {
  nav .nav-logo img { height: 100px; }
  nav .nav-links { gap: 28px; }
}

@media (max-width: 1129px) {
  nav .nav-logo img { height: 90px; }
  nav.has-js .nav-links { display: none; }

  nav.has-js .nav-toggle {
    display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px;
    margin-left: auto; width: 44px; height: 44px; padding: 0; cursor: pointer;
    background: rgba(240, 244, 255, 0.05); border: 1px solid #1e2a45; border-radius: 8px;
  }
  /* The menu panel drops to its own full-width row under the logo row */
  nav.has-js .nav-bottom { flex-basis: 100%; margin-left: 0; }
  .nav-toggle:focus-visible, .sub-toggle:focus-visible { outline: 2px solid #2563ff; outline-offset: 2px; }
  .nav-toggle-bar {
    display: block; width: 20px; height: 2px; border-radius: 1px; background: #f0f4ff;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
  .nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) { opacity: 0; }
  .nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* Open menu panel (solid background so page content doesn't show through) */
  nav.menu-open { background: #0a0e1a; }
  nav.menu-open .nav-links {
    display: flex; flex-direction: column; gap: 0; width: 100%;
    max-height: calc(100vh - 130px); max-height: calc(100dvh - 130px); overflow-y: auto;
    margin-top: 10px; padding: 4px 0 12px; list-style: none;
  }
  nav.menu-open .nav-links > li { border-bottom: 1px solid #1e2a45; }
  nav.menu-open .nav-links > li > a { display: block; padding: 13px 4px; font-size: 16px; }

  /* Submenus: collapsed under their parent, expanded with the chevron button */
  nav.has-js .nav-has-sub {
    display: grid; grid-template-columns: 1fr auto; align-items: center;
    padding-bottom: 0; margin-bottom: 0;
  }
  nav.has-js .nav-has-sub > a::after { content: none; }
  nav.has-js .sub-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; padding: 0; cursor: pointer;
    background: none; border: none; color: #94a3b8; font-size: 14px;
  }
  .sub-toggle::before { content: '▾'; transition: transform 0.2s ease; }
  .sub-toggle[aria-expanded="true"]::before { transform: rotate(180deg); }
  nav.has-js .nav-has-sub .nav-sub,
  nav.has-js .nav-has-sub:hover .nav-sub,
  nav.has-js .nav-has-sub:focus-within .nav-sub {
    grid-column: 1 / -1; display: none;
    position: static; opacity: 1; visibility: visible; transform: none;
    min-width: 0; margin: 0; padding: 0 0 10px 14px;
    background: none; border: none; border-radius: 0; box-shadow: none;
  }
  nav.has-js .nav-has-sub.sub-open > .nav-sub { display: block; }
  nav.has-js .nav-sub .nav-has-sub > a::before { content: none; }
  nav.has-js .nav-sub .nav-sub { padding-bottom: 4px; }
  nav.has-js .nav-sub a { padding: 9px 10px; font-size: 15px; white-space: normal; }
}

/* Narrow phones: shrink the logo just enough to keep the menu button on its row
   (24px side padding x2 + 44px button + 12px gap = 104px) */
@media (max-width: 480px) {
  nav { column-gap: 12px; }
  nav .nav-logo img { height: auto; width: min(273px, calc(100vw - 104px)); }
}

/* Current page and the menu path that leads to it (marked by /assets/nav.js). */
.nav-links a.nav-trail-link { color: var(--cyan); }
.nav-links a.nav-current { color: var(--cyan); font-weight: 600; }
.nav-sub a.nav-current {
  color: var(--white); background: rgba(0, 229, 255, 0.12); box-shadow: inset 3px 0 0 var(--cyan);
}
