import { NestedSegmentedPicker, type PickerOption, type PickerSubOption } from "./NestedSegmentedPicker";

interface NestedSegmentedPickerExampleProps {
  /** Inert catalog thumbnail: same resting pose, no interaction, bar only. */
  preview?: boolean;
}

export default function NestedSegmentedPickerExample({ preview = false }: NestedSegmentedPickerExampleProps) {
  return (
    <div inert={preview}>
      <NestedSegmentedPicker
        options={OPTIONS}
        parentId="photos"
        subOptions={SUB_OPTIONS}
        defaultPicked="photos"
        defaultSubPicked="favorites"
        label="Library filter"
        actionLabel={preview ? undefined : actionLabel}
      />
    </div>
  );
}

function actionLabel(picked: string, subPicked: string | null) {
  const sub = SUB_OPTIONS.find((option) => option.id === subPicked);
  const name = picked === "photos" && sub ? sub.ariaLabel.toLowerCase() : NAMES[picked];
  return `Download ${name}`;
}

const OPTIONS: PickerOption[] = [
  { id: "photos", label: "Photos" },
  { id: "videos", label: "Videos" },
  { id: "files", label: "Files" },
  { id: "shared", label: "Shared" },
];

const SUB_OPTIONS: PickerSubOption[] = [
  { id: "recent", label: "Recent", ariaLabel: "Recent photos" },
  { id: "favorites", label: "Favorites", ariaLabel: "Favorite photos" },
];

const NAMES: Record<string, string> = { photos: "all photos", videos: "videos", files: "files", shared: "shared items" };
import { useLayoutEffect, useRef, useState, type CSSProperties } from "react";
import { animate, type AnimationPlaybackControls } from "motion";
import "./NestedSegmentedPicker.css";

export interface PickerOption {
  id: string;
  label: string;
}

export interface PickerSubOption extends PickerOption {
  /** Full accessible name. The visible word often repeats a row label, e.g. "Recent" → "Recent photos". */
  ariaLabel: string;
}

export interface NestedSegmentedPickerProps {
  /** Top-level choices, in order. One of them is the parent. */
  options: readonly PickerOption[];
  /** The choice that opens into the nested control. */
  parentId: string;
  subOptions: readonly PickerSubOption[];
  defaultPicked?: string;
  /** null means none: the parent's own default. */
  defaultSubPicked?: string | null;
  onChange?: (picked: string, subPicked: string | null) => void;
  /** Group name read before the pressed choice. */
  label?: string;
  /** Names the round button for the current pick. Omit to hide the button. */
  actionLabel?: (picked: string, subPicked: string | null) => string;
  onAction?: (picked: string, subPicked: string | null) => void;
  className?: string;
  style?: CSSProperties;
}

/**
 * A glass segmented bar. Picking the parent springs its chip wide to uncover an
 * inset groove of optional sub-options, with one thumb that slides between them.
 *
 * React owns the pressed state; the open/close and thumb motion are imperative so
 * every change can measure what is drawn, stop, update, measure again and spring.
 */
