/* ==========================================================================
 Header and navigation
 Fixed top bar, desktop links and the slide-down mobile menu.
 ========================================================================== */

.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  transition:
    box-shadow 0.3s ease,
    background-color 0.35s ease;
}
.site-header.scrolled {
  box-shadow:
    0 1px 0 var(--line),
    0 8px 24px rgba(20, 45, 80, 0.06);
}
/* Over the dark car animation the header is transparent with light text; it turns white once the page content begins */
.site-header.on-dark {
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.site-header.on-dark::before {
  content: '';
  position: absolute;
  inset: 0 0 -40px;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(rgba(3, 4, 6, 0.7), transparent);
}
.on-dark .navlink {
  color: #fff;
}
.on-dark .brand {
  background-color: transparent;
  box-shadow: none;
}
.on-dark .navlink:hover {
  color: var(--blue-light);
}
.on-dark .menu-toggle {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.on-dark .menu-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}
/* header spans the full width so the logo lines up with the panel's headline */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  max-width: none;
  padding-inline: 20px;
}
@media (min-width: 768px) {
  .header-bar {
    height: 72px;
    padding-inline: 56px;
  }
}
/* Once the page turns white the bar is slimmer, so more of the page shows under it */
.site-header.scrolled .header-bar {
  height: 52px;
}
@media (min-width: 768px) {
  .site-header.scrolled .header-bar {
    height: 60px;
  }
}
/* The logo's lettering is silver on transparent, so it sits on a dark plate wherever the page behind it is light */
.brand {
  --brand-scale: 1;
  display: inline-flex;
  padding: 4px 12px;
  border-radius: 999px;
  background-color: var(--logo-plate);
  box-shadow: 0 4px 14px rgba(11, 12, 15, 0.18);
  transform: scale(var(--brand-scale));
  transform-origin: left center;
  transition:
    transform 0.35s var(--ease-spring),
    background-color 0.3s ease,
    box-shadow 0.3s ease;
}
/* No plate over the animation, so pull the logo back to the header's left edge */
.on-dark .brand {
  margin-left: -12px;
}
/* Smaller once the page turns white, so the dark plate stays discreet */
.site-header.scrolled .brand {
  --brand-scale: 0.8;
}
.brand:hover {
  transform: translateY(-1px) scale(var(--brand-scale));
}
.brand:active {
  transform: scale(var(--brand-scale));
}
.brand:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}
.on-dark .brand:focus-visible {
  outline-color: var(--blue-light);
}
.brand-logo {
  display: block;
  width: auto;
  height: 36px;
}
@media (min-width: 768px) {
  .brand-logo {
    height: 42px;
  }
}
.nav {
  display: none;
  align-items: center;
  gap: 28px;
}
@media (min-width: 1024px) {
  .nav {
    display: flex;
  }
}
.navlink {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  border-radius: 6px;
  padding: 4px 2px;
  transition: color 0.2s ease;
}
.navlink:hover {
  color: var(--blue);
}
.navlink:active {
  color: var(--blue-dark);
}
.nav .btn {
  min-height: 42px;
  padding: 0 18px;
  font-size: 14px;
}
.menu-toggle {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 0;
  background: var(--mist);
  color: var(--ink);
  cursor: pointer;
  transition:
    transform 0.2s var(--ease-spring),
    background-color 0.2s ease;
}
.menu-toggle:hover {
  background: var(--mist-2);
}
.menu-toggle:active {
  transform: scale(0.94);
}
@media (min-width: 1024px) {
  .menu-toggle {
    display: none;
  }
}
/* The menu button serves only over the homepage's car animation. Everywhere else the row of links under the logo
   (.quick-nav) shows every page, so the button and its menu go */
.site-header:not(.on-dark) :is(.menu-toggle, .mobile-nav) {
  display: none;
}
.menu-toggle span {
  display: block;
  width: 18px;
  height: 1.5px;
  background: currentColor;
  border-radius: 2px;
  transition:
    transform 0.35s var(--ease-spring),
    opacity 0.2s ease;
}
.menu-toggle span + span {
  margin-top: 5px;
}
.menu-toggle[aria-expanded='true'] span:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}
.menu-toggle[aria-expanded='true'] span:nth-child(2) {
  opacity: 0;
}
.menu-toggle[aria-expanded='true'] span:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}
.mobile-nav {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 72px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow-3);
  opacity: 0;
  transform: translateY(-12px);
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity 0.25s var(--ease-exit),
    transform 0.35s var(--ease-spring),
    visibility 0s 0.35s;
}
.mobile-nav.open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  visibility: visible;
  transition:
    opacity 0.25s ease,
    transform 0.4s var(--ease-spring);
}
.mobile-nav a:not(.btn) {
  display: block;
  padding: 14px 12px;
  border-radius: 10px;
  font-weight: 500;
}
.mobile-nav a:not(.btn):hover {
  background: var(--mist);
}
.mobile-nav a:not(.btn):active {
  background: var(--mist-2);
}
.mobile-nav .btn {
  width: 100%;
  margin-top: 8px;
}
@media (min-width: 1024px) {
  .mobile-nav {
    display: none;
  }
}

