/* ─── Shared Navigation ─── */
/* Included by all pages via <link rel="stylesheet" href="nav.css"> */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 17, 20, 0.82);
  backdrop-filter: blur(16px) saturate(1.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: var(--max-w, 960px);
  margin: 0 auto;
  padding: 0 var(--space-lg, 32px);
  display: flex;
  align-items: center;
  gap: var(--space-sm, 12px);
  min-height: 56px;
}

.brand {
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm, 12px);
  align-items: center;
  margin-left: auto;
}
.nav a {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
}
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a.active { color: var(--accent); font-weight: 600; }

/* ─── Theme toggle ─── */
.theme-toggle {
  background: var(--surface, #1c1f26);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  margin-left: 8px;
  transition: background 0.2s;
}
.theme-toggle:hover { background: var(--surface-hover); }

/* ─── Hamburger ─── */
.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 6px 10px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 6px;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
  margin-left: auto;
}
.hamburger:hover { background: var(--surface); }
.hamburger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ─── Mobile: hamburger dropdown ─── */
@media (max-width: 640px) {
  .hamburger { display: inline-flex; }
  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: rgba(15, 17, 20, 0.96);
    backdrop-filter: blur(16px) saturate(1.6);
    -webkit-backdrop-filter: blur(16px) saturate(1.6);
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
    z-index: 99;
    gap: 0;
  }
  .nav.nav-open {
    display: flex;
    animation: nav-fade-in 0.2s ease-out;
  }
  .nav a {
    padding: 14px 24px;
    min-height: 44px;
    display: flex;
    align-items: center;
    font-size: 15px;
    border-radius: 0;
    width: 100%;
    box-sizing: border-box;
  }
  .nav a:hover { background: var(--surface); }
  .topbar { position: sticky; }
  .topbar-inner { position: relative; }
}

@keyframes nav-fade-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Responsive nav spacing ─── */
@media (max-width: 779px) {
  .topbar-inner { padding: 0 var(--space-md, 20px); }
  .nav { gap: var(--space-xs, 6px); }
  .nav a { padding: 10px 14px; min-height: 44px; display: inline-flex; align-items: center; font-size: 14px; }
}

/* ─── Light mode ─── */
[data-theme="light"] .topbar {
  background: rgba(248, 249, 251, 0.82);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .topbar {
    background: rgba(248, 249, 251, 0.82);
  }
}
@media (max-width: 640px) {
  [data-theme="light"] .nav {
    background: rgba(248, 249, 251, 0.96);
  }
}
@media (max-width: 640px) and (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .nav {
    background: rgba(248, 249, 251, 0.96);
  }
}

/* ─── Focus indicators ─── */
.nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
