/* Site header: logo left, small navigation right. Sticky: below 1440px wide it
   hides when scrolling down and comes back when scrolling up (main.js sets
   is-scrolled and is-hidden). Over a hero the bar is transparent with a white
   navigation; once scrolled the navigation gets a subtly transparent light
   background with a blur, and the logo turns grayscale. On small screens the
   navigation becomes a full-screen panel behind a Menu toggle. */

.site-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--theme-space-sm);
  min-height: var(--theme-header-height);
  padding-inline: var(--theme-margin);
  color: var(--theme-color-text);

  /* The bar itself lets clicks and hovers through to what is behind it (the hero
     slider); only the logo, the menu toggle and the navigation take them. */
  pointer-events: none;
}

.site-header :is(.site-header__logo, .site-header__toggle, .site-header__nav) {
  pointer-events: auto;
}

.site-header--overlay {
  position: fixed;
  inset: 0 0 auto;
  color: var(--theme-color-text-inverse);
}

/* Background layer behind the header content. Over a hero it is a soft dark
   gradient for the white navigation, fading out once scrolled (a gradient
   itself cannot be transitioned, its opacity can). */

.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0;
  pointer-events: none;
}

.site-header--overlay::before {
  background: linear-gradient(to bottom, rgb(0 0 0 / 5%), transparent);
  opacity: 1;
}

.site-header.is-scrolled {
  color: var(--theme-color-text);
}

.site-header--overlay.is-scrolled::before {
  opacity: 0;
}

/* The bar only slides away on screens narrower than the 1440px design width
   (smaller laptops, tablets, phones). On a larger desktop it stays in view:
   the logo and navigation stay readable on any background once scrolled. */

@media (width < 1440px) {
  .site-header.is-hidden:not(.is-open, :focus-within) {
    transform: translateY(-100%);
  }
}

@media (prefers-reduced-motion: no-preference) {
  /* The bar slides away and back more slowly than the other transitions, on a
     smoother curve (the theme's signature curve covers most of the distance in
     the first moments, which feels abrupt for something this large). */
  .site-header {
    --theme-header-slide: 0.9s;

    transition:
      transform var(--theme-header-slide) cubic-bezier(0.5, 0, 0.15, 1),
      color var(--theme-duration) var(--theme-ease-signature);
  }

  .site-header::before {
    transition: opacity var(--theme-duration) var(--theme-ease-signature);
  }

  .site-header__nav {
    transition:
      background-color 1s var(--theme-ease-signature),
      backdrop-filter var(--theme-duration) var(--theme-ease-signature);
  }
}

/* Current page: a permanent underline in the text colour (white over a hero),
   on the bottom edge of the navigation like the other underlines. */

@media (width > 768px) {
  .site-header__menu > li > .site-header__link[aria-current='page'] {
    position: relative;
  }

  .site-header__menu > li > .site-header__link[aria-current='page']::after {
    content: '';
    position: absolute;
    inset: auto 0 0;
    block-size: 1px;
    background: currentcolor;
  }

  .site-header__link--cta[aria-current='page']::after {
    content: none;
  }
}

/* Once scrolled, only the navigation gets the subtly transparent light
   background with a blur; the logo stays free on the page. Desktop only,
   on small screens the navigation is the full-screen panel. */

@media (width > 768px) {
  .site-header__nav {
    margin-inline: 0 -0.6rem;
    padding-inline: 0.6rem;
  }

  .site-header.is-scrolled .site-header__nav {
    background: rgb(255 255 255 / 72%);
  }

  @supports (backdrop-filter: blur(1px)) {
    .site-header.is-scrolled .site-header__nav {
      backdrop-filter: blur(14px) saturate(1.4);
    }
  }
}

.site-header__logo {
  display: block;
  width: clamp(8.5rem, 13.9vw, 12.5rem);
}

.site-header__logo .logo {
  width: 100%;
  height: auto;

  /* The ring touches the edges of the artwork; let its edge anti-alias past the
     box instead of being cut flat at the bottom. */
  overflow: visible;
}