/* Phones and tablets: the main links in one row under the logo, so every page shows them without opening a menu.
   Hidden over the homepage's car animation, where the step rail sits in its place */
.quick-nav {
  display: flex;
  justify-content: space-between;
  height: 36px;
  padding-inline: 8px;
  border-top: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  transition:
    opacity 0.25s ease,
    transform 0.35s var(--ease-spring);
}
.quick-nav::-webkit-scrollbar {
  display: none;
}
.quick-nav a {
  display: flex;
  align-items: center;
  flex: none;
  padding: 0 5px;
  color: var(--ink-2);
  font-size: clamp(12px, 3.6vw, 14px);
  font-weight: 600;
  white-space: nowrap;
  border-radius: 8px;
  transition: color 0.2s ease;
}
.quick-nav a:hover {
  color: var(--blue);
}
.quick-nav a:active {
  color: var(--blue-dark);
}
.quick-nav a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -4px;
}
.on-dark .quick-nav {
  position: absolute;
  inset: 100% 0 auto;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  visibility: hidden;
}
@media (min-width: 640px) {
  .quick-nav {
    justify-content: center;
    gap: 24px;
  }
}
@media (min-width: 1024px) {
  .quick-nav {
    display: none;
  }
}

/* The right-hand side of the header: the links (wide screens), the language switcher and the menu button */
.header-end {
  display: flex;
  align-items: center;
  gap: 12px;
}
@media (min-width: 1024px) {
  .header-end {
    gap: 24px;
  }
}

/* Language switcher: a native <details>, so it opens without JavaScript and its links stay plain HTML.
   Every link goes to the same page in that language */
.lang-switch {
  position: relative;
}
.lang-switch summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--mist);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  list-style: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition:
    transform 0.2s var(--ease-spring),
    background-color 0.2s ease,
    color 0.2s ease;
}
.lang-switch summary::-webkit-details-marker {
  display: none;
}
.lang-switch summary svg {
  width: 16px;
  height: 16px;
  flex: none;
}
.lang-switch summary svg:last-child {
  width: 14px;
  height: 14px;
  opacity: 0.7;
  transition: transform 0.3s var(--ease-spring);
}
.lang-switch[open] summary svg:last-child {
  transform: rotate(180deg);
}
.lang-switch summary:hover {
  background: var(--mist-2);
  color: var(--blue);
}
.lang-switch summary:active {
  transform: scale(0.95);
}
.lang-switch summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}
.on-dark .lang-switch summary {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.on-dark .lang-switch summary:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.on-dark .lang-switch summary:focus-visible {
  outline-color: var(--blue-light);
}
/* Once the page turns white the bar is slimmer, so the switcher is too */
.site-header.scrolled .lang-switch summary {
  min-height: 36px;
}
.lang-switch-menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 2;
  min-width: 168px;
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-3);
  animation: lang-menu-in 0.3s var(--ease-spring);
}
@keyframes lang-menu-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}
.lang-switch-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 500;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}
.lang-switch-menu a:hover {
  background: var(--mist);
  color: var(--blue);
}
.lang-switch-menu a:active {
  background: var(--mist-2);
}
.lang-switch-menu a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}
/* The language being read is marked with a tick */
.lang-switch-menu a[aria-current] {
  color: var(--blue);
  font-weight: 700;
}
.lang-switch-menu a[aria-current]::after {
  content: '';
  width: 6px;
  height: 11px;
  margin-inline-end: 4px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translateY(-2px);
}

/* The three languages as a row in the mobile menu */
.mobile-langs {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  padding: 12px 4px 4px;
  border-top: 1px solid var(--line);
}
.mobile-nav .mobile-langs a {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--mist);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}
.mobile-nav .mobile-langs a[aria-current] {
  background: var(--blue-soft);
  color: var(--blue);
}

@media (prefers-reduced-motion: reduce) {
  .lang-switch-menu {
    animation: none;
  }
}
