/* Shared top bar. Linked by the landing page, the manual, the blog and the
   essays. Colours come from the page's tokens, with the landing palette as
   the fallback so a page that does not define them still matches. */
nav.site {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; flex-wrap: nowrap; gap: 1.6rem;
  row-gap: 0.35rem;
  padding: 0.55rem max(1.25rem, env(safe-area-inset-right)) 0.55rem max(1.25rem, env(safe-area-inset-left));
  background: var(--nav-bg, rgba(255, 255, 255, .95));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft, #e8eaed);
  font-family: Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.925rem;
  box-sizing: border-box;
}
nav.site * { box-sizing: border-box; }
nav.site a { color: var(--muted, #5f6368); font-weight: 500; text-decoration: none; white-space: nowrap; }
nav.site a:hover { color: var(--ink, #202124); text-decoration: none; }
nav.site a.brand { display: flex; align-items: center; margin-right: 0.4rem; }
nav.site a.brand img { height: 28px; width: auto; max-width: none; border-radius: 0; box-shadow: none; }
nav.site a.brand img.dark { display: none; }
:root[data-theme="dark"] nav.site a.brand img.light { display: none; }
:root[data-theme="dark"] nav.site a.brand img.dark { display: block; }
nav.site .spacer { flex: 1; }
.nav-toggle {
  display: none;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink, #202124);
  cursor: pointer;
}
.nav-toggle:focus-visible {
  outline: 2px solid var(--accent, #2f6fb0);
  outline-offset: 3px;
}
.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  position: relative;
}
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
}
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }
nav.site.is-open .nav-toggle-bars { background: transparent; }
nav.site.is-open .nav-toggle-bars::before { top: 0; transform: rotate(45deg); }
nav.site.is-open .nav-toggle-bars::after { top: 0; transform: rotate(-45deg); }
/* Desktop: the panel is not a box, so its links stay in the bar. */
.nav-menu { display: contents; }
nav.site a.cta {
  color: #fff; background: var(--accent, #2f6fb0); padding: 0.4rem 0.95rem; border-radius: 999px;
}
nav.site a.cta:hover { background: var(--accent-deep, #245488); color: #fff; }
nav.site a[aria-current="page"] { color: var(--ink, #202124); }
nav.site .theme-toggle { white-space: nowrap; }

.theme-toggle {
  flex: none; align-self: center;
  font-family: "Roboto Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .72rem; letter-spacing: .02em;
  color: var(--muted, #5f6368); background: var(--surface, #fff);
  border: 1px solid var(--line, #dadce0); border-radius: 999px;
  padding: .35rem .75rem; cursor: pointer; line-height: 1;
}
.theme-toggle:hover { color: var(--ink, #202124); border-color: var(--muted, #5f6368); }
nav.site a.cta:focus-visible, .theme-toggle:focus-visible {
  outline: 2px solid var(--ink, #202124);
  outline-offset: 3px;
}

:root[data-theme="dark"] nav.site {
  background: var(--nav-bg, rgba(14, 18, 23, .92));
  border-bottom-color: var(--line-soft, #1e232b);
}
:root[data-theme="dark"] nav.site a { color: var(--muted, #8b939e); }
:root[data-theme="dark"] nav.site a:hover,
:root[data-theme="dark"] nav.site a[aria-current="page"] { color: var(--ink, #e6e9ee); }
:root[data-theme="dark"] nav.site a.cta { color: #fff; background: var(--accent, #6aa9e0); }
:root[data-theme="dark"] nav.site a.cta:hover { background: var(--accent-deep, #8fc0ee); color: #fff; }
:root[data-theme="dark"] nav.site .theme-toggle {
  color: var(--muted, #8b939e);
  background: var(--surface, #171b21);
  border-color: var(--line, #262c34);
}
:root[data-theme="dark"] nav.site .theme-toggle:hover {
  color: var(--ink, #e6e9ee);
  border-color: var(--muted, #8b939e);
}

@media (max-width: 720px) {
  nav.site { flex-wrap: nowrap; gap: 0.5rem; min-height: 56px; }
  .nav-toggle { display: inline-flex; margin-left: auto; }
  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 30;
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    padding: 0.35rem max(1.15rem, env(safe-area-inset-right)) 0.75rem max(1.15rem, env(safe-area-inset-left));
    background: var(--bg, var(--ground, #fff));
    border-bottom: 1px solid var(--line-soft, var(--line, #e8eaed));
    box-shadow: 0 8px 24px rgba(32, 33, 36, .12);
  }
  nav.site.is-open .nav-menu { display: flex; }
  .nav-menu .spacer { display: none; }
  .nav-menu a,
  .nav-menu .theme-toggle {
    display: flex;
    align-items: center;
    align-self: flex-start;
    min-height: 44px;
    width: fit-content;
    max-width: 100%;
  }
  .nav-menu a.cta { padding: 0.4rem 0.95rem; }
}
:root[data-theme="dark"] .nav-menu {
  background: var(--bg, var(--ground, #0e1217));
  border-bottom-color: var(--line-soft, var(--line, #1e232b));
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
