/* Public navigation adaptation.
   The desktop composition stays open; only the navigation density changes when
   the header no longer has enough room for its full information hierarchy. */

html body header[data-adaptive-nav] {
  --nav-inline-gap: 6px;
  --nav-link-padding: 14px;
  --nav-control-size: 44px;
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto;
  align-items: center;
  min-width: 0;
}

html body header[data-adaptive-nav] > :is(.brand, .portal-brand) { min-width: 0; }

html body header[data-adaptive-nav] > nav {
  min-width: 0;
  width: 100%;
  justify-self: stretch;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--nav-inline-gap);
}

html body header[data-adaptive-nav] > nav > a {
  min-height: var(--nav-control-size);
  min-width: 0;
  padding-inline: var(--nav-link-padding);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: 999px;
}

html body header[data-adaptive-nav] > nav > form {
  min-height: var(--nav-control-size);
  display: flex;
  align-items: center;
}

html body header[data-adaptive-nav] > nav > form .text-button {
  min-height: var(--nav-control-size);
  padding-inline: var(--nav-link-padding);
  border-radius: 999px;
}

html body header[data-adaptive-nav] > .nav-menu-toggle {
  display: none;
  appearance: none;
  width: var(--nav-control-size);
  height: var(--nav-control-size);
  padding: 0;
  place-items: center;
  flex-shrink: 0;
  cursor: pointer;
  color: var(--site-ink, var(--ink, currentColor));
  background: var(--control-glass, var(--glass-fill, var(--panel, transparent)));
  border: 1px solid var(--control-edge, var(--glass-edge, var(--line, currentColor)));
  border-radius: 50%;
  box-shadow: var(--control-shadow, var(--glass-shadow, none));
  backdrop-filter: blur(16px) saturate(125%);
  -webkit-backdrop-filter: blur(16px) saturate(125%);
}

html body header[data-adaptive-nav] > .nav-menu-toggle:hover {
  background: var(--control-hover, var(--site-panel, var(--panel, transparent)));
}

html body header[data-adaptive-nav] > .nav-menu-toggle:active {
  transform: scale(.972);
}

.nav-menu-toggle svg {
  width: 20px;
  height: 20px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.nav-menu-toggle .nav-menu-line {
  transform-origin: 12px 12px;
  transition: transform 180ms cubic-bezier(.16, 1, .3, 1), opacity 140ms ease;
}

html body header[data-adaptive-nav][data-nav-open] .nav-menu-line:first-child {
  transform: rotate(45deg) translateY(6px);
}

html body header[data-adaptive-nav][data-nav-open] .nav-menu-line:nth-child(2) { opacity: 0; }

html body header[data-adaptive-nav][data-nav-open] .nav-menu-line:last-child {
  transform: rotate(-45deg) translateY(-6px);
}

/* The density is measured from the real header width by adaptive-nav.js. */
html body header[data-adaptive-nav][data-nav-density="balanced"] {
  --nav-inline-gap: 2px;
  --nav-link-padding: 10px;
}

html body header[data-adaptive-nav][data-nav-density="compact"] {
  --nav-inline-gap: 0px;
  --nav-link-padding: 7px;
}

html body header[data-adaptive-nav][data-nav-density="compact"] > nav > a { font-size: .94em; }

html body header[data-adaptive-nav][data-nav-density="compact"] > .theme-toggle {
  width: 40px;
  height: 40px;
}

@media (min-width: 1121px) {
  html body header[data-adaptive-nav] {
    --nav-inline-gap: 4px;
    --nav-link-padding: 14px;
  }
}

@media (min-width: 761px) and (max-width: 1120px) {
  html body header[data-adaptive-nav] { gap: 12px; }

  html body header[data-adaptive-nav] > :is(.brand, .portal-brand) { font-size: clamp(16px, 1.7vw, 18px); }

  html body header[data-adaptive-nav] > :is(.brand, .portal-brand) .product-mark {
    width: 30px;
    height: 30px;
  }

  html body header[data-adaptive-nav] > .portal-brand img {
    width: 30px;
    height: 30px;
  }

  html body header[data-adaptive-nav] > nav > a { font-size: clamp(13px, 1.45vw, 14px); }

  html body header[data-adaptive-nav] > .theme-toggle {
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 760px) {
  html body header[data-adaptive-nav] {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 4px 8px;
    padding-inline-start: max(12px, env(safe-area-inset-left));
    padding-inline-end: max(12px, env(safe-area-inset-right));
  }

  html body header[data-adaptive-nav] > :is(.brand, .portal-brand) {
    grid-column: 1;
    grid-row: 1;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  html body header[data-adaptive-nav] > .nav-menu-toggle {
    display: grid;
    grid-column: 2;
    grid-row: 1;
  }

  html body header[data-adaptive-nav] > .theme-toggle {
    grid-column: 3;
    grid-row: 1;
    width: var(--nav-control-size);
    height: var(--nav-control-size);
  }

  html body header[data-adaptive-nav] > nav {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    justify-content: stretch;
    gap: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--site-line, var(--control-edge, var(--line, currentColor)));
  }

  /* JS adds data-nav-mobile before it hides the closed menu. Without JS the
     links remain visible, so the public pages stay navigable. */
  html body header[data-adaptive-nav][data-nav-mobile] > nav[hidden] {
    display: none !important;
  }

  html body header[data-adaptive-nav] > nav > a {
    min-height: 44px;
    padding-inline: 12px;
    justify-content: flex-start;
    border-radius: 12px;
    font-size: 14px;
  }

  html body header[data-adaptive-nav] > nav > a:hover,
  html body header[data-adaptive-nav] > nav > a[aria-current] {
    background: var(--control-hover, var(--site-panel, var(--panel, transparent)));
  }

  html body header[data-adaptive-nav] > nav > form .text-button {
    width: 100%;
    text-align: left;
    padding-inline: 12px;
    border-radius: 12px;
  }
}

@media (max-width: 760px) and (orientation: landscape) {
  html body header[data-adaptive-nav] > nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding-top: 4px;
  }

  html body header[data-adaptive-nav] > nav > a {
    justify-content: center;
    padding-inline: 8px;
  }

  html body header[data-adaptive-nav] > nav > form .text-button {
    text-align: center;
    padding-inline: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav-menu-toggle .nav-menu-line { transition: none; }
}

@media (prefers-reduced-transparency: reduce) {
  html body header[data-adaptive-nav] > .nav-menu-toggle {
    background: var(--control-solid, var(--surface-raised));
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media print {
  html body header[data-adaptive-nav] > .nav-menu-toggle { display: none !important; }
  html body header[data-adaptive-nav] > nav[hidden] { display: flex !important; }
}
