/* Keep the existing navigation available before and after the landing hero.
   Load after premium.css on the tool pages and content.css on documents. */
html {
  --navigation-header-height: 74px;
  scroll-padding-top: calc(var(--navigation-header-height) + 16px);
}

body > .site-header,
body > .site-header.is-hero-header-visible {
  position: sticky;
  inset: auto;
  top: 0;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition: none;
  --navigation-focus: var(--primary, var(--lime, #d9ff1a));
}

body > .site-header .header-inner {
  min-width: 0;
}

body > .site-header .brand,
body > .site-header .theme-toggle {
  min-width: 44px;
  min-height: 44px;
}

body > .site-header .nav-links a,
body > .site-header .top-nav a {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  transition: color 160ms ease, background-color 160ms ease;
}

body > .site-header .language-links a,
body > .site-header .locale-links a {
  display: grid;
  min-width: 44px;
  min-height: 44px;
  padding: 0 6px;
  place-items: center;
}

body > .site-header .nav-links {
  color: var(--muted);
}

body > .site-header .nav-links a:hover,
body > .site-header .nav-links a:focus-visible {
  background: var(--soft);
  color: var(--text);
}

body > .site-header .top-nav a:hover,
body > .site-header .top-nav a:focus-visible {
  background: rgba(141, 80, 255, 0.28);
  color: #fff;
}

body > .site-header .language-links a:hover,
body > .site-header .language-links a:focus-visible {
  background: var(--soft);
  color: var(--text);
}

body > .site-header .locale-links a:focus-visible {
  background: rgba(141, 80, 255, 0.34);
  color: #fff;
}

body > .site-header :is(a, button):focus-visible {
  outline: 2px solid var(--navigation-focus);
  outline-offset: 3px;
}

body > .site-header :is(.nav-links, .top-nav) a:active {
  opacity: 0.78;
}

/* A sticky header now occupies space; keep the authored hero within the
   remaining viewport while allowing its content to determine a taller size. */
html[data-theme] .hero.reference-hero {
  min-height: calc(100svh - var(--navigation-header-height));
}

html[data-theme] .built-hero-shell {
  min-height: min(calc(100svh - var(--navigation-header-height)), 760px);
}

@media (min-width: 961px) and (max-width: 1200px) {
  html[data-theme] body > .site-header .header-inner {
    gap: 10px;
  }

  body > .site-header .nav-links {
    gap: 2px;
  }

  body > .site-header .nav-links a {
    padding-inline: 8px;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
  }

  body > .site-header .theme-toggle [data-theme-label] {
    display: none;
  }

  body > .site-header .theme-toggle {
    padding: 5px;
  }
}

@media (max-width: 960px) {
  html {
    --navigation-header-height: 126px;
  }

  body > .site-header .header-inner {
    flex-wrap: wrap;
    column-gap: 12px;
    row-gap: 8px;
  }

  html[data-theme] body > .site-header .header-inner {
    padding: 10px 0;
  }

  body > .site-header .nav-links {
    display: grid;
    flex: 1 0 100%;
    order: 4;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    width: 100%;
    gap: 4px;
    padding: 8px 0 0;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
  }

  body > .site-header .nav-links a {
    min-width: 0;
    padding: 6px 8px;
    font-size: 0.78rem;
    letter-spacing: 0;
    overflow-wrap: anywhere;
  }

  body > .site-header .language-links {
    margin-left: auto;
  }

  body > .site-header .theme-toggle {
    min-width: 48px;
  }
}

@media (min-width: 641px) and (max-width: 960px) {
  body > .site-header .brand-wordmark {
    display: grid;
  }
}

@media (max-width: 900px) {
  body > .site-header .top-nav {
    display: grid;
    flex: 1 0 100%;
    order: 3;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    margin: 0;
    gap: 4px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
  }

  body > .site-header .top-nav a {
    display: inline-flex;
    min-width: 0;
    padding: 6px 10px;
    overflow-wrap: anywhere;
  }

  /* Match the original hiding conditions without raising the specificity of
     spacing rules that the compact layout adjusts below. */
  body > .site-header .top-nav a:not(.tool-link):not([aria-current="page"]),
  body > .site-header .top-nav a:not(.tool-link) {
    display: inline-flex;
  }

  body > .site-header .locale-links {
    margin-left: auto;
  }

  body > .site-header .header-inner {
    padding-block: 10px;
  }
}

@media (max-width: 640px) {
  html {
    --navigation-header-height: 170px;
  }

  body > .site-header .header-inner {
    width: calc(100% - 24px);
    column-gap: 8px;
  }

  html[data-theme] body > .site-header .header-inner {
    padding: 8px 0;
  }

  body > .site-header .brand-wordmark,
  body > .site-header .theme-toggle [data-theme-label] {
    display: none;
  }

  body > .site-header .brand {
    flex: 0 1 auto;
    gap: 6px;
  }

  body > .site-header .brand-mark {
    width: 36px;
    height: 36px;
  }

  body > .site-header .nav-links {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body > .site-header .nav-links a,
  body > .site-header .top-nav a {
    padding-inline: 6px;
    border-radius: 12px;
    font-size: 0.76rem;
  }

  body > .site-header .language-links,
  body > .site-header .locale-links {
    gap: 0;
    padding: 3px;
  }

  body > .site-header .theme-toggle {
    width: 48px;
    padding: 2px;
    justify-content: center;
    gap: 0;
  }

  body > .site-header .brand img:not(.brand-mark) {
    width: 32px;
    height: 32px;
  }

  body > .site-header .brand-copy strong {
    font-size: 0.94rem;
  }
}

@media (max-width: 360px) {
  body > .site-header .brand-copy strong {
    font-size: 0.86rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  body > .site-header *,
  body > .site-header *::before,
  body > .site-header *::after {
    transition: none;
    animation: none;
  }
}
