/* Global header for the English and German sites. */
html { scrollbar-gutter: stable; }

.nav {
  --header-height: 76px;
  position: sticky;
  top: 0;
  z-index: 50;
  color: var(--fg);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.nav > .wrap,
.nav-links,
.nav-actions {
  display: flex;
  align-items: center;
}

.nav > .wrap {
  min-height: var(--header-height);
  gap: clamp(16px, 3vw, 48px);
}

.nav .brand :is(img, svg) { width: 160px; height: auto; aspect-ratio: 312 / 72; }
.nav-links { margin-inline: auto; gap: clamp(14px, 2.2vw, 32px); }
.nav-actions { gap: 12px; }

.nav-direct,
.menu-toggle,
.lang-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  color: var(--fg-2, var(--muted));
  font: 550 14px/1.4 var(--sans);
  white-space: nowrap;
}

.menu-toggle {
  anchor-name: --nav-toggle;
  /* Only a desktop pointer should open the menu without activation. */
  interest-delay: calc(infinity * 1s) 180ms;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.menu-toggle::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-top: -3px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

.nav-disclosure:has(:popover-open) .menu-toggle::after {
  margin-top: 3px;
  transform: rotate(225deg);
}

.nav-direct:hover,
.menu-toggle:hover,
.lang-switch:hover,
.nav-disclosure:has(:popover-open) .menu-toggle { color: var(--accent); }

.nav-direct[aria-current],
.nav-disclosure:has(.resource-links [aria-current]) .desktop-label,
.nav-panel a[aria-current] {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.lang-switch {
  min-width: 40px;
  font: 600 12px/1 var(--mono, ui-monospace, monospace);
  letter-spacing: .04em;
}

.nav .btn { min-height: 44px; white-space: nowrap; }
/* The English homepage uses a longer contact label than the other pages. */
.nav:lang(en) .btn { inline-size: 12em; }

.nav-panel {
  position: fixed;
  inset: var(--header-height) auto auto;
  left: 50%;
  left: anchor(--nav-toggle left, 50%);
  margin: 0;
  width: max-content;
  min-width: 216px;
  max-height: calc(100dvh - var(--header-height));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 0 0 4px 4px;
  background: var(--surface, #fdfdf9);
  color: var(--fg);
  box-shadow: 0 8px 20px rgb(24 46 43 / 9%);
}

.nav-panel a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 2px;
  font: 500 14px/1.4 var(--sans);
}

.nav-panel a:hover,
.nav-panel a:focus-visible {
  color: var(--accent);
  background: var(--bg);
}
.nav-panel a:focus-visible { outline-offset: -2px; }

.mobile-label, .menu-service, .menu-heading, .menu-footer { display: none; }

@media (min-width: 900px) and (max-width: 1023px) {
  .nav > .wrap { gap: 16px; }
  .nav-links { gap: 14px; }
}

@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  /* Keep the trigger under the pointer all the way down to the panel. */
  .menu-toggle { min-height: var(--header-height); }
  .menu-toggle:hover { interest-delay-start: 100ms; }
  @supports selector(:popover-open) and (not selector(:interest-source)) {
    .nav-disclosure { position: relative; }
    /* Let the native button control the panel when navigating by keyboard. */
    .nav-disclosure:hover:not(:has(.menu-toggle:focus-visible)) {
      .nav-panel:not(:popover-open) {
        display: block;
        position: absolute;
        inset: 100% auto auto 0;
      }
      .menu-toggle { color: var(--accent); }
      .menu-toggle::after {
        margin-top: 3px;
        transform: rotate(225deg);
      }
    }
  }
}

@media (min-width: 900px) and (prefers-reduced-motion: no-preference) {
  .nav-panel { animation: resources-open 140ms ease-out; }
  @keyframes resources-open {
    from { opacity: 0; transform: translateY(-3px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (max-width: 899px) {
  .nav { --header-height: 64px; }
  .nav > .wrap { gap: 16px; }
  .nav .brand { flex: 0 1 146px; min-width: 0; }
  .nav .brand :is(img, svg) { width: 100%; }
  .nav-links { margin-inline: auto 0; }
  .nav-direct, .desktop-label, .nav-actions .lang-switch { display: none; }
  .mobile-label { display: inline; }
  .menu-toggle { min-width: 64px; color: var(--fg); }
  .nav-panel {
    inset-inline: auto 0;
    width: min(100%, 460px);
    padding: 18px 20px 8px;
  }
  .nav-panel:popover-open {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 20px;
  }
  .menu-service, .menu-heading { display: block; }
  .menu-heading {
    margin: 0 0 4px;
    padding: 0 8px 9px;
    border-bottom: 1px solid var(--line);
    color: var(--signature);
    font: 600 13px/1.4 var(--sans);
  }
  .nav-panel a { padding-inline: 8px; }
  .menu-footer {
    display: flex;
    justify-content: space-between;
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    padding-top: 4px;
  }
}

@media (max-width: 540px) {
  .nav > .wrap { gap: 8px; padding-inline: 12px; }
  .nav .brand { flex-basis: 132px; }
  .nav .btn { padding: 7px 10px; font-size: 12px; }
  .nav:lang(en) .btn { inline-size: 11.25em; }
  .nav-panel { padding-inline: 12px; }
  .nav-panel:popover-open { column-gap: 8px; }
}

/* Keep the destinations usable in browsers without native popovers. */
@supports not selector(:popover-open) {
  .nav { position: static; }
  .nav > .wrap { flex-wrap: wrap; justify-content: space-between; row-gap: 0; }
  .nav-links { order: 1; width: 100%; flex-wrap: wrap; gap: 0 18px; }
  .nav-direct, .nav-actions .lang-switch { display: inline-flex; }
  .nav-disclosure, .nav-panel, .resource-links { display: contents; }
  .menu-toggle, .menu-service, .menu-heading, .menu-footer { display: none; }
  .nav-panel a { padding-inline: 0; }
}
