# Book a Visit

> A booking form: the coming days, the free times worked out from the opening hours, name and email. On send it rolls up into the answer, with Add to calendar as an .ics file.

Forms · booking form, appointment booking, time slot picker, schedule a visit, opening hours, add to calendar, ics file, reservation form, date picker, availability · HTML, CSS, vanilla JS · no dependencies · updated 2026-11-05
Demo: https://kodza.dev/components/book-a-visit/
Source on GitHub: https://github.com/kodza-dev/kodza/tree/main/components/book-a-visit

## Files

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

- [`kodza-book-a-visit.css`](https://kodza.dev/registry/book-a-visit/kodza-book-a-visit.css) · 37.3 KB
- [`kodza-book-a-visit.js`](https://kodza.dev/registry/book-a-visit/kodza-book-a-visit.js) · 37.8 KB
- [`kodza-book-a-visit.html`](https://kodza.dev/registry/book-a-visit/kodza-book-a-visit.html) · 2.6 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-book-a-visit.css https://kodza.dev/registry/book-a-visit/kodza-book-a-visit.css
curl -fsSL --create-dirs -o kodza/kodza-book-a-visit.js https://kodza.dev/registry/book-a-visit/kodza-book-a-visit.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-book-visit`
- Variables (set them on the root element itself: it declares its own defaults):
  - `--kz-book-visit-width: 520px`
  - `--kz-book-visit-bg: #fff`
  - `--kz-book-visit-fg: #0a0a0a`
  - `--kz-book-visit-muted: rgba(10, 10, 10, 0.62)`
  - `--kz-book-visit-off: rgba(10, 10, 10, 0.3)` — closed days, times gone or taken
  - `--kz-book-visit-line: rgba(10, 10, 10, 0.1)`
  - `--kz-book-visit-soft: rgba(10, 10, 10, 0.04)` — the row of days
  - `--kz-book-visit-hover: rgba(10, 10, 10, 0.05)`
  - `--kz-book-visit-halo: rgba(10, 10, 10, 0.06)` — around a field in focus
  - `--kz-book-visit-ink: #0a0a0a` — the pill, the mark, the button
  - `--kz-book-visit-on-ink: #fff`
  - `--kz-book-visit-duration: 0.55s` — the slide of the pill. 0s = no motion
  - `--kz-book-visit-ease: cubic-bezier(0.22, 1, 0.36, 1)`
- Attributes:
  - `data-address` (e.g. `Carrer de la Roca 14, 07460 Pollença, Mallorca`)
  - `data-days` (e.g. `7`)
  - `data-done` (e.g. `Thank you, {name}.`)
  - `data-hours` (e.g. `mon closed; tue-fri 10:00-14:00, 16:00-19:00; sat 10:00-14:00; sun closed`)
  - `data-length` (e.g. `40`)
  - `data-notice` (e.g. `60`)
  - `data-place` (e.g. `Es Pinar`)
  - `data-taken` (e.g. `tue 11:20, wed 16:40, thu 10:40, thu 16:00, fri 11:20, sat 10:00`)
  - `data-timezone` (e.g. `Europe/Madrid`)
  - `data-value` (e.g. `email`)
- Events: `kodza:submit` (bubbling, from the root)
- 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.

- On a day (focus in `.kodza-book-visit__day input`):
  - `ArrowLeft` / `ArrowRight`: Moves to the previous or next open day
- On a time (focus in `.kodza-book-visit__slot input`):
  - `ArrowLeft` / `ArrowRight`: Moves to the previous or next free time
  - `ArrowUp` / `ArrowDown`: Moves a row up or down
  - `Home` / `End`: Goes to the first or last free time
- In a field (focus in `.kodza-book-visit__input`):
  - `Enter`: Books the visit, or shows what is missing

## Dark mode

The values Kodza uses on a dark background (`#0a0a0a`). For a page that follows the system theme, add them after the component's CSS:

```css
@media (prefers-color-scheme: dark) {
  .kodza-book-visit {
    --kz-book-visit-bg: #161616;
    --kz-book-visit-fg: #f2f2f0;
    --kz-book-visit-muted: rgba(242, 242, 240, 0.62);
    --kz-book-visit-off: rgba(242, 242, 240, 0.3);
    --kz-book-visit-line: rgba(255, 255, 255, 0.12);
    --kz-book-visit-soft: rgba(255, 255, 255, 0.05);
    --kz-book-visit-hover: rgba(255, 255, 255, 0.07);
    --kz-book-visit-halo: rgba(255, 255, 255, 0.08);
    --kz-book-visit-ink: #f2f2f0;
    --kz-book-visit-on-ink: #0a0a0a;
  }
}
```

A site with its own theme switch puts the same rules under its dark selector instead (`[data-theme="dark"] .kodza-book-visit { … }`); a single dark section, under that section's class.

## Use it

### Plain HTML page

- CSS: `kodza/kodza-book-a-visit.css` next to the page (the Files commands as they are), linked in `<head>`: `<link rel="stylesheet" href="kodza/kodza-book-a-visit.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.
- Where it goes: on the page of the place to visit (a flat, a table, a salon, a workshop), under its photos or in the contact section. Write the opening hours in data-hours (days, then ranges, separated by semicolons), the length of a visit in data-length (minutes), how many days to offer in data-days, the notice in data-notice (minutes) and the times already taken in data-taken; the times are worked out in the place's timezone (data-timezone). Point the form's action at your form service or your own endpoint: it sends date, time, name and email; data-send="fetch" sends it without leaving the page. Listen for kodza:submit to send it yourself.
- JS: `kodza/kodza-book-a-visit.js`, loaded with `<script src="kodza/kodza-book-a-visit.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. A site with its own type sets it once for every Kodza component, on `:root`, never by editing the CSS (unset, nothing changes): `--kz-font-display`, the display face (headings, big numbers, wordmarks); `--kz-font-display-weight`, its weight; `--kz-font-display-scale`, a multiplier on its sizes (1 by default); `--kz-font-display-tracking`, its letter-spacing; `--kz-font-display-case`, its case (`uppercase`…); `--kz-font-label`, the face of the small labels (meta, captions, counters, hints, footer links, button labels); `--kz-font-label-size`, their size, one for all of them (`11px`…); `--kz-font-label-weight`, their weight; `--kz-font-label-tracking`, their letter-spacing; `--kz-font-label-case`, their case (`uppercase`…; code and units keep theirs); `--kz-font-label-leading`, their line-height (`1.45`…; buttons, pills and keys keep their box); `--kz-font-mono`, the monospace face (code, labels, counters). 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">`.
- Corners: a site with its own shapes sets them once for every Kodza component, on `:root`, never by editing the CSS (unset, nothing changes): `--kz-radius-scale` multiplies every corner (`0` square, `0.5` softer, `1` Kodza); `--kz-radius-pill` sets the pills (`0` squares them).
- Motion: a site sets its pace once for every Kodza component, on `:root`, never by editing the CSS or the JS: `--kz-motion-scale` multiplies every duration (`0.5` twice as fast, `2` twice as slow, `0` no motion at all, loops stopped, like reduced motion). Unset, nothing changes.
- 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-book-a-visit.css' -e 'd' -e '}' -e '/^KODZA-JS$/{r kodza/kodza-book-a-visit.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">`. A site with its own type sets it once for every Kodza component, on `:root`, never by editing the CSS (unset, nothing changes): `--kz-font-display`, the display face (headings, big numbers, wordmarks); `--kz-font-display-weight`, its weight; `--kz-font-display-scale`, a multiplier on its sizes (1 by default); `--kz-font-display-tracking`, its letter-spacing; `--kz-font-display-case`, its case (`uppercase`…); `--kz-font-label`, the face of the small labels (meta, captions, counters, hints, footer links, button labels); `--kz-font-label-size`, their size, one for all of them (`11px`…); `--kz-font-label-weight`, their weight; `--kz-font-label-tracking`, their letter-spacing; `--kz-font-label-case`, their case (`uppercase`…; code and units keep theirs); `--kz-font-label-leading`, their line-height (`1.45`…; buttons, pills and keys keep their box); `--kz-font-mono`, the monospace face (code, labels, counters).
- Corners: a site with its own shapes sets them once for every Kodza component, on `:root`, never by editing the CSS (unset, nothing changes): `--kz-radius-scale` multiplies every corner (`0` square, `0.5` softer, `1` Kodza); `--kz-radius-pill` sets the pills (`0` squares them).
- Motion: a site sets its pace once for every Kodza component, on `:root`, never by editing the CSS or the JS: `--kz-motion-scale` multiplies every duration (`0.5` twice as fast, `2` twice as slow, `0` no motion at all, loops stopped, like reduced motion). Unset, nothing changes.
- 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.
- Forms: there is nowhere to send them. Handle `submit` in your script with `event.preventDefault()` and show the result in the page.
- Where it goes: on the page of the place to visit (a flat, a table, a salon, a workshop), under its photos or in the contact section. Write the opening hours in data-hours (days, then ranges, separated by semicolons), the length of a visit in data-length (minutes), how many days to offer in data-days, the notice in data-notice (minutes) and the times already taken in data-taken; the times are worked out in the place's timezone (data-timezone). Point the form's action at your form service or your own endpoint: it sends date, time, name and email; data-send="fetch" sends it without leaving the page. Listen for kodza:submit to send it yourself.

### 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.
- 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-book-a-visit', $uri . 'kodza-book-a-visit.css', [], filemtime($dir . 'kodza-book-a-visit.css'));
    wp_enqueue_script('kodza-book-a-visit', $uri . 'kodza-book-a-visit.js', [], filemtime($dir . 'kodza-book-a-visit.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: it takes the colour of the text around it (or keeps its own monochrome): nothing to point at the theme.
- WordPress turns straight quotes and `--` into typographic ones in the text of a Custom HTML block (not inside `<code>` or `<pre>`).

#### With Elementor

- HTML: an **HTML** widget (Elementor shows it to administrators only). It keeps the code exactly as pasted, straight quotes included.
- 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.

### Shopify

- Files: `assets/kodza-book-a-visit.css` and `assets/kodza-book-a-visit.js` (the Files commands with `-o assets/…`).
- In the section: `{{ 'kodza-book-a-visit.css' | asset_url | stylesheet_tag }}` and `<script src="{{ 'kodza-book-a-visit.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`.
- Where it goes: on the page of the place to visit (a flat, a table, a salon, a workshop), under its photos or in the contact section. Write the opening hours in data-hours (days, then ranges, separated by semicolons), the length of a visit in data-length (minutes), how many days to offer in data-days, the notice in data-notice (minutes) and the times already taken in data-taken; the times are worked out in the place's timezone (data-timezone). Point the form's action at your form service or your own endpoint: it sends date, time, name and email; data-send="fetch" sends it without leaving the page. Listen for kodza:submit to send it yourself.

### React / Next.js

- Files, side by side (e.g. in `components/kodza/`): `BookAVisit.tsx` (below), the CSS block under Code saved as `book-a-visit.css` and the JS block as `book-a-visit.js`, both as they are. The HTML block is already inside the component: skip it.
- Use it: `import { BookAVisit } from '@/components/kodza/BookAVisit';` then `<BookAVisit />`. Props: `place` (`data-place`: "Es Pinar"), `address` (`data-address`: "Carrer de la Roca 14, 07460 Pollença, Mallorca"), `hours` (`data-hours`: "mon closed; tue-fri 10:00-14:00, 16:00-19:00; sat 10:00-14:00; sun closed"), `length` (`data-length`: "40"), `timezone` (`data-timezone`: "Europe/Madrid"), `days` (`data-days`: "7"), `notice` (`data-notice`: "60"), `taken` (`data-taken`: "tue 11:20, wed 16:40, thu 10:40, thu 16:00, fri 11:20, sat 10:00"), `vars` (the `--kz-…` variables listed under API, e.g. `vars={{ '--kz-book-visit-width': … }}`), `onSubmit` (the `kodza:submit` event), `className`, `style` and the other props of its `<form>` (`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 './book-a-visit.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.
- Built from your data (tabs, rows, options)? Add what the markup is made of to the `key`, as plain values (ids, text, numbers). What the visitor changes (the open tab, the sort, what they type) is the script's: follow it with `onClick` or `onInput` on the root, and change it from your code as a visitor would (click the tab; set the field's value, then dispatch a bubbling `input` event). Fields stay uncontrolled (`defaultValue`, `name`).

```tsx
'use client';
// Kodza — Book a Visit, for React. From https://kodza.dev/components/book-a-visit/
// 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: book-a-visit.css and book-a-visit.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.
// data-kodza-manual keeps the script from starting it on its own: the effect below does, once
// React has hydrated the markup (on a page that streams in, the script can load first).
// Built from your data (tabs, rows, options)? Put what the markup is made of in the key, as plain
// values (ids, text, numbers): a change starts the script again on fresh markup. What the visitor
// changes (the open tab, the sort, what they type) is the script's: keep it out of the key, follow
// it with onClick or onInput on the root, and change it from your code as a visitor would (click
// the tab; set the field's value, then dispatch a bubbling input event).
import { useRef, useEffect, type ComponentPropsWithoutRef, type ComponentRef, type CSSProperties } from 'react';
import './book-a-visit.css';

export type BookAVisitProps = Omit<ComponentPropsWithoutRef<'form'>, "children" | "vars" | "place" | "address" | "hours" | "length" | "timezone" | "days" | "notice" | "taken" | "onSubmit"> & {
  /** data-place on the root (default: Es Pinar) */
  place?: "Es Pinar";
  /** data-address on the root (default: Carrer de la Roca 14, 07460 Pollença, Mallorca) */
  address?: "Carrer de la Roca 14, 07460 Pollença, Mallorca";
  /** data-hours on the root (default: mon closed; tue-fri 10:00-14:00, 16:00-19:00; sat 10:00-14:00; sun closed) */
  hours?: "mon closed; tue-fri 10:00-14:00, 16:00-19:00; sat 10:00-14:00; sun closed";
  /** data-length on the root (default: 40) */
  length?: "40";
  /** data-timezone on the root (default: Europe/Madrid) */
  timezone?: "Europe/Madrid";
  /** data-days on the root (default: 7) */
  days?: "7";
  /** data-notice on the root (default: 60) */
  notice?: "60";
  /** data-taken on the root (default: tue 11:20, wed 16:40, thu 10:40, thu 16:00, fri 11:20, sat 10:00) */
  taken?: "tue 11:20, wed 16:40, thu 10:40, thu 16:00, fri 11:20, sat 10:00";
  /** Settings, as CSS variables on the root */
  vars?: {
    /** default: 520px */
    "--kz-book-visit-width"?: string | number;
    /** default: #fff */
    "--kz-book-visit-bg"?: string | number;
    /** default: #0a0a0a */
    "--kz-book-visit-fg"?: string | number;
    /** default: rgba(10, 10, 10, 0.62) */
    "--kz-book-visit-muted"?: string | number;
    /** closed days, times gone or taken — default: rgba(10, 10, 10, 0.3) */
    "--kz-book-visit-off"?: string | number;
    /** default: rgba(10, 10, 10, 0.1) */
    "--kz-book-visit-line"?: string | number;
    /** the row of days — default: rgba(10, 10, 10, 0.04) */
    "--kz-book-visit-soft"?: string | number;
    /** default: rgba(10, 10, 10, 0.05) */
    "--kz-book-visit-hover"?: string | number;
    /** around a field in focus — default: rgba(10, 10, 10, 0.06) */
    "--kz-book-visit-halo"?: string | number;
    /** the pill, the mark, the button — default: #0a0a0a */
    "--kz-book-visit-ink"?: string | number;
    /** default: #fff */
    "--kz-book-visit-on-ink"?: string | number;
    /** the slide of the pill. 0s = no motion — default: 0.55s */
    "--kz-book-visit-duration"?: string | number;
    /** default: cubic-bezier(0.22, 1, 0.36, 1) */
    "--kz-book-visit-ease"?: string | number;
  };
  /** "kodza:submit", fired by the script (bubbles from the root) */
  onSubmit?: (event: CustomEvent) => void;
  className?: string;
};

export function BookAVisit({ place = "Es Pinar", address = "Carrer de la Roca 14, 07460 Pollença, Mallorca", hours = "mon closed; tue-fri 10:00-14:00, 16:00-19:00; sat 10:00-14:00; sun closed", length = "40", timezone = "Europe/Madrid", days = "7", notice = "60", taken = "tue 11:20, wed 16:40, thu 10:40, thu 16:00, fri 11:20, sat 10:00", vars, onSubmit, className, style, ...rest }: BookAVisitProps) {
  const ref = useRef<ComponentRef<'form'>>(null);
  const classes = ["kodza-book-visit", 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, place, address, hours, length, timezone, days, notice, taken, 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('./book-a-visit.js').then(() => {
      if (live) document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root } }));
    });
    return () => {
      live = false;
      document.dispatchEvent(new CustomEvent('kodza:destroy', { detail: { root } }));
    };
  }, [key]);

  useEffect(() => {
    const root = ref.current;
    if (!root || !onSubmit) return;
    const listener = (event: Event) => onSubmit(event as CustomEvent);
    root.addEventListener("kodza:submit", listener);
    return () => root.removeEventListener("kodza:submit", listener);
  }, [onSubmit, key]);

  return (
    <form action="#" method="post" key={key} {...rest} className={classes} data-kodza-manual data-place={place} data-address={address} data-hours={hours} data-length={length} data-timezone={timezone} data-days={days} data-notice={notice} data-taken={taken} style={{ ...vars, ...style } as CSSProperties} ref={ref}>
      <p className="kodza-book-visit__eyebrow">Visits · 40 min</p>
      <h2 className="kodza-book-visit__title" data-done={"Thank you, {name}."}>Come and see Es Pinar at the right hour.</h2>
      <div className="kodza-book-visit__stage">
        <div className="kodza-book-visit__form">
          <div className="kodza-book-visit__fields kodza-book-visit__fields--when">
            <label className="kodza-book-visit__box kodza-book-visit__box--fixed">
              <input className="kodza-book-visit__input" type="date" name="date" required />
              {' '}
              <span className="kodza-book-visit__label">Day</span>
            </label>
            {' '}
            <label className="kodza-book-visit__box kodza-book-visit__box--fixed">
              <input className="kodza-book-visit__input" type="time" name="time" required />
              {' '}
              <span className="kodza-book-visit__label">Time</span>
            </label>
          </div>
          <div className="kodza-book-visit__fields kodza-book-visit__fields--who">
            <label className="kodza-book-visit__box">
              <input className="kodza-book-visit__input" type="text" name="name" autoComplete="name" placeholder=" " required />
              {' '}
              <span className="kodza-book-visit__label">Your name</span>
            </label>
            {' '}
            <label className="kodza-book-visit__box">
              <input className="kodza-book-visit__input" type="email" name="email" autoComplete="email" placeholder=" " required />
              {' '}
              <span className="kodza-book-visit__label">Email</span>
            </label>
          </div>
          <div className="kodza-book-visit__foot">
            <p className="kodza-book-visit__note" aria-live="polite">
              <span className="kodza-book-visit__help">We confirm by email. No call.</span>
              {' '}
              <span className="kodza-book-visit__error" />
            </p>
            <button className="kodza-book-visit__send" type="submit">Book the visit</button>
          </div>
        </div>
        <div className="kodza-book-visit__done" hidden>
          <p className="kodza-book-visit__when">Your visit</p>
          <p className="kodza-book-visit__text">The details are on their way to <span data-value="email">your inbox</span>. Plans change? Reply to that email. Nobody will call you.</p>
          <div className="kodza-book-visit__actions">
            <a className="kodza-book-visit__calendar" href="#" download="visit.ics">Add to calendar</a>
            {' '}
            <button className="kodza-book-visit__again" type="reset">Book another</button>
          </div>
        </div>
      </div>
    </form>
  );
}
```

- Where it goes: on the page of the place to visit (a flat, a table, a salon, a workshop), under its photos or in the contact section. Write the opening hours in data-hours (days, then ranges, separated by semicolons), the length of a visit in data-length (minutes), how many days to offer in data-days, the notice in data-notice (minutes) and the times already taken in data-taken; the times are worked out in the place's timezone (data-timezone). Point the form's action at your form service or your own endpoint: it sends date, time, name and email; data-send="fetch" sends it without leaving the page. Listen for kodza:submit to send it yourself.

## Code

```html
<form class="kodza-book-visit" action="#" method="post" data-place="Es Pinar" data-address="Carrer de la Roca 14, 07460 Pollença, Mallorca" data-hours="mon closed; tue-fri 10:00-14:00, 16:00-19:00; sat 10:00-14:00; sun closed" data-length="40" data-timezone="Europe/Madrid" data-days="7" data-notice="60" data-taken="tue 11:20, wed 16:40, thu 10:40, thu 16:00, fri 11:20, sat 10:00">
  <p class="kodza-book-visit__eyebrow">Visits · 40 min</p>
  <h2 class="kodza-book-visit__title" data-done="Thank you, {name}.">Come and see Es&nbsp;Pinar at the right hour.</h2>
  <div class="kodza-book-visit__stage">
    <div class="kodza-book-visit__form">
      <div class="kodza-book-visit__fields kodza-book-visit__fields--when">
        <label class="kodza-book-visit__box kodza-book-visit__box--fixed">
          <input class="kodza-book-visit__input" type="date" name="date" required>
          <span class="kodza-book-visit__label">Day</span>
        </label>
        <label class="kodza-book-visit__box kodza-book-visit__box--fixed">
          <input class="kodza-book-visit__input" type="time" name="time" required>
          <span class="kodza-book-visit__label">Time</span>
        </label>
      </div>
      <div class="kodza-book-visit__fields kodza-book-visit__fields--who">
        <label class="kodza-book-visit__box">
          <input class="kodza-book-visit__input" type="text" name="name" autocomplete="name" placeholder=" " required>
          <span class="kodza-book-visit__label">Your name</span>
        </label>
        <label class="kodza-book-visit__box">
          <input class="kodza-book-visit__input" type="email" name="email" autocomplete="email" placeholder=" " required>
          <span class="kodza-book-visit__label">Email</span>
        </label>
      </div>
      <div class="kodza-book-visit__foot">
        <p class="kodza-book-visit__note" aria-live="polite">
          <span class="kodza-book-visit__help">We confirm by email. No call.</span>
          <span class="kodza-book-visit__error"></span>
        </p>
        <button class="kodza-book-visit__send" type="submit">Book the visit</button>
      </div>
    </div>
    <div class="kodza-book-visit__done" hidden>
      <p class="kodza-book-visit__when">Your visit</p>
      <p class="kodza-book-visit__text">The details are on their way to <span data-value="email">your inbox</span>. Plans change? Reply to that email. Nobody will call you.</p>
      <div class="kodza-book-visit__actions">
        <a class="kodza-book-visit__calendar" href="#" download="visit.ics">Add to calendar</a>
        <button class="kodza-book-visit__again" type="reset">Book another</button>
      </div>
    </div>
  </div>
</form>
```

```css
/* Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license */
/* Kodza — Book a Visit
   A booking form that needs no call: the coming days in a row under a sliding ink pill, the free
   times of the day picked, the name and the email. On send, the form rolls up and the answer
   takes its place, with Add to calendar.
   Everything is tuned with the --kz-book-visit-* variables; the opening hours, the length of a
   visit and the times taken are data- attributes on the form, the words and timings constants
   at the top of the script. */
.kodza-book-visit {
  --kz-book-visit-width: 520px;
  --kz-book-visit-bg: #fff;
  --kz-book-visit-fg: #0a0a0a;
  --kz-book-visit-muted: rgba(10, 10, 10, 0.62);
  --kz-book-visit-off: rgba(10, 10, 10, 0.3); /* closed days, times gone or taken */
  --kz-book-visit-line: rgba(10, 10, 10, 0.1);
  --kz-book-visit-soft: rgba(10, 10, 10, 0.04); /* the row of days */
  --kz-book-visit-hover: rgba(10, 10, 10, 0.05);
  --kz-book-visit-halo: rgba(10, 10, 10, 0.06); /* around a field in focus */
  --kz-book-visit-ink: #0a0a0a; /* the pill, the mark, the button */
  --kz-book-visit-on-ink: #fff;
  --kz-book-visit-duration: 0.55s; /* the slide of the pill. 0s = no motion */
  --kz-book-visit-ease: cubic-bezier(0.22, 1, 0.36, 1);

  box-sizing: border-box;
  width: 100%;
  max-width: var(--kz-book-visit-width);
  margin: 0;
  padding: 28px;
  border: 1px solid var(--kz-book-visit-line);
  border-radius: calc(16px * var(--kz-radius-scale, 1));
  background: var(--kz-book-visit-bg);
  color: var(--kz-book-visit-fg);
  font-family: inherit;
  text-align: left;
}

.kodza-book-visit__eyebrow,
.kodza-book-visit__legend {
  color: var(--kz-book-visit-muted);
  font-family: var(--kz-font-label, var(--kz-font-mono, ui-monospace, "SF Mono", Menlo, monospace));
  font-size: var(--kz-font-label-size, 12px);
  font-weight: var(--kz-font-label-weight, 400);
  letter-spacing: var(--kz-font-label-tracking, 0);
  text-transform: var(--kz-font-label-case, none);
  line-height: var(--kz-font-label-leading, 1.4);
}

.kodza-book-visit__eyebrow {
  margin: 0 0 12px;
}

.kodza-book-visit__title {
  margin: 0 0 24px;
  color: inherit;
  font-family: var(--kz-font-display, inherit);
  font-size: calc(26px * var(--kz-font-display-scale, 1));
  font-weight: var(--kz-font-display-weight, 600);
  line-height: 1.1;
  letter-spacing: var(--kz-font-display-tracking, -0.04em);
  text-transform: var(--kz-font-display-case, none);
  text-wrap: balance;
}

.kodza-book-visit__title:focus {
  outline: none;
}

/* The title's two lines (the question, then the thanks) share one place, each at its own height,
   so the title can go from one to the other without a jump */
.kodza-book-visit__lines {
  display: grid;
  align-items: start;
}

.kodza-book-visit__line {
  grid-area: 1 / 1;
}

.kodza-book-visit__lines.is-rolling,
.kodza-book-visit__stage.is-rolling {
  overflow: clip;
}

/* The form and the answer share one place too */
.kodza-book-visit__stage {
  display: grid;
  align-items: start;
}

.kodza-book-visit__form,
.kodza-book-visit__done {
  grid-area: 1 / 1;
  min-width: 0;
}

.kodza-book-visit__group {
  min-width: 0;
  margin: 0 0 20px;
  padding: 0;
  border: 0;
}

.kodza-book-visit__group--time {
  margin-bottom: 24px;
}

.kodza-book-visit__legend {
  float: left;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0 0 10px;
  padding: 0;
}

/* A word that rolls: the month beside Day, the count beside Time */
.kodza-book-visit__roll {
  display: inline-grid;
  justify-items: end;
  overflow: hidden;
  white-space: nowrap;
}

.kodza-book-visit__word {
  grid-area: 1 / 1;
  font-variant-numeric: tabular-nums;
}

/* The days */
.kodza-book-visit__days {
  position: relative;
  clear: both;
  display: grid;
  grid-template-columns: repeat(var(--kz-book-visit-count, 7), minmax(0, 1fr));
  padding: 4px;
  border-radius: calc(16px * var(--kz-radius-scale, 1));
  background: var(--kz-book-visit-soft);
}

.kodza-book-visit__day,
.kodza-book-visit__ghost {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  box-sizing: border-box;
  height: 56px;
}

.kodza-book-visit__day {
  position: relative;
  min-width: 0;
  border-radius: calc(12px * var(--kz-radius-scale, 1));
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color calc(0.2s * var(--kz-motion-scale, 1)) ease;
}

.kodza-book-visit__weekday {
  color: var(--kz-book-visit-muted);
  font-family: var(--kz-font-label, inherit);
  font-size: var(--kz-font-label-size, 12px);
  font-weight: var(--kz-font-label-weight, 500);
  letter-spacing: var(--kz-font-label-tracking, 0);
  text-transform: var(--kz-font-label-case, none);
  line-height: 1;
}

.kodza-book-visit__date {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.02em;
}

.kodza-book-visit__day.is-off {
  cursor: not-allowed;
}

.kodza-book-visit__day.is-off .kodza-book-visit__weekday,
.kodza-book-visit__day.is-off .kodza-book-visit__date {
  color: var(--kz-book-visit-off);
}

.kodza-book-visit__day:has(.kodza-book-visit__radio:focus-visible),
.kodza-book-visit__slot:has(.kodza-book-visit__radio:focus-visible) {
  outline: 2px solid var(--kz-book-visit-fg);
  outline-offset: 2px;
}

/* A radio over its whole option: the option is the target */
.kodza-book-visit__radio {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: inherit;
  appearance: none;
}

/* The pill: two windows cut at its edges, over an ink layer with a white copy of the days, so the
   letters turn white exactly at the edges as it slides */
.kodza-book-visit__lane {
  position: absolute;
  inset: 4px;
  overflow: hidden;
  border-radius: calc(12px * var(--kz-radius-scale, 1));
  pointer-events: none;
}

.kodza-book-visit__pill,
.kodza-book-visit__edge,
.kodza-book-visit__mirror {
  position: absolute;
  inset: 0;
}

.kodza-book-visit__pill {
  overflow: hidden;
  border-radius: calc(12px * var(--kz-radius-scale, 1)) 0 0 calc(12px * var(--kz-radius-scale, 1));
  transform: translateX(var(--kz-book-visit-l, 0px));
}

.kodza-book-visit__edge {
  overflow: hidden;
  border-radius: 0 calc(12px * var(--kz-radius-scale, 1)) calc(12px * var(--kz-radius-scale, 1)) 0;
  transform: translateX(calc(-1 * var(--kz-book-visit-l, 0px) - var(--kz-book-visit-r, 100%)));
}

.kodza-book-visit__mirror {
  background: var(--kz-book-visit-ink);
  color: var(--kz-book-visit-on-ink);
  transform: translateX(var(--kz-book-visit-r, 100%));
}

.kodza-book-visit__ghost {
  position: absolute;
  top: 0;
  bottom: 0;
}

.kodza-book-visit__ghost .kodza-book-visit__weekday {
  color: inherit;
  opacity: 0.72;
}

/* The times of the day picked */
.kodza-book-visit__times {
  clear: both;
  display: grid;
  min-height: calc(var(--kz-book-visit-rows, 3) * 40px + (var(--kz-book-visit-rows, 3) - 1) * 8px);
}

.kodza-book-visit__slots {
  position: relative;
  grid-area: 1 / 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-content: start;
  gap: 8px;
}

.kodza-book-visit__slot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  height: 40px;
  border-radius: var(--kz-radius-pill, 999px);
  box-shadow: inset 0 0 0 1px var(--kz-book-visit-line);
  font-family: var(--kz-font-label, inherit);
  font-size: var(--kz-font-label-size, 13px);
  font-weight: var(--kz-font-label-weight, 500);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--kz-font-label-tracking, 0);
  text-transform: var(--kz-font-label-case, none);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    color calc(0.2s * var(--kz-motion-scale, 1)) ease calc(0.1s * var(--kz-motion-scale, 1)),
    background-color calc(0.2s * var(--kz-motion-scale, 1)) ease,
    box-shadow calc(0.2s * var(--kz-motion-scale, 1)) ease;
}

