/* ═══════════════════════════════════════════════════════
   NAVIGATION — fixed top bar, hamburger, mobile overlay
   Depends on: tokens.css
   ═══════════════════════════════════════════════════════ */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 202;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  padding-inline: var(--gutter);
  transition: background 0.6s var(--ease-out), box-shadow 0.6s;
}

.nav.scrolled {
  background: rgba(25, 31, 46, 0.88);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  box-shadow: 0 1px 40px rgba(0, 0, 0, 0.4);
}

.nav__inner {
  width: 100%;
  max-width: var(--content-w);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Logo ──────────────────────────────────────────────── */
.nav__logo {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  transition: opacity 0.3s;
}
.nav__logo:hover { opacity: 0.75; }

.nav__logomark {
  height: 26px;
  width: auto;
  color: var(--accent);
  flex-shrink: 0;
  transition: color 0.9s ease, opacity 0.5s ease;
  will-change: opacity, color;
}

.nav__wordmark {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text);
  transition: color 0.3s;
}

/* ── Desktop links ─────────────────────────────────────── */
.nav__links {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  list-style: none;
}

.nav__links a {
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted); /* was --text-dim (≈2.8:1); --text-muted passes WCAG AA 4.5:1 */
  transition: color 0.3s;
}
.nav__links a:hover    { color: var(--text); }
.nav__link--active     { color: var(--accent) !important; }

/* ── Language toggle ───────────────────────────────────── */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 1.5rem;
}

.lang-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  transition: color 0.3s;
  /* 44×44px Apple HIG / WCAG 2.5.5 minimum touch target */
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.lang-btn.active { color: var(--accent); }
.lang-btn:hover  { color: var(--text-muted); }
.lang-sep        { color: var(--text-dim); font-size: 0.7rem; }

/* ── Theme toggle pill ──────────────────────────────────── */
.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  background: rgba(128,128,128,0.10);
  border: 1px solid rgba(128,128,128,0.08);
  border-radius: 99px;
  padding: 3px;
  margin-left: 0.75rem;
  flex-shrink: 0;
}

/* Sliding highlight — covers active icon */
.theme-toggle__thumb {
  position: absolute;
  left: 3px;
  top: 3px;
  bottom: 3px;
  width: calc(50% - 3px);
  background: var(--accent);
  border-radius: 99px;
  transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1),
              background 0.38s ease;
  pointer-events: none;
  z-index: 0;
}
/* Slide to the right (☾) in light mode */
[data-theme="light"] .theme-toggle__thumb { transform: translateX(100%); }

.theme-toggle__opt {
  position: relative;
  z-index: 1;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1;
  padding: 4px 10px;
  border-radius: 99px;
  color: var(--text-dim);
  transition: color 0.38s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
}
/* Active icon gets bg-contrast colour */
[data-theme="dark"]  .theme-toggle__opt[data-value="dark"],
[data-theme="light"] .theme-toggle__opt[data-value="light"] { color: var(--bg); }
.theme-toggle__opt:hover { opacity: 0.8; }

/* ── Hamburger ─────────────────────────────────────────── */
.nav__hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
  z-index: 203; /* always above overlay */
}

.nav__hamburger span {
  display: block;
  position: absolute;
  width: 22px;
  height: 1.5px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.4s var(--ease-out), opacity 0.3s, top 0.4s var(--ease-out);
}
.nav__hamburger span:nth-child(1) { top: 16px; }
.nav__hamburger span:nth-child(2) { top: 22px; }
.nav__hamburger span:nth-child(3) { top: 28px; }

/* X state when open */
.nav__hamburger[aria-expanded="true"] span:nth-child(1) {
  top: 22px; transform: rotate(45deg);
}
.nav__hamburger[aria-expanded="true"] span:nth-child(2) {
  opacity: 0; transform: scaleX(0);
}
.nav__hamburger[aria-expanded="true"] span:nth-child(3) {
  top: 22px; transform: rotate(-45deg);
}

/* ── Mobile overlay ────────────────────────────────────── */
@media (max-width: 768px) {
  .nav__hamburger { display: flex; }
  .nav__logomark  { display: none; }
  .nav            { padding-inline: 16px; }

  .nav__links {
    position: fixed;
    inset: 0;
    z-index: 201;
    background: rgba(13, 17, 28, 0.97);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0;
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity 0.4s var(--ease-out), transform 0.4s var(--ease-out);
    pointer-events: none;
  }
  .nav__links.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
  .nav__links a {
    font-size: clamp(1.6rem, 7vw, 2.2rem);
    letter-spacing: 0.12em;
    padding: 0.75rem 0;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.4s var(--ease-out), transform 0.4s var(--ease-out), color 0.2s;
  }
  .nav__links.open a                   { opacity: 1; transform: translateY(0); }
  .nav__links.open li:nth-child(1) a  { transition-delay: 0.05s; }
  .nav__links.open li:nth-child(2) a  { transition-delay: 0.10s; }
  .nav__links.open li:nth-child(3) a  { transition-delay: 0.15s; }
  .nav__links.open li:nth-child(4) a  { transition-delay: 0.20s; }

  .lang-toggle {
    margin-left: 0;
    margin-top: 2rem;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s 0.25s var(--ease-out), transform 0.4s 0.25s var(--ease-out);
  }
  .nav__links.open .lang-toggle { opacity: 1; transform: translateY(0); }

  .theme-toggle {
    margin-left: 0;
    margin-top: 1rem;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s 0.30s var(--ease-out), transform 0.4s 0.30s var(--ease-out);
    padding: 5px;
  }
  .theme-toggle__opt {
    font-size: 1.25rem;
    padding: 8px 18px;
  }
  .theme-toggle__thumb {
    transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1);
    left: 5px; top: 5px; bottom: 5px;
    width: calc(50% - 5px);
  }
  .nav__links.open .theme-toggle { opacity: 1; transform: translateY(0); }

  /* No GPU blur on mobile nav */
  .nav.scrolled {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(13, 17, 28, 0.96) !important;
  }
}

/* ── Light mode nav overrides ──────────────────────────── */
[data-theme="light"] .nav.scrolled {
  background: rgba(240, 237, 228, 0.90);
  box-shadow: 0 1px 40px rgba(124, 85, 53, 0.09);
}
@media (max-width: 768px) {
  [data-theme="light"] .nav__links {
    background: rgba(240, 237, 228, 0.97);
  }
  [data-theme="light"] .nav.scrolled {
    background: rgba(240, 237, 228, 0.96) !important;
  }
}

/* iOS scroll lock when mobile menu is open */
body.menu-open {
  overflow: hidden;
  touch-action: none;
}
