# Perimeter Marquee Split Card: Text Ribbon Around the Edges and Draggable Percentage Handles

## Goal
Build a white page with one centred **black card**. A thin band runs along **all four inner edges** carrying the text **"YOUR SPLIT · "** as a **single continuous ribbon**: four strips (top, right, bottom, left), each a time-based marquee looping without a seam, the bottom and left strips rotated 180° so the text appears to travel around the card, all at the same speed in px/s. Inside the band, **three columns** ("Save", "Invest", "Give") show big monospaced percentages (**40 %, 40 %, 20 %**) and are separated by **two draggable handles** (white rounded pills) that move points from one column to its neighbour so the three always **add up to 100**. Handles work with pointer drag and with **left/right arrow keys**; each column keeps at least 10 %. GSAP only for the marquee.

## Tech
Vanilla HTML/CSS/JS with ES module imports. `gsap` (npm), no plugins. Fonts: **Schibsted Grotesk** (500) for labels, **JetBrains Mono** for the ribbon and percentages.

## Layout / HTML
```html
<div class="pm">
  <section class="pm-stage">
    <article class="pm-card">
      <div class="pm-frame" aria-hidden="true">
        <div class="pm-strip pm-strip--top"><span data-pm-text>YOUR SPLIT · </span></div>
        <div class="pm-strip pm-strip--right"><span data-pm-text>YOUR SPLIT · </span></div>
        <div class="pm-strip pm-strip--bottom"><span data-pm-text>YOUR SPLIT · </span></div>
        <div class="pm-strip pm-strip--left"><span data-pm-text>YOUR SPLIT · </span></div>
      </div>
      <div class="pm-split" data-pm-split>
        <div class="pm-col"><p class="pm-label">Save</p><p class="pm-pct" data-pm-pct>40 %</p></div>
        <div class="pm-handle" data-pm-handle="0" role="separator" tabindex="0" aria-orientation="vertical"
             aria-label="Move the split between Save and Invest" aria-valuemin="10" aria-valuemax="90" aria-valuenow="40"></div>
        <div class="pm-col"><p class="pm-label">Invest</p><p class="pm-pct" data-pm-pct>40 %</p></div>
        <div class="pm-handle" data-pm-handle="1" role="separator" tabindex="0" aria-orientation="vertical"
             aria-label="Move the split between Invest and Give" aria-valuemin="10" aria-valuemax="90" aria-valuenow="40"></div>
        <div class="pm-col"><p class="pm-label">Give</p><p class="pm-pct" data-pm-pct>20 %</p></div>
      </div>
    </article>
  </section>
</div>
```

## Styling
`:root`: `--pm-bg:#fff`, `--pm-card:#0a0a0a`, `--pm-ink:#fff`, `--pm-muted:rgba(255,255,255,.45)`, `--pm-accent:#fff` (focus ring), `--pm-band:26px`.

- `.pm-stage`: `min-height:100svh; display:grid; place-items:center; padding:clamp(1rem,4vw,3rem)`.
- `.pm-card`: `position:relative; width:min(1100px,100%); height:clamp(340px,60vh,540px); background:var(--pm-card); color:var(--pm-ink); border-radius:6px; overflow:hidden` (360px tall under 640px).
- `.pm-strip`: absolute, `overflow:hidden`, JetBrains Mono `11px`, `letter-spacing:.14em`, `line-height:var(--pm-band)`, `--pm-muted`, `white-space:nowrap`; its spans `display:inline-block`.
  - `--top`: `left:0; right:0; top:0; height:var(--pm-band)`.
  - `--bottom`: same at `bottom:0`, `transform:rotate(180deg)`.
  - `--right` / `--left`: `top:var(--pm-band); bottom:var(--pm-band); width:var(--pm-band); writing-mode:vertical-rl`; `--right` at `right:0`; `--left` at `left:0` with `rotate(180deg)`.
- `.pm-split`: `position:absolute; inset:var(--pm-band); display:flex`.
- `.pm-col`: `flex:0 0 33.333%; min-width:0; display:flex; flex-direction:column; justify-content:space-between; padding:clamp(1rem,3vw,2.25rem); overflow:hidden`. Columns after a handle get `border-left:1px dashed rgba(255,255,255,.28)`. Text `white-space:nowrap`.
- `.pm-label`: `clamp(1rem,1.8vw,1.4rem)`, weight 500. `.pm-pct`: JetBrains Mono `clamp(1.8rem,6vw,5rem)`, `letter-spacing:-.06em`, `line-height:1`.
- `.pm-handle`: `position:relative; z-index:2; flex:none; width:0; align-self:center; touch-action:none`. `::before` is the grip: `left:-16px; top:-36px; width:32px; height:72px; border-radius:40px; background:var(--pm-ink); cursor:grab; transition:transform .2s`, `scaleY(1.08)` on hover/drag. `::after` is a 2×24px notch in the card colour centred on it. `:focus-visible::before` gets a double box-shadow ring (card colour then `--pm-accent`). Under 640px the grip is 24×60px.

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

```js
const DEFAULTS = { speed: 40, split: [40, 40, 20], min: 10, step: 5 };
```

**Ribbon** `buildStrips()`, for each strip:
- restore its original markup, then **repeat the span's text** until the span is at least as long as the strip (width for top/bottom, height for left/right; vertical-rl stacks the inline-block spans vertically);
- append **one clone** of the span;
- `gsap.fromTo(strip.children, { xPercent: 0 }, { xPercent: -100, duration: spanLength / speed, ease: "none", repeat: -1 })` for horizontals, `yPercent` for verticals. When the tween ends each copy is exactly where the other started, so the loop has no seam, and dividing by `speed` keeps the four strips at the same px/s.
- Rebuild on `resize` (debounced 150 ms) and after `document.fonts.ready`.

**Split**: an array of three numbers that sums to 100. `paint()` sets each column's `flex-basis` to `n%`, writes `n %` into the percentages and updates `aria-valuenow` / `aria-valuetext` on the handles. `shift(i, d)` adds `d` to column `i` and subtracts it from `i+1`, refusing if either would drop below `min`.
- **Drag**: on `pointerdown` capture the pointer and remember `x0`. On `pointermove`, `unit = split.clientWidth / 100`; `d = trunc((clientX - x0) / unit)`; apply `shift` one point at a time up to `|d|` (stopping at the limit) and advance `x0 += d * unit`. So one point per 1 % of the card's inner width.
- **Keyboard**: ArrowLeft/ArrowRight on a focused handle → `shift(i, ∓step)`.

`prefers-reduced-motion: reduce`: strips are filled but not animated; the handles work the same.

**destroy()**: kill the tweens, restore the strips' markup, remove listeners, clear `flex-basis`.

## Assets / images
None.

## Behavior notes
- Filling each span to its own strip length is what makes any card size loop seamlessly.
- Rotating the bottom and left strips 180° makes the four directions read as one ribbon travelling round the card.
- Swap the labels or the starting split in markup and `split`; the sum must be 100.
- 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`**: `--pm-bg`, `--pm-card`, `--pm-ink`, `--pm-muted`, `--pm-accent`, `--pm-band`. 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.