.kodza-book-visit__slot:has(.kodza-book-visit__radio:checked) {
  color: var(--kz-book-visit-on-ink);
  box-shadow: inset 0 0 0 1px transparent;
}

.kodza-book-visit__slot.is-off {
  color: var(--kz-book-visit-off);
  box-shadow: inset 0 0 0 1px var(--kz-book-visit-soft);
  text-decoration: line-through;
  cursor: not-allowed;
}

/* The ink mark: it travels to the time you pick */
.kodza-book-visit__mark {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--kz-book-visit-mark-w, 0);
  height: var(--kz-book-visit-mark-h, 0);
  border-radius: var(--kz-radius-pill, 999px);
  background: var(--kz-book-visit-ink);
  transform: translate(var(--kz-book-visit-mark-x, 0), var(--kz-book-visit-mark-y, 0));
  transition:
    transform calc(0.4s * var(--kz-motion-scale, 1)) var(--kz-book-visit-ease),
    opacity calc(0.2s * var(--kz-motion-scale, 1)) ease;
}

.kodza-book-visit__mark.is-hidden {
  opacity: 0;
  transform: translate(var(--kz-book-visit-mark-x, 0), var(--kz-book-visit-mark-y, 0)) scale(0.4);
}

.kodza-book-visit__mark.is-instant {
  transition: none;
}