export function NestedSegmentedPicker({
  options, parentId, subOptions, defaultPicked = options[0]?.id ?? parentId, defaultSubPicked = null,
  onChange, label = "Choices", actionLabel, onAction, className = "", style,
}: NestedSegmentedPickerProps) {
  const [picked, setPicked] = useState(defaultPicked);
  const [subPicked, setSubPicked] = useState<string | null>(defaultSubPicked);
  // The first render draws the final state; these constant props are never patched afterwards.
  const initiallyOpen = useRef(defaultPicked === parentId).current;

  const chip = useRef<HTMLDivElement>(null);
  const parentButton = useRef<HTMLButtonElement>(null);
  const groove = useRef<HTMLDivElement>(null);
  const row = useRef<HTMLDivElement>(null);
  const thumb = useRef<HTMLSpanElement>(null);
  const subButtons = useRef(new Map<string, HTMLButtonElement>());
  const motion = useRef<MotionState>({ open: null, thumbOn: undefined, unfurl: 0, chip: [], thumb: [] });
  const current = useRef(subPicked);
  current.current = subPicked;

  // Open or close the parent chip. Order matters: measure, stop, set, measure, animate.
  function unfurl(next: boolean) {
    const m = motion.current, el = chip.current!, g = groove.current!;
    if (m.open === next) return;
    const first = m.open === null;
    m.open = next;
    const still = reducedMotion();
    const from = el.getBoundingClientRect().width;
    const run = ++m.unfurl;
    stop(m.chip);
    el.style.width = "";
    g.style.opacity = "";
    el.toggleAttribute("data-open", next);
    el.toggleAttribute("data-closing", !next && !first && !still);
    el.removeAttribute("data-springing");
    g.hidden = !next;
    g.inert = !next;
    if (first) return;
    const reveal = () => {
      if (next) el.scrollIntoView({ block: "nearest", inline: "nearest", behavior: still ? "auto" : "smooth" });
    };
    if (still) return reveal();
    if (!next) g.hidden = false; // stays visible while the chip closes over it
    const to = next ? el.getBoundingClientRect().width : parentButton.current!.getBoundingClientRect().width;
    el.setAttribute("data-springing", "");
    const fade = animate(g, { opacity: next ? [0, 1] : [1, 0] }, { duration: FACE_FADE, ease: next ? "easeIn" : "linear" });
    const spring = animate(el, { width: [`${from}px`, `${to}px`] }, SPRING);
    m.chip = [fade, spring];
    spring.finished.then(() => {
      if (run !== m.unfurl) return; // a newer change took over
      el.style.width = "";
      el.removeAttribute("data-closing");
      el.removeAttribute("data-springing");
      g.hidden = !next;
      g.style.opacity = "";
      reveal();
    }, () => {});
  }

  // Place the groove thumb under the picked sub-option, from wherever it is drawn now.
  function placeThumb(id: string | null) {
    const m = motion.current, t = thumb.current!, r = row.current!;
    const target = id ? subButtons.current.get(id) : undefined;
    const was = m.thumbOn, first = was === undefined;
    m.thumbOn = target ? id : null;
    const rowBox = r.getBoundingClientRect(), drawn = t.getBoundingClientRect();
    const from = { x: drawn.left - rowBox.left, width: drawn.width };
    stop(m.thumb);
    t.style.opacity = "";
    t.toggleAttribute("data-shown", Boolean(target));
    let to = from;
    if (target) {
      const box = target.getBoundingClientRect();
      to = { x: box.left - rowBox.left, width: box.width };
    }
    t.style.left = `${to.x}px`;
    t.style.width = `${to.width}px`;
    r.setAttribute("data-ready", "");
    if (first || reducedMotion() || was === m.thumbOn) return;
    if (!was || !m.thumbOn) {
      m.thumb = [animate(t, { opacity: m.thumbOn ? [0, 1] : [1, 0] }, { duration: FACE_FADE, ease: "linear" })];
      return;
    }
    m.thumb = [animate(t, { left: [`${from.x}px`, `${to.x}px`], width: [`${from.width}px`, `${to.width}px`] }, SPRING)];
  }

  // One render path for every pick; unfurl first so the groove is laid out before the thumb measures.
  useLayoutEffect(() => {
    unfurl(picked === parentId);
    placeThumb(subPicked);
  }, [picked, subPicked, parentId]);

  // Label widths change once web fonts load.
  useLayoutEffect(() => {
    let live = true;
    document.fonts?.ready.then(() => live && placeThumb(current.current));
    const m = motion.current;
    return () => { live = false; stop(m.chip); stop(m.thumb); };
  }, []);

  function pick(id: string) {
    if (id === picked) return;
    setPicked(id);
    onChange?.(id, subPicked);
  }

  function pickSub(id: string) {
    const next = id === subPicked ? null : id; // re-picking clears: a sub-option is optional
    setSubPicked(next);
    onChange?.(picked, next);
  }

  const action = actionLabel?.(picked, subPicked);

  return (
    <div className={`nsp ${className}`} style={style}>
      <div className="nsp-glass nsp-bar">
        <div className="nsp-choices" role="group" aria-label={label}>
          {options.map((option) => option.id === parentId ? (
            <div key={option.id} ref={chip} className="nsp-parent" data-open={initiallyOpen ? "" : undefined}>
              <div className="nsp-clip">
                <button ref={parentButton} type="button" className="nsp-choice"
                  aria-pressed={picked === option.id} onClick={() => pick(option.id)}>
                  {option.label}
                </button>
                <div ref={groove} className="nsp-groove" hidden={!initiallyOpen} inert={!initiallyOpen}>
                  <div ref={row} className="nsp-row">
                    <span ref={thumb} className="nsp-thumb" aria-hidden="true" />
                    {subOptions.map((sub) => (
                      <button key={sub.id} type="button" className="nsp-sub" aria-label={sub.ariaLabel}
                        aria-pressed={subPicked === sub.id} onClick={() => pickSub(sub.id)}
                        ref={(node) => {
                          if (node) subButtons.current.set(sub.id, node);
                          else subButtons.current.delete(sub.id);
                        }}>
                        {sub.label}
                      </button>
                    ))}
                  </div>
                </div>
              </div>
            </div>
          ) : (
            <button key={option.id} type="button" className="nsp-choice"
              aria-pressed={picked === option.id} onClick={() => pick(option.id)}>
              {option.label}
            </button>
          ))}
        </div>
      </div>
      {action && (
        <button type="button" className="nsp-glass nsp-round" aria-label={action} title={action}
          onClick={() => onAction?.(picked, subPicked)}>
          <DownloadIcon />
        </button>
      )}
    </div>
  );
}

