/* Site header, after the Prime design artifact: logo, menu with a sliding
   underline, a small pill "Contact" button and, below 900px, a round menu
   button that opens a full-screen green menu. Transparent over the home and
   Diensten heroes (white text, white button), half see-through white once
   scrolled and on inner pages (dark text, green button). JS flips
   data-state="top|scrolled" on the header and data-state on #site-nav. */

@layer components {
  .site-header {
    position: fixed;
    inset: 0 0 auto;
    z-index: 50;
    color: var(--theme-color-inverse-text);
    transition: box-shadow 0.35s;
  }

  .site-header[data-state='scrolled'] {
    color: var(--theme-color-text);
    box-shadow: 0 1px 0 var(--theme-color-border);
  }

  /* Half see-through with the page blurred behind it, like the Appel site. On a
     layer of its own: backdrop-filter on the header itself would trap the
     full-screen mobile menu (position: fixed) inside the header bar. */
  .site-header::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: color-mix(in srgb, var(--theme-color-background) 90%, transparent);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.35s;
  }

  .site-header[data-state='scrolled']::before {
    opacity: 1;
  }

  .site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    width: min(100% - 2 * var(--theme-gutter), var(--theme-container));
    height: 92px;
    margin-inline: auto;
    transition: height 0.35s;
  }

  .site-header[data-state='scrolled'] .site-header__inner {
    height: 76px;
  }

  /* Logo: both versions stacked, cross-faded. */
  .site-header__logo {
    position: relative;
    z-index: 2;
    display: block;
    flex: none;
    width: 229px;
    height: 30px;
  }

  .site-header__logo img {
    position: absolute;
    inset: 0;
    width: auto;
    height: 30px;
    transition: opacity 0.3s;
  }

  .site-header__logo-dark,
  .site-header[data-state='scrolled'] .site-header__logo-light {
    opacity: 0;
  }

  .site-header[data-state='scrolled'] .site-header__logo-dark {
    opacity: 1;
  }

  .site-header__menu,
  .site-header__nav > div > ul {
    display: flex;
    align-items: center;
    gap: 34px;
    list-style: none;
  }

  .site-header__menu a,
  .site-header__nav > div > ul a {
    position: relative;
    display: block;
    padding-block: 8px;
    color: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.3s;
  }

  .site-header__menu a::after,
  .site-header__nav > div > ul a::after {
    content: '';
    position: absolute;
    inset: auto 0 2px;
    height: 1.5px;
    background: currentcolor;
    scale: 0 1;
    transform-origin: left;
    transition: scale 0.3s;
  }

  .site-header__menu a:hover::after,
  .site-header__menu a[aria-current]::after,
  .site-header__menu a[data-state='active']::after,
  .site-header__nav > div > ul a:hover::after {
    scale: 1 1;
  }

  /* Only in the mobile menu. */
  .site-header__nav-cta {
    display: none;
  }

  .site-header__actions {
    position: relative;
    z-index: 2;
    display: flex;
    flex: none;
    align-items: center;
    gap: 18px;
  }

  /* Language switch: "NL | EN" in small caps, the current one underlined,
     a missing version dimmed. Takes the header's color, so it is white over
     the heroes and dark once scrolled. */
  .language-switch {
    display: flex;
    align-items: center;
    list-style: none;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.08em;
  }

  .language-switch li + li::before {
    content: '';
    display: inline-block;
    width: 1px;
    height: 0.9em;
    margin-inline: 2px;
    background: currentcolor;
    opacity: 0.4;
    vertical-align: -0.1em;
  }

  .language-switch__link {
    display: inline-block;
    padding: 10px 6px;
    color: inherit;
    text-decoration: none;
    text-underline-offset: 5px;
    text-decoration-thickness: 1.5px;
  }

  a.language-switch__link {
    opacity: 0.7;
    transition: opacity 0.3s;
  }

  a.language-switch__link:hover {
    opacity: 1;
    text-decoration-line: underline;
  }

  a.language-switch__link:focus-visible {
    border-radius: 4px;
    outline: 2px solid currentcolor;
    outline-offset: 0;
    opacity: 1;
  }

  .language-switch__link[aria-current] {
    text-decoration-line: underline;
  }

  .language-switch__link[aria-disabled] {
    opacity: 0.35;
  }

  /* Contact button: white over the hero, green once the header is solid. */
  .site-header[data-state='scrolled'] .site-header__cta {
    /* stylelint-disable custom-property-pattern -- the .button's own local properties (base.css), not tokens */
    --button-icon-bg: rgb(255 255 255 / 16%);
    --button-icon-fg: var(--theme-color-primary-foreground);
    /* stylelint-enable custom-property-pattern */

    background: var(--theme-color-primary);
    color: var(--theme-color-primary-foreground);
  }

  .site-header[data-state='scrolled'] .site-header__cta:hover {
    background: color-mix(in srgb, var(--theme-color-primary) 75%, #000);
  }

  /* Round menu button, two lines that turn into a cross. */
  .site-header__toggle {
    display: none;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 1.5px solid rgb(255 255 255 / 60%);
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition:
      border-color 0.3s,
      color 0.3s;
  }

  .site-header[data-state='scrolled'] .site-header__toggle {
    border-color: var(--theme-color-border);
    color: var(--theme-color-primary);
  }

  .site-header__toggle-bars {
    position: relative;
    display: block;
    width: 16px;
    height: 8px;
  }

  .site-header__toggle-bars::before,
  .site-header__toggle-bars::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    border-radius: 2px;
    background: currentcolor;
    transition:
      rotate 0.3s,
      top 0.3s;
  }

  .site-header__toggle-bars::before {
    top: 0;
  }

  .site-header__toggle-bars::after {
    top: 6px;
  }

  .site-header__toggle[aria-expanded='true'] .site-header__toggle-bars::before,
  .site-header__toggle[aria-expanded='true'] .site-header__toggle-bars::after {
    top: 3px;
  }

  .site-header__toggle[aria-expanded='true'] .site-header__toggle-bars::before {
    rotate: 45deg;
  }

  .site-header__toggle[aria-expanded='true'] .site-header__toggle-bars::after {
    rotate: -45deg;
  }

  @media (width <= 56.25rem) {
    .site-header__cta {
      display: none;
    }

    .site-header__toggle {
      display: grid;
    }

    /* Full-screen green menu: big links with lines between, then the button. */
    .site-header__nav {
      position: fixed;
      inset: 0;
      display: flex;
      flex-direction: column;
      padding: calc(76px + 28px) var(--theme-gutter) 24px;
      overflow-y: auto;
      background: var(--theme-color-primary);
      color: var(--theme-color-inverse-text);
      opacity: 0;
      visibility: hidden;
      transition:
        opacity 0.3s,
        visibility 0.3s;
    }

    .site-header__nav[data-state='open'] {
      opacity: 1;
      visibility: visible;
    }

    .site-header__menu,
    .site-header__nav > div > ul {
      flex-direction: column;
      align-items: stretch;
      gap: 0;
    }

    .site-header__menu a,
    .site-header__nav > div > ul a {
      padding-block: 14px;
      border-bottom: 1px solid rgb(255 255 255 / 14%);
      font-size: 1.875rem;
    }

    .site-header__menu a::after,
    .site-header__nav > div > ul a::after {
      display: none;
    }

    .site-header__nav-cta {
      display: inline-flex;
      align-self: flex-start;
      margin-top: 28px;
    }
  }

  @media (width <= 37.5rem) {
    .site-header__logo {
      width: 183px;
      height: 24px;
    }

    .site-header__logo img {
      height: 24px;
    }

    .site-header__inner {
      height: 76px;
    }

    .site-header__nav-cta {
      align-self: stretch;
    }
  }

  /* Narrow phones (24rem, 384px, and less): logo, language switch and menu button
     no longer fit with the default gaps, so tighten them and let the logo
     scale down instead of pushing the menu button off screen. */
  @media (width <= 24rem) {
    .site-header__inner {
      gap: 12px;
    }

    .site-header__actions {
      gap: 10px;
    }

    .site-header__logo {
      flex: 0 1 183px;
      min-width: 0;
      height: auto;
      aspect-ratio: 183 / 24;
    }

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

@layer components {
  /* Mobile menu open: logo and menu button sit on the green panel. */
  :root[data-nav-open='true'] .site-header {
    color: var(--theme-color-inverse-text);
  }

  :root[data-nav-open='true'] .site-header__logo-light {
    opacity: 1;
  }

  :root[data-nav-open='true'] .site-header__logo-dark {
    opacity: 0;
  }

  :root[data-nav-open='true'] .site-header__toggle {
    border-color: rgb(255 255 255 / 60%);
    color: var(--theme-color-inverse-text);
  }
}