.kodza-book-visit__empty {
  grid-area: 1 / 1;
  align-self: center;
  margin: 0;
  color: var(--kz-book-visit-muted);
  font-size: 15px;
  line-height: 1.55;
}

@media (hover: hover) {
  .kodza-book-visit__day:not(.is-off):hover,
  .kodza-book-visit__slot:not(.is-off):not(:has(.kodza-book-visit__radio:checked)):hover {
    background: var(--kz-book-visit-hover);
  }
}

/* The fields: Text Field's box, its label folds up */
.kodza-book-visit__fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.kodza-book-visit__fields--when {
  margin-bottom: 12px;
}

.kodza-book-visit__box {
  position: relative;
  display: block;
  box-sizing: border-box;
  height: 56px;
  margin: 0;
  border-radius: calc(12px * var(--kz-radius-scale, 1));
  box-shadow: inset 0 0 0 1px var(--kz-book-visit-line);
  cursor: text;
  transition: box-shadow calc(0.2s * var(--kz-motion-scale, 1)) ease;
}

.kodza-book-visit__box:focus-within {
  box-shadow: inset 0 0 0 1.5px var(--kz-book-visit-ink), 0 0 0 4px var(--kz-book-visit-halo);
}

.kodza-book-visit__box:has([aria-invalid="true"]) {
  box-shadow: inset 0 0 0 1.5px var(--kz-book-visit-ink);
}

.kodza-book-visit__input {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 22px 16px 6px;
  border: 0;
  border-radius: inherit;
  background: none;
  box-shadow: none;
  color: inherit;
  font: inherit;
  font-size: 16px;
  line-height: 22px;
  outline: none;
  appearance: none;
}

