/*
 * Shared top navigation.
 *
 * One definition of the bar for every page that has one, taken from the
 * journal. Link this AFTER the page's own <style> block so it settles ties
 * on equal specificity; the !important flags below exist only where pages
 * already used them and would otherwise win.
 *
 * Expects the page to define the usual tokens (--bg, --text, --muted,
 * --line, --line-2, --accent, --text-inverse, --g50, --nav-bg) and this
 * markup:
 *
 *   <nav>
 *     <a class="nav-logo">…</a>
 *     <div class="nav-links">
 *       <a>…</a> <button class="theme-toggle">…</button>
 *       <a class="nav-signin">Sign In</a> <a class="nav-cta">Get Started</a>
 *     </div>
 *     <button class="nav-toggle">…</button>
 *   </nav>
 */

:root nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 70px;
  padding: 14px 52px;
  border: 0;
  border-bottom: 1px solid var(--line, var(--g200));
  background: var(--nav-bg, var(--bg));
  backdrop-filter: blur(20px);
  box-shadow: none;
}

:root nav .nav-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text, var(--ink));
  font-family: 'Geist', system-ui, sans-serif;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}
nav .nav-logo span { color: inherit; }
nav .nav-logo-img { width: 22px; height: 22px; border-radius: 0; object-fit: contain; margin: 0; vertical-align: middle; }

nav .nav-links { display: flex; align-items: center; gap: 30px; min-width: 0; }

:root nav .nav-links > a:not(.nav-cta):not(.nav-signin):not(.nav-dashboard) {
  color: var(--muted, var(--g500));
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
  text-decoration: none;
  text-transform: uppercase;
  transition: color 0.2s ease;
}
nav .nav-links > a:hover,
nav .nav-links > a[aria-current="page"] { color: var(--text, var(--ink)); transform: none; }

/* Sign In: quiet text button. Get Started: the ink one. */
:root nav .nav-links > a.nav-signin {
  padding: 0;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-image: none;
  color: var(--muted, var(--g500)) !important;
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 500 !important;
  letter-spacing: 1px;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color 0.2s ease;
}
nav .nav-links > a.nav-signin:hover { background: transparent; color: var(--text, var(--ink)) !important; }

:root nav .nav-links > a.nav-cta {
  flex: 0 0 auto;
  padding: 9px 18px;
  border: 0;
  border-radius: 6px;
  background-color: var(--text, var(--ink)) !important;
  background-image: none !important;
  box-shadow: none;
  color: var(--bg) !important;
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 500 !important;
  letter-spacing: 1px;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}
nav .nav-links > a.nav-cta:hover { opacity: 0.88; transform: none; }

/* Signed-in state, injected by nav-auth.js. */
nav .nav-account { display: flex; align-items: center; gap: 12px; }
nav .nav-account-name { color: var(--text, var(--ink)); font-size: 12px; font-weight: 500; letter-spacing: 0; text-transform: none; }
nav .nav-dashboard,
:root nav .nav-signout {
  padding: 8px 12px;
  border: 1px solid var(--line-2, var(--g300));
  border-radius: 6px;
  background: transparent;
  color: var(--text, var(--ink)) !important;
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 1px;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
nav .nav-dashboard:hover,
nav .nav-signout:hover { background: var(--g100, var(--g50)); }
nav .nav-signout:hover { color: #ef4444 !important; border-color: #ef4444; }

/* Theme toggle: small pill with the moon/sun glyph. */
:root nav .theme-toggle {
  position: static;
  width: 58px;
  height: 32px;
  flex: 0 0 auto;
  overflow: visible;
  border: 1px solid var(--line-2, var(--g300));
  border-radius: 999px;
  background: var(--g50);
  box-shadow: none;
  color: var(--text, var(--ink));
  cursor: pointer;
  transition: border-color 0.2s ease;
}
nav .theme-toggle:hover { border-color: var(--muted-2, var(--g400, var(--line-2, var(--g300)))); transform: none; }
nav .theme-toggle::before,
nav .theme-toggle::after { content: none !important; }
:root nav .theme-toggle-label {
  position: static;
  width: auto;
  height: auto;
  clip: auto;
  overflow: visible;
  font-size: 0;
}
nav .theme-toggle-label::after { content: '☾'; font-size: 16px; line-height: 1; }
:root[data-theme="light"] nav .theme-toggle-label::after { content: '☀'; }

@media (max-width: 1000px) {
  nav { padding: 14px 24px; }
  :root nav .nav-toggle {
    display: grid;
    gap: 4px;
    padding: 8px;
    border: 0;
    background: transparent;
    cursor: pointer;
  }
  nav .nav-toggle span { display: block; width: 22px; height: 1px; background: var(--text, var(--ink)); }
  :root nav .nav-links {
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    display: none;
    align-items: stretch;
    padding: 18px 24px 26px;
    border-bottom: 1px solid var(--line, var(--g200));
    background: var(--nav-bg, var(--bg));
    backdrop-filter: blur(20px);
  }
  nav .nav-links.open { display: flex; flex-direction: column; gap: 14px; }
  nav .nav-account { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  nav, nav * { transition: none !important; }
}
