header.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

header.top .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}

.brand {
  font-family: var(--heading);
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
}

.brand.with-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand .logo {
  height: 44px;
  width: auto;
  flex: none;
}

/* A logo drawn only in black; dark themes set --logo-mono-filter to lighten it. */
.brand .logo.mono {
  filter: var(--logo-mono-filter, none);
}

.nav-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-bar a {
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .95rem;
  color: var(--muted);
}

.nav-bar a:hover {
  color: var(--text);
}

.nav-bar a.btn {
  background: var(--accent);
  color: var(--accent-text);
}

/* Hamburger: on phones only, and only once shared/menu/ has switched the
 * slide-out menu on (it removes `hidden`). Without the script, phones keep
 * just the contact button, as before. */
.menu-toggle {
  display: none;
}

.menu-icon,
.menu-icon::before,
.menu-icon::after {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.menu-icon {
  position: relative;
}

.menu-icon::before,
.menu-icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.menu-icon::before {
  top: -7px;
}

.menu-icon::after {
  top: 7px;
}

/* Slide-out menu: every section on the page, from the left. Outside the
 * header, whose backdrop-filter would otherwise confine the fixed panel. */
.menu {
  position: fixed;
  inset: 0;
  z-index: 20;
  visibility: hidden;
  transition: visibility 0s .3s;
}

.menu.is-open {
  visibility: visible;
  transition: none;
}

.menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 24, .5);
  opacity: 0;
  transition: opacity .3s;
}

.menu.is-open .menu-backdrop {
  opacity: 1;
}

.menu-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  width: min(320px, 85vw);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  color: var(--text);
  box-shadow: 8px 0 32px rgba(0, 0, 0, .25);
  transform: translateX(-100%);
  transition: transform .3s cubic-bezier(.2, .8, .2, 1);
}

.menu.is-open .menu-panel {
  transform: none;
}

.menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 0 10px 0 20px;
  border-bottom: 1px solid var(--line);
}

.menu-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--heading);
  font-weight: 700;
  font-size: 1.15rem;
}

.menu-toggle,
.menu-close {
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: inherit;
  cursor: pointer;
}

.menu-close {
  display: grid;
}

.menu-close svg {
  width: 24px;
  height: 24px;
}

.menu-toggle:hover,
.menu-close:hover {
  background: color-mix(in srgb, var(--text) 8%, transparent);
}

.menu-list {
  list-style: none;
  margin: 0;
  padding: 10px 0;
}

.menu-list a {
  display: block;
  padding: 14px 20px 14px 17px;
  border-left: 3px solid transparent;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.05rem;
}

.menu-list a:hover,
.menu-list a:focus-visible {
  background: color-mix(in srgb, var(--text) 5%, transparent);
  border-left-color: var(--highlight);
  outline: none;
}

/* The page behind an open menu doesn't scroll. */
html.menu-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  header.top .wrap {
    gap: 8px;
  }

  .menu-toggle:not([hidden]) {
    display: grid;
    margin-left: -10px;
    color: var(--text);
  }

  /* With the hamburger on the left, the title follows it. */
  .brand {
    margin-right: auto;
  }

  .nav-bar a:not(.btn) {
    display: none;
  }

  .brand .logo {
    height: 36px;
  }
}

@media (min-width: 641px) {
  .menu {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .menu,
  .menu-backdrop,
  .menu-panel {
    transition: none;
  }
}

/* On small phones the logo stands in for the title. */
@media (max-width: 420px) {
  .brand.with-logo span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}