.kodza-book-visit__label {
  position: absolute;
  top: 50%;
  left: 16px;
  color: var(--kz-book-visit-muted);
  font-size: 15px;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  transform: translateY(-50%);
  transform-origin: left top;
  transition: transform calc(0.35s * var(--kz-motion-scale, 1)) var(--kz-book-visit-ease);
}

.kodza-book-visit__input:focus ~ .kodza-book-visit__label,
.kodza-book-visit__input:not(:placeholder-shown) ~ .kodza-book-visit__label,
.kodza-book-visit__box--fixed .kodza-book-visit__label {
  transform: translateY(-18px) scale(0.8);
}

/* The foot: help or error, then the button */
.kodza-book-visit__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
}

.kodza-book-visit__note {
  display: grid;
  flex: 1 1 200px;
  margin: 0;
  font-family: var(--kz-font-label, inherit);
  font-size: var(--kz-font-label-size, 13px);
  font-weight: var(--kz-font-label-weight, 400);
  letter-spacing: var(--kz-font-label-tracking, 0);
  text-transform: var(--kz-font-label-case, none);
  line-height: var(--kz-font-label-leading, 1.4);
}

.kodza-book-visit__help,
.kodza-book-visit__error {
  grid-area: 1 / 1;
  align-self: center;
  transition:
    opacity calc(0.2s * var(--kz-motion-scale, 1)) ease,
    transform calc(0.3s * var(--kz-motion-scale, 1)) var(--kz-book-visit-ease),
    visibility calc(0.3s * var(--kz-motion-scale, 1));
}

.kodza-book-visit__help {
  color: var(--kz-book-visit-muted);
}

.kodza-book-visit__error {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--kz-book-visit-fg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
}