function DownloadIcon() {
  return (
    <svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path d={ARROW_PATH} fill="currentColor" />
      <path d={CLOUD_PATH} fill="currentColor" />
    </svg>
  );
}

interface MotionState {
  open: boolean | null; // null = never laid out
  thumbOn: string | null | undefined; // undefined = never placed
  unfurl: number;
  chip: AnimationPlaybackControls[];
  thumb: AnimationPlaybackControls[];
}

function stop(animations: AnimationPlaybackControls[]) {
  animations.forEach((animation) => animation.stop());
  animations.length = 0;
}

function reducedMotion() {
  return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
}

/** One spring drives every move. Damping ratio ≈ 0.87: it barely overshoots and settles in ≈333ms. */
const SPRING = { type: "spring", mass: 1, stiffness: 640, damping: 44 } as const;
/** Groove and thumb fades, in seconds. */
const FACE_FADE = 0.1;

const ARROW_PATH = "M8 7.09961C8.49706 7.09961 8.90039 7.50294 8.90039 8V11.8262L9.86328 10.8633C10.2148 10.5118 10.7852 10.5118 11.1367 10.8633C11.4882 11.2148 11.4882 11.7852 11.1367 12.1367L8.63672 14.6367C8.28525 14.9882 7.71475 14.9882 7.36328 14.6367L4.86328 12.1367C4.51181 11.7852 4.51181 11.2148 4.86328 10.8633C5.21475 10.5118 5.78525 10.5118 6.13672 10.8633L7.09961 11.8262V8C7.09961 7.50294 7.50294 7.09961 8 7.09961Z";
const CLOUD_PATH = "M8 1.09961C10.4046 1.09961 12.3641 2.89665 12.7354 5.21289C14.2781 5.59727 15.4002 7.0217 15.4004 8.68359C15.4004 9.46442 15.1536 10.1914 14.7334 10.7822C14.4453 11.1873 13.8836 11.2822 13.4785 10.9941C13.0735 10.7061 12.9786 10.1443 13.2666 9.73926C13.4752 9.44603 13.5996 9.08195 13.5996 8.68359C13.5994 7.68056 12.8154 6.91038 11.9004 6.91016C11.4034 6.91016 11.0002 6.50766 11 6.01074C11 4.26904 9.63333 2.90039 8 2.90039C6.70291 2.90039 5.57737 3.75873 5.16504 4.98926C5.05651 5.31326 4.77398 5.54871 4.43555 5.5957C3.30576 5.75232 2.4004 6.75901 2.40039 8.01562C2.40039 8.50078 2.53524 8.9492 2.7666 9.32617C3.0267 9.74974 2.89428 10.3044 2.4707 10.5645C2.04721 10.8244 1.49351 10.6919 1.2334 10.2686C0.831513 9.61408 0.599609 8.84043 0.599609 8.01562C0.599622 6.07466 1.88196 4.41491 3.6582 3.92188C4.42127 2.26538 6.06736 1.09961 8 1.09961Z";
/* Nested segmented picker: a lit glass bar whose parent chip springs open into
   an inset groove of sub-options. Plain colours use light-dark(); gradients,
   shadow lists and rim widths can't, so dark overrides them by selector. */
.nsp {
  --nsp-ink: light-dark(#0d0d0d, #f5f5f3);
  --nsp-muted: light-dark(#686664, #aaa9a5);
  --nsp-rim: light-dark(#fff, #5c5c5c);
  --nsp-inner-rim: light-dark(transparent, #464646);
  --nsp-groove: light-dark(color-mix(in srgb, #0d0d0d 6%, transparent), rgb(0 0 0 / 24%));

  --nsp-rim-top: 1.3px;
  --nsp-rim-bottom: 1.1px;
  --nsp-inner-rim-width: 0px;
  --nsp-body: linear-gradient(180deg, #fdfdfd, #fafafa 2%, #f8f8f8 4.5%, #f6f6f6 8.5%, #f4f4f4 13%, #f2f2f2 18%,
    #f2f2f2 35%, #f4f4f4 43%, #f6f6f6 55%, #f6f6f6 83%, #f8f8f8 92%, #fafafa 96%, #fdfdfd 99%, #fefefe);
  --nsp-edge: -.9px 0 0 -.55px #a0a0a0, .9px 0 0 -.55px #a0a0a0, 0 0 0 .5px #d7d7d7, 0 4px 4px #00000004;
  --nsp-thumb: linear-gradient(180deg, #fff, #fbfbfb 40%, #f7f7f7);
  --nsp-thumb-edge: inset 0 1px 0 #fff, -.6px 0 0 -.3px #b4b4b4, .6px 0 0 -.3px #b4b4b4,
    0 0 0 .5px rgb(0 0 0 / 8%), 0 1px 2px rgb(0 0 0 / 6%), 0 3px 8px -2px rgb(0 0 0 / 8%);
  --nsp-groove-edge: inset 0 .5px 1.5px rgb(0 0 0 / 10%);

  display: grid;
  /* The bar may shrink and scroll; the optional round button gets an implicit column that never does. */
  grid-template-columns: minmax(0, auto);
  grid-auto-columns: auto;
  grid-auto-flow: column;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  min-width: 0;
  color: var(--nsp-ink);
  font-size: 12px;
  line-height: normal;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

:root[data-theme="dark"] .nsp {
  --nsp-rim-top: .34px;
  --nsp-rim-bottom: .34px;
  --nsp-inner-rim-width: .67px;
  --nsp-body: linear-gradient(180deg, #2d2d2d, #282828 3%, #232323 10%, #212121 20%, #212121 35%, #202020 60%,
    #202020 85%, #232323 93%, #272727 98%, #2b2b2b);
  --nsp-edge: none;
  --nsp-thumb: linear-gradient(180deg, #3d3d3d, #363636 40%, #333);
  --nsp-thumb-edge: inset 0 .5px 0 #5c5c5c, 0 1px 2px rgb(0 0 0 / 30%), 0 3px 8px -2px rgb(0 0 0 / 35%);
  --nsp-groove-edge: inset 0 .5px 1.5px rgb(0 0 0 / 45%);
}

/* No data-theme means the page follows the OS. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .nsp {
    --nsp-rim-top: .34px;
    --nsp-rim-bottom: .34px;
    --nsp-inner-rim-width: .67px;
    --nsp-body: linear-gradient(180deg, #2d2d2d, #282828 3%, #232323 10%, #212121 20%, #212121 35%, #202020 60%,
      #202020 85%, #232323 93%, #272727 98%, #2b2b2b);
    --nsp-edge: none;
    --nsp-thumb: linear-gradient(180deg, #3d3d3d, #363636 40%, #333);
    --nsp-thumb-edge: inset 0 .5px 0 #5c5c5c, 0 1px 2px rgb(0 0 0 / 30%), 0 3px 8px -2px rgb(0 0 0 / 35%);
    --nsp-groove-edge: inset 0 .5px 1.5px rgb(0 0 0 / 45%);
  }
}

.nsp *, .nsp *::before, .nsp *::after { box-sizing: border-box; }

/* Glass: a rim, then a body gradient inset top and bottom so the rim bends round the ends. */
.nsp-glass {
  position: relative;
  isolation: isolate;
  min-width: 0;
  padding: 3px;
  border: 0;
  border-radius: 999px;
  background: var(--nsp-rim);
  box-shadow: var(--nsp-edge);
}
.nsp-glass::after {
  content: "";
  position: absolute;
  inset: var(--nsp-rim-top) 0 var(--nsp-rim-bottom);
  z-index: -2;
  border: 0 solid var(--nsp-inner-rim);
  border-block-width: var(--nsp-inner-rim-width);
  border-radius: inherit;
  background: var(--nsp-body) padding-box;
  pointer-events: none;
}

.nsp-choice, .nsp-sub {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--nsp-muted);
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
}
.nsp-choice { padding: 8px 12px; }
.nsp-choice[aria-pressed="true"], .nsp-sub[aria-pressed="true"] { color: var(--nsp-ink); }
.nsp-choice[aria-pressed="true"] { background: var(--nsp-thumb); box-shadow: var(--nsp-thumb-edge); }
/* Inset ring: the scrolling row would clip an outset one. */
.nsp-choice:focus-visible, .nsp-sub:focus-visible, .nsp-round:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--nsp-ink) 55%, transparent);
  outline-offset: -2px;
}

/* Choices row: scrolls when narrow. The negative margin keeps thumb shadows off the scroll edge. */
.nsp-choices {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: -3px;
  padding: 3px;
  overflow-x: auto;
  scrollbar-width: none;
  border-radius: 999px;
}
.nsp-choices::-webkit-scrollbar { display: none; }

/* Parent chip: the face is its thumb, painted behind the clip so the groove sits on it. */
.nsp-parent {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  flex: none;
  border-radius: 999px;
}
.nsp-parent::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--nsp-thumb);
  box-shadow: var(--nsp-thumb-edge);
  opacity: 0;
}
.nsp-parent[data-open]::before { opacity: 1; }
/* Closing fades the face over the spring's settle time (≈333ms for 640/44/1). */
.nsp-parent[data-closing]::before { transition: opacity 333ms ease-out; }
.nsp-clip {
  display: inline-flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  border-radius: inherit;
}
.nsp-parent[data-springing] .nsp-clip { overflow: hidden; }
.nsp-clip > * { flex: none; }
.nsp-clip > .nsp-choice[aria-pressed="true"] { background: none; box-shadow: none; }

/* Groove: the nested segmented control, cut into the open chip. */
.nsp-groove {
  display: flex;
  flex: none;
  margin: 3px 3px 3px 0;
  border-radius: 999px;
  background: var(--nsp-groove);
  box-shadow: var(--nsp-groove-edge);
}
.nsp-groove[hidden] { display: none; }
.nsp-row {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  gap: 2px;
  padding: 2px;
}
.nsp-sub { position: relative; z-index: 1; padding: 3px 10px; }
.nsp-thumb {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--nsp-thumb);
  box-shadow: var(--nsp-thumb-edge);
  opacity: 0;
  pointer-events: none;
}
.nsp-thumb[data-shown] { opacity: 1; }
/* Before the thumb is measured (server render), the picked sub-option wears its own. */
.nsp-row:not([data-ready]) .nsp-sub[aria-pressed="true"] {
  background: var(--nsp-thumb);
  box-shadow: var(--nsp-thumb-edge);
}

/* Round action button */
.nsp-round {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--nsp-ink);
  cursor: pointer;
}
.nsp-round svg { flex: none; }
.nsp-round:active { scale: .96; }

@media (hover: hover) and (pointer: fine) {
  .nsp-choice, .nsp-sub { transition: color 150ms ease-out; }
  .nsp-choice[aria-pressed="false"]:hover, .nsp-sub[aria-pressed="false"]:hover { color: var(--nsp-ink); }
}
@media (prefers-reduced-motion: reduce) {
  .nsp-choice, .nsp-sub { transition: none; }
  .nsp-round:active { scale: none; }
}
# Nested segmented picker

A pill-shaped glass bar of choices with a round action button beside it. One choice is a **parent**. When you pick it, its chip springs wide and uncovers an inset segmented control of sub-options, with one thumb that slides between them.

## Get started

Requires React 19 and Motion:

```sh
npm install motion
```

Copy `NestedSegmentedPicker.tsx` and `NestedSegmentedPicker.css` into the same folder. No Astro, Tailwind or site styles are required. In frameworks with server components, place the component behind a client boundary. Labels inherit your font at 12px. The colours follow `color-scheme`, and the dark glass switches on `:root[data-theme="dark"]`, or on the OS setting when `data-theme` is absent.

```tsx
import { NestedSegmentedPicker } from "./NestedSegmentedPicker";

<NestedSegmentedPicker
  label="Library filter"
  options={[
    { id: "photos", label: "Photos" },
    { id: "videos", label: "Videos" },
    { id: "files", label: "Files" },
  ]}
  parentId="photos"
  subOptions={[
    { id: "recent", label: "Recent", ariaLabel: "Recent photos" },
    { id: "favorites", label: "Favorites", ariaLabel: "Favorite photos" },
  ]}
  onChange={(picked, subPicked) => console.log(picked, subPicked)}
  actionLabel={(picked) => `Download ${picked}`}
  onAction={(picked, subPicked) => download(picked, subPicked)}
/>
```

`example.tsx` is the Playground demo: Photos open with Favorites picked.

## Props

| Prop | Purpose |
| --- | --- |
| `options` | Top-level choices, in order. Each is as wide as its label. |
| `parentId` | The choice that opens into the nested control. |
| `subOptions` | The parent's sub-options. `ariaLabel` gives each its full name, because the visible word usually repeats a row label. |
| `defaultPicked` / `defaultSubPicked` | Initial state. `null` means no sub-option: the parent's own default. |
| `onChange(picked, subPicked)` | Runs on every pick. |
| `label` | The group's accessible name. |
| `actionLabel(picked, subPicked)` | Names the icon-only round button (also its `title`). Omit it to hide the button. |
| `onAction` | Runs when the round button is pressed. |

## Behaviour

- Exactly one top-level choice is always picked. Picking the parent opens it, and picking anything else closes it.
- A sub-option is optional. Pick the picked one again to clear it.
- The sub-option survives closing: reopen the parent and it is still picked.
- When the bar is wider than its container, the choices row scrolls with its scrollbar hidden. The open chip scrolls into view, and the round button never shrinks or moves.

## Motion

One spring drives every move: mass 1, stiffness 640, damping 44 (damping ratio ≈ 0.87). It settles in about 333ms.

- **Opening:** the groove is laid out at rest beside the parent's label. The chip's width springs open under a clip, so its rounded edge sweeps across a groove that never stretches or slides. The groove fades in over 100ms with ease-in, so its rounded end never meets the chip's as a visible lens.
- **Closing:** the chip springs closed over the still-visible groove. The groove fades over 100ms (linear), and the raised face fades over the spring's length (ease-out).
- **Thumb:** the first pick fades it in, picking another sub-option springs its position and width, and a re-pick that clears it fades it out in place.
- **Interruptions:** every change starts from what is drawn (`getBoundingClientRect`), never from an old target.
- Nothing animates on first render. Under `prefers-reduced-motion: reduce`, every change is instant.

## Accessibility

- The row is `role="group"` with your `label`. Every choice is a native `<button>` with `aria-pressed`.
- A closed groove is `hidden` and `inert`, so Tab never lands on a sub-option you can't see.
- Picks update `aria-pressed` in place, so focus stays on the clicked button.
- Focus rings are inset, because the scrolling row would clip outset ones.
Nested segmented picker