/* Once the page is scrolled the logo drops its copper colour: a layer in the
   shape of the logo (the mask) inverts and desaturates what is behind it, so
   it is white over dark and black over light, whatever the background. At the
   top of the page, and with the mobile menu open, it keeps the brand colour.
   Browsers without masks or backdrop filters keep the copper logo. */

@supports (backdrop-filter: blur(1px)) and (mask-image: linear-gradient(#000, #000)) {
  .site-header__logo {
    position: relative;
  }

  .site-header__logo::after {
    content: '';
    position: absolute;

    /* One unit of the artwork (198.1 x 36.42) of margin on each side, matching the
       margin in logo-mask.svg's viewBox, so the ring is not cut flat. */
    inset: -2.746% -0.505%;
    backdrop-filter: grayscale(1) invert(1);
    mask: url('../svg/logo-mask.svg') center / 100% 100% no-repeat;
    opacity: 0;
    pointer-events: none;
  }

  .site-header.is-scrolled:not(.is-open) .site-header__logo::after {
    opacity: 1;
  }

  .site-header.is-scrolled:not(.is-open) .site-header__logo .logo {
    opacity: 0;
  }

  /* Hover (at the top of the page): the logo changes to the scrolled colour
     (a crossfade, the shape itself does not move). */

  @media (hover: hover) {
    .site-header:not(.is-open) .site-header__logo:is(:hover, :focus-visible)::after {
      opacity: 1;
    }

    .site-header:not(.is-scrolled, .is-open) .site-header__logo:is(:hover, :focus-visible) .logo {
      opacity: 0;
    }
  }

  @media (prefers-reduced-motion: no-preference) {
    .site-header__logo::after,
    .site-header__logo .logo {
      transition: opacity 0.5s var(--theme-ease-signature);
    }
  }
}

.site-header__menu {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 1.389vw, 1.5rem);
}

