.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header__inner {
  max-width: var(--page-max);
  margin: 0 auto;
  height: var(--header-height);
  padding: 0 var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}

.header__brand:hover {
  text-decoration: none;
  color: var(--ink);
}

/* The full TechFabric lockup. The wordmark half is drawn in currentColor so it is
   correct on a light ground as well as the dark one it was designed for; the
   crimson half is fixed in the artwork. */
.header__logo {
  height: 26px;
  width: auto;
  flex: none;
  color: var(--ink);
}

.header__divider {
  width: 1px;
  height: 18px;
  background: var(--border-strong);
  flex: none;
}

.header__title {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.theme-toggle {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--ink-muted);
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.theme-toggle:hover {
  color: var(--ink);
  background: var(--surface-raised);
  border-color: var(--border-strong);
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
}

.theme-toggle__moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__sun {
    display: none;
  }

  :root:not([data-theme="light"]) .theme-toggle__moon {
    display: block;
  }
}

:root[data-theme="dark"] .theme-toggle__sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle__moon {
  display: block;
}

:root[data-theme="light"] .theme-toggle__sun {
  display: block;
}

:root[data-theme="light"] .theme-toggle__moon {
  display: none;
}

@media (max-width: 40rem) {
  .header__divider,
  .header__title {
    display: none;
  }

  .header__inner {
    padding: 0 var(--space-4);
    gap: var(--space-3);
  }
}

/* The one action worth taking from any page in the manual. Sits with search and
   the theme toggle so it is present on every chapter, not only the front door. */
.header__contact {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-base);
  letter-spacing: var(--tracking-subheading);
  color: var(--ink);
  text-decoration: none;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.header__contact:hover {
  color: var(--surface);
  background: var(--ink);
  border-color: var(--ink);
}

/* Below the search box's own breakpoint the header is tight; the footer and the
   contents page both carry the same link, so hiding it here costs nothing. */
@media (max-width: 40rem) {
  .header__contact { display: none; }
}
