# back-to-top — shared "↑ top" jump affordance

One file, one rule, every surface. A neat `↑ top` link that appears **only on
long pages**, injected at the very bottom (above the provenance footer when one
is present). Single source — change it here, the whole portfolio updates.

## Use

```html
<script src="https://assets.gf.cx/back-to-top/back-to-top.js" defer></script>
```

That's it. No markup, no per-page CSS. New surfaces get it from
`gfcx_subdomain_new.py`; existing pages get it retroactively via the sweep
tool `~/bin/gfcx_backtop.py` (audit / apply, dry-run by default).

## The conditional logic (when it shows)

Runtime, not a static "is this a long page" decision:

- On load + on resize, compare `document.documentElement.scrollHeight` to the
  viewport.
- Reveal **only** when the page is `>= 2.2 × innerHeight` **and** `>= 1400px`
  tall — far enough that the header has scrolled off and a jump back actually
  helps.
- Short page → link stays hidden. So the `<script>` is safe to inject into
  *every* page; each page decides at runtime whether to render the button.

## Polite by design

- Singleton-guarded (safe to load twice).
- No-ops if a page already ships a hand-wired `a.backtop` (those win — e.g. the
  happiness.gf.cx `behaviour/` long-reads, the origin of the pattern).
- Themes off local CSS vars (`--mono` / `--ink-soft` / `--accent`) with
  fallbacks, so it inherits each surface's palette.
- Reduced-motion aware; hidden in `@media print`.

## Lineage

Pattern origin: `happiness.gf.cx/behaviour/` long-reads (`.backtop`). Documented
at `patterns.gf.cx/back-to-top-jump-icon/`. v0.1.0 · 2026-06-25.