.kodza-book-visit__error::before {
  content: "";
  flex: none;
  width: 14px;
  height: 14px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='6.5' fill='none' stroke='black' stroke-width='1.5'/%3E%3Cpath d='M8 4.5v4.2M8 10.9v.1' stroke='black' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='6.5' fill='none' stroke='black' stroke-width='1.5'/%3E%3Cpath d='M8 4.5v4.2M8 10.9v.1' stroke='black' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.kodza-book-visit.is-error .kodza-book-visit__help {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
}

.kodza-book-visit.is-error .kodza-book-visit__error {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.kodza-book-visit__send,
.kodza-book-visit__calendar,
.kodza-book-visit__again {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  margin: 0;
  border: 0;
  border-radius: var(--kz-radius-pill, 999px);
  font-family: var(--kz-font-label, inherit);
  font-size: var(--kz-font-label-size, 15px);
  font-weight: var(--kz-font-label-weight, 500);
  letter-spacing: var(--kz-font-label-tracking, -0.01em);
  text-transform: var(--kz-font-label-case, none);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color calc(0.2s * var(--kz-motion-scale, 1)) ease,
    opacity calc(0.2s * var(--kz-motion-scale, 1)) ease,
    transform calc(0.2s * var(--kz-motion-scale, 1)) var(--kz-book-visit-ease);
}

.kodza-book-visit__send,
.kodza-book-visit__calendar {
  background: var(--kz-book-visit-ink);
  color: var(--kz-book-visit-on-ink);
}

.kodza-book-visit__send {
  height: 48px;
  padding: 0 24px;
}

.kodza-book-visit__send[aria-busy="true"] {
  opacity: 0.6;
  cursor: progress;
}

.kodza-book-visit__send:active,
.kodza-book-visit__calendar:active,
.kodza-book-visit__again:active {
  transform: scale(0.97);
}

.kodza-book-visit__send:focus-visible,
.kodza-book-visit__calendar:focus-visible,
.kodza-book-visit__again:focus-visible {
  outline: 2px solid var(--kz-book-visit-fg);
  outline-offset: 2px;
}

/* The answer */
.kodza-book-visit__when {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kodza-book-visit__text {
  max-width: 40em;
  margin: 0 0 24px;
  color: var(--kz-book-visit-muted);
  font-size: 15px;
  line-height: 1.55;
  text-wrap: pretty;
}

.kodza-book-visit__text [data-value] {
  color: var(--kz-book-visit-fg);
}

.kodza-book-visit__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kodza-book-visit__calendar,
.kodza-book-visit__again {
  height: 44px;
  padding: 0 20px;
}

.kodza-book-visit__again {
  background: none;
  box-shadow: inset 0 0 0 1px var(--kz-book-visit-line);
  color: inherit;
}

@media (hover: hover) {
  .kodza-book-visit__send:not([aria-busy="true"]):hover,
  .kodza-book-visit__calendar:hover {
    opacity: 0.86;
  }

  .kodza-book-visit__again:hover {
    background: var(--kz-book-visit-hover);
  }
}

.kodza-book-visit__done[hidden],
.kodza-book-visit__form[hidden],
.kodza-book-visit__line[hidden],
.kodza-book-visit__slots[hidden],
.kodza-book-visit__empty[hidden],
.kodza-book-visit__fields[hidden] {
  display: none;
}

@media (max-width: 600px) {
  .kodza-book-visit {
    padding: 20px;
  }

  .kodza-book-visit__fields {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .kodza-book-visit__day,
  .kodza-book-visit__slot,
  .kodza-book-visit__mark,
  .kodza-book-visit__box,
  .kodza-book-visit__label,
  .kodza-book-visit__help,
  .kodza-book-visit__error,
  .kodza-book-visit__send,
  .kodza-book-visit__calendar,
  .kodza-book-visit__again {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}

/* Theming example — on a dark background:
.dark-section .kodza-book-visit {
  --kz-book-visit-bg: #161616;
  --kz-book-visit-fg: #f2f2f0;
  --kz-book-visit-muted: rgba(242, 242, 240, 0.62);
  --kz-book-visit-off: rgba(242, 242, 240, 0.3);
  --kz-book-visit-line: rgba(255, 255, 255, 0.12);
  --kz-book-visit-soft: rgba(255, 255, 255, 0.05);
  --kz-book-visit-hover: rgba(255, 255, 255, 0.07);
  --kz-book-visit-halo: rgba(255, 255, 255, 0.08);
  --kz-book-visit-ink: #f2f2f0;
  --kz-book-visit-on-ink: #0a0a0a;
}
*/

/* kodza-guard dad43afeb006 — 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-book-visit__title):not(#_) {
  outline: revert;
}

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

:where(.kodza-book-visit__slot):not(#_) {
  outline: revert;
  text-decoration: revert;
  background-color: revert;
  background-image: revert;
  outline-offset: revert;
  color: revert;
}

:where(.kodza-book-visit__send):not(#_),
:where(.kodza-book-visit__calendar):not(#_),
:where(.kodza-book-visit__again):not(#_) {
  outline: revert;
  outline-offset: revert;
}

:where(.kodza-book-visit__empty):not(#_):where(:not([hidden])) {
  display: revert;
}

:where(.kodza-book-visit__empty):not(#_):where([hidden]) {
  display: none;
}

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

.kodza-book-visit:not(#_) {
  outline: revert;
  text-decoration: revert;
  transition: revert;
  list-style: revert;
  position: revert;
  box-shadow: revert;
  outline-offset: revert;
  appearance: revert;
  max-height: revert;
  font-size: revert;
  font-weight: revert;
  font-style: revert;
  line-height: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-book-visit__eyebrow: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;
  font-style: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-book-visit__title:not(#_) {
  border: revert;
  padding: revert;
  border-radius: 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;
  font-style: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-book-visit__lines:not(#_),
.kodza-book-visit__line:not(#_),
.kodza-book-visit__stage:not(#_),
.kodza-book-visit__form:not(#_),
.kodza-book-visit__caption:not(#_),
.kodza-book-visit__roll:not(#_),
.kodza-book-visit__word:not(#_),
.kodza-book-visit__days:not(#_),
.kodza-book-visit__weekday:not(#_),
.kodza-book-visit__date:not(#_),
.kodza-book-visit__lane:not(#_),
.kodza-book-visit__pill:not(#_),
.kodza-book-visit__edge:not(#_),
.kodza-book-visit__mirror:not(#_),
.kodza-book-visit__times:not(#_),
.kodza-book-visit__slots:not(#_),
.kodza-book-visit__mark:not(#_),
.kodza-book-visit__time:not(#_),
.kodza-book-visit__fields:not(#_),
.kodza-book-visit__label:not(#_),
.kodza-book-visit__foot:not(#_),
.kodza-book-visit__help:not(#_),
.kodza-book-visit__error:not(#_),
.kodza-book-visit__done:not(#_),
.kodza-book-visit__actions:not(#_),
.kodza-book-visit__text span:where(:not([class*="kodza-"])):not(#_) {
  box-sizing: revert;
}

.kodza-book-visit__group:not(#_) {
  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-book-visit__legend:not(#_) {
  border: revert;
  border-radius: revert;
  outline: revert;
  text-decoration: revert;
  transition: revert;
  list-style: revert;
  box-sizing: revert;
  position: revert;
  background-color: revert;
  background-image: revert;
  box-shadow: revert;
  outline-offset: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  font-style: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
  white-space: revert;
}

.kodza-book-visit__day:not(#_) {
  border: revert;
  margin: revert;
  padding: revert;
  text-decoration: revert;
  list-style: 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;
}

.kodza-book-visit__radio:not(#_) {
  border: revert;
  padding: revert;
  border-radius: revert;
  outline: revert;
  text-decoration: revert;
  transition: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  background-color: revert;
  background-image: revert;
  box-shadow: revert;
  outline-offset: 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-book-visit__slot:not(#_) {
  border: revert;
  margin: revert;
  padding: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  font-style: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-book-visit__empty: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;
  font-family: revert;
  font-weight: revert;
  font-style: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-book-visit__box:not(#_) {
  border: revert;
  padding: revert;
  outline: revert;
  text-decoration: revert;
  list-style: revert;
  float: revert;
  background-color: revert;
  background-image: 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-book-visit__input:not(#_) {
  text-decoration: revert;
  transition: revert;
  list-style: revert;
  float: revert;
  outline-offset: revert;
  max-width: revert;
  max-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-book-visit__note: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-style: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-book-visit__send:not(#_) {
  list-style: revert;
  float: revert;
  position: revert;
  box-shadow: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  font-style: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
  min-height: revert;
}

.kodza-book-visit__when: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-style: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-book-visit__text: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-height: revert;
  font-family: revert;
  font-weight: revert;
  font-style: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-book-visit__calendar:not(#_) {
  list-style: revert;
  float: revert;
  position: revert;
  box-shadow: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  font-style: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-book-visit__again:not(#_) {
  list-style: revert;
  float: revert;
  position: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  font-style: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
  min-height: revert;
}

.kodza-book-visit:not(#_):where(:not([hidden])),
.kodza-book-visit__eyebrow:not(#_):where(:not([hidden])),
.kodza-book-visit__title:not(#_):where(:not([hidden])),
.kodza-book-visit__group:not(#_):where(:not([hidden])),
.kodza-book-visit__radio:not(#_):where(:not([hidden])),
.kodza-book-visit__input:not(#_):where(:not([hidden])),
.kodza-book-visit__when:not(#_):where(:not([hidden])),
.kodza-book-visit__text:not(#_):where(:not([hidden])) {
  display: revert;
}

.kodza-book-visit:not(#_):where([hidden]),
.kodza-book-visit__eyebrow:not(#_):where([hidden]),
.kodza-book-visit__title:not(#_):where([hidden]),
.kodza-book-visit__group:not(#_):where([hidden]),
.kodza-book-visit__radio:not(#_):where([hidden]),
.kodza-book-visit__input:not(#_):where([hidden]),
.kodza-book-visit__when:not(#_):where([hidden]),
.kodza-book-visit__text:not(#_):where([hidden]) {
  display: none;
}

.kodza-book-visit__error: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-book-visit:not(#_) {
  box-sizing: border-box;
  padding: 28px;
  border: 1px solid var(--kz-book-visit-line);
  border-radius: calc(16px * var(--kz-radius-scale, 1));
  background: var(--kz-book-visit-bg);
  color: var(--kz-book-visit-fg);
  font-family: inherit;
  text-align: left;
}

.kodza-book-visit:not(#_) {
  width: min(100%, var(--kz-book-visit-width));
}

.kodza-book-visit__eyebrow:not(#_),
.kodza-book-visit__legend:not(#_) {
  color: var(--kz-book-visit-muted);
  font-family: var(--kz-font-label, var(--kz-font-mono, ui-monospace, "SF Mono", Menlo, monospace));
  font-size: var(--kz-font-label-size, 12px);
  font-weight: var(--kz-font-label-weight, 400);
  letter-spacing: var(--kz-font-label-tracking, 0);
  text-transform: var(--kz-font-label-case, none);
  line-height: var(--kz-font-label-leading, 1.4);
}

.kodza-book-visit__eyebrow:not(#_) {
  margin: 0 0 12px;
}

.kodza-book-visit__title:not(#_) {
  margin: 0 0 24px;
  color: inherit;
  font-family: var(--kz-font-display, inherit);
  font-size: calc(26px * var(--kz-font-display-scale, 1));
  font-weight: var(--kz-font-display-weight, 600);
  line-height: 1.1;
  letter-spacing: var(--kz-font-display-tracking, -0.04em);
  text-transform: var(--kz-font-display-case, none);
}

.kodza-book-visit__title:focus:not(#_) {
  outline: none;
}

.kodza-book-visit__group:not(#_) {
  margin: 0 0 20px;
  padding: 0;
  border: 0;
}

.kodza-book-visit__group--time:not(#_) {
  margin-bottom: 24px;
}

.kodza-book-visit__legend:not(#_) {
  float: left;
  display: flex;
  margin: 0 0 10px;
  padding: 0;
}

.kodza-book-visit__day:not(#_) {
  display: flex;
  box-sizing: border-box;
}

.kodza-book-visit__day:not(#_) {
  position: relative;
  border-radius: calc(12px * var(--kz-radius-scale, 1));
  transition: background-color calc(0.2s * var(--kz-motion-scale, 1)) ease;
}

.kodza-book-visit__day:has(.kodza-book-visit__radio:focus-visible):not(#_),
.kodza-book-visit__slot:has(.kodza-book-visit__radio:focus-visible):not(#_) {
  outline: 2px solid var(--kz-book-visit-fg);
  outline-offset: 2px;
}

.kodza-book-visit__radio:not(#_) {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: inherit;
  appearance: none;
}

.kodza-book-visit__slot:not(#_) {
  position: relative;
  display: grid;
  border-radius: var(--kz-radius-pill, 999px);
  box-shadow: inset 0 0 0 1px var(--kz-book-visit-line);
  font-family: var(--kz-font-label, inherit);
  font-size: var(--kz-font-label-size, 13px);
  font-weight: var(--kz-font-label-weight, 500);
  letter-spacing: var(--kz-font-label-tracking, 0);
  text-transform: var(--kz-font-label-case, none);
  line-height: 1;
  transition: color calc(0.2s * var(--kz-motion-scale, 1)) ease calc(0.1s * var(--kz-motion-scale, 1)),
    background-color calc(0.2s * var(--kz-motion-scale, 1)) ease,
    box-shadow calc(0.2s * var(--kz-motion-scale, 1)) ease;
}

.kodza-book-visit__slot:has(.kodza-book-visit__radio:checked):not(#_) {
  color: var(--kz-book-visit-on-ink);
  box-shadow: inset 0 0 0 1px transparent;
}

.kodza-book-visit__slot.is-off:not(#_) {
  color: var(--kz-book-visit-off);
  box-shadow: inset 0 0 0 1px var(--kz-book-visit-soft);
  text-decoration: line-through;
}

.kodza-book-visit__empty:not(#_) {
  margin: 0;
  color: var(--kz-book-visit-muted);
  font-size: 15px;
  line-height: 1.55;
}

@media (hover: hover) {
  .kodza-book-visit__day:not(.is-off):hover:not(#_),
  .kodza-book-visit__slot:not(.is-off):not(:has(.kodza-book-visit__radio:checked)):hover:not(#_) {
    background: var(--kz-book-visit-hover);
  }
}

.kodza-book-visit__box:not(#_) {
  position: relative;
  display: block;
  box-sizing: border-box;
  margin: 0;
  border-radius: calc(12px * var(--kz-radius-scale, 1));
  box-shadow: inset 0 0 0 1px var(--kz-book-visit-line);
  transition: box-shadow calc(0.2s * var(--kz-motion-scale, 1)) ease;
}

.kodza-book-visit__box:focus-within:not(#_) {
  box-shadow: inset 0 0 0 1.5px var(--kz-book-visit-ink), 0 0 0 4px var(--kz-book-visit-halo);
}

.kodza-book-visit__box:has([aria-invalid="true"]):not(#_) {
  box-shadow: inset 0 0 0 1.5px var(--kz-book-visit-ink);
}

.kodza-book-visit__input:not(#_) {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 22px 16px 6px;
  border: 0;
  border-radius: inherit;
  background: none;
  box-shadow: none;
  color: inherit;
  font: inherit;
  font-size: 16px;
  line-height: 22px;
  outline: none;
  appearance: none;
}

.kodza-book-visit__note:not(#_) {
  display: grid;
  margin: 0;
  font-family: var(--kz-font-label, inherit);
  font-size: var(--kz-font-label-size, 13px);
  font-weight: var(--kz-font-label-weight, 400);
  letter-spacing: var(--kz-font-label-tracking, 0);
  text-transform: var(--kz-font-label-case, none);
  line-height: var(--kz-font-label-leading, 1.4);
}

.kodza-book-visit__send:not(#_),
.kodza-book-visit__again:not(#_) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  margin: 0;
  border: 0;
  border-radius: var(--kz-radius-pill, 999px);
  font-family: var(--kz-font-label, inherit);
  font-size: var(--kz-font-label-size, 15px);
  font-weight: var(--kz-font-label-weight, 500);
  letter-spacing: var(--kz-font-label-tracking, -0.01em);
  text-transform: var(--kz-font-label-case, none);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color calc(0.2s * var(--kz-motion-scale, 1)) ease,
    opacity calc(0.2s * var(--kz-motion-scale, 1)) ease,
    transform calc(0.2s * var(--kz-motion-scale, 1)) var(--kz-book-visit-ease);
}

.kodza-book-visit__calendar:not(#_) {
  display: inline-flex;
  box-sizing: border-box;
  margin: 0;
  border: 0;
  border-radius: var(--kz-radius-pill, 999px);
  font-family: var(--kz-font-label, inherit);
  font-size: var(--kz-font-label-size, 15px);
  font-weight: var(--kz-font-label-weight, 500);
  letter-spacing: var(--kz-font-label-tracking, -0.01em);
  text-transform: var(--kz-font-label-case, none);
  line-height: 1;
  text-decoration: none;
  transition: background-color calc(0.2s * var(--kz-motion-scale, 1)) ease,
    opacity calc(0.2s * var(--kz-motion-scale, 1)) ease,
    transform calc(0.2s * var(--kz-motion-scale, 1)) var(--kz-book-visit-ease);
}

.kodza-book-visit__send:not(#_) {
  background: var(--kz-book-visit-ink);
  color: var(--kz-book-visit-on-ink);
}

.kodza-book-visit__calendar:not(#_) {
  background: var(--kz-book-visit-ink);
  color: var(--kz-book-visit-on-ink);
}

.kodza-book-visit__send:not(#_) {
  height: 48px;
  padding: 0 24px;
}

.kodza-book-visit__send[aria-busy="true"]:not(#_) {
  opacity: 0.6;
  cursor: progress;
}

.kodza-book-visit__send:active:not(#_),
.kodza-book-visit__again:active:not(#_) {
  transform: scale(0.97);
}

.kodza-book-visit__send:focus-visible:not(#_),
.kodza-book-visit__again:focus-visible:not(#_) {
  outline: 2px solid var(--kz-book-visit-fg);
  outline-offset: 2px;
}

.kodza-book-visit__calendar:focus-visible:not(#_) {
  outline: 2px solid var(--kz-book-visit-fg);
  outline-offset: 2px;
}

.kodza-book-visit__when:not(#_) {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.kodza-book-visit__text:not(#_) {
  max-width: 40em;
  margin: 0 0 24px;
  color: var(--kz-book-visit-muted);
  font-size: 15px;
  line-height: 1.55;
}

.kodza-book-visit__calendar:not(#_) {
  padding: 0 20px;
}

.kodza-book-visit__again:not(#_) {
  height: 44px;
  padding: 0 20px;
}

.kodza-book-visit__again:not(#_) {
  background: none;
  box-shadow: inset 0 0 0 1px var(--kz-book-visit-line);
  color: inherit;
}

@media (hover: hover) {
  .kodza-book-visit__send:not([aria-busy="true"]):hover:not(#_) {
    opacity: 0.86;
  }
}

@media (hover: hover) {
  .kodza-book-visit__again:hover:not(#_) {
    background: var(--kz-book-visit-hover);
  }
}

.kodza-book-visit__empty[hidden]:not(#_) {
  display: none;
}

@media (max-width: 600px) {
  .kodza-book-visit:not(#_) {
    padding: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kodza-book-visit__day:not(#_),
  .kodza-book-visit__slot:not(#_),
  .kodza-book-visit__box:not(#_),
  .kodza-book-visit__calendar:not(#_) {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kodza-book-visit__send:not(#_),
  .kodza-book-visit__again: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 — Book a Visit
// A booking form that needs no call. The days to come sit in a row (closed ones greyed out), an
// ink pill slides to the one you pick, and its free times appear below. The times come from the
// opening hours and the length of a visit; those already past, too soon or taken are struck out.
// On send, the form rolls up and the answer takes its place: the day, the time and the place,
// with Add to calendar (an .ics file made on the spot) and Book another.
// The form is a real one: it goes to its `action` (date=YYYY-MM-DD, time=HH:MM, name, email),
// the usual way, or with fetch under data-send="fetch". Without the script, a date and a time field
// stand in for the days and the times.
// Settings, on the form: data-hours ("mon closed; tue-fri 10:00-14:00, 16:00-19:00; sat 10:00-14:00"),
// data-length (minutes per visit), data-timezone (the place's, such as "Europe/Madrid": the times
// are the place's, wherever the visitor is), data-days (how many days are offered), data-notice
// (minutes: a time closer than that is too soon), data-taken ("thu 10:40, 2026-11-12 16:00": the
// times already booked, by weekday or by date), data-place and data-address (in the answer and
// the calendar event), data-failed (the message when a fetch send fails), data-locale (days and
// months, "en-GB" by default), data-now ("2026-11-05T09:30", to freeze the clock in a demo).
// The title's data-done is its line once booked, {name} the visitor's first name. The words of
// the script, and the timings, are the constants below.
// The page hears kodza:submit (cancelable, event.detail.data the FormData) before the send.
(() => {
  const SELECTOR = '.kodza-book-visit';
  const WORDS = {
    count: '{free} of {total} free', // beside "Time"
    closed: '{day}, closed',
    full: '{day}, nothing free',
    taken: '{time}, taken',
    soon: '{time}, too soon',
    none: 'No free visits in the coming days.',
    pickDay: 'Pick a day.',
    pickTime: 'Pick a time.',
    name: 'Your name, so we know who to expect.',
    email: 'That email does not look right.',
    failed: 'That did not go through. Try again.',
    event: 'Visit · {place}', // the calendar event's title
    details: 'Booked by {name}, {email}.',
  };
  const LENGTH = 40; // minutes per visit, without data-length
  const AHEAD = 7; // days offered, without data-days
  const NOTICE = 60; // minutes: a time closer than that is too soon, without data-notice
  const LOCALE = 'en-GB'; // the names of days and months, without data-locale
  const STAGE = 900; // ms: the form rolls up and the answer comes in
  const LAG_IN = 60; // ms: the answer starts this much after the form
  const SLIDE = 450; // ms: the times of one day make way for another's
  const SHIFT = 24; // px: how far they slide, towards the day picked
  const WORD = 500; // ms: a word rolls (the month, the count of free times)
  const ROLL = 'cubic-bezier(0.65, 0, 0.35, 1)';
  const ARRIVE = 'cubic-bezier(0.22, 1, 0.36, 1)';
  // The pill under the days, Segmented Control's: its front edge leads, the back one catches up
  const LEAD = 0.7; // the front edge arrives in this share of the slide
  const LAG = 0.14; // the back edge waits this share of the slide before it follows
  const SAMPLES = 30; // keyframes per slide: each edge follows its own curve
  const ease = (t) => 1 - (1 - t) ** 4; // close to cubic-bezier(0.22, 1, 0.36, 1)

  const DAYS = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];
  const DAY = 864e5;
  const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
  // The site's pace, --kz-motion-scale (set on :root, read on the instance): every duration of the
  // script times it, and 0 moves nothing, like reduced motion
  const paceOf = (el) => {
    const pace = parseFloat(getComputedStyle(el).getPropertyValue('--kz-motion-scale'));
    return pace >= 0 ? pace : 1;
  };
  const seconds = (value) => {
    const n = parseFloat(value);
    if (!(n >= 0)) return 0.55;
    return /ms\s*$/.test(value) ? n / 1000 : n;
  };
  const fill = (text, values) => text.replace(/\{(\w+)\}/g, (all, key) => (key in values ? values[key] : all));
  const clock = (text) => {
    const [h, m] = text.split(':').map(Number);
    return h * 60 + m;
  };
  const hhmm = (min) => `${String(Math.floor(min / 60) % 24).padStart(2, '0')}:${String(min % 60).padStart(2, '0')}`;

  // "mon closed; tue-fri 10:00-14:00, 16:00-19:00" → the opening ranges of each weekday, in
  // minutes (a range past midnight ends on the next day)
  const hoursOf = (text) => {
    const week = DAYS.map(() => []);
    (text || '').toLowerCase().split(';').forEach((part) => {
      const match = part.trim().match(/^([a-z]{3})(?:\s*-\s*([a-z]{3}))?\b(.*)$/);
      if (!match) return;
      const a = DAYS.indexOf(match[1]);
      const b = match[2] ? DAYS.indexOf(match[2]) : a;
      if (a < 0 || b < 0) return;
      const ranges = [...match[3].matchAll(/(\d{1,2}:\d{2})\s*-\s*(\d{1,2}:\d{2})/g)].map(([, from, to]) => {
        const start = clock(from);
        const end = clock(to);
        return [start, end > start ? end : end + 1440];
      });
      for (let i = a; ; i = (i + 1) % 7) {
        week[i] = ranges;
        if (i === b) break;
      }
    });
    return week;
  };
  // A visit starts at the opening, then every `length` minutes, and ends before the closing
  const startsOf = (ranges, length) => {
    const starts = [];
    ranges.forEach(([open, close]) => {
      for (let t = open; t + length <= close && t < 1440; t += length) starts.push(t);
    });
    return starts;
  };
  // The date and the minute of the day at a moment, in a time zone (the visitor's without one)
  const partsAt = (date, zone) => {
    const parts = {};
    new Intl.DateTimeFormat('en-CA', {
      timeZone: zone || undefined, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', hourCycle: 'h23',
    }).formatToParts(date).forEach(({ type, value }) => { parts[type] = value; });
    return { day: `${parts.year}-${parts.month}-${parts.day}`, min: (Number(parts.hour) % 24) * 60 + Number(parts.minute) };
  };
  const keyOf = (date) => date.toISOString().slice(0, 10);
  // .ics text: commas, semicolons and line breaks escaped, long lines folded
  const icsText = (text) => String(text).replace(/[\\;,]/g, (c) => `\\${c}`).replace(/\r?\n/g, '\\n');
  const fold = (line) => {
    const parts = [];
    for (let i = 0; i < line.length; i += 73) parts.push((i ? ' ' : '') + line.slice(i, i + 73));
    return parts.join('\r\n');
  };
  const stamp = (date) => date.toISOString().replace(/[-:]/g, '').replace(/\.\d{3}/, '');

  // One instance, with its own state: two copies on a page never interfere. Everything it
  // starts is tied to `signal` (listeners get { signal }, observers and timers stop on its
  // 'abort' event), so kodza:destroy stops it all.
  function mount(root, signal) {
    const pace = paceOf(root);
    const still = reduceMotion || !pace; // the still path: no motion asked, by the visitor or the site
    const q = (name) => root.querySelector(`.kodza-book-visit__${name}`);
    const title = q('title');
    const stage = q('stage');
    const panel = q('form');
    const done = q('done');
    const native = q('fields--when');
    const note = q('note');
    const error = q('error');
    const button = q('send');
    const calendar = q('calendar');
    const nameInput = root.elements.name;
    const emailInput = root.elements.email;
    if (!stage || !panel || !done || !native || !button || !nameInput || !emailInput) return;
    const duration = seconds(getComputedStyle(root).getPropertyValue('--kz-book-visit-duration')) * pace * 1000;

    const data = root.dataset;
    const week = hoursOf(data.hours);
    const length = Math.max(5, parseInt(data.length, 10) || LENGTH);
    const ahead = Math.min(14, Math.max(1, parseInt(data.days, 10) || AHEAD));
    const notice = Number.isFinite(parseFloat(data.notice)) ? parseFloat(data.notice) : NOTICE;
    const zone = data.timezone || '';
    const locale = data.locale || LOCALE;
    const taken = new Set();
    (data.taken || '').toLowerCase().split(',').forEach((item) => {
      const match = item.trim().match(/^([a-z]{3}|\d{4}-\d{2}-\d{2})\s+(\d{1,2}:\d{2})$/);
      if (match) taken.add(`${match[1]} ${hhmm(clock(match[2]))}`);
    });
    const nowAt = () => {
      const fixed = (data.now || '').match(/^(\d{4}-\d{2}-\d{2})T(\d{1,2}:\d{2})/);
      if (fixed) return { day: fixed[1], min: clock(fixed[2]) };
      try {
        return partsAt(new Date(), zone);
      } catch {
        return partsAt(new Date());
      }
    };
    const format = (options) => new Intl.DateTimeFormat(locale, { timeZone: 'UTC', ...options });
    const weekdayOf = format({ weekday: 'short' });
    const dateOf = format({ day: 'numeric' });
    const monthOf = format({ month: 'long' });
    const longOf = format({ weekday: 'long', day: 'numeric', month: 'long' });

    // The days to come, from the place's today, and the times of each
    const today = Date.parse(`${nowAt().day}T00:00:00Z`);
    const days = Array.from({ length: ahead }, (_, i) => {
      const date = new Date(today + i * DAY);
      const weekday = (date.getUTCDay() + 6) % 7;
      return { date, key: keyOf(date), weekday, starts: startsOf(week[weekday], length) };
    });

    const make = (tag, name, text) => {
      const el = document.createElement(tag);
      if (name) el.className = name.split(' ').map((part) => `kodza-book-visit__${part}`).join(' ');
      if (text != null) el.textContent = text;
      return el;
    };
    const legend = (caption, value) => {
      const el = make('legend', 'legend');
      const roll = make('span', 'roll');
      roll.append(make('span', 'word', value));
      el.append(make('span', 'caption', caption), roll);
      return { el, roll };
    };

    // The days: real radios in a row, under Segmented Control's ink pill
    const dayGroup = make('fieldset', 'group group--day');
    const dayLegend = legend(native.querySelector('[name="date"] ~ .kodza-book-visit__label')?.textContent.trim() || 'Day', monthOf.format(days[0].date));
    const track = make('div', 'days');
    track.style.setProperty('--kz-book-visit-count', String(ahead));
    const options = days.map((day) => {
      const option = make('label', 'day');
      const input = make('input', 'radio');
      input.type = 'radio';
      input.name = 'date';
      input.value = day.key;
      option.append(input, make('span', 'weekday', weekdayOf.format(day.date)), make('span', 'date', dateOf.format(day.date)));
      track.append(option);
      return option;
    });
    const dayInputs = options.map((option) => option.querySelector('input'));
    dayGroup.append(dayLegend.el, track);

    // The pill over the days: the lane, the window cut at its left edge (pill), the window cut at
    // its right edge (edge), and the ink with the white copy of the days (mirror)
    const lane = make('span', 'lane');
    lane.setAttribute('aria-hidden', 'true');
    const pill = make('span', 'pill');
    const edge = make('span', 'edge');
    const mirror = make('span', 'mirror');
    const ghosts = options.map((option) => {
      const ghost = make('span', 'ghost');
      ghost.append(...[...option.querySelectorAll('span')].map((span) => span.cloneNode(true)));
      return ghost;
    });
    mirror.append(...ghosts);
    edge.append(mirror);
    pill.append(edge);
    lane.append(pill);
    track.append(lane);

    // The times: one grid per day, stacked in one place, a mark under the time picked
    const timeGroup = make('fieldset', 'group group--time');
    const timeLegend = legend(native.querySelector('[name="time"] ~ .kodza-book-visit__label')?.textContent.trim() || 'Time', '');
    const times = make('div', 'times');
    const rows = Math.ceil(Math.max(1, ...days.map((day) => day.starts.length)) / 4);
    times.style.setProperty('--kz-book-visit-rows', String(rows));
    const grids = days.map((day) => {
      const grid = make('div', 'slots');
      grid.hidden = true;
      const mark = make('span', 'mark is-hidden');
      mark.setAttribute('aria-hidden', 'true');
      grid.append(mark);
      day.slots = day.starts.map((t) => {
        const slot = make('label', 'slot');
        const input = make('input', 'radio');
        input.type = 'radio';
        input.name = 'time';
        input.value = hhmm(t);
        slot.append(input, make('span', 'time', hhmm(t)));
        grid.append(slot);
        return { t, slot, input, state: 'free' };
      });
      times.append(grid);
      return grid;
    });
    const empty = make('p', 'empty', WORDS.none);
    empty.hidden = true;
    times.append(empty);
    timeGroup.append(timeLegend.el, times);

    // The date and time fields stand down: the radios carry the values now
    native.hidden = true;
    native.querySelectorAll('input').forEach((input) => { input.disabled = true; });
    panel.prepend(dayGroup, timeGroup);

    // The state of every time: past and too soon, taken, or free; a day with nothing free goes grey
    const refresh = () => {
      const now = nowAt();
      const base = Date.parse(`${now.day}T00:00:00Z`);
      days.forEach((day, i) => {
        const index = Math.round((day.date.getTime() - base) / DAY);
        day.slots.forEach((item) => {
          const time = hhmm(item.t);
          item.state = index * 1440 + item.t < now.min + notice ? 'soon'
            : taken.has(`${day.key} ${time}`) || taken.has(`${DAYS[day.weekday]} ${time}`) ? 'taken' : 'free';
          item.slot.classList.toggle('is-off', item.state !== 'free');
          if (item.state === 'free') item.input.removeAttribute('aria-label');
          else item.input.setAttribute('aria-label', fill(WORDS[item.state], { time }));
        });
        day.free = day.slots.filter((item) => item.state === 'free').length;
        const off = !day.free;
        const long = longOf.format(day.date);
        dayInputs[i].disabled = off;
        dayInputs[i].setAttribute('aria-label', off ? fill(day.starts.length ? WORDS.full : WORDS.closed, { day: long }) : long);
        options[i].classList.toggle('is-off', off);
        ghosts[i].classList.toggle('is-off', off);
      });
    };

    // Only the times of the day shown can be picked (arrow keys stay in it)
    let shown = -1;
    const enable = (index) => days.forEach((day, i) => day.slots.forEach((item) => {
      item.input.disabled = i !== index || item.state !== 'free';
    }));

    // A word that changes rolls: the old one goes up, the new one comes from below, the width follows
    const roll = (box, text) => {
      const old = box.lastElementChild;
      if (old?.textContent === text) return;
      box.getAnimations({ subtree: true }).forEach((animation) => animation.finish());
      [...box.children].slice(0, -1).forEach((el) => el.remove());
      const word = make('span', 'word', text);
      if (still || !old || !box.offsetParent) {
        box.replaceChildren(word);
        return;
      }
      const from = box.offsetWidth;
      box.append(word);
      old.setAttribute('aria-hidden', 'true');
      old.classList.add('is-leaving');
      const to = word.offsetWidth;
      const timing = { duration: WORD * pace, easing: ARRIVE };
      box.animate([{ width: `${from}px` }, { width: `${to}px` }], timing);
      old.animate([{ transform: 'translateY(0)' }, { transform: 'translateY(-110%)' }], { ...timing, fill: 'forwards' });
      word.animate([{ transform: 'translateY(110%)' }, { transform: 'translateY(0)' }], timing).onfinish = () => old.remove();
    };

    // The mark under the time picked glides to it; from nothing, it grows in place
    const placeMark = (grid, instant) => {
      const mark = grid.firstElementChild;
      const checked = grid.querySelector('.kodza-book-visit__radio:checked');
      if (!checked) {
        mark.classList.add('is-hidden');
        return;
      }
      const slot = checked.closest('.kodza-book-visit__slot');
      const hidden = mark.classList.contains('is-hidden');
      if (instant || hidden) mark.classList.add('is-instant');
      mark.style.setProperty('--kz-book-visit-mark-x', `${slot.offsetLeft}px`);
      mark.style.setProperty('--kz-book-visit-mark-y', `${slot.offsetTop}px`);
      mark.style.setProperty('--kz-book-visit-mark-w', `${slot.offsetWidth}px`);
      mark.style.setProperty('--kz-book-visit-mark-h', `${slot.offsetHeight}px`);
      if (instant || hidden) {
        void mark.offsetWidth;
        mark.classList.remove('is-instant');
      }
      mark.classList.remove('is-hidden');
    };

    // Another day: its times slide in from the side of that day, the others slide out
    const showDay = (next, instant) => {
      const before = shown;
      shown = next;
      enable(next);
      empty.hidden = next >= 0;
      const chosen = root.querySelector('.kodza-book-visit__slots .kodza-book-visit__radio:checked');
      if (chosen && next >= 0) {
        const twin = days[next].slots.find((item) => item.input.value === chosen.value && item.state === 'free');
        if (twin) twin.input.checked = true;
        else chosen.checked = false;
      } else if (chosen) chosen.checked = false;
      if (next >= 0) {
        roll(dayLegend.roll, monthOf.format(days[next].date));
        roll(timeLegend.roll, fill(WORDS.count, { free: days[next].free, total: days[next].slots.length }));
      } else {
        roll(timeLegend.roll, '');
      }
      const dir = before >= 0 && next >= 0 && next < before ? -1 : 1;
      grids.forEach((grid, i) => {
        if (i === next) {
          grid.getAnimations().forEach((animation) => animation.cancel());
          grid.hidden = false;
          grid.inert = false;
          placeMark(grid, true);
          if (!instant && !still && before !== next && before >= 0) {
            grid.animate([
              { transform: `translateX(${SHIFT * dir}px)`, opacity: 0 },
              { transform: 'none', opacity: 1 },
            ], { duration: SLIDE * pace, delay: SLIDE * pace * 0.25, easing: ARRIVE, fill: 'backwards' });
          }
          return;
        }
        if (i === before && !instant && !still && !grid.hidden) {
          grid.inert = true;
          // Gone before the new times show, so the two grids never read on top of each other
          grid.animate([{ opacity: 1 }, { opacity: 0 }], { duration: SLIDE * pace * 0.3, easing: 'linear', fill: 'forwards' });
          grid.animate([
            { transform: 'none' },
            { transform: `translateX(${-SHIFT * dir}px)` },
          ], { duration: SLIDE * pace * 0.5, easing: 'cubic-bezier(0.55, 0, 1, 0.45)', fill: 'forwards' }).onfinish = () => {
            if (shown === i) return;
            grid.hidden = true;
            grid.getAnimations().forEach((animation) => animation.cancel());
          };
          return;
        }
        grid.getAnimations().forEach((animation) => animation.cancel());
        grid.hidden = true;
      });
    };

    // Each day's place in the lane, in its own pixels (a parent scaled by a transform, like a
    // thumbnail, changes nothing)
    let boxes = [];
    const measure = () => {
      const box = lane.getBoundingClientRect();
      const scale = box.width / lane.offsetWidth || 1;
      const full = lane.offsetWidth;
      boxes = options.map((option) => {
        const rect = option.getBoundingClientRect();
        const left = (rect.left - box.left) / scale;
        const width = rect.width / scale;
        return { left, width, right: full - left - width };
      });
      ghosts.forEach((ghost, i) => {
        ghost.style.left = `${boxes[i].left}px`;
        ghost.style.width = `${boxes[i].width}px`;
      });
    };
    // The three moving layers for given edges: the windows put their cuts there, the ink cancels
    // their shift and stays put
    const shifts = ({ left, right }) => [left, -left - right, right];
    const rest = (edges) => {
      track.style.setProperty('--kz-book-visit-l', `${edges.left}px`);
      track.style.setProperty('--kz-book-visit-r', `${edges.right}px`);
    };
    // The edges at a point of a slide: the front edge (the side it goes to) leads, the back
    // edge follows, so the pill stretches on the way and shrinks back as it lands
    let move = null;
    const edgesAt = ({ from, to, forward, grow }, t) => {
      const front = ease(grow ? t : Math.min(1, t / LEAD));
      const back = grow ? front : ease(Math.max(0, (t - LAG) / (1 - LAG)));
      return {
        left: from.left + (to.left - from.left) * (forward ? back : front),
        right: from.right + (to.right - from.right) * (forward ? front : back),
      };
    };
    const now = () => {
      const t = move?.animations[0].currentTime;
      return move && t != null && move.animations[0].playState === 'running' ? edgesAt(move, Math.min(1, t / duration)) : null;
    };
    const stop = () => {
      move?.animations.forEach((animation) => animation.cancel());
      move = null;
    };
    // From nothing chosen, the pill opens from the middle of the day
    const slide = (from, to) => {
      stop();
      rest(to);
      if (still || !duration) return;
      const grow = !from;
      if (grow) from = { left: to.left + to.width / 2, right: to.right + to.width / 2 };
      const plan = { from, to, grow, forward: to.left > from.left };
      const frames = [[], [], []];
      for (let i = 0; i <= SAMPLES; i += 1) {
        shifts(edgesAt(plan, i / SAMPLES)).forEach((x, n) => frames[n].push({ transform: `translateX(${x}px)` }));
      }
      const timing = { duration, easing: 'linear' };
      move = { ...plan, animations: [pill, edge, mirror].map((el, n) => el.animate(frames[n], timing)) };
      move.animations[0].onfinish = () => { move = null; };
    };
    const clear = () => {
      stop();
      track.style.removeProperty('--kz-book-visit-l');
      track.style.removeProperty('--kz-book-visit-r');
    };
    let current = -1;
    const update = (instant) => {
      const next = dayInputs.findIndex((input) => input.checked);
      if (next === current && !instant) return;
      const from = instant ? null : now() || boxes[current] || null;
      current = next;
      if (next < 0) clear();
      else if (instant) {
        stop();
        rest(boxes[next]);
      } else slide(from, boxes[next]);
      showDay(next, instant);
    };
    const place = () => {
      const before = boxes;
      measure();
      const same = move && boxes.every((box, i) => Math.abs(box.left - before[i].left) < 0.5 && Math.abs(box.width - before[i].width) < 0.5);
      if (!same) {
        stop();
        if (current >= 0) rest(boxes[current]);
        else clear();
      }
      if (shown >= 0) placeMark(grids[shown], true);
    };

    // The first day with something free is picked at the start, and after a reset
    const pickFirst = () => {
      const first = days.findIndex((day) => day.free);
      dayInputs.forEach((input, i) => { input.defaultChecked = i === first; });
      if (first >= 0) dayInputs[first].checked = true;
    };

    // What is missing, said under the button (the help line gives way to it), the field focused
    let errorField = null;
    const clean = () => {
      errorField?.removeAttribute('aria-invalid');
      errorField = null;
      root.classList.remove('is-error');
    };
    const fail = (field, message, focus = field) => {
      clean();
      error.textContent = message;
      root.classList.add('is-error');
      errorField = field;
      if (field.matches('input:not([type="radio"])')) field.setAttribute('aria-invalid', 'true');
      focus?.focus();
    };
    const invalid = () => {
      const day = dayInputs.find((input) => input.checked);
      if (!day) return fail(dayInputs[0], WORDS.pickDay, dayInputs.find((input) => !input.disabled)) || true;
      const free = days[shown]?.slots.find((item) => item.state === 'free');
      if (!root.querySelector('.kodza-book-visit__slots .kodza-book-visit__radio:checked')) return fail(free?.input || dayInputs[0], WORDS.pickTime, free?.input) || true;
      if (!nameInput.value.trim()) return fail(nameInput, WORDS.name) || true;
      if (!emailInput.value.trim() || !emailInput.validity.valid) return fail(emailInput, WORDS.email) || true;
      return false;
    };
    root.noValidate = true;
    const settle = () => {
      if (!errorField) return;
      const fixed = errorField.type === 'radio' ? root.querySelector(`[name="${errorField.name}"]:checked`) : errorField === nameInput ? nameInput.value.trim() : emailInput.value.trim() && emailInput.validity.valid;
      if (fixed) clean();
    };
    root.addEventListener('input', settle, { signal });

    // Two blocks in one place: the one leaving rolls up (down on the way back), the other follows,
    // and the box between them changes height with them
    const swap = (box, out, into, back) => {
      box.getAnimations({ subtree: true }).forEach((animation) => animation.cancel());
      out.hidden = false;
      into.hidden = false;
      if (still) {
        out.hidden = true;
        return;
      }
      const hOut = out.offsetHeight;
      const hIn = into.offsetHeight;
      box.classList.add('is-rolling');
      const timing = { duration: STAGE * pace, easing: ROLL };
      const travel = back ? [hIn, -hIn] : [-hOut, hOut];
      // The height holds until the new content has landed, its lag included
      const grow = box.animate(
        [{ height: `${Math.max(hOut, 1)}px` }, { height: `${Math.max(hIn, 1)}px` }],
        { ...timing, fill: 'forwards' },
      );
      // The tail of the block leaving fades, so no edge of it lingers over the one coming in
      out.animate([
        { transform: 'translateY(0)', opacity: 1 },
        { opacity: 1, offset: 0.6 },
        { transform: `translateY(${travel[0]}px)`, opacity: 0 },
      ], { ...timing, fill: 'forwards' });
      into.animate([{ transform: `translateY(${travel[1]}px)` }, { transform: 'translateY(0)' }], {
        ...timing, delay: LAG_IN * pace, fill: 'backwards',
      }).onfinish = () => {
        out.hidden = true;
        box.classList.remove('is-rolling');
        out.getAnimations().forEach((animation) => animation.cancel());
        grow.cancel();
      };
    };

    // The title gets its thanks line next to the first one, for the swap
    const lines = make('span', 'lines');
    const first = make('span', 'line');
    if (title) first.append(...title.childNodes);
    const thanks = make('span', 'line');
    thanks.hidden = true;
    lines.append(first, thanks);
    if (title) title.append(lines);

    // The answer, and its calendar file
    let booked = false;
    let file = '';
    const revoke = () => {
      if (file) URL.revokeObjectURL(file);
      file = '';
    };
    const utc = (key, min) => {
      // The place's wall clock to a moment: guess as UTC, then correct by the zone's offset, twice
      // (a day that changes the clock)
      const wall = Date.parse(`${key}T00:00:00Z`) + min * 6e4;
      let at = wall;
      for (let i = 0; i < 2; i += 1) {
        try {
          const parts = partsAt(new Date(at), zone);
          at += wall - (Date.parse(`${parts.day}T00:00:00Z`) + parts.min * 6e4);
        } catch {
          break;
        }
      }
      return new Date(at);
    };
    const ics = (values) => {
      const start = utc(values.date, clock(values.time));
      const end = new Date(start.getTime() + length * 6e4);
      const lines = [
        'BEGIN:VCALENDAR', 'VERSION:2.0', 'PRODID:-//Kodza//Book a Visit//EN', 'CALSCALE:GREGORIAN', 'METHOD:PUBLISH',
        'BEGIN:VEVENT',
        `UID:${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}@${location.hostname || 'kodza'}`,
        `DTSTAMP:${stamp(new Date())}`, `DTSTART:${stamp(start)}`, `DTEND:${stamp(end)}`,
        `SUMMARY:${icsText(fill(WORDS.event, values))}`,
        data.address || data.place ? `LOCATION:${icsText([data.place, data.address].filter(Boolean).join(', '))}` : '',
        `DESCRIPTION:${icsText(fill(WORDS.details, values))}`,
        'END:VEVENT', 'END:VCALENDAR',
      ].filter(Boolean).map(fold);
      return new Blob([`${lines.join('\r\n')}\r\n`], { type: 'text/calendar;charset=utf-8' });
    };
    const finish = (form) => {
      booked = true;
      const values = {
        date: form.get('date'), time: form.get('time'), name: String(form.get('name') || '').trim(), email: String(form.get('email') || '').trim(), place: data.place || '',
      };
      taken.add(`${values.date} ${values.time}`);
      const day = days.find((item) => item.key === values.date);
      const when = q('when');
      if (when) when.textContent = [day ? `${weekdayOf.format(day.date)} ${dateOf.format(day.date)}` : values.date, values.time, values.place].filter(Boolean).join(' · ');
      done.querySelectorAll('[data-value]').forEach((el) => {
        if (values[el.dataset.value]) el.textContent = values[el.dataset.value];
      });
      if (calendar) {
        revoke();
        file = URL.createObjectURL(ics(values));
        calendar.href = file;
        calendar.download = `${(values.place || 'visit').toLowerCase().normalize('NFD').replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') || 'visit'}-visit.ics`;
      }
      thanks.textContent = fill(title?.dataset.done || '', { name: values.name.split(/\s+/)[0] });
      if (thanks.textContent) swap(lines, first, thanks);
      swap(stage, panel, done);
      if (title) {
        title.tabIndex = -1;
        title.focus({ preventScroll: true });
      }
    };

    // The send: kodza:submit first (the page can take it over), then the form's action, the usual
    // way, or with fetch under data-send="fetch"
    let sending = false;
    const send = async (form) => {
      sending = true;
      button.setAttribute('aria-busy', 'true');
      const method = (root.getAttribute('method') || 'get').toUpperCase();
      const url = method === 'GET' ? `${root.action}${root.action.includes('?') ? '&' : '?'}${new URLSearchParams(form)}` : root.action;
      try {
        const response = await fetch(url, { method, body: method === 'GET' ? undefined : form, headers: { Accept: 'application/json' }, signal });
        if (!response.ok) throw new Error(String(response.status));
        sending = false;
        finish(form);
      } catch {
        if (signal.aborted) return;
        sending = false;
        fail(button, data.failed || WORDS.failed, null);
      }
      button.removeAttribute('aria-busy');
    };
    root.addEventListener('submit', (event) => {
      if (booked || sending || invalid()) {
        event.preventDefault();
        return;
      }
      clean();
      const form = new FormData(root);
      if (!root.dispatchEvent(new CustomEvent('kodza:submit', { detail: { data: form }, bubbles: true, cancelable: true }))) {
        event.preventDefault();
        finish(form);
        return;
      }
      if (data.send !== 'fetch') return; // sent the usual way
      event.preventDefault();
      send(form);
    }, { signal });

    // A day picked: the pill slides, its times come in. A time picked: the mark glides to it
    root.addEventListener('change', (event) => {
      if (dayInputs.includes(event.target)) update();
      else if (event.target.name === 'time') placeMark(event.target.closest('.kodza-book-visit__slots'));
      settle();
    }, { signal });

    // Up and down move a row in the times; Home and End go to the first and last free one
    times.addEventListener('keydown', (event) => {
      if (!['ArrowUp', 'ArrowDown', 'Home', 'End'].includes(event.key) || shown < 0) return;
      const free = days[shown].slots.filter((item) => item.state === 'free').map((item) => item.input);
      const at = free.indexOf(event.target);
      if (at < 0) return;
      event.preventDefault();
      let next = event.key === 'Home' ? free[0] : event.key === 'End' ? free[free.length - 1] : null;
      if (!next) {
        const all = days[shown].slots.map((item) => item.input);
        const columns = getComputedStyle(grids[shown]).gridTemplateColumns.split(' ').length || 4;
        const step = event.key === 'ArrowDown' ? columns : -columns;
        for (let i = all.indexOf(event.target) + step; i >= 0 && i < all.length; i += step) {
          if (!all[i].disabled) {
            next = all[i];
            break;
          }
        }
      }
      if (!next || next === event.target) return;
      next.checked = true;
      next.dispatchEvent(new Event('change', { bubbles: true }));
      next.focus();
    }, { signal });

    // Book another (the form's reset): the day and the times come back, the time just booked taken
    root.addEventListener('reset', () => requestAnimationFrame(() => {
      if (signal.aborted) return;
      const inside = done.contains(document.activeElement) || document.activeElement === title;
      const wasBooked = booked;
      booked = false;
      clean();
      revoke();
      refresh();
      const fallback = dayInputs.findIndex((input) => input.defaultChecked);
      if (fallback < 0 || dayInputs[fallback].disabled) pickFirst();
      else dayInputs[fallback].checked = true;
      update(true);
      if (wasBooked) {
        swap(stage, done, panel, true);
        if (!thanks.hidden) swap(lines, thanks, first, true);
        title?.removeAttribute('tabindex');
      }
      if (inside) dayInputs.find((input) => input.checked)?.focus({ preventScroll: true });
    }), { signal });

    refresh();
    pickFirst();
    measure();
    update(true);
    const observer = new ResizeObserver(place);
    observer.observe(track);
    observer.observe(times);
    // A time that is going by while the page stays open: once a minute, the states are redone
    const timer = setInterval(() => {
      if (booked) return;
      refresh();
      enable(shown);
      const chosen = root.querySelector('.kodza-book-visit__slots .kodza-book-visit__radio:checked');
      if (chosen?.disabled) {
        chosen.checked = false;
        if (shown >= 0) placeMark(grids[shown]);
      }
      if (shown >= 0) roll(timeLegend.roll, fill(WORDS.count, { free: days[shown].free, total: days[shown].slots.length }));
    }, 60000);
    signal.addEventListener('abort', () => {
      observer.disconnect();
      clearInterval(timer);
      stop();
      revoke();
    });
    document.fonts?.ready.then(() => !signal.aborted && place());
  }

  // 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. Each running root
  // keeps its markup as written under KODZA, shared by every Kodza script on the page: a Kodza
  // component inside another one is saved as written, not half-started, and stopped with it. Two
  // components on one root (a reveal on a stat card) both start, and stop together.
  const KODZA = Symbol.for('kodza');
  const RUNNING = Symbol.for(`kodza ${SELECTOR}`); // a root this component runs on, for every copy of this script
  const instances = new WeakMap();
  const find = (scope = document) => [scope, ...scope.querySelectorAll(SELECTOR)].filter((el) => el.matches?.(SELECTOR));
  const attrsOf = (el) => [...el.attributes].map((a) => [a.name, a.value]);
  const put = (el, saved) => {
    [...el.attributes].forEach((a) => el.removeAttribute(a.name));
    saved.attrs.forEach(([name, value]) => el.setAttribute(name, value));
    el.innerHTML = saved.html;
  };
  // The markup inside a root as written: Kodza components already running in it give back their own
  const written = (root) => {
    const all = [...root.querySelectorAll('*')];
    if (!all.some((el) => el[KODZA])) return root.innerHTML;
    const copy = root.cloneNode(true);
    const twins = copy.querySelectorAll('*');
    let last = null;
    all.forEach((el, i) => {
      if (!el[KODZA] || last?.contains(el)) return;
      last = el;
      put(twins[i], el[KODZA]);
    });
    return copy.innerHTML;
  };
  const init = (scope) => find(scope).forEach((root) => {
    // Already running, maybe from another copy of this script. Marked is-ready with no Kodza component
    // running on it, a root is a copy of a started one (a cloned slide): it is left as it is
    if (root[RUNNING] || (root.classList.contains('is-ready') && !root[KODZA])) return;
    // Rendered by React (data-kodza-manual): React starts it, with an init aimed at that markup once
    // it has hydrated it. Any earlier start would change markup React has not taken over yet
    const owner = root.closest('[data-kodza-manual]');
    if (owner && !(scope && owner.contains(scope))) return;
    const controller = new AbortController();
    // Another Kodza component already running on this root: its markup as written is kept, and the
    // two stop together
    const before = root[KODZA];
    const saved = { html: before ? before.html : written(root), attrs: before ? before.attrs : attrsOf(root), stop: () => destroy(root) };
    if (before) before.above = saved;
    instances.set(root, { controller, saved, before });
    root[KODZA] = saved;
    root[RUNNING] = true;
    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.saved.above?.stop(); // a Kodza component started after it on the same root stops first
    // The Kodza components running inside it stop first: once its markup is put back, their own
    // script could not find them any more
    root.querySelectorAll('*').forEach((el) => el[KODZA]?.stop());
    instance.controller.abort();
    delete root[RUNNING];
    // Started on top of another one: that one stops next, and puts the markup back
    if (instance.before) {
      delete instance.before.above;
      root[KODZA] = instance.before;
      return instance.before.stop();
    }
    delete root[KODZA];
    put(root, instance.saved);
  });
  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).
