/* nxREclaw — responsive navigation (phones, foldables, small landscape)
   Loaded after each page's inline <style> so it wins on equal specificity. */

nav {
  /* Fallback height used before nav.js measures the real bar. */
  --nav-h: 76px;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* ---------- Hamburger toggle (mobile only) ---------- */
.nav-toggle {
  display: none;
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  background: rgba(34, 211, 238, 0.06);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  transition: 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.nav-toggle:hover,
.nav-toggle:focus-visible {
  color: var(--cyan-bright);
  border-color: rgba(34, 211, 238, 0.45);
  background: rgba(34, 211, 238, 0.12);
}
.nav-toggle-bars {
  display: block;
  position: relative;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: background 0.2s;
}
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.22s ease, top 0.22s ease;
}
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }

/* Animate into an X while the panel is open */
nav.nav-open .nav-toggle-bars { background: transparent; }
nav.nav-open .nav-toggle-bars::before { top: 0; transform: rotate(45deg); }
nav.nav-open .nav-toggle-bars::after { top: 0; transform: rotate(-45deg); }

/* Accessible label, visually hidden */
.nav-toggle-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- Mobile / foldable layout ---------- */
@media (max-width: 980px) {
  .nav-toggle { display: inline-flex; }

  /* Near-opaque bar: mobile browsers that skip backdrop-filter were left
     with a barely-there strip over the hero artwork. */
  nav { background: rgba(5, 5, 12, 0.97); }

  nav .nav-inner {
    gap: 12px;
    padding: 0 16px;
  }

  nav .nav-logo img { height: 56px; }

  /* Drop-down panel instead of the hidden-away desktop row */
  nav .nav-links {
    display: flex;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    flex-wrap: nowrap;
    padding: 10px 16px 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    /* Solid, not translucent: page text ghosted through the panel on dark
       screens, and some mobile browsers drop backdrop-filter entirely. */
    background: #07070f;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
    max-height: calc(100vh - var(--nav-h));
    max-height: calc(100dvh - var(--nav-h));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  }

  nav.nav-open .nav-links {
    visibility: visible;
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  /* Full-width, thumb-sized rows */
  nav .nav-links > a {
    font-size: 1rem;
    padding: 13px 14px;
    border-radius: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }
  nav .nav-links > a:last-of-type { border-bottom: 0; }
  nav .nav-links a.active {
    background: rgba(34, 211, 238, 0.08);
  }
  nav .nav-links .nav-cta {
    margin: 8px 0 4px;
    text-align: center;
    padding: 13px 18px !important;
    border-bottom: 0;
  }
  nav .nav-links .lang-switch {
    margin: 6px 0 0;
    justify-content: center;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }
  nav .nav-links .lang-switch a {
    font-size: 0.95rem;
    padding: 8px 10px !important;
  }
}

/* ---------- Narrow foldable cover screens (down to 280px) ---------- */
@media (max-width: 400px) {
  nav .nav-inner { gap: 8px; padding: 0 12px; }
  nav .nav-logo img { height: 44px; }
  nav .nav-links { padding-left: 12px; padding-right: 12px; }
}

/* ---------- Short viewports: unfolded flip phones, landscape ---------- */
@media (max-width: 980px) and (max-height: 520px) {
  nav .nav-logo img { height: 38px; }
  nav .nav-links > a { padding: 10px 14px; font-size: 0.95rem; }
  nav .nav-links .nav-cta { padding: 10px 18px !important; }
}

@media (prefers-reduced-motion: reduce) {
  nav .nav-links,
  .nav-toggle,
  .nav-toggle-bars,
  .nav-toggle-bars::before,
  .nav-toggle-bars::after {
    transition: none;
  }
}
