# Curtain Menu Sphere Toggle: Rolling Label, Spinning Gradient Ball & Clip-Path Curtain Menu

## Goal
Build a white page whose only element is a **fixed menu button** in the top-right corner: a text label that **rolls from "Menu" to "Close"** (the old word slides up out of a mask while the new one slides in from below) next to a **44px ball with a radial gradient** that **spins a little on hover** and whose **two short strokes turn into an X** when open. Clicking it drops a **black full-width panel from the top with a clip-path curtain** over a dimming veil; inside, a small mono label and **large numbered links** (number, title, one-line description, hidden arrow) **rise in with a short stagger**. Hovering a link **slides its title sideways**, tints it with the accent and reveals the arrow. Closing (button, veil click, link click or Escape) **plays the same timeline in reverse, faster**. GSAP for the curtain, veil and stagger; CSS transitions for the label, ball and hovers.

## Tech
Vanilla HTML/CSS/JS with ES module imports. `gsap` (npm), no plugins. Fonts: **Funnel Display** (button and links), **Overpass Mono** (label and numbers).

## Layout / HTML
```html
<div class="cm">
  <button class="cm-toggle" type="button" aria-expanded="false" aria-controls="cm-menu">
    <span class="cm-toggle__text"><span class="cm-toggle__a">Menu</span><span class="cm-toggle__b" aria-hidden="true">Close</span></span>
    <span class="cm-ball" aria-hidden="true"><i></i><i></i></span>
  </button>

  <div class="cm-menu" id="cm-menu" aria-hidden="true">
    <div class="cm-veil" data-cm-close></div>
    <nav class="cm-panel" aria-label="Main">
      <p class="cm-label">Explore</p>
      <ul class="cm-links">
        <li><a href="#"><span class="cm-n">01</span><span class="cm-t">Product</span><span class="cm-d">Everything it does, in one place</span><span class="cm-f" aria-hidden="true">→</span></a></li>
        … 02 Pricing · 03 About · 04 Contact
      </ul>
    </nav>
  </div>
</div>
```

## Styling
`:root`: `--cm-page:#fff`, `--cm-panel:#050608`, `--cm-ink:#0a0b0f`, `--cm-panel-ink:#fff`, `--cm-muted:#a4a9b4`, `--cm-rule:#23262e`, `--cm-accent:#3d7bff`, `--cm-ease:cubic-bezier(.2,.7,.1,1)`.

- `.cm`: `min-height:100svh; background:var(--cm-page); color:var(--cm-ink); font-family:"Funnel Display"`.
- `.cm-toggle`: `position:fixed; top:18px; right:clamp(1.25rem,2.5vw,2rem); z-index:90; display:flex; align-items:center; gap:12px; background:none; border:0; font-size:15px; transition:color .35s var(--cm-ease)`. With `.cm.is-open` its colour becomes `--cm-panel-ink` (it now sits on the black panel).
- **Label roll**: `.cm-toggle__text { position:relative; display:block; height:1.3em; overflow:hidden; line-height:1.3 }`; both words `display:block; transition:transform .45s var(--cm-ease)`; `__b` is `position:absolute; inset:0; transform:translateY(110%)`. Open: `__a → translateY(-110%)`, `__b → none`.
- **Ball**: `width/height:44px; border-radius:50%; background:radial-gradient(circle at 34% 28%, #fafbff 0, #9aa1af 38%, #2b2f38 78%, #0d0f13 100%); box-shadow:0 6px 18px rgba(0,0,0,.35), inset 0 -3px 6px rgba(0,0,0,.35); transition:transform .5s var(--cm-ease)`; on button hover `rotate(-24deg) scale(1.06)`. Strokes `i`: `position:absolute; left:30%; right:30%; height:1.6px; background:#fff; border-radius:2px; transition:transform .45s, left .45s`; first at `top:42%`, second at `top:56%; left:40%` (shorter). Open: first `translateY(3px) rotate(45deg)`, second `left:30%; translateY(-3px) rotate(-45deg)`.
- `.cm-menu`: `position:fixed; inset:0; z-index:80; visibility:hidden; pointer-events:none`; `.is-visible` makes it visible and clickable.
- `.cm-veil`: `position:absolute; inset:0; background:rgba(5,6,8,.55); opacity:0`.
- `.cm-panel`: `position:absolute; inset:0 0 auto 0; max-height:100svh; overflow-y:auto; padding:120px clamp(1.25rem,3vw,2.5rem) 40px; background:var(--cm-panel); color:var(--cm-panel-ink); border-bottom:1px solid var(--cm-rule); clip-path:inset(0 0 100% 0)` (fully clipped from the bottom = closed).
- `.cm-label`: Overpass Mono `12px`, `letter-spacing:.08em`, uppercase, muted, `margin-bottom:18px`.
- Links: `li + li { border-top:1px solid var(--cm-rule) }`; `a { display:grid; grid-template-columns:56px 1fr auto; grid-template-rows:auto auto; align-items:baseline; padding:22px 0 }`. `.cm-n` mono `13px`, muted, `grid-row:span 2`. `.cm-t`: `clamp(2.25rem,4.2vw,3.6rem); line-height:1; letter-spacing:-.03em; transition:transform .45s var(--cm-ease), color .3s`. `.cm-d`: `grid-column:2; margin-top:8px; 15px; muted`. `.cm-f`: `grid-row:1/span 2; grid-column:3; align-self:center; 28px; opacity:0; transform:translateX(-12px)`. Hover/focus-visible: `.cm-t → translateX(14px)` + accent colour; `.cm-f → opacity:1; transform:none`.
- `@media (max-width:600px)`: panel `padding-top:96px`; link grid `40px 1fr auto`, `padding:18px 0`; description `13px`; arrow `22px`.

