/* Shared mobile navigation — pure CSS "checkbox hack", no JavaScript.
 * Loaded last on every page so it overrides each page's own nav rules.
 * CSP-safe: no inline script or style required.
 * Markup (injected before <ul class="nav-links">):
 *   <input type="checkbox" id="nav-toggle" class="nav-toggle" aria-label="Toggle navigation menu">
 *   <label for="nav-toggle" class="nav-burger" aria-hidden="true"><span></span><span></span><span></span></label>
 */

/* Focusable but visually removed; the burger label is the visible affordance. */
.nav-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}

/* Hidden on desktop; the full nav-links row shows instead. */
.nav-burger { display: none; }

@media (max-width: 768px) {
  nav { position: relative; }

  .nav-burger {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    margin-left: auto;
    padding: 11px 9px;
    box-sizing: border-box;
    cursor: pointer;
    border-radius: 6px;
  }

  .nav-burger span {
    display: block;
    width: 100%;
    height: 2px;
    border-radius: 2px;
    background: var(--text, #e8e8ea);
    transition: transform 0.2s ease, opacity 0.2s ease;
  }

  /* Collapsed by default, even where a page's own CSS shows the row. */
  nav .nav-links {
    display: none !important;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: 0.4rem 0;
    z-index: 60;
    background: var(--bg, #0b0b0f);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  }

  /* Expand when the (label-toggled) checkbox is checked. */
  .nav-toggle:checked ~ .nav-links { display: flex !important; }

  nav .nav-links li { width: 100%; }

  nav .nav-links a {
    display: block;
    padding: 0.85rem 1.5rem;
    font-size: 0.78rem;
  }

  nav .nav-links .nav-cta {
    margin: 0.5rem 1.5rem;
    text-align: center;
  }

  /* Animate the three bars into an X while open. */
  .nav-toggle:checked ~ .nav-burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle:checked ~ .nav-burger span:nth-child(2) { opacity: 0; }
  .nav-toggle:checked ~ .nav-burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* Keyboard focus ring lands on the burger when the checkbox is focused. */
  .nav-toggle:focus-visible ~ .nav-burger {
    outline: 3px solid #0066cc;
    outline-offset: 3px;
  }
}

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