.site-header__link {
  font-size: clamp(0.75rem, 0.903vw, 0.8125rem);
  letter-spacing: -0.01em;
  font-weight: 500;
  line-height: 1;
  padding-block: 0.4em;
  background-image: linear-gradient(currentcolor, currentcolor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1px;
  transition: background-size var(--theme-duration) var(--theme-ease-signature);
}

.site-header__link:hover,
.site-header__link--cta {
  background-size: 100% 1px;
}

/* Desktop: one line follows the hovered link and slides between links
   (CSS anchor positioning). The hovered link takes the anchor name, the
   line grows in from the left on the first hover, then moves along. The
   gap between links is padding on the list items instead, so the pointer
   never leaves the menu on its way from one link to the next. The line
   disappears when the pointer leaves. Browsers without anchor positioning
   keep the per-link underline above. */

@media (width > 768px) {
  @supports (anchor-name: --nav-line) {
    .site-header__menu {
      --theme-menu-gap: clamp(1rem, 1.389vw, 1.5rem);

      position: relative;
      align-items: stretch;
      gap: 0;
      margin-inline-end: calc(var(--theme-menu-gap) / -2);
    }

    /* The links fill the full height of the navigation, so every underline
       sits on the bottom edge of the navigation background. */
    .site-header__menu > li {
      display: flex;
      min-block-size: 3.1rem;
      padding-inline: calc(var(--theme-menu-gap) / 2);
    }

    .site-header__menu > li > .site-header__link {
      display: flex;
      align-items: center;
      padding-block: 0;
    }

    .site-header__menu > .site-header__language {
      align-items: center;
    }

    .site-header__menu > li:hover > .site-header__link:not(.site-header__link--cta),
    .site-header__link:not(.site-header__link--cta):focus-visible {
      anchor-name: --nav-line;
      background-size: 0% 1px;
    }

    .site-header__menu::after {
      content: '';
      position: absolute;
      position-anchor: --nav-line;
      inset-block-end: 0;
      inset-inline: anchor(start) anchor(end);
      block-size: 1px;
      background: currentcolor;
      transform-origin: left center;
      scale: 0 1;
      pointer-events: none;
    }

    .site-header__menu:has(
        > li:hover > .site-header__link:not(.site-header__link--cta),
        .site-header__link:not(.site-header__link--cta):focus-visible
      )::after {
      scale: 1 1;
      transition:
        inset-inline var(--theme-duration) var(--theme-ease-signature),
        scale var(--theme-duration) var(--theme-ease-signature);
    }
  }
}

.site-header__language {
  --theme-language-height: 1.9rem;
  --theme-language-width: 2.75rem;
  --theme-language-gap: 0;

  font-size: clamp(0.75rem, 0.903vw, 0.8125rem);
  font-weight: 500;
  line-height: 1;
}

/* Collapsed: just the current language. On hover or focus the
   other languages grow in towards the left (the menu slides along); the
   current one stays at the right edge. Choosing another language folds
   the current one away (after the click, class set in main.js), so the chosen
   one stays visible while the page loads. */

.site-header__language-list {
  display: flex;
  justify-content: flex-end;
}

.site-header__language-list li {
  max-inline-size: var(--theme-language-width);
  transition:
    max-inline-size var(--theme-duration) var(--theme-ease-signature),
    margin-inline-end var(--theme-duration) var(--theme-ease-signature),
    opacity var(--theme-duration) var(--theme-ease-signature);
}

.site-header__language-list li:has([aria-current]) {
  order: 1;
}

.site-header__language-list li:not(:has([aria-current])) {
  max-inline-size: 0;
  opacity: 0;
  overflow: hidden;
}

.site-header__language:is(:hover, :focus-within)
  .site-header__language-list
  li:not(:has([aria-current])) {
  max-inline-size: var(--theme-language-width);
  margin-inline-end: var(--theme-language-gap);
  opacity: 1;
}

.site-header__language-list :is(a, span) {
  display: grid;
  place-items: center;
  inline-size: var(--theme-language-width);
  block-size: var(--theme-language-height);
  cursor: pointer;
  transition:
    background-color var(--theme-duration) var(--theme-ease-signature),
    color var(--theme-duration) var(--theme-ease-signature);
}

/* Open: solid blocks side by side so they read over a hero image. */

.site-header__language:is(:hover, :focus-within) .site-header__language-list :is(a, span) {
  background: var(--theme-color-background);
  color: var(--theme-color-text);
}

.site-header__language:is(:hover, :focus-within) .site-header__language-list [aria-current] {
  background: var(--theme-color-surface);
}

.site-header__language-list [lang='nl'] {
  --theme-flag: linear-gradient(#ae1c28 33.4%, #fff 33.4% 66.7%, #21468b 66.7%);
}

.site-header__language-list [lang='en'] {
  --theme-flag: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 30' preserveAspectRatio='none'%3E%3CclipPath id='s'%3E%3Cpath d='M0 0v30h60V0z'/%3E%3C/clipPath%3E%3CclipPath id='t'%3E%3Cpath d='M30 15h30v15zv15h-30zh-30V0zV0h30z'/%3E%3C/clipPath%3E%3Cg clip-path='url(%23s)'%3E%3Cpath d='M0 0v30h60V0z' fill='%23012169'/%3E%3Cpath d='M0 0l60 30m0-30L0 30' stroke='%23fff' stroke-width='6'/%3E%3Cpath d='M0 0l60 30m0-30L0 30' clip-path='url(%23t)' stroke='%23C8102E' stroke-width='4'/%3E%3Cpath d='M30 0v30M0 15h60' stroke='%23fff' stroke-width='10'/%3E%3Cpath d='M30 0v30M0 15h60' stroke='%23C8102E' stroke-width='6'/%3E%3C/g%3E%3C/svg%3E");
}

/* Hovering a language fills its button with that language's flag. */

.site-header__language .site-header__language-list :is(a, [aria-current]):hover {
  background:
    linear-gradient(rgb(0 0 0 / 22%), rgb(0 0 0 / 22%)),
    var(--theme-flag) center / cover;
  color: #fff;
  font-weight: 600;
  -webkit-text-stroke: 0.45px currentcolor;
  text-shadow:
    0 0 0.4rem rgb(0 0 0 / 70%),
    0 1px 2px rgb(0 0 0 / 70%);
}

.site-header__language-list a:hover {
  background: var(--theme-color-surface);
}

.site-header__language-list .is-muted {
  cursor: default;
  opacity: 0.4;
}

.site-header__language-list.is-chosen li:has([aria-current]) {
  max-inline-size: 0;
  margin-inline-end: 0;
  opacity: 0;
  overflow: hidden;
}

.site-header__link--cta {
  /* The text colour, a little softer than the link itself. */
  --theme-cta-line: color-mix(in srgb, currentcolor 50%, transparent);

  background-image: linear-gradient(var(--theme-cta-line), var(--theme-cta-line));
  display: inline-flex;
  align-items: center;
  gap: 1.5em;
  padding-inline-end: 0.1em;
}

.site-header__link--cta svg {
  width: 0.9em;
  height: auto;
}

.site-header__toggle {
  display: none;
}

@media (width <= 768px) {
  .site-header__toggle {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-size: var(--theme-fs-sm);
  }

  .site-header__toggle-icon,
  .site-header__toggle-icon::before {
    display: block;
    width: 1.25rem;
    height: 1px;
    background: currentcolor;
    transition: rotate var(--theme-duration) var(--theme-ease-signature);
  }

  .site-header__toggle-icon {
    position: relative;
    translate: 0 -3px;
  }

  .site-header__toggle-icon::before {
    content: '';
    position: absolute;
    inset-block-start: 6px;
  }

  .site-header__nav {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: flex-end;
    padding: var(--theme-header-height) var(--theme-margin) var(--theme-space-lg);
    background: var(--theme-color-inverse);
    color: var(--theme-color-text-inverse);
    opacity: 0;
    visibility: hidden;
    transition:
      opacity var(--theme-duration) var(--theme-ease-signature),
      visibility var(--theme-duration);
  }

  .site-header__menu {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .site-header__link {
    font-size: var(--theme-fs-6xl);
    letter-spacing: var(--theme-tracking-heading);
  }

  .site-header__language {
    font-size: var(--theme-fs-sm);
  }

  .site-header__language-list {
    justify-content: flex-start;
  }

  .site-header__language-list li,
  .site-header__language-list li:not(:has([aria-current])),
  .site-header__language:is(:hover, :focus-within)
    .site-header__language-list
    li:not(:has([aria-current])) {
    max-inline-size: none;
    margin-inline-end: 0;
    opacity: 1;
    overflow: visible;
  }

  .site-header__language-list li:has([aria-current]) {
    order: 0;
  }

  .site-header__language-list li + li::before {
    content: '|';
    margin-inline: 0.4em;
  }

  .site-header__language-list :is(a, span),
  .site-header__language:is(:hover, :focus-within) .site-header__language-list :is(a, span),
  .site-header__language:is(:hover, :focus-within) .site-header__language-list [aria-current] {
    display: inline;
    inline-size: auto;
    block-size: auto;
    background: none;
    color: inherit;
  }

  .site-header__language-list [aria-current] {
    text-decoration: underline;
    text-underline-offset: 0.25em;
  }

  .site-header__language-list.is-chosen li:has([aria-current]) {
    max-inline-size: none;
    margin-inline-end: 0;
    opacity: 1;
  }

  /* Scrolled, the toggle and logo sit on a light blurred bar, so they stay
     readable over any image. */
  .site-header.is-scrolled::before {
    background: rgb(255 255 255 / 72%);
    opacity: 1;
  }

  @supports (backdrop-filter: blur(1px)) {
    .site-header.is-scrolled::before {
      backdrop-filter: blur(14px) saturate(1.4);
    }
  }

  .site-header.is-open::before {
    opacity: 0;
  }

  .site-header__link[aria-current='page'] {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
  }

  .site-header.is-open .site-header__nav {
    opacity: 1;
    visibility: visible;
  }

  .site-header.is-open .site-header__toggle {
    color: var(--theme-color-text-inverse);
  }

  .site-header.is-open .site-header__toggle-icon {
    translate: 0;
    rotate: 45deg;
  }

  .site-header.is-open .site-header__toggle-icon::before {
    inset-block-start: 0;
    rotate: 90deg;
  }

  .site-header.is-open .site-header__logo {
    position: relative;
    z-index: 2;
  }
}
