# Scroll Header

> A floating glass pill that clears the top of the page, frosts as you scroll, steps aside while you read and turns to dark glass over dark sections.

Navigation · header, scroll, sticky, nav · HTML, CSS, vanilla JS · no dependencies · updated 2026-10-21
Demo: https://kodza.dev/components/scroll-header/

Takes the whole screen (or reacts to the page scroll): give it a page, not a small box.

## Files

The code below, served as files: byte for byte what the Kodza site copies (the CSS includes its theme guard).

- [`kodza-scroll-header.css`](https://kodza.dev/registry/scroll-header/kodza-scroll-header.css) · 21.3 KB
- [`kodza-scroll-header.js`](https://kodza.dev/registry/scroll-header/kodza-scroll-header.js) · 9.1 KB
- [`kodza-scroll-header.html`](https://kodza.dev/registry/scroll-header/kodza-scroll-header.html) · 1.0 KB · the markup, to adapt and paste into your page

**Can you run shell commands? Download the CSS and the JS, don't retype them.** Retyping costs thousands of tokens and can drop or change lines of the CSS. Put the files where your stack expects them (Use it says where: change the `-o` paths):

```bash
curl -fsSL --create-dirs -o kodza/kodza-scroll-header.css https://kodza.dev/registry/scroll-header/kodza-scroll-header.css
curl -fsSL --create-dirs -o kodza/kodza-scroll-header.js https://kodza.dev/registry/scroll-header/kodza-scroll-header.js
```

Then load the files from your page as Use it shows, instead of pasting the content. The HTML is the part you adapt (text, links, modifiers): paste it from the Code section. Copy the CSS and the JS from the Code section only if you can't run commands, exactly as they are. (Windows PowerShell: `curl.exe`.)

## API

- Root: `.kodza-scroll-header`
- Variables (set them on the root element itself: it declares its own defaults):
  - `--kz-header-fg: #0a0a0a`
  - `--kz-header-muted: rgba(10, 10, 10, 0.6)`
  - `--kz-header-soft: rgba(10, 10, 10, 0.07)`
  - `--kz-header-glass: rgba(255, 255, 255, 0.74)`
  - `--kz-header-edge: rgba(10, 10, 10, 0.08)`
  - `--kz-header-shadow: rgba(10, 10, 10, 0.08)`
  - `--kz-header-ink: #0a0a0a`
  - `--kz-header-on-ink: #ffffff`
  - `--kz-header-dark-fg: rgba(255, 255, 255, 0.92)`
  - `--kz-header-dark-muted: rgba(255, 255, 255, 0.62)`
  - `--kz-header-dark-soft: rgba(255, 255, 255, 0.1)`
  - `--kz-header-dark-glass: rgba(30, 30, 30, 0.72)`
  - `--kz-header-dark-edge: rgba(255, 255, 255, 0.1)`
  - `--kz-header-dark-shadow: rgba(0, 0, 0, 0.32)`
  - `--kz-header-dark-ink: #ffffff`
  - `--kz-header-dark-on-ink: #0a0a0a`
  - `--kz-header-top: 12px`
  - `--kz-header-height: 60px`
  - `--kz-header-max: 1080px`
  - `--kz-header-max-scrolled: var(--kz-header-max)`
  - `--kz-header-radius: 22px`
  - `--kz-header-duration: 0.5s`
  - `--kz-header-ease: cubic-bezier(0.22, 1, 0.36, 1)`
  - `--kz-header-hide-after: 600px`
  - `--kz-header-hide-duration: 0.8s`
  - `--kz-header-hide-ease: cubic-bezier(0.65, 0, 0.35, 1)`
  - `--kz-header-width-duration: 0.7s`
  - `--kz-header-width-ease: cubic-bezier(0.65, 0, 0.35, 1)`
- Modifiers: `.kodza-scroll-header--keep`, `.kodza-scroll-header--solid`
- Attributes:
  - `data-header-tone`
  - `data-tone`
- Lifecycle: `kodza:init` / `kodza:destroy` on `document`, with `{ detail: { root } }` to target a container.

## Keyboard

What each key does, by where the focus is. Keep it working when you adapt the HTML: same elements, same classes.

- In the open menu (while `.kodza-scroll-header.is-open` is on the page):
  - `Escape`: Closes the menu, focus back on its button
- While it's hidden (while `.kodza-scroll-header.is-hidden` is on the page):
  - `Tab`: Tabbing into it brings it back in view

## Dark mode

Over a section marked `data-header-tone="dark"` it turns to dark glass by itself. On a page that is dark everywhere, put `data-tone="dark"` on the header (your theme switch can toggle it).

## Use it

### Plain HTML page

- CSS: `kodza/kodza-scroll-header.css` next to the page (the Files commands as they are), linked in `<head>`: `<link rel="stylesheet" href="kodza/kodza-scroll-header.css">`. Without a shell, paste it in a `<style>` in `<head>` instead. It only touches `kodza-` classes.
- HTML: where the component goes. Paste it as many times as you need: instances never interfere.
- JS: `kodza/kodza-scroll-header.js`, loaded with `<script src="kodza/kodza-scroll-header.js" defer></script>` in `<head>`. Without a shell, paste it in a `<script>` before `</body>` (or in `<head>`: it waits for the page). One copy per page, whatever the number of instances.
- Restyle with the `--kz-…` variables, set on the component's root element itself (the root declares its own defaults, so a value on an ancestor is ignored), and with the modifiers / attributes listed under API.
- Font: it takes the page's own. The Kodza look is Geist: `<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap">`.
- Content added later (AJAX navigation, a SPA route, a builder preview): start it with `document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root: container } }))`; before removing it, the same call with `'kodza:destroy'` stops it and puts the original markup back.

### Claude artifact (claude.ai)

- Paste the CSS in a `<style>` and the JS in a `<script>` at the end, in the artifact itself: it loads stylesheets only from Google Fonts and scripts only from a few CDNs, so no `<link>` or `<script src>` to Kodza.
- Writing the artifact file with a shell? Insert the downloaded files (Files) with a command instead of retyping them: a line `KODZA-CSS` alone inside the `<style>`, `KODZA-JS` inside the `<script>`, then `sed -e '/^KODZA-CSS$/{r kodza/kodza-scroll-header.css' -e 'd' -e '}' -e '/^KODZA-JS$/{r kodza/kodza-scroll-header.js' -e 'd' -e '}' page.html > artifact.html`.
- Font: load Geist from Google Fonts (allowed): `<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap">`.
- Dark mode: the viewer sets `data-theme="dark"` or `"light"` on `<html>`, or nothing when it follows the system. Write the Dark mode rules twice: inside `@media (prefers-color-scheme: dark)` with `:root:not([data-theme="light"])` in front of each selector, and with `:root[data-theme="dark"]` in front of each selector.

### WordPress

- HTML: a **Custom HTML** block (or a pattern / template part). WordPress keeps this markup as it is only for users allowed to post unfiltered HTML (Administrators; Super Admins on multisite): for anyone else it strips tags such as `<svg>`, `<input>` or `<dialog>`, so add it from the theme (a pattern or template part) instead.
- This one spans the page: a block theme keeps a Custom HTML block to the width of the text column, so put it inside a **Group** block set to **Full width**, with **Inner blocks use content width** turned off.
- CSS and JS: the downloaded files go in the theme, under `wp-content/themes/<your-theme>/kodza/` (the child theme if there is one), enqueued from its functions.php (or a code-snippets plugin):
  ```php
  add_action('wp_enqueue_scripts', function () {
    $dir = get_stylesheet_directory() . '/kodza/';
    $uri = get_stylesheet_directory_uri() . '/kodza/';
    wp_enqueue_style('kodza-scroll-header', $uri . 'kodza-scroll-header.css', [], filemtime($dir . 'kodza-scroll-header.css'));
    wp_enqueue_script('kodza-scroll-header', $uri . 'kodza-scroll-header.js', [], filemtime($dir . 'kodza-scroll-header.js'), true);
  });
  ```
  Scoped to `kodza-` classes, the CSS never touches the theme. One copy of the JS, whatever the number of blocks.
- No access to the theme files? The CSS can also go, as it is, in **Appearance → Customize → Additional CSS** (classic theme) or **Styles → Additional CSS** in the Site Editor (block theme).
- Theme with AJAX page transitions: fire `kodza:init` on the new content after each swap (and `kodza:destroy` on the old one).
- Performance plugin (WP Rocket, LiteSpeed Cache, Perfmatters…) with **Delay JavaScript execution** turned on: add `kodza` to the scripts it must not delay. Otherwise the component waits for the visitor's first scroll, tap or mouse move, and that first click can be lost.
- Colours: by default, match the theme's palette. After the component's CSS, point these variables at the theme's colours, on the component root, Kodza's value as the fallback:
  `.kodza-scroll-header { --kz-header-fg: var(TEXT, #0a0a0a); --kz-header-ink: var(ACCENT, #0a0a0a); --kz-header-on-ink: var(BACKGROUND, #ffffff); }`
  TEXT, BACKGROUND and ACCENT (the colour the theme fills its own buttons with) are the theme's own colour variables — block themes (theme.json, like Twenty Twenty-Five): `--wp--preset--color--contrast`, `--wp--preset--color--base`, `--wp--preset--color--contrast` (they fill their buttons with it; their accent-1… colours are decorative); Astra: `--ast-global-color-2`, `--ast-global-color-4`, `--ast-global-color-0`; Kadence: `--global-palette3`, `--global-palette9`, `--global-palette1`; GeneratePress: `--contrast`, `--base-3`, `--accent`; Blocksy: `--theme-palette-color-4`, `--theme-palette-color-8`, `--theme-palette-color-1`. Use only these names, and only if the site really has them (the theme's CSS, or Styles → Colors): the `--wp--preset--color--black`, `--white`, `--vivid-…` that WordPress adds everywhere are not the theme's palette. Another theme, or one without these variables (Hello Elementor, OceanWP): leave the variables alone, it keeps Kodza's monochrome; same when the developer asks for monochrome or the Kodza look. Leave the translucent greys (`rgba(10, 10, 10, …)`) as they are: they suit any light background. On a dark palette, set the other variables from Dark mode too.
- WordPress turns straight quotes and `--` into typographic ones in the text of a Custom HTML block (not inside `<code>` or `<pre>`).
- Put it in the site header (Site Editor → Patterns → Header, or a page template without the theme's own header) rather than in the page content: a sticky element only sticks inside its parent. Logged in, keep it below the admin bar: --kz-header-top: calc(var(--wp-admin--admin-bar--height, 0px) + 12px) on the header.

#### With Elementor

- HTML: an **HTML** widget (Elementor shows it to administrators only). It keeps the code exactly as pasted, straight quotes included.
- This one spans the page: give the widget its own container, **Content Width: Full Width**, padding 0.
- CSS and JS: as above. Elementor's Site Settings → Theme Style styles every button, field, link and image of the page, components included; the theme guard at the end of the CSS keeps the component's buttons, fields and link colours as they are.
- The Elementor editor redraws each widget after the page has loaded: without the script below, the component stays still in the editor preview (the published page works). Add it once per site, in the footer like the component's script (`kodza/elementor-editor.js`, or a code-snippets plugin):

```js
// Kodza in the Elementor editor: the editor redraws each HTML widget after the page has loaded.
// Start Kodza in what it draws, stop it in what it replaces or removes. Once per site.
window.addEventListener('elementor/frontend/init', () => {
  if (!elementorFrontend.isEditMode()) return;
  class KodzaWidget extends elementorModules.frontend.handlers.Base {
    onInit() {
      super.onInit();
      this.kodza = [...this.$element[0].children];
      document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root: this.$element[0] } }));
    }
    onDestroy() {
      super.onDestroy();
      this.kodza.forEach((root) => document.dispatchEvent(new CustomEvent('kodza:destroy', { detail: { root } })));
    }
  }
  elementorFrontend.elementsHandler.attachHandler('html', KodzaWidget);
});
```

- No child theme: everything can go in the HTML widget instead, `<style>` with the CSS, the HTML, then `<script>` with the JS. It works on the page and in the editor without the script above. This one reads the page around it, and a script in the widget runs before the rest of the page exists: put its `<script>` in an HTML widget at the bottom of the page instead.

### Shopify

- Files: `assets/kodza-scroll-header.css` and `assets/kodza-scroll-header.js` (the Files commands with `-o assets/…`).
- In the section: `{{ 'kodza-scroll-header.css' | asset_url | stylesheet_tag }}` and `<script src="{{ 'kodza-scroll-header.js' | asset_url }}" defer></script>`, then the HTML.
- The theme editor re-renders sections: restart them with
  `document.addEventListener('shopify:section:load', (e) => document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root: e.target } })));`
  and the same with `shopify:section:unload` → `kodza:destroy`.

### React / Next.js

- Files, side by side (e.g. in `components/kodza/`): `ScrollHeader.tsx` (below), the CSS block under Code saved as `scroll-header.css` and the JS block as `scroll-header.js`, both as they are. The HTML block is already inside the component: skip it.
- Use it: `import { ScrollHeader } from '@/components/kodza/ScrollHeader';` then `<ScrollHeader />`. Props: `variant` ("keep", "solid", or several in an array), `vars` (the `--kz-…` variables listed under API, e.g. `vars={{ '--kz-header-fg': … }}`), `className`, `style` and the other props of its `<header>` (`onClick`, `aria-…`).
- Next.js App Router: it is a Client Component already (`'use client'`). Pages Router: Next.js takes global CSS only in `pages/_app`, so move the `import './scroll-header.css'` line there.
- Safe under StrictMode, client-side navigation and prop changes: when a prop changes, the `key` gives React a fresh element, `kodza:destroy` stops the script on the old one and `kodza:init` starts it on the new one.

```tsx
'use client';
// Kodza — Scroll Header, for React. From https://kodza.dev/components/scroll-header/
// Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license
// Next to this file: scroll-header.css and scroll-header.js, the component's CSS and JS from Kodza, as they are.
// Yours to edit: the markup is plain JSX below.
// The script changes this markup once React has rendered it (it adds layers, splits text, moves
// nodes), so React must not patch it afterwards. When a prop changes, the key gives React a fresh
// element: kodza:destroy stops the script on the old one, kodza:init starts it on the new one.
import { useRef, useEffect, type ComponentPropsWithoutRef, type ComponentRef, type CSSProperties } from 'react';
import './scroll-header.css';

type Variant = "keep" | "solid";

export type ScrollHeaderProps = Omit<ComponentPropsWithoutRef<'header'>, "children" | "variant" | "vars"> & {
  /** Modifier class(es): .kodza-scroll-header--keep, .kodza-scroll-header--solid */
  variant?: Variant | Variant[];
  /** Settings, as CSS variables on the root */
  vars?: {
    /** default: #0a0a0a */
    "--kz-header-fg"?: string | number;
    /** default: rgba(10, 10, 10, 0.6) */
    "--kz-header-muted"?: string | number;
    /** default: rgba(10, 10, 10, 0.07) */
    "--kz-header-soft"?: string | number;
    /** default: rgba(255, 255, 255, 0.74) */
    "--kz-header-glass"?: string | number;
    /** default: rgba(10, 10, 10, 0.08) */
    "--kz-header-edge"?: string | number;
    /** default: rgba(10, 10, 10, 0.08) */
    "--kz-header-shadow"?: string | number;
    /** default: #0a0a0a */
    "--kz-header-ink"?: string | number;
    /** default: #ffffff */
    "--kz-header-on-ink"?: string | number;
    /** default: rgba(255, 255, 255, 0.92) */
    "--kz-header-dark-fg"?: string | number;
    /** default: rgba(255, 255, 255, 0.62) */
    "--kz-header-dark-muted"?: string | number;
    /** default: rgba(255, 255, 255, 0.1) */
    "--kz-header-dark-soft"?: string | number;
    /** default: rgba(30, 30, 30, 0.72) */
    "--kz-header-dark-glass"?: string | number;
    /** default: rgba(255, 255, 255, 0.1) */
    "--kz-header-dark-edge"?: string | number;
    /** default: rgba(0, 0, 0, 0.32) */
    "--kz-header-dark-shadow"?: string | number;
    /** default: #ffffff */
    "--kz-header-dark-ink"?: string | number;
    /** default: #0a0a0a */
    "--kz-header-dark-on-ink"?: string | number;
    /** default: 12px */
    "--kz-header-top"?: string | number;
    /** default: 60px */
    "--kz-header-height"?: string | number;
    /** default: 1080px */
    "--kz-header-max"?: string | number;
    /** default: var(--kz-header-max) */
    "--kz-header-max-scrolled"?: string | number;
    /** default: 22px */
    "--kz-header-radius"?: string | number;
    /** default: 0.5s */
    "--kz-header-duration"?: string | number;
    /** default: cubic-bezier(0.22, 1, 0.36, 1) */
    "--kz-header-ease"?: string | number;
    /** default: 600px */
    "--kz-header-hide-after"?: string | number;
    /** default: 0.8s */
    "--kz-header-hide-duration"?: string | number;
    /** default: cubic-bezier(0.65, 0, 0.35, 1) */
    "--kz-header-hide-ease"?: string | number;
    /** default: 0.7s */
    "--kz-header-width-duration"?: string | number;
    /** default: cubic-bezier(0.65, 0, 0.35, 1) */
    "--kz-header-width-ease"?: string | number;
  };
  className?: string;
};

export function ScrollHeader({ variant, vars, className, style, ...rest }: ScrollHeaderProps) {
  const ref = useRef<ComponentRef<'header'>>(null);
  const classes = ["kodza-scroll-header", ...([] as string[]).concat(variant ?? []).map((v) => `kodza-scroll-header--${v}`), className].filter(Boolean).join(' ');
  // Everything the markup is made of: when it changes, React gets a fresh element (see the top)
  const key = JSON.stringify([classes, vars, style, rest]);

  // Starts the script on this element once React has rendered it, stops it when it goes
  useEffect(() => {
    const root = ref.current;
    let live = true;
    // @ts-ignore: a plain script, no types to find
    import('./scroll-header.js').then(() => {
      if (live) document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root } }));
    });
    return () => {
      live = false;
      document.dispatchEvent(new CustomEvent('kodza:destroy', { detail: { root } }));
    };
  }, [key]);

  return (
    <header key={key} {...rest} className={classes} style={{ ...vars, ...style } as CSSProperties} ref={ref}>
      <div className="kodza-scroll-header__bar">
        <a className="kodza-scroll-header__brand" href="#"> <span className="kodza-scroll-header__mark" aria-hidden="true"> <svg viewBox="0 0 16 16"> <path d="M5 3v10M11.5 3 6.5 8l5 5" /> </svg> </span> kodza </a>
        <nav className="kodza-scroll-header__nav" aria-label="Main">
          <a className="kodza-scroll-header__link" href="#" aria-current="page">Components</a>
          {' '}
          <a className="kodza-scroll-header__link" href="#">Docs</a>
          {' '}
          <a className="kodza-scroll-header__link" href="#">Changelog</a>
        </nav>
        <div className="kodza-scroll-header__actions">
          <a className="kodza-scroll-header__cta kodza-scroll-header__cta--quiet" href="#">Sign in</a>
          {' '}
          <a className="kodza-scroll-header__cta" href="#">Get started</a>
          {' '}
          <button className="kodza-scroll-header__burger" type="button" aria-expanded="false" aria-label="Menu">
            <span />
            <span />
          </button>
        </div>
      </div>
      <div className="kodza-scroll-header__panel">
        <div className="kodza-scroll-header__panel-in" />
      </div>
    </header>
  );
}
```

## Code

```html
<header class="kodza-scroll-header">
  <div class="kodza-scroll-header__bar">
    <a class="kodza-scroll-header__brand" href="#">
      <span class="kodza-scroll-header__mark" aria-hidden="true"><svg viewBox="0 0 16 16"><path d="M5 3v10M11.5 3 6.5 8l5 5"/></svg></span>
      kodza
    </a>
    <nav class="kodza-scroll-header__nav" aria-label="Main">
      <a class="kodza-scroll-header__link" href="#" aria-current="page">Components</a>
      <a class="kodza-scroll-header__link" href="#">Docs</a>
      <a class="kodza-scroll-header__link" href="#">Changelog</a>
    </nav>
    <div class="kodza-scroll-header__actions">
      <a class="kodza-scroll-header__cta kodza-scroll-header__cta--quiet" href="#">Sign in</a>
      <a class="kodza-scroll-header__cta" href="#">Get started</a>
      <button class="kodza-scroll-header__burger" type="button" aria-expanded="false" aria-label="Menu"><span></span><span></span></button>
    </div>
  </div>
  <div class="kodza-scroll-header__panel">
    <div class="kodza-scroll-header__panel-in"></div>
  </div>
</header>
```

```css
/* Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license */
/* Kodza — Scroll Header
   A floating glass pill for the top of a site. Clear over the top of the page, it turns to
   frosted glass as soon as you scroll, steps aside while you read down and comes back the
   moment you scroll up (or tab into it). It reads the room: over a section marked
   data-header-tone="dark" it turns to dark glass. Below 760px (or as soon as they no longer
   fit), the links and the actions' links fold into the pill behind a two-line button. Its
   height never changes, so nothing under it moves. A link marked aria-current (page, or the
   section in view) gets the soft pill. Any button can sit in the actions (--quiet for a
   second call to action); a filled logo goes in __mark--fill.
   Options, one class each: --keep (never hides), --solid (glass from the start).
   --kz-header-hide-after sets how far the page scrolls before it steps aside, and
   --kz-header-max-scrolled the width it narrows to with the glass. The script measures what the
   bar needs (--kz-header-content): line --kz-header-max up with your page's column and set
   --kz-header-max-scrolled: calc(var(--kz-header-content) + 48px), and the bar sits on the column
   at the top, then hugs its links once you scroll.
   Everything is tuned with the --kz-header-* variables. */
.kodza-scroll-header {
  --kz-header-fg: #0a0a0a;
  --kz-header-muted: rgba(10, 10, 10, 0.6);
  --kz-header-soft: rgba(10, 10, 10, 0.07);
  --kz-header-glass: rgba(255, 255, 255, 0.74);
  --kz-header-edge: rgba(10, 10, 10, 0.08);
  --kz-header-shadow: rgba(10, 10, 10, 0.08);
  --kz-header-ink: #0a0a0a;
  --kz-header-on-ink: #ffffff;
  --kz-header-dark-fg: rgba(255, 255, 255, 0.92);
  --kz-header-dark-muted: rgba(255, 255, 255, 0.62);
  --kz-header-dark-soft: rgba(255, 255, 255, 0.1);
  --kz-header-dark-glass: rgba(30, 30, 30, 0.72);
  --kz-header-dark-edge: rgba(255, 255, 255, 0.1);
  --kz-header-dark-shadow: rgba(0, 0, 0, 0.32);
  --kz-header-dark-ink: #ffffff;
  --kz-header-dark-on-ink: #0a0a0a;
  --kz-header-top: 12px;
  --kz-header-height: 60px;
  --kz-header-max: 1080px;
  --kz-header-max-scrolled: var(--kz-header-max);
  /* Set by the script while the links are on the bar: the width they need, logo and actions included */
  --kz-header-content: 100%;
  --kz-header-radius: 22px;
  --kz-header-duration: 0.5s;
  --kz-header-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --kz-header-hide-after: 600px;
  --kz-header-hide-duration: 0.8s;
  --kz-header-hide-ease: cubic-bezier(0.65, 0, 0.35, 1);
  --kz-header-width-duration: 0.7s;
  --kz-header-width-ease: cubic-bezier(0.65, 0, 0.35, 1);

  position: sticky;
  top: var(--kz-header-top);
  z-index: 50;
  width: min(var(--kz-header-max), calc(100% - 24px));
  margin: 0 auto;
  color: var(--kz-header-fg);
  transition:
    transform var(--kz-header-duration) var(--kz-header-ease),
    width var(--kz-header-width-duration) var(--kz-header-width-ease),
    color 0.35s ease;
}

/* With the glass, the pill narrows to --kz-header-max-scrolled (never wider than at the top) */
.kodza-scroll-header.is-scrolled,
.kodza-scroll-header.is-open,
.kodza-scroll-header--solid {
  width: min(var(--kz-header-max-scrolled), var(--kz-header-max), calc(100% - 24px));
}

/* Over a dark section: the same pill, in dark glass */
.kodza-scroll-header.is-dark {
  --kz-header-fg: var(--kz-header-dark-fg);
  --kz-header-muted: var(--kz-header-dark-muted);
  --kz-header-soft: var(--kz-header-dark-soft);
  --kz-header-glass: var(--kz-header-dark-glass);
  --kz-header-edge: var(--kz-header-dark-edge);
  --kz-header-shadow: var(--kz-header-dark-shadow);
  --kz-header-ink: var(--kz-header-dark-ink);
  --kz-header-on-ink: var(--kz-header-dark-on-ink);
}

/* Hidden while reading down (once the page has scrolled --kz-header-hide-after past it),
   shadow included. It leaves slowly and comes back quickly. */
.kodza-scroll-header.is-hidden {
  transform: translateY(calc(-100% - var(--kz-header-top) - 32px));
  transition:
    transform var(--kz-header-hide-duration) var(--kz-header-hide-ease),
    width var(--kz-header-width-duration) var(--kz-header-width-ease),
    color 0.35s ease;
}

/* The glass: clear at the top of the page, frosted once you scroll */
.kodza-scroll-header::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--kz-header-radius);
  background: var(--kz-header-glass);
  box-shadow: inset 0 0 0 1px var(--kz-header-edge), 0 10px 30px var(--kz-header-shadow);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  backdrop-filter: blur(20px) saturate(1.4);
  opacity: 0;
  transform: scale(0.97, 0.9);
  transition:
    opacity 0.4s ease,
    transform var(--kz-header-duration) var(--kz-header-ease),
    background-color 0.35s ease,
    box-shadow 0.35s ease;
  pointer-events: none;
}

.kodza-scroll-header.is-scrolled::before,
.kodza-scroll-header.is-open::before,
.kodza-scroll-header--solid::before {
  opacity: 1;
  transform: none;
}

.kodza-scroll-header__bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--kz-header-height);
  padding: 0 10px 0 16px;
}

.kodza-scroll-header__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  color: inherit;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.kodza-scroll-header__mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--kz-header-ink);
  color: var(--kz-header-on-ink);
  transition: background-color 0.35s ease, color 0.35s ease;
}

.kodza-scroll-header__mark svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* A filled logo of your own (an svg drawn with fill, not with a stroke) */
.kodza-scroll-header__mark--fill svg {
  fill: currentColor;
  stroke: none;
}

.kodza-scroll-header__nav {
  display: flex;
  gap: 2px;
  margin: 0 auto;
}

.kodza-scroll-header__link {
  padding: 8px 13px;
  border-radius: 999px;
  color: var(--kz-header-muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.25s ease, background-color 0.25s ease;
}

.kodza-scroll-header__link:hover {
  color: var(--kz-header-fg);
}

.kodza-scroll-header__link[aria-current]:not([aria-current="false"]) {
  background: var(--kz-header-soft);
  color: var(--kz-header-fg);
}

.kodza-scroll-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kodza-scroll-header__cta {
  display: inline-grid;
  place-items: center;
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--kz-header-ink);
  color: var(--kz-header-on-ink);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.35s ease, color 0.35s ease, opacity 0.25s ease;
}

.kodza-scroll-header__cta:hover {
  opacity: 0.85;
}

/* A second call to action, quieter */
.kodza-scroll-header__cta--quiet {
  background: var(--kz-header-soft);
  color: var(--kz-header-fg);
}

/* Two lines that cross into an X */
.kodza-scroll-header__burger {
  position: relative;
  display: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--kz-header-soft);
  cursor: pointer;
}

.kodza-scroll-header__burger span {
  position: absolute;
  right: 12px;
  left: 12px;
  height: 1.6px;
  border-radius: 2px;
  background: var(--kz-header-fg);
  transition: transform 0.4s var(--kz-header-ease);
}

.kodza-scroll-header__burger span:first-child {
  top: 16px;
}

.kodza-scroll-header__burger span:last-child {
  top: 22px;
}

.kodza-scroll-header.is-open .kodza-scroll-header__burger span:first-child {
  transform: translateY(3px) rotate(45deg);
}

.kodza-scroll-header.is-open .kodza-scroll-header__burger span:last-child {
  transform: translateY(-3px) rotate(-45deg);
}

.kodza-scroll-header__brand:focus-visible,
.kodza-scroll-header__link:focus-visible,
.kodza-scroll-header__cta:focus-visible,
.kodza-scroll-header__burger:focus-visible,
.kodza-scroll-header__panel-link:focus-visible {
  outline: 2px solid var(--kz-header-fg);
  outline-offset: 3px;
}

/* The small-screen menu: the pill grows to show the links */
.kodza-scroll-header__panel {
  position: relative;
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--kz-header-duration) var(--kz-header-ease);
}

.kodza-scroll-header.is-open .kodza-scroll-header__panel {
  grid-template-rows: 1fr;
}

.kodza-scroll-header__panel-in {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 16px;
  overflow: hidden;
  visibility: hidden;
  transition: visibility 0s linear var(--kz-header-duration);
}

.kodza-scroll-header.is-open .kodza-scroll-header__panel-in {
  visibility: visible;
  transition-delay: 0s;
}

.kodza-scroll-header__panel-link {
  padding: 14px 2px;
  border-top: 1px solid var(--kz-header-soft);
  border-radius: 4px;
  color: inherit;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
  text-decoration: none;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.3s ease;
}

.kodza-scroll-header.is-open .kodza-scroll-header__panel-link {
  opacity: 1;
  transform: none;
  transition:
    opacity 0.4s ease calc(0.12s + var(--i, 0) * 50ms),
    transform 0.5s var(--kz-header-ease) calc(0.12s + var(--i, 0) * 50ms);
}

.kodza-scroll-header__panel-link:last-child {
  margin-bottom: 14px;
}

/* The point where the page starts to scroll under the header (added by the script) */
.kodza-scroll-header__sentinel {
  display: block;
  height: 1px;
  margin-bottom: -1px;
}

/* Folded: the links (and the actions' links) wait in the menu. Below 760px, or when the
   script finds they no longer fit on the bar */
@media (max-width: 760px) {
  .kodza-scroll-header__nav,
  .kodza-scroll-header__actions > a {
    display: none;
  }

  .kodza-scroll-header__actions {
    margin-left: auto;
  }

  .kodza-scroll-header__burger {
    display: block;
  }
}

.kodza-scroll-header.is-folded .kodza-scroll-header__nav,
.kodza-scroll-header.is-folded .kodza-scroll-header__actions > a {
  display: none;
}

.kodza-scroll-header.is-folded .kodza-scroll-header__actions {
  margin-left: auto;
}

.kodza-scroll-header.is-folded .kodza-scroll-header__burger {
  display: block;
}

@media (min-width: 761px) {
  .kodza-scroll-header:not(.is-folded) .kodza-scroll-header__panel {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kodza-scroll-header,
  .kodza-scroll-header::before,
  .kodza-scroll-header__panel,
  .kodza-scroll-header__panel-link,
  .kodza-scroll-header__burger span {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}

/* The dark glass follows the sections marked data-header-tone="dark". To retune it:
.kodza-scroll-header {
  --kz-header-dark-glass: rgba(20, 20, 20, 0.8);
  --kz-header-dark-ink: #f2f2f0;
}
*/

/* kodza-guard 1669807482c9 — generated by Kodza, do not edit.
   Theme guard: keeps a site's own CSS (WordPress themes, Bootstrap, CSS resets…) off this
   component. :not(#_) is always true and weighs as much as an id, so these lines win over
   theme rules made of classes and tags. Customise the component through its --kz-* variables. */

/* What the browser gives, where the component sets it only in some states: at the lowest weight, so its own rules below put it back */

:where(.kodza-scroll-header__brand):not(#_),
:where(.kodza-scroll-header__cta):not(#_),
:where(.kodza-scroll-header__burger):not(#_) {
  outline: revert;
  outline-offset: revert;
}

:where(.kodza-scroll-header__link):not(#_) {
  outline: revert;
  background-color: revert;
  background-image: revert;
  outline-offset: revert;
}

:where(.kodza-scroll-header__panel-link):not(#_) {
  outline: revert;
  margin-bottom: revert;
  outline-offset: revert;
}

/* What the browser gives, on everything the component leaves to it */

.kodza-scroll-header:not(#_) {
  border: revert;
  padding: revert;
  border-radius: revert;
  outline: revert;
  text-decoration: revert;
  list-style: revert;
  box-sizing: revert;
  background-color: revert;
  background-image: revert;
  box-shadow: revert;
  outline-offset: revert;
  appearance: revert;
  max-height: revert;
  font-family: revert;
  font-size: revert;
  font-weight: revert;
  font-style: revert;
  line-height: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-scroll-header__bar:not(#_),
.kodza-scroll-header__mark:not(#_),
.kodza-scroll-header__actions:not(#_),
.kodza-scroll-header__panel:not(#_),
.kodza-scroll-header__panel-in:not(#_),
.kodza-scroll-header__burger span:where(:not([class*="kodza-"])):not(#_) {
  box-sizing: revert;
}

.kodza-scroll-header__brand:not(#_) {
  border: revert;
  margin: revert;
  padding: revert;
  transition: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  position: revert;
  background-color: revert;
  background-image: revert;
  box-shadow: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  font-family: revert;
  font-style: revert;
  line-height: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-scroll-header__nav:not(#_) {
  border: revert;
  padding: revert;
  border-radius: revert;
  outline: revert;
  text-decoration: revert;
  transition: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  position: revert;
  background-color: revert;
  background-image: revert;
  box-shadow: revert;
  outline-offset: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  color: revert;
  font-family: revert;
  font-size: revert;
  font-weight: revert;
  font-style: revert;
  line-height: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-scroll-header__link:not(#_),
.kodza-scroll-header__cta:not(#_) {
  border: revert;
  margin: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  position: revert;
  box-shadow: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  font-family: revert;
  font-style: revert;
  line-height: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-scroll-header__burger:not(#_) {
  margin: revert;
  text-decoration: revert;
  transition: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  box-shadow: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  color: revert;
  font-family: revert;
  font-size: revert;
  font-weight: revert;
  font-style: revert;
  line-height: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
  white-space: revert;
  min-height: revert;
}

.kodza-scroll-header__panel-link:not(#_) {
  list-style: revert;
  box-sizing: revert;
  float: revert;
  position: revert;
  margin-top: revert;
  margin-right: revert;
  margin-left: revert;
  border-right-width: revert;
  border-bottom-width: revert;
  border-left-width: revert;
  border-right-style: revert;
  border-bottom-style: revert;
  border-left-style: revert;
  border-right-color: revert;
  border-bottom-color: revert;
  border-left-color: revert;
  background-color: revert;
  background-image: revert;
  box-shadow: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  font-family: revert;
  font-style: revert;
  line-height: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-scroll-header__mark svg:where(:not([class*="kodza-"])):not(#_) {
  border: revert;
  margin: revert;
  padding: revert;
  border-radius: revert;
  outline: revert;
  text-decoration: revert;
  transition: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  position: revert;
  background-color: revert;
  background-image: revert;
  box-shadow: revert;
  outline-offset: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  color: revert;
  font-family: revert;
  font-size: revert;
  font-weight: revert;
  font-style: revert;
  line-height: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-scroll-header:not(#_):where(:not([hidden])),
.kodza-scroll-header__link:not(#_):where(:not([hidden])),
.kodza-scroll-header__panel-link:not(#_):where(:not([hidden])),
.kodza-scroll-header__mark svg:where(:not([class*="kodza-"])):not(#_):where(:not([hidden])) {
  display: revert;
}

.kodza-scroll-header:not(#_):where([hidden]),
.kodza-scroll-header__link:not(#_):where([hidden]),
.kodza-scroll-header__panel-link:not(#_):where([hidden]),
.kodza-scroll-header__mark svg:where(:not([class*="kodza-"])):not(#_):where([hidden]) {
  display: none;
}

.kodza-scroll-header:not(#_)::before {
  box-sizing: revert;
}

/* The component's own rules, one step stronger: real buttons and fields, what it sets on tags themes style (links, lists, headings, images…), and the root width (a theme may narrow it, never widen it) */

.kodza-scroll-header:not(#_) {
  position: sticky;
  color: var(--kz-header-fg);
  transition: transform var(--kz-header-duration) var(--kz-header-ease),
    width var(--kz-header-width-duration) var(--kz-header-width-ease),
    color 0.35s ease;
}

.kodza-scroll-header:not(#_) {
  width: min(var(--kz-header-max), calc(100% - 24px));
}

.kodza-scroll-header.is-scrolled:not(#_),
.kodza-scroll-header.is-open:not(#_),
.kodza-scroll-header--solid:not(#_) {
  width: min(var(--kz-header-max-scrolled), var(--kz-header-max), calc(100% - 24px));
}

.kodza-scroll-header.is-hidden:not(#_) {
  transition: transform var(--kz-header-hide-duration) var(--kz-header-hide-ease),
    width var(--kz-header-width-duration) var(--kz-header-width-ease),
    color 0.35s ease;
}

.kodza-scroll-header__brand:not(#_) {
  display: inline-flex;
  border-radius: 8px;
  color: inherit;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.kodza-scroll-header__nav:not(#_) {
  display: flex;
  margin: 0 auto;
}

.kodza-scroll-header__link:not(#_) {
  padding: 8px 13px;
  border-radius: 999px;
  color: var(--kz-header-muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.25s ease, background-color 0.25s ease;
}

.kodza-scroll-header__link:hover:not(#_) {
  color: var(--kz-header-fg);
}

.kodza-scroll-header__link[aria-current]:not([aria-current="false"]):not(#_) {
  background: var(--kz-header-soft);
  color: var(--kz-header-fg);
}

.kodza-scroll-header__cta:not(#_) {
  display: inline-grid;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--kz-header-ink);
  color: var(--kz-header-on-ink);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.35s ease, color 0.35s ease, opacity 0.25s ease;
}

.kodza-scroll-header__cta--quiet:not(#_) {
  background: var(--kz-header-soft);
  color: var(--kz-header-fg);
}

.kodza-scroll-header__burger:not(#_) {
  position: relative;
  display: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--kz-header-soft);
  cursor: pointer;
}

.kodza-scroll-header__brand:focus-visible:not(#_),
.kodza-scroll-header__link:focus-visible:not(#_),
.kodza-scroll-header__cta:focus-visible:not(#_),
.kodza-scroll-header__panel-link:focus-visible:not(#_) {
  outline: 2px solid var(--kz-header-fg);
  outline-offset: 3px;
}

.kodza-scroll-header__burger:focus-visible:not(#_) {
  outline: 2px solid var(--kz-header-fg);
  outline-offset: 3px;
}

.kodza-scroll-header__panel-link:not(#_) {
  padding: 14px 2px;
  border-top: 1px solid var(--kz-header-soft);
  border-radius: 4px;
  color: inherit;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
  text-decoration: none;
  transition: opacity 0.2s ease, transform 0.3s ease;
}

.kodza-scroll-header.is-open .kodza-scroll-header__panel-link:not(#_) {
  transition: opacity 0.4s ease calc(0.12s + var(--i, 0) * 50ms),
    transform 0.5s var(--kz-header-ease) calc(0.12s + var(--i, 0) * 50ms);
}

.kodza-scroll-header__panel-link:last-child:not(#_) {
  margin-bottom: 14px;
}

@media (max-width: 760px) {
  .kodza-scroll-header__nav:not(#_),
  .kodza-scroll-header__actions > a:not(#_) {
    display: none;
  }
}

@media (max-width: 760px) {
  .kodza-scroll-header__burger:not(#_) {
    display: block;
  }
}

.kodza-scroll-header.is-folded .kodza-scroll-header__nav:not(#_),
.kodza-scroll-header.is-folded .kodza-scroll-header__actions > a:not(#_) {
  display: none;
}

.kodza-scroll-header.is-folded .kodza-scroll-header__burger:not(#_) {
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  .kodza-scroll-header:not(#_),
  .kodza-scroll-header__panel-link:not(#_) {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}
```

```js
// Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license
// Kodza — Scroll Header
// Marks the header "is-scrolled" once the page scrolls under it (a 1px sentinel just above it
// tells), "is-hidden" while the visitor reads down (until they scroll up or tab into it), and
// "is-dark" over a section marked data-header-tone="dark". On small screens, or as soon as the
// links no longer fit on the bar ("is-folded"), they wait in the pill's menu (with the actions'
// links, copied as plain links) and the two-line button opens it. While the links are on the bar,
// it measures the width they need into --kz-header-content, for a pill that hugs them.
(() => {
  const SELECTOR = '.kodza-scroll-header';
  let uid = 0;

  // The tone of the section right under the header. Hidden, it is read where the header will
  // come back (stuck at the top), so it never returns in the tone of a section it left. While a
  // view transition draws over the page (a page transition), the point only reaches <html>: the
  // marked sections are then found by their boxes, the innermost one last
  const readTone = (root) => {
    const box = root.getBoundingClientRect();
    const bottom = root.classList.contains('is-hidden') ? (parseFloat(getComputedStyle(root).top) || 0) + root.offsetHeight : box.bottom;
    const x = box.left + box.width / 2;
    const y = Math.min(innerHeight - 1, Math.max(0, bottom - 6));
    const under = document.elementsFromPoint(x, y).find((el) => !root.contains(el));
    const zone = under && under !== document.documentElement
      ? under.closest('[data-header-tone]')
      : [...document.querySelectorAll('[data-header-tone]')].filter((el) => {
        const r = el.getBoundingClientRect();
        return !root.contains(el) && x >= r.left && x <= r.right && y >= r.top && y <= r.bottom;
      }).pop();
    root.classList.toggle('is-dark', (zone?.dataset.headerTone || root.dataset.tone) === 'dark');
  };

  // One instance. Everything it starts is tied to `signal`, so kodza:destroy stops it all
  function mount(root, signal) {
    const sentinel = document.createElement('span');
    sentinel.className = 'kodza-scroll-header__sentinel';
    sentinel.setAttribute('aria-hidden', 'true');
    root.before(sentinel);
    const observer = new IntersectionObserver(([entry]) => {
      const scrolled = !entry.isIntersecting && entry.boundingClientRect.top < 0;
      root.classList.toggle('is-scrolled', scrolled);
      if (!scrolled) root.classList.remove('is-hidden');
    });
    observer.observe(sentinel);
    signal.addEventListener('abort', () => {
      observer.disconnect();
      sentinel.remove();
    });
    root.addEventListener('focusin', () => root.classList.remove('is-hidden'), { signal });

    // The small-screen menu: the same links, bigger, and the actions' links last (any button
    // kind: only its address and its words are copied, without what is hidden from screen readers)
    const bar = root.querySelector('.kodza-scroll-header__bar');
    const burger = root.querySelector('.kodza-scroll-header__burger');
    const panel = root.querySelector('.kodza-scroll-header__panel-in');
    let fit;
    const words = (node) => [...node.childNodes].map((child) => {
      if (child.nodeType === Node.TEXT_NODE) return child.textContent;
      if (child.nodeType !== Node.ELEMENT_NODE || child.getAttribute('aria-hidden') === 'true') return '';
      return words(child);
    }).join('').replace(/\s+/g, ' ').trim();
    if (burger && panel) {
      const sources = [...root.querySelectorAll('.kodza-scroll-header__link, .kodza-scroll-header__actions a[href]')];
      panel.append(...sources.map((source, i) => {
        const link = document.createElement('a');
        link.className = 'kodza-scroll-header__panel-link';
        ['href', 'target', 'rel', 'aria-current'].forEach((name) => source.hasAttribute(name) && link.setAttribute(name, source.getAttribute(name)));
        link.textContent = source.getAttribute('aria-label') || words(source);
        link.style.setProperty('--i', i);
        return link;
      }));
      panel.id = `kodza-scroll-header-${++uid}`;
      burger.setAttribute('aria-controls', panel.id);
      const set = (open) => {
        root.classList.toggle('is-open', open);
        burger.setAttribute('aria-expanded', String(open));
        burger.setAttribute('aria-label', open ? 'Close the menu' : 'Menu');
      };
      burger.addEventListener('click', () => set(!root.classList.contains('is-open')), { signal });
      panel.addEventListener('click', (event) => event.target.closest('a') && set(false), { signal });
      root.addEventListener('keydown', (event) => {
        if (event.key === 'Escape' && root.classList.contains('is-open')) {
          set(false);
          burger.focus();
        }
      }, { signal });

      // Above 760px, fold only when the bar runs out of room (measured unfolded, in one frame)
      fit = () => {
        root.classList.remove('is-folded');
        const folded = innerWidth > 760 && bar.scrollWidth > bar.clientWidth + 1;
        root.classList.toggle('is-folded', folded);
        if (!folded && innerWidth > 760 && root.classList.contains('is-open')) set(false);
      };
    }

    // The width the bar's content needs (logo, links, actions, gaps and padding), for a pill that
    // hugs it. Folded, the menu needs the whole width: the variable goes back to 100%
    const hug = () => {
      if (!bar || burger?.offsetWidth) return root.style.removeProperty('--kz-header-content');
      const style = getComputedStyle(bar);
      const shown = [...bar.children].filter((child) => child.offsetWidth);
      const width = shown.reduce((sum, child) => sum + child.offsetWidth, 0) + Math.max(0, shown.length - 1) * (parseFloat(style.columnGap) || 0) + parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
      root.style.setProperty('--kz-header-content', `${Math.ceil(width)}px`);
    };
    if (bar) {
      const sizer = new ResizeObserver(() => {
        fit?.();
        hug();
      });
      [bar, ...bar.children].forEach((el) => sizer.observe(el));
      document.fonts?.ready.then(() => !signal.aborted && (fit?.(), hug()));
      signal.addEventListener('abort', () => sizer.disconnect());
    }

    let lastY = window.scrollY;
    let ticking = false;
    const update = () => {
      ticking = false;
      const y = window.scrollY;
      const delta = y - lastY;
      const locked = root.classList.contains('kodza-scroll-header--keep') || root.classList.contains('is-open') || root.contains(document.activeElement);
      if (Math.abs(delta) >= 6 && !locked) {
        // Only a header stuck at the top hides (measured on its container: the header itself
        // moves when hidden), and only once the page has scrolled --kz-header-hide-after past it
        const stuck = root.classList.contains('is-scrolled') && root.parentElement.getBoundingClientRect().bottom > root.offsetHeight;
        const far = sentinel.getBoundingClientRect().top < -(parseFloat(getComputedStyle(root).getPropertyValue('--kz-header-hide-after')) || 600);
        if (delta < 0 || !stuck) root.classList.remove('is-hidden');
        else if (far) root.classList.add('is-hidden');
      }
      readTone(root);
      if (Math.abs(delta) >= 6) lastY = y;
    };
    const queue = () => {
      if (!ticking) {
        ticking = true;
        requestAnimationFrame(update);
      }
    };
    window.addEventListener('scroll', queue, { passive: true, signal });
    window.addEventListener('resize', queue, { signal });
    readTone(root);
  }

  // Kodza lifecycle, the same in every component: `kodza:init` starts the instances inside
  // event.detail.root (the whole page by default), `kodza:destroy` stops them and puts their
  // markup back. For themes and apps that swap content without a page load.
  const instances = new WeakMap();
  const find = (scope = document) => [scope, ...scope.querySelectorAll(SELECTOR)].filter((el) => el.matches?.(SELECTOR));
  const init = (scope) => find(scope).forEach((root) => {
    if (root.classList.contains('is-ready')) return; // already running, maybe from another copy of this script
    const controller = new AbortController();
    instances.set(root, { controller, html: root.innerHTML, attrs: [...root.attributes].map((a) => [a.name, a.value]) });
    mount(root, controller.signal);
    root.classList.add('is-ready');
  });
  const destroy = (scope) => find(scope).forEach((root) => {
    const instance = instances.get(root);
    if (!instance) return;
    instances.delete(root);
    instance.controller.abort();
    [...root.attributes].forEach((a) => root.removeAttribute(a.name));
    instance.attrs.forEach(([name, value]) => root.setAttribute(name, value));
    root.innerHTML = instance.html;
  });
  document.addEventListener('kodza:init', (event) => init(event.detail?.root));
  document.addEventListener('kodza:destroy', (event) => destroy(event.detail?.root));
  init();
  // Loaded in <head>, the script runs before the markup exists: once more when it is parsed
  if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', () => init(), { once: true });
})();
```

Free to use, from Kodza (https://kodza.dev).
