/* A shared timeline prevents hidden responsive groups replaying when resized. */
@property --header-surface-progress {
  syntax: "<number>";
  inherits: true;
  initial-value: 1;
}

@property --header-content-progress {
  syntax: "<number>";
  inherits: true;
  initial-value: 1;
}

/* The glass reveals independently: text, focus rings and popovers stay unclipped. */
.site-header {
  --header-glass-blur: 100px;
  --header-reveal-duration: 680ms;
  --header-content-duration: 520ms;
  --header-content-delay: 120ms;
  --header-enter-offset: clamp(1.25rem, 4vw, 4rem);
  position: relative;
  isolation: isolate;
  background: none;
  backdrop-filter: none;
}

.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--color-glass);
  backdrop-filter: blur(var(--header-glass-blur));
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .site-header {
    animation:
      header-glass-reveal var(--header-reveal-duration) var(--ease-out) backwards,
      header-content-settle var(--header-content-duration) var(--ease-out) var(--header-content-delay) backwards;
  }

  .site-header::before {
    opacity: clamp(0, calc(var(--header-surface-progress, 1) * 5), 1);
    clip-path: inset(0 calc((50% - 1.5rem) * (1 - var(--header-surface-progress, 1))) round var(--radius-pill));
  }

  .site-header > :is(.brand, .desktop-nav, .header-contact, .menu-toggle) {
    opacity: var(--header-content-progress, 1);
    translate:
      calc(var(--header-enter-x, 0px) * (1 - var(--header-content-progress, 1)))
      calc(var(--header-enter-y, 0px) * (1 - var(--header-content-progress, 1)));
  }

  .site-header > .brand {
    --header-enter-x: var(--header-enter-offset);
  }

  .site-header > .desktop-nav {
    --header-enter-y: .625rem;
  }

  .site-header > :is(.header-contact, .menu-toggle) {
    --header-enter-x: calc(-1 * var(--header-enter-offset));
  }

  /* Keyboard users can interact immediately, including during the entrance. */
  .site-header:focus-within {
    animation-duration: 1ms;
    animation-delay: 0ms;
  }
}

@keyframes header-glass-reveal {
  from {
    --header-surface-progress: 0;
  }
  to {
    --header-surface-progress: 1;
  }
}

@keyframes header-content-settle {
  from {
    --header-content-progress: 0;
  }
  to {
    --header-content-progress: 1;
  }
}