## GSAP effect (be exact)
Build in `mount(config)` → `destroy()`.

```js
const DEFAULTS = { curtain: .6, veil: .35, itemsAt: .2, itemsY: 24, stagger: .025, closeSpeed: 1.6 };
```

**One paused timeline**
```js
const tl = gsap.timeline({ paused: true, defaults: { ease: "power3.inOut" } })
  .set(menu, { className: "cm-menu is-visible" })
  .to(veil, { opacity: 1, duration: .35 }, 0)
  .to(panel, { clipPath: "inset(0 0 0% 0)", duration: .6 }, 0)
  .from(items, { y: 24, opacity: 0, duration: .45, stagger: .025, ease: "power3.out" }, .2);
// items = ".cm-label, .cm-links li"
```
The `className` set at time 0 is undone automatically when the timeline is reversed to the start, which hides the menu again.

**Open / close**: `setOpen(open)`: write `aria-expanded` on the button and `aria-hidden` on the menu, toggle `.is-open` on `.cm` (this drives the label roll, the X and the button colour), then `open ? tl.timeScale(1).play() : tl.timeScale(1.6).reverse()`. The button toggles; the veil, every link and `Escape` close.

With `prefers-reduced-motion: reduce`, all durations become 0 (the menu still opens and closes, instantly).

**destroy()**: remove listeners, `tl.progress(0).kill()`, `clearProps:"all"` on veil, panel and items, reset the classes and ARIA attributes.

## Assets / images
None.

## Behavior notes
- Reversing the same timeline (faster) guarantees the close is the exact path back; a separate close timeline tends to drift from the open one.
- The panel is `inset: 0 0 auto 0`, so it is only as tall as its content; the veil covers whatever is below. With many links it scrolls inside (`max-height:100svh; overflow-y:auto`).
- The button sits above the menu (`z-index:90` vs `80`) and stays clickable while it is open.
- Only the prefixed variables are global.

## Using this outside its demo page

This component is written as a complete page: that is how the demo is meant to look. If you are dropping it into an existing project, or combining it with other components, these are the things it declares at document level and that you need to move or reconcile first.

- **Palette on `:root`**: `--cm-page`, `--cm-panel`, `--cm-ink`, `--cm-panel-ink`, `--cm-muted`, `--cm-rule`, `--cm-accent`, `--cm-ease`. Generic names like `--ink`, `--paper` or `--muted` are defined by many components in this catalogue with different values, and they will also collide with whatever your own project defines. Move them onto the component's wrapper (`.my-section { --ink: … }`) or keep the prefix.
- **Rules on `*, *::before, *::after`, `html, body`**: the demo owns the whole document, so these set the box model and resets. Dropped into an existing project they restyle the entire page, not just this section. Re-target them at the component's wrapper before using it.
- **Full-screen overlay**: a fixed element covers the viewport while the menu is open. Only one such menu should exist per page; if your page already has an overlay menu, keep one and drop the other, or the second silently sits on top of the first.
