{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"odometer","type":"registry:block","title":"Odometer","description":"Object. A mechanical drum counter. A digit moves only while the one to its right carries, so 1,099 to 1,100 rolls three drums over together. Not a number that fades into another.","registryDependencies":[],"files":[{"path":"tactile/odometer/odometer.mjs","type":"registry:file","target":"tactile/odometer/odometer.mjs","content":"/**\n * Odometer — TACTILE UI.\n *\n * A mechanical drum counter as a number display: numerals printed on drums\n * that turn behind a window, the way an odometer, a tally counter or a petrol\n * pump register shows a number. Three mechanisms:\n *\n *   1. The carry. Only the last drum is driven; every other drum moves only\n *      while the drum to its right passes from 9 to 0. The first carry takes\n *      the last tenth of the last drum's step, and every carry above it turns\n *      in lock-step with the drum below, so 1,099 → 1,100 rolls the tens and\n *      the hundreds over TOGETHER at the very end of the units' turn. A number\n *      ticker that tweens each digit on its own cannot do that, and it is the\n *      whole reason this reads as a machine. `drumPositions` is that rule as a\n *      pure function of one continuous value.\n *   2. A spring on the value, not on the digits. A new value is a target; the\n *      continuous value springs toward it (optional overshoot), and every drum\n *      follows from the carry rule. A drum turning faster than the spin cap is\n *      drawn turning AT the cap, smeared: a jump of millions spins the low drums\n *      as a blur while the high ones visibly roll, and all of them land exactly.\n *   3. Light that does not turn. A drum is a cylinder on a horizontal axle, so\n *      the light on it depends only on height in the window, never on how far\n *      it has turned. One overlay per drum, computed once from the lamp, gives\n *      the darkening toward the top and bottom and the specular band along the\n *      drum; the numerals roll through it. The faces are real DOM text on a\n *      ten-sided CSS 3D drum, so the figures are crisp and truly foreshortened.\n *\n * It costs nothing at rest: the loop runs only while a value is travelling,\n * sleeps once it lands — a slow tally sleeps between its steps too — pauses off\n * screen and in a hidden tab, and a two-second frame gap cannot blow up the\n * spring.\n *\n * The housing is a machined plate in a material that belongs to the drums\n * (black anodised aluminium for ink drums, satin steel for bone, blackened\n * brass worn bright at the edges for brass): diamond-cut chamfers lit by the\n * one lamp, countersunk screws, an optional paint-filled engraved label, and a\n * cover glass with the lamp's reflection in it and a refracting edge.\n *\n * `size: 'fit'` (the default) fills the host's box — a preview stage, a tile,\n * a phone — and follows it; a number fixes the numeral size and shrinks only\n * when the host is narrower.\n *\n * The number is text. A visually hidden element holds the formatted value and\n * announces it politely once it has LANDED — never each frame; while counting\n * it stops announcing and is kept current for anyone who reads it; a counter\n * set `announce: false` (a tally beside the real content) never announces. The\n * drums are aria-hidden. Reduced motion: the value changes instantly, nothing spins,\n * no frame is requested.\n *\n * The numerals are Big Shoulders Bold (SIL OFL 1.1), shipped beside the CSS as\n * WOFF2 with its licence, so the drums print the same figures on every\n * platform. No dependencies, no image. The exported helpers are pure and\n * tested in Node.\n */\n\nexport const clamp = (n, lo, hi) => Math.min(hi, Math.max(lo, n));\n\n/** How much of the last drum's step the first carry takes. The brief: the last tenth. */\nexport const CARRY = 0.1;\n\n/** More drums than a double can count exactly would lie about the last digit. */\nexport const MAX_DRUMS = 15;\n\nconst wrap10 = (p) => ((p % 10) + 10) % 10;\n/** A change of drum position folded into [-5, 5): 9.9 → 0.1 is +0.2, not -9.8. */\nexport const wrapDelta = (d) => wrap10(d + 5) - 5;\n\n/** |value| in units of the last drum, with binary dust removed: 10.1 at two decimals is 1010, not 1009.9999999999999. */\nexport function scaled(value, decimals = 0) {\n  const n = Math.abs(value) * 10 ** decimals;\n  const r = Math.round(n);\n  return Math.abs(n - r) < 1e-6 ? r : n;\n}\n\n/** The value rounded to what the drums can show. */\nexport function quantise(value, decimals = 0) {\n  const f = 10 ** decimals;\n  const q = Math.round(value * f) / f;\n  return q === 0 ? 0 : q; // never -0: it would print a sign\n}\n\n/**\n * Every drum's position in [0, 10) for a continuous value; index 0 is the\n * last (least significant) drum. The last drum turns with the value. Drum k\n * turns only while drum k-1 passes from 9 to 0: the first carry over the last\n * `carry` of that step, every carry above it in lock-step with the drum below.\n */\nexport function drumPositions(value, count, decimals = 0, carry = CARRY) {\n  const n = scaled(value, decimals);\n  const out = new Array(count);\n  if (count < 1) return out;\n  let below = n % 10;\n  out[0] = below;\n  for (let k = 1; k < count; k += 1) {\n    const w = k === 1 ? carry : 1;\n    const digit = Math.floor(n / 10 ** k) % 10;\n    below = digit + clamp((below - 10 + w) / w, 0, 1);\n    out[k] = below;\n  }\n  return out;\n}\n\n/** How many drums a value needs: its integer digits (at least one) plus the decimals. */\nexport function drumsFor(value, decimals = 0) {\n  const whole = Math.floor(Math.abs(value));\n  return (whole >= 1 ? String(whole).length : 1) + decimals;\n}\n\n/**\n * Which drums print their zero. A leading drum — nothing but zeros at and\n * above it — has a blank where its 0 would be, so 89 on six drums reads \"89\",\n * not \"000089\". The units and the decimals always print.\n */\nexport function blankZeros(value, count, decimals = 0) {\n  const n = scaled(value, decimals);\n  return Array.from({ length: count }, (_, k) => k > decimals && n < 10 ** k);\n}\n\n/**\n * Left to right: the sign plate, then drums and fixed separator plates. A\n * group separator stands to the right of the integer drum whose place is a\n * locale break (3, 6, 9… or 3, 5, 7… in en-IN); the decimal plate stands to\n * the right of the units drum.\n */\nexport function slotsFor(count, decimals, breaks = [], signed = false) {\n  const out = signed ? [{ kind: 'sign' }] : [];\n  for (let k = count - 1; k >= 0; k -= 1) {\n    out.push({ kind: 'drum', k });\n    const j = k - decimals;\n    if (j > 0 && breaks.includes(j)) out.push({ kind: 'group', k });\n    if (k === decimals && decimals > 0) out.push({ kind: 'decimal', k });\n  }\n  return out;\n}\n\n/**\n * A locale's number, taken apart: the group and decimal marks, the minus\n * sign, the ten digit glyphs the drums are printed with, and where the group\n * breaks fall. Read from Intl.NumberFormat parts, so en-IN's lakh grouping,\n * fr-FR's narrow space and ar-EG's digits all come from the platform.\n */\nexport function numberStyle(locale = 'en-US', decimals = 0, grouping = true) {\n  let nf;\n  try {\n    nf = new Intl.NumberFormat(locale, { minimumFractionDigits: decimals, maximumFractionDigits: decimals, useGrouping: grouping });\n  } catch {\n    nf = new Intl.NumberFormat('en-US', { minimumFractionDigits: decimals, maximumFractionDigits: decimals, useGrouping: grouping });\n  }\n  const loc = nf.resolvedOptions().locale;\n  const parts = nf.formatToParts(888888888888888n);\n  const ints = parts.filter((p) => p.type === 'integer').map((p) => p.value.length);\n  const breaks = [];\n  let acc = 0;\n  for (let i = ints.length - 1; i > 0; i -= 1) {\n    acc += ints[i];\n    breaks.push(acc);\n  }\n  const group = parts.find((p) => p.type === 'group')?.value ?? '';\n  const decimal = new Intl.NumberFormat(loc, { minimumFractionDigits: 1 }).formatToParts(1.5)\n    .find((p) => p.type === 'decimal')?.value ?? '.';\n  const minus = new Intl.NumberFormat(loc).formatToParts(-1).find((p) => p.type === 'minusSign')?.value ?? '-';\n  const plain = new Intl.NumberFormat(loc, { useGrouping: false });\n  const digits = Array.from({ length: 10 }, (_, i) => plain.format(i));\n  return { nf, locale: loc, group, decimal, minus, digits, breaks };\n}\n\n/** The value as a sentence reads it: sign, prefix, the locale's number, suffix. */\nexport function formatValue(value, style, prefix = '', suffix = '') {\n  const body = style.nf.format(Math.abs(value));\n  return `${value < 0 ? style.minus : ''}${prefix}${body}${suffix}`;\n}\n\n/**\n * Advance the value's spring. The step is clamped to 1/30 s and sub-stepped\n * at 1/120 s: a background tab that returns with a 2.5 s frame gap advances\n * one sane frame instead of launching the drums.\n */\nexport function stepSpring(s, target, dt, stiffness = 140, damping = 0.85) {\n  const c = 2 * damping * Math.sqrt(stiffness);\n  let left = clamp(dt, 0, 1 / 30);\n  while (left > 1e-6) {\n    const h = Math.min(left, 1 / 120);\n    s.v += (stiffness * (target - s.x) - c * s.v) * h;\n    s.x += s.v * h;\n    left -= h;\n  }\n  return s;\n}\n\n/** Landed: within a thousandth of the last drum's step, and still. */\nexport function landed(s, target, decimals = 0) {\n  const lsd = 10 ** -decimals;\n  const tol = Math.max(lsd * 1e-3, Math.abs(target) * 1e-15);\n  return Math.abs(target - s.x) <= tol && Math.abs(s.v) < lsd * 0.02;\n}\n\n/** How smeared a drum is from its speed in digits per second: none below a third of the cap, all of it at the cap. */\nexport function smear(speed, cap) {\n  const t = clamp((speed - cap / 3) / (cap - cap / 3), 0, 1);\n  return t * t * (3 - 2 * t);\n}\n\n/**\n * A drum turning faster than the cap is DRAWN turning at the cap: past it a\n * frame skips more than half a digit, the figures strobe and can even appear\n * to run backwards. Returns the drawn position and whether it free-runs.\n */\nexport function spin(phase, truePos, speed, dir, cap, dt) {\n  if (speed > cap && dt > 0) return { pos: wrap10(phase + dir * cap * dt), free: true };\n  return { pos: wrap10(truePos), free: false };\n}\n\n/** Screen direction toward the lamp: 0° is from above, clockwise; y points down. */\nexport function lampOf(light) {\n  const t = (light * Math.PI) / 180;\n  return { lx: Math.sin(t), ly: -Math.cos(t) };\n}\n\n// Drum geometry, in em of the numeral size. Ten faces: the radius follows\n// from the face (the chord between two numerals).\nexport const FACE = 1.12;\nexport const RADIUS = FACE / (2 * Math.tan(Math.PI / 10));\nexport const WINDOW = 1.56;\n\n/** The family name the stylesheet gives the bundled face. */\nexport const FACE_FAMILY = 'Odometer Figures';\n\n/**\n * The numeral size that fills a box: the object's width and height are\n * linear in its numeral size (every length is in em), plus a margin of\n * `pad` em on each side for the plate's shadow. A missing dimension (0) does\n * not constrain; with neither, `fallback`.\n */\nexport function fitSize(availW, availH, perW, perH, { pad = 0.22, min = 8, max = 400, fallback = 72 } = {}) {\n  const byW = availW > 0 && perW > 0 ? availW / (perW + 2 * pad) : Infinity;\n  const byH = availH > 0 && perH > 0 ? availH / (perH + 2 * pad) : Infinity;\n  const s = Math.min(byW, byH);\n  return clamp(Number.isFinite(s) ? Math.floor(s * 10) / 10 : fallback, min, max);\n}\n\n/**\n * When the next step of a tally is due, in ms after `t0`: the tally adds one\n * last-drum step every |1 / rate| s (value per second).\n */\nexport function nextStepAt(t0, now, rate, decimals = 0) {\n  const every = (10 ** -decimals / Math.abs(rate)) * 1000;\n  return t0 + (Math.floor((now - t0) / every + 1e-9) + 1) * every;\n}\n\nconst smoothstep = (a, b, x) => {\n  const t = clamp((x - a) / (b - a), 0, 1);\n  return t * t * (3 - 2 * t);\n};\n\n/**\n * The light on a drum from the top of the window (0) to the bottom (1):\n * `dark` is how much black to lay over the printed surface, `light` how much\n * lamp. Lambert from the lamp 38° off the line of sight, a specular band where\n * the drum's normal bisects lamp and eye, and occlusion where the window's lip\n * hides the drum as it curves away.\n */\nexport function drumLight(light, gloss = 0.2, samples = 21, radius = RADIUS, half = WINDOW / 2) {\n  const { lx, ly } = lampOf(light);\n  const E = Math.sin((38 * Math.PI) / 180);\n  const Z = Math.cos((38 * Math.PI) / 180);\n  const L = [lx * E, ly * E, Z];\n  // The band lies where the normal (in the drum's plane of turn) is nearest\n  // the half-vector. A lamp to the side still lights the band; it is fainter.\n  const hy = L[1];\n  const hz = L[2] + 1;\n  const hl = Math.hypot(hy, hz);\n  const side = 1 - 0.45 * Math.abs(lx);\n  const out = [];\n  for (let i = 0; i < samples; i += 1) {\n    const at = i / (samples - 1);\n    const y = (-1 + 2 * at) * half;\n    const s = clamp(-y / radius, -1, 1);\n    const c = Math.sqrt(1 - s * s);\n    const ny = -s;\n    const dif = Math.max(0, ny * L[1] + c * L[2]) / Z;\n    const spec = gloss * side * Math.max(0, (ny * hy + c * hz) / hl) ** 90;\n    const ao = smoothstep(0.42, 1, Math.abs(y) / half) * 0.72;\n    const b = dif * (1 - ao);\n    out.push({ at, dark: clamp(1 - b, 0, 0.94), light: clamp((b - 1) * 0.45 + spec, 0, 1) });\n  }\n  return out;\n}\n\n// ------------------------------------------------------------------ the object\n\nlet probe;\n/**\n * How far to move a figure down so its ink, not its line box, sits on the\n * drum's centre line. Digits stand on the baseline, above the descender\n * space, so a centred line box puts them high: the next figure peeks in at\n * the bottom of the window and none at the top. Measured from the font the\n * page actually resolved — the bundled face once it has loaded, a fallback\n * before — and measured again when the face arrives.\n */\nfunction opticalLift(cs) {\n  try {\n    probe ??= document.createElement('canvas').getContext('2d');\n    probe.font = `${cs.fontWeight} 100px ${cs.fontFamily}`;\n    const m = probe.measureText('0123456789');\n    const A = m.fontBoundingBoxAscent / 100;\n    const D = m.fontBoundingBoxDescent / 100;\n    const gA = m.actualBoundingBoxAscent / 100;\n    const gD = m.actualBoundingBoxDescent / 100;\n    const lift = (D - A + gA - gD) / 2;\n    return Number.isFinite(lift) ? clamp(lift, -0.2, 0.2) : 0;\n  } catch {\n    return 0;\n  }\n}\n\n/**\n * Housings. `base` is the plate's body, `light`/`dark` its lit and shaded\n * tones; `edge`/`edgeDark` the metal a chamfer cuts down to (a diamond-cut\n * edge on anodised aluminium is bright bare aluminium, on blackened brass it\n * is brass); `ink` the paint in the engraving; `screw` the screws' metal.\n */\nexport const PLATES = Object.freeze({\n  anodised: Object.freeze({ base: '#232427', light: '#5e626a', dark: '#0a0b0d', ink: '#e9e2d1', edge: '#f4f6f8', edgeDark: '#2b2e33', screw: '#c9ced4', brush: 0.5 }),\n  steel: Object.freeze({ base: '#a8adb3', light: '#f4f6f8', dark: '#3d4247', ink: '#1b1d20', edge: '#ffffff', edgeDark: '#565b61', screw: '#bfc4ca', brush: 0.7 }),\n  graphite: Object.freeze({ base: '#393b40', light: '#8e939a', dark: '#111214', ink: '#e2e5e9', edge: '#e9ecef', edgeDark: '#2a2c30', screw: '#c4c9cf', brush: 0.55 }),\n  blackened: Object.freeze({ base: '#2a241b', light: '#6b5838', dark: '#0e0b07', ink: '#dcb96f', edge: '#f6dfa0', edgeDark: '#4e3810', screw: '#c7a256', brush: 0.5 }),\n});\n\n/**\n * Drum finishes, each in the housing it would be sold in. `red` is the\n * signal drum (the classic odometer tenths).\n */\nexport const FINISHES = Object.freeze({\n  ink: Object.freeze({ drum: '#1a1b1d', figure: '#ece4d2', plate: 'anodised', gloss: 0.34, tint: '255, 250, 240' }),\n  bone: Object.freeze({ drum: '#e6dfd0', figure: '#17181a', plate: 'steel', gloss: 0.14, tint: '255, 252, 245' }),\n  steel: Object.freeze({ drum: '#5e646b', figure: '#f6f8f9', plate: 'graphite', gloss: 0.5, tint: '240, 246, 252' }),\n  brass: Object.freeze({ drum: '#b48a3a', figure: '#1f1507', plate: 'blackened', gloss: 0.55, tint: '255, 236, 190' }),\n});\n\n/**\n * `finish: 'auto'` follows the page: each finish the kit ships has the drums it\n * calls for, bone in a steel housing on a light one, ink in anodised aluminium\n * on AMOLED. On Graphite, Black, Phosphor and Night (`page`) the counter is\n * drawn from the page's object tokens, in that finish's own language:\n * anodised metal with bright cut edges, black glass traced in the display's\n * light, dim metal with its figures lit from inside. A finish not listed goes\n * by the page's tone.\n */\nexport const AUTO = Object.freeze({\n  aluminium: 'bone', graphite: 'page', porcelain: 'bone', black: 'page', paper: 'bone', phosphor: 'page',\n  daylight: 'bone', night: 'page', 'e-paper': 'bone', amoled: 'ink',\n});\n\n/** The drums drawn: the finish asked for, or on `auto` the page's finish's, then its tone, then the system's. */\nexport function resolveMaterial(own, around, prefersDark, tone) {\n  if (own !== 'auto') return own;\n  if (AUTO[around]) return AUTO[around];\n  return (tone === 'light' || tone === 'dark' ? tone === 'dark' : prefersDark) ? 'ink' : 'bone';\n}\n\nexport const SIGNAL = Object.freeze({ drum: '#d93a2b', figure: '#fff3e6' });\n\nexport const BEZELS = Object.freeze(['slot', 'cells', 'bare']);\nexport const REDS = Object.freeze(['none', 'last', 'decimals']);\n\nexport const DEFAULTS = Object.freeze({\n  value: 0,\n  decimals: 0,\n  prefix: '',\n  currency: '',\n  suffix: '',\n  locale: 'en-US',\n  grouping: true,\n  digits: 1,\n  zeros: false,\n  finish: 'auto',\n  red: 'none',\n  bezel: 'slot',\n  stiffness: 140,\n  damping: 0.85,\n  maxSpin: 24,\n  count: 0,\n  wear: 0.35,\n  light: 315,\n  size: 'fit',\n  label: '',\n  sound: false,\n  announce: true,\n});\n\nfunction normalise(opts, previous) {\n  const o = { ...DEFAULTS, ...previous, ...opts };\n  o.decimals = clamp(Math.round(+o.decimals || 0), 0, 6);\n  o.digits = clamp(Math.round(+o.digits || 1), 1, MAX_DRUMS - o.decimals);\n  o.prefix = String(o.prefix ?? '').slice(0, 8);\n  o.currency = String(o.currency ?? '').slice(0, 3);\n  o.suffix = String(o.suffix ?? '').slice(0, 24);\n  o.label = String(o.label ?? '').slice(0, 32);\n  o.locale = String(o.locale || 'en-US');\n  o.grouping = o.grouping !== false;\n  o.zeros = !!o.zeros;\n  if (o.finish !== 'auto' && !FINISHES[o.finish]) o.finish = 'auto';\n  if (!REDS.includes(o.red)) o.red = 'none';\n  if (!BEZELS.includes(o.bezel)) o.bezel = 'slot';\n  o.stiffness = clamp(+o.stiffness || 140, 10, 1000);\n  o.damping = clamp(+o.damping || 0.85, 0.2, 2);\n  o.maxSpin = clamp(+o.maxSpin || 24, 3, 120);\n  o.count = Number.isFinite(+o.count) ? +o.count : 0;\n  o.wear = clamp(+o.wear || 0, 0, 1);\n  o.light = ((+o.light || 0) % 360 + 360) % 360;\n  // 'fit' (or 0) fills the host; a number is the numeral size in px.\n  o.size = +o.size > 0 ? clamp(+o.size, 8, 400) : 'fit';\n  o.sound = !!o.sound;\n  // false: an ambient counter (a tally beside the real content) is read in place, never announced.\n  o.announce = o.announce !== false;\n  return o;\n}\n\n/** The largest magnitude the drums can hold at these decimals. */\nconst limitFor = (decimals) => (10 ** (MAX_DRUMS - decimals) - 1) / 10 ** decimals;\n\n/** A stable pseudo-random number in [0, 1) per drum and purpose: wear must not change between renders. */\nconst hash = (i, salt) => {\n  const x = Math.sin(i * 12.9898 + salt * 78.233) * 43758.5453;\n  return x - Math.floor(x);\n};\n\nconst STRUCTURE = ['decimals', 'locale', 'grouping', 'digits', 'zeros', 'finish', 'red', 'bezel', 'prefix', 'currency', 'suffix', 'label', 'wear'];\n\nconst el = (tag, cls, text) => {\n  const n = document.createElement(tag);\n  if (cls) n.className = cls;\n  if (text !== undefined) n.textContent = text;\n  return n;\n};\n\n/**\n * Put a drum's faces where position `pos` puts them. Each face carries its\n * whole transform under a flat parent with perspective: nesting the faces in\n * a rotating preserve-3d drum is the obvious build, and Chrome culls the face\n * above the axle in it at some viewport sizes (a black cap on every drum at 0).\n * Only faces that can reach the window are placed: a face spans ±18° and the\n * window shows ±27° of the drum, so nothing past 45° is ever seen. Hiding the\n * rest matters — every face kept visible costs a layer and a repaint.\n */\nfunction turn(faces, pos) {\n  for (let i = 0; i < 10; i += 1) {\n    const a = wrapDelta(pos - i) * 36; // degrees from the front, in [-180, 180)\n    const f = faces[i];\n    const show = Math.abs(a) < 47;\n    if (show !== f.show) {\n      f.el.style.visibility = show ? '' : 'hidden';\n      f.show = show;\n    }\n    if (show) f.el.style.transform = `translateZ(calc(var(--od-r) * -1)) rotateX(${a.toFixed(3)}deg) translateZ(var(--od-r))`;\n  }\n}\n\nconst hex = (h) => [1, 3, 5].map((i) => parseInt(h.slice(i, i + 2), 16));\nconst mixHex = (a, b, t) => {\n  const pa = hex(a);\n  const pb = hex(b);\n  return `rgb(${pa.map((v, i) => Math.round(v + (pb[i] - v) * t)).join(', ')})`;\n};\n/** The same mix, as #rrggbb. */\nconst blend = (a, b, t) => `#${((1 << 24) | hex(a).map((v, i) => Math.round(v + (hex(b)[i] - v) * t)).reduce((n, v) => (n << 8) | v, 0)).toString(16).slice(1)}`;\n\n/** The page's object tokens a `page` counter is made from (--tui-obj-plate ... --tui-obj-mark). */\nexport const LOOK = Object.freeze(['plate', 'dark', 'body', 'lite', 'spec', 'env', 'frame', 'edge', 'mark']);\n\nlet hexProbe = null;\n/** Any opaque CSS colour (hex, rgb(), oklch() ...) as #rrggbb, the form the maths here reads: painted as one pixel and read back. */\nconst cssHex = (value) => {\n  hexProbe ??= document.createElement('canvas');\n  hexProbe.width = 1;\n  hexProbe.height = 1;\n  const g = hexProbe.getContext('2d', { willReadFrequently: true });\n  g.fillStyle = '#000000';\n  g.fillStyle = value;\n  g.fillRect(0, 0, 1, 1);\n  const [r, gg, b] = g.getImageData(0, 0, 1, 1).data;\n  return `#${((1 << 24) | (r << 16) | (gg << 8) | b).toString(16).slice(1)}`;\n};\n\n/** The page's object tokens as hex colours and numbers, or null on a page without them. */\nexport function readLook(el) {\n  const s = getComputedStyle(el);\n  const v = (k) => s.getPropertyValue(`--tui-obj-${k}`).trim();\n  if (!v('frame')) return null;\n  const t = Object.fromEntries(LOOK.map((k) => [k, cssHex(v(k) || v('frame'))]));\n  t.shadow = clamp(parseFloat(v('shadow')) || 0.4, 0, 1);\n  t.glow = clamp(parseFloat(v('glow')) || 0, 0, 1);\n  return t;\n}\n\n/**\n * The counter in a page's own material, from its object tokens: the housing is\n * the finish's frame with its mid tone as the lit sheen, its dark for the\n * shaded side and its edge for every chamfer, bright where the lamp catches\n * it; the drums are the finish's dark glass, their figures and the engraving\n * its mark. With glow the figures, the engraving and the housing's edge glow.\n * The signal drum stays red.\n */\nexport function finishFrom(t) {\n  const tint = hex(t.spec).join(', ');\n  return {\n    key: ['page', ...LOOK.map((k) => t[k]), t.glow].join('|'),\n    drum: blend(t.plate, t.dark, 0.5), figure: t.mark, gloss: 0.34, tint,\n    plate: {\n      base: t.frame, light: t.body, dark: t.dark, ink: t.mark, edge: t.edge, edgeDark: blend(t.frame, t.edge, 0.14), screw: t.lite, brush: 0.5,\n    },\n    edge: t.edge, glow: t.glow, hot: tint, shade: t.shadow / 0.5,\n  };\n}\n\n/**\n * How much lamp a 45° chamfer takes, per side (top, right, bottom, left).\n * `recess` is a window cut into the plate, whose walls face inward; otherwise\n * the plate's own raised edge, whose walls face out. Same lamp as the drums.\n */\nexport function bevel(light, recess) {\n  const { lx, ly } = lampOf(light);\n  const E = Math.sin((38 * Math.PI) / 180);\n  const Z = Math.cos((38 * Math.PI) / 180);\n  const s = recess ? 1 : -1;\n  const k = Math.SQRT1_2;\n  const lit = (nx, ny) => clamp(k * (nx * lx * E + ny * ly * E) + k * Z, 0, 1);\n  return [lit(0, s), lit(-s, 0), lit(0, -s), lit(s, 0)];\n}\n\n/**\n * The chamfer colours, per side (top, right, bottom, left): each side's angle\n * to the lamp mixes the plate's bare-metal edge from dark to lit. `raise` is\n * the plate's outer edge, `recess` the window's walls.\n */\nexport function chamfers(light, plate = 'anodised') {\n  const p = typeof plate === 'object' ? plate : PLATES[plate] ?? PLATES.anodised;\n  const tone = (b) => mixHex(p.edgeDark, p.edge, 0.7 * clamp((b - 0.3) / 0.62, 0, 1) ** 1.3);\n  return { raise: bevel(light, false).map(tone), recess: bevel(light, true).map(tone) };\n}\n\nconst rgba = (rgb, a) => `rgba(${rgb}, ${a.toFixed(3)})`;\nconst f3 = (n) => Number(n.toFixed(3));\n\nexport class Odometer {\n  constructor(host, opts = {}) {\n    if (!host) throw new Error('Odometer needs a host element');\n    this.host = host;\n    this.o = normalise(opts);\n    this.mq = typeof matchMedia === 'function' ? matchMedia('(prefers-reduced-motion: reduce)') : null;\n    this.reduced = !!this.mq?.matches;\n    this.dark = typeof matchMedia === 'function' ? matchMedia('(prefers-color-scheme: dark)') : null;\n\n    this.target = this.#clampValue(this.o.value);\n    this.s = { x: this.target, v: 0 };\n    this.visible = false;\n    this.raf = 0;\n    this.last = 0;\n    this.lastInt = Math.floor(scaled(this.target, this.o.decimals));\n    this.lastTick = 0;\n    this.lastText = 0;\n    this.counting = null;\n    this.timer = 0;\n\n    const root = el('div', 'od');\n    root.dataset.object = 'odometer';\n    root.dataset.state = 'asleep';\n    // The number is text: this is what a screen reader reads, copies and hears.\n    this.text = el('span', 'od-text');\n    this.text.setAttribute('aria-live', this.o.announce ? 'polite' : 'off');\n    this.text.setAttribute('aria-atomic', 'true');\n    this.plate = el('div', 'od-plate');\n    this.plate.setAttribute('aria-hidden', 'true');\n    root.append(this.text, this.plate);\n    this.root = root;\n    // The first value is content, not news: it is in place before the live\n    // region reaches the page, so nothing announces a number nobody changed.\n    this.style = numberStyle(this.o.locale, this.o.decimals, this.o.grouping);\n    this.text.textContent = formatValue(this.target, this.style, this.o.currency + this.o.prefix, this.o.suffix);\n    host.append(root);\n\n    this.on = {\n      motion: (e) => {\n        this.reduced = e.matches;\n        if (this.reduced) this.#jump();\n        this.#restartCount();\n        this.#wake();\n      },\n      visibility: () => {\n        if (document.hidden) this.#sleep();\n        else this.#wake();\n      },\n      gesture: () => this.#armAudio(),\n      // On auto the drums follow the page's finish: a change of it builds them again in the finish it now means.\n      finish: () => {\n        if (this.o.finish !== 'auto' || this.#material().key === this.mat?.key) return;\n        this.#build();\n        this.#paint(0);\n      },\n    };\n    this.mq?.addEventListener?.('change', this.on.motion);\n    this.dark?.addEventListener?.('change', this.on.finish);\n    document.addEventListener('visibilitychange', this.on.visibility);\n    this.finishObs = new MutationObserver(this.on.finish);\n    this.finishObs.observe(document.documentElement, { attributes: true, attributeFilter: ['data-finish', 'data-tone'], subtree: true });\n\n    this.#build();\n    this.#paint(0);\n    if (this.o.sound) this.#listenForGesture();\n    // The face arrives after the first build (it is invisible until then, not\n    // a fallback that jumps): measure the figures again once it has.\n    document.fonts?.load?.(`700 1em \"${FACE_FAMILY}\"`).then(() => {\n      if (this.root.isConnected) { this.#dress(); this.#fit(); }\n    }, () => {});\n\n    this.io = new IntersectionObserver(([entry]) => {\n      this.visible = entry.isIntersecting;\n      this.seen = true;\n      if (this.visible) this.#wake();\n    });\n    this.io.observe(root);\n    // Fit: the counter fills its host and follows it. A fixed size keeps its\n    // numeral size and shrinks only when the host is narrower.\n    this.ro = new ResizeObserver(() => this.#fit());\n    this.ro.observe(host);\n\n    if (this.o.count) this.count(this.o.count);\n  }\n\n  /** The value the drums are going to (or showing, once landed). */\n  get value() { return this.target; }\n\n  /** What the counter is doing now: asleep, or running while a value travels. */\n  get state() { return this.root.dataset.state; }\n\n  /**\n   * Roll to a new value. `instant` jumps without spinning; so does reduced\n   * motion, and so does a counter known to be off screen or in a hidden tab:\n   * nobody can watch that roll, and its text must not wait for them to.\n   */\n  setValue(v, { instant = false } = {}) {\n    const t = this.#clampValue(v);\n    if (!Number.isFinite(t)) return this;\n    this.target = t;\n    if (this.counting) {\n      this.counting.base = t;\n      this.counting.t0 = performance.now();\n    }\n    if (instant || this.reduced || (this.seen && !this.visible) || document.hidden) {\n      this.#jump();\n      return this;\n    }\n    this.#grow();\n    this.#wake();\n    return this;\n  }\n\n  /**\n   * A live tally: add `rate` (value per second, negative counts down) in\n   * whole steps of the last drum, until count(0). Each step rolls like any\n   * other change; fast enough, the steps blend into a steady spin.\n   */\n  count(rate = 1) {\n    const r = Number.isFinite(+rate) ? +rate : 0;\n    this.o.count = r;\n    this.counting = r ? { rate: r, base: this.target, t0: performance.now() } : null;\n    this.#live();\n    this.#restartCount();\n    this.#wake();\n    return this;\n  }\n\n  /** Change options in place. A `value` rolls to it; everything else redraws. */\n  update(opts = {}) {\n    const prev = this.o;\n    this.o = normalise(opts, this.o);\n    if (STRUCTURE.some((k) => prev[k] !== this.o[k])) {\n      this.target = this.#clampValue(this.target);\n      this.s.x = this.#clampValue(this.s.x);\n      this.#build();\n    } else if (prev.light !== this.o.light || prev.size !== this.o.size) {\n      this.#dress();\n      this.#fit();\n    }\n    this.#paint(0);\n    if (this.o.sound && !prev.sound) this.#listenForGesture();\n    if (this.o.announce !== prev.announce) this.#live();\n    if ('count' in opts && this.o.count !== (this.counting?.rate ?? 0)) this.count(this.o.count);\n    if ('value' in opts && this.#clampValue(opts.value) !== this.target) this.setValue(opts.value);\n    else this.#announce();\n    return this;\n  }\n\n  destroy() {\n    cancelAnimationFrame(this.raf);\n    clearInterval(this.timer);\n    clearTimeout(this.stepTimer);\n    this.io.disconnect();\n    this.ro.disconnect();\n    this.finishObs.disconnect();\n    this.mq?.removeEventListener?.('change', this.on.motion);\n    this.dark?.removeEventListener?.('change', this.on.finish);\n    document.removeEventListener('visibilitychange', this.on.visibility);\n    this.#stopListening();\n    this.audio?.close?.();\n    this.root.remove();\n  }\n\n  // ---------------------------------------------------------------- values\n\n  #clampValue(v) {\n    const lim = limitFor(this.o.decimals);\n    return quantise(clamp(Number.isFinite(+v) ? +v : 0, -lim, lim), this.o.decimals);\n  }\n\n  /** Straight to the target: reduced motion, `instant`, or a restart. */\n  #jump() {\n    this.s.x = this.target;\n    this.s.v = 0;\n    this.#grow();\n    this.#shrink();\n    this.#paint(0);\n    this.#announce();\n    this.lastInt = Math.floor(scaled(this.target, this.o.decimals));\n  }\n\n  // ---------------------------------------------------------------- the build\n\n  /**\n   * The finish drawn: the option, or on `auto` the page's finish around the\n   * host. `{ key, name, fin, plate }`: what changes it, the name on the root\n   * (`page` for a counter made from the page's tokens), its drums and its housing.\n   */\n  #material() {\n    const name = resolveMaterial(this.o.finish, this.host.closest('[data-finish]')?.dataset.finish, this.dark?.matches,\n      this.host.closest('[data-tone=\"light\"], [data-tone=\"dark\"]')?.dataset.tone);\n    if (name === 'page') {\n      // Read from the host, not the root: the root's own data-finish would answer with its finish's tokens.\n      const t = readLook(this.host);\n      if (t) {\n        const fin = finishFrom(t);\n        return { key: fin.key, name, fin, plate: fin.plate };\n      }\n      return { key: 'ink', name: 'ink', fin: FINISHES.ink, plate: PLATES[FINISHES.ink.plate] };\n    }\n    const fin = FINISHES[name];\n    return { key: name, name, fin, plate: PLATES[fin.plate] };\n  }\n\n  /** Drums and plates for the current count, sign and locale. */\n  #build() {\n    const o = this.o;\n    this.mat = this.#material();\n    this.material = this.mat.name;\n    this.style = numberStyle(o.locale, o.decimals, o.grouping);\n    this.count_ = Math.min(MAX_DRUMS, Math.max(\n      o.digits + o.decimals, drumsFor(this.target, o.decimals), drumsFor(this.s.x, o.decimals),\n    ));\n    this.signed = this.target < 0 || this.s.x < 0;\n    const root = this.root;\n    root.dataset.bezel = o.bezel;\n    // The finish drawn, not `auto`; written only when it changes, so the observer above never chases its own tail.\n    if (root.dataset.finish !== this.material) root.dataset.finish = this.material;\n\n    const win = el('div', 'od-window');\n    this.drums = [];\n    this.seps = [];\n    this.signEl = null;\n    // Born in the state they show: a blank toggled after the first style pass\n    // would fade out on page load, a ghost \"00\" in the leading drums.\n    const blanks = o.zeros ? null : blankZeros(this.s.x, this.count_, o.decimals);\n    let cur = o.currency ? el('span', 'od-sep od-currency') : null;\n    cur?.append(el('span', 'od-glyph', o.currency));\n    for (const slot of slotsFor(this.count_, o.decimals, o.grouping ? this.style.breaks : [], this.signed)) {\n      if (slot.kind === 'drum') {\n        // The currency drum stands before the first digit, after the sign: it never rolls.\n        if (cur) { win.append(cur); cur = null; }\n        win.append(this.#drum(slot.k, !!blanks?.[slot.k]));\n      }\n      else {\n        const glyph = slot.kind === 'sign' ? this.style.minus : slot.kind === 'group' ? this.style.group : this.style.decimal;\n        const sep = el('span', `od-sep od-${slot.kind}`);\n        sep.append(el('span', 'od-glyph', glyph));\n        const shown = slot.kind === 'sign' ? this.s.x < 0 : slot.kind === 'group' ? !blanks?.[slot.k] : true;\n        sep.classList.toggle('od-off', !shown);\n        if (slot.kind === 'sign') this.signEl = sep;\n        if (slot.kind === 'group') this.seps.push({ el: sep, k: slot.k, shown });\n        win.append(sep);\n      }\n    }\n    win.append(el('span', 'od-glass'));\n    this.plate.replaceChildren(win);\n    if (o.prefix) this.plate.append(el('span', 'od-prefix', o.prefix));\n    if (o.suffix) this.plate.append(el('span', /^\\s*[^\\p{L}\\p{N}]{1,2}\\s*$/u.test(o.suffix) ? 'od-suffix od-mark' : 'od-suffix', o.suffix));\n    // A paint-filled engraving under the window, ruled out to its edges.\n    if (o.label) {\n      const label = el('span', 'od-label');\n      label.append(el('span', 'od-label-t', o.label));\n      this.plate.append(label);\n    }\n    // Two countersunk screws, each driven home at its own angle.\n    if (o.bezel !== 'bare') {\n      for (const side of ['l', 'r']) {\n        const screw = el('span', `od-screw od-screw-${side}`);\n        screw.style.setProperty('--od-slot', `${Math.round(hash(side === 'l' ? 1 : 2, 7) * 180)}deg`);\n        this.plate.append(screw);\n      }\n    }\n    this.window = win;\n    this.#dress();\n    this.#fit();\n  }\n\n  #drum(k, blank) {\n    const o = this.o;\n    const cell = el('span', 'od-cell');\n    const red = o.red === 'last' ? k === 0 : o.red === 'decimals' ? (o.decimals ? k < o.decimals : k === 0) : false;\n    if (red) cell.classList.add('od-red');\n    const rot = el('span', 'od-rot');\n    const w = o.wear;\n    const faces = [];\n    for (let i = 0; i < 10; i += 1) {\n      const face = el('span', 'od-face');\n      faces.push({ el: face, show: null });\n      // Print registration: every figure was stamped a hair off true.\n      const ink = el('span', 'od-ink');\n      ink.style.transform = `translate(${f3((hash(k * 10 + i, 3) - 0.5) * 0.03 * w)}em, ${f3((hash(k * 10 + i, 4) - 0.5) * 0.026 * w)}em)`;\n      ink.style.setProperty('--ink', String(f3(1 - hash(k * 10 + i, 5) * 0.22 * w)));\n      ink.append(el('span', 'od-n', this.style.digits[i]), el('span', 'od-m', this.style.digits[i]));\n      face.append(ink);\n      rot.append(face);\n    }\n    cell.append(rot, el('span', 'od-lens'));\n    // Wear: each drum sits a little off its detent and has a little play on\n    // the axle. Stable per drum, so the number never shimmers between renders.\n    const drum = {\n      k,\n      cell,\n      rot,\n      faces,\n      zero: faces[0].el,\n      offset: (hash(k, 1) - 0.5) * 0.09 * w,\n      shown: NaN,\n      phase: 0,\n      blur: 0,\n      b: -1,\n      blank,\n      free: false,\n    };\n    drum.zero.classList.toggle('od-blank', blank);\n    cell.style.marginLeft = `${f3((hash(k, 2) - 0.5) * 0.024 * w)}em`;\n    this.drums[k] = drum;\n    return cell;\n  }\n\n  /** Everything the lamp and the finish decide, as custom properties. */\n  #dress() {\n    const o = this.o;\n    const { fin, plate } = this.mat;\n    const { lx, ly } = lampOf(o.light);\n    const s = this.root.style;\n    const set = (k, v) => s.setProperty(k, v);\n    set('--od-drum', fin.drum);\n    set('--od-figure', fin.figure);\n    set('--od-signal', SIGNAL.drum);\n    set('--od-signal-figure', SIGNAL.figure);\n    set('--od-metal', plate.base);\n    set('--od-metal-light', plate.light);\n    set('--od-metal-dark', plate.dark);\n    set('--od-plate-ink', plate.ink);\n    set('--od-edge', plate.edge);\n    set('--od-edge-dark', plate.edgeDark);\n    set('--od-screw', plate.screw);\n    set('--od-brush', String(plate.brush));\n    // A finish that glows lights its figures, its engraving and its housing's edge from within (data-glow; odometer.css).\n    set('--od-glow', String(fin.glow ?? 0));\n    this.root.toggleAttribute('data-glow', Boolean(fin.glow));\n\n    const shade = drumLight(o.light, fin.gloss);\n    const stops = (f) => shade.map((p) => `${f(p)} ${(p.at * 100).toFixed(1)}%`).join(', ');\n    set('--od-shade', `linear-gradient(180deg, ${stops((p) => `rgba(0, 0, 0, ${p.dark.toFixed(3)})`)})`);\n    set('--od-spec', `linear-gradient(180deg, ${stops((p) => rgba(fin.tint, p.light))})`);\n\n    const e = (n) => `${f3(n)}em`;\n    // In numeral-size units, for the small text on the plate whose own em is tiny.\n    const u = (n) => `calc(var(--od-size) * ${f3(n)})`;\n    const ang = Math.round(o.light + 180);\n    set('--od-lift', e(opticalLift(getComputedStyle(this.root))));\n    // Diamond-cut chamfers: the window's walls and the plate's edge are cut\n    // through the finish to bare metal, each side lit by the lamp.\n    // Each side takes its own tone from its angle to the lamp; over that, the\n    // specular hot spot, brightest at one corner and gone by the middle.\n    const cut = chamfers(o.light, plate);\n    set('--od-recess', cut.recess.join(' '));\n    set('--od-raise', cut.raise.join(' '));\n    // The hot spot is the finish's own spec (white unless it says otherwise), and the shadows fall as hard as its object shadow says.\n    const hotC = fin.hot ?? '255, 255, 255';\n    const sk = fin.shade ?? 1;\n    const hot = (deg) => `linear-gradient(${deg}deg, rgba(${hotC}, 0.62) 0%, rgba(${hotC}, 0.22) 22%, rgba(${hotC}, 0) 52%)`;\n    set('--od-raise-hot', hot(ang));\n    set('--od-recess-hot', hot(Math.round(o.light)));\n    // Edges facing the lamp are lit, the far ones dark; shadows fall away from it.\n    set('--od-rim', `linear-gradient(90deg, rgba(${lx < 0 ? '255, 255, 255' : '0, 0, 0'}, ${f3(0.1 + 0.12 * Math.abs(lx))}) 0, transparent 9%, transparent 91%, rgba(${lx < 0 ? '0, 0, 0' : '255, 255, 255'}, ${f3(0.1 + 0.12 * Math.abs(lx))}) 100%)`);\n    // A plate on a surface: a tight contact shadow, then the soft one the lamp throws.\n    set('--od-plate-shadow', [\n      `${e(-lx * 0.012)} ${e(-ly * 0.012)} ${e(0.018)} rgba(0, 0, 0, ${f3(clamp(0.5 * sk, 0, 1))})`,\n      `${e(-lx * 0.05)} ${e(-ly * 0.05)} ${e(0.1)} rgba(0, 0, 0, ${f3(clamp(0.26 * sk, 0, 1))})`,\n      `${e(-lx * 0.16)} ${e(-ly * 0.16)} ${e(0.42)} rgba(0, 0, 0, ${f3(clamp(0.3 * sk, 0, 1))})`,\n    ].join(', '));\n    // Brushed metal lights as a band across its grain, on the lamp's side, and\n    // falls off away from the lamp.\n    const band = Math.round(50 + lx * 26);\n    set('--od-plate-sheen', [\n      `linear-gradient(90deg, rgba(255, 255, 255, 0) ${band - 26}%, rgba(255, 255, 255, 0.075) ${band}%, rgba(255, 255, 255, 0) ${band + 26}%)`,\n      `linear-gradient(${ang}deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.03) 36%, rgba(0, 0, 0, 0.04) 60%, rgba(0, 0, 0, 0.26))`,\n    ].join(', '));\n    set('--od-chamfer', [\n      `${e(-lx * 0.016)} ${e(-ly * 0.016)} 0 rgba(255, 255, 255, 0.1)`,\n      `${e(lx * 0.016)} ${e(ly * 0.016)} 0 rgba(0, 0, 0, 0.45)`,\n    ].join(', '));\n    // The window's own walls: the lip on the lamp side throws a shadow onto\n    // the drums, the far wall catches a thread of light. Then the cover\n    // glass's edge: a bright rim where it meets the frame, a dark refraction\n    // band just inside it, and the green of float glass seen through its\n    // thickness.\n    set('--od-wall', [\n      `inset ${e(-lx * 0.05)} ${e(-ly * 0.05)} ${e(0.07)} rgba(0, 0, 0, 0.66)`,\n      `inset ${e(lx * 0.012)} ${e(ly * 0.012)} 0 rgba(255, 255, 255, 0.1)`,\n      `inset 0 0 0 ${e(0.007)} rgba(255, 255, 255, 0.12)`,\n      `inset 0 0 0 ${e(0.022)} rgba(0, 0, 0, 0.2)`,\n      `inset 0 0 ${e(0.07)} ${e(0.018)} rgba(120, 170, 150, 0.1)`,\n    ].join(', '));\n    // The cover glass: the lamp's reflection is a softbox, a pane of light\n    // with a clean far edge, lying across the lamp's corner of the glass; a\n    // faint second pane from the room; and a sliver of the lamp along the\n    // glass's lamp-side edges, seen through the glass's thickness.\n    set('--od-glass', [\n      `linear-gradient(${ang}deg, rgba(255, 255, 255, 0.02) 0%, rgba(255, 255, 255, 0.12) 17%, rgba(255, 255, 255, 0.05) 31%, rgba(255, 255, 255, 0) 31.6%)`,\n      `linear-gradient(${ang}deg, rgba(255, 255, 255, 0) 52%, rgba(255, 255, 255, 0.028) 53%, rgba(255, 255, 255, 0.012) 60%, rgba(255, 255, 255, 0) 60.5%)`,\n      `linear-gradient(${ly <= 0 ? 180 : 0}deg, rgba(255, 255, 255, ${f3(0.04 + 0.12 * Math.abs(ly))}), rgba(255, 255, 255, 0) ${e(0.05)})`,\n      `linear-gradient(${lx <= 0 ? 90 : 270}deg, rgba(255, 255, 255, ${f3(0.02 + 0.08 * Math.abs(lx))}), rgba(255, 255, 255, 0) ${e(0.04)})`,\n    ].join(', '));\n    // Paint-filled engraving: the lip nearest the lamp shades the groove,\n    // the far wall catches the light.\n    set('--od-engrave', `${u(-lx * 0.009)} ${u(-ly * 0.009)} 0 rgba(255, 255, 255, 0.22), ${u(lx * 0.007)} ${u(ly * 0.007)} 0 rgba(0, 0, 0, 0.55)`);\n    set('--od-groove', `inset ${u(lx * 0.006)} ${u(ly * 0.006)} 0 rgba(0, 0, 0, 0.6), inset ${u(-lx * 0.006)} ${u(-ly * 0.006)} 0 rgba(255, 255, 255, 0.2)`);\n    set('--od-screw-hl', `${Math.round(50 + lx * 30)}% ${Math.round(50 + ly * 30)}%`);\n    set('--od-screw-sink', `inset ${e(lx * 0.012)} ${e(ly * 0.012)} ${e(0.014)} rgba(0, 0, 0, 0.75), inset ${e(-lx * 0.008)} ${e(-ly * 0.008)} 0 rgba(255, 255, 255, 0.16)`);\n    set('--od-screw-shadow', `${e(-lx * 0.01)} ${e(-ly * 0.01)} ${e(0.014)} rgba(0, 0, 0, 0.7)`);\n\n    // One camera for the whole window: each drum's vanishing point is the\n    // window's centre, so the outer drums are seen very slightly from the side.\n    const px = parseFloat(getComputedStyle(this.root).fontSize) || 72;\n    const mid = this.window.offsetWidth / 2;\n    for (const d of this.drums) {\n      if (d) d.rot.style.perspectiveOrigin = `${f3((mid - d.cell.offsetLeft) / px)}em 50%`;\n    }\n  }\n\n  /**\n   * Fit mode fills the host's box; a fixed size shrinks only to fit its\n   * width. The host is measured with the counter taken out of it: a host that\n   * takes its size from its content has none of its own, and the counter must\n   * not chase itself — it falls back to 72px numerals.\n   */\n  #fit() {\n    if (!this.root.isConnected) return;\n    const host = this.host;\n    const cs = getComputedStyle(host);\n    const pad = (k) => parseFloat(cs[k]) || 0;\n    const now = parseFloat(this.root.style.getPropertyValue('--od-size')) || 72;\n    const perW = this.root.offsetWidth / now;\n    const perH = this.root.offsetHeight / now;\n    let want;\n    if (this.o.size === 'fit') {\n      const shown = this.root.style.display;\n      this.root.style.display = 'none';\n      const w = host.clientWidth - pad('paddingLeft') - pad('paddingRight');\n      const h = host.clientHeight - pad('paddingTop') - pad('paddingBottom');\n      this.root.style.display = shown;\n      want = fitSize(w, h, perW, perH);\n    } else {\n      const avail = host.clientWidth - pad('paddingLeft') - pad('paddingRight');\n      want = avail > 0 && perW > 0 ? Math.min(this.o.size, Math.floor((avail / perW) * 10) / 10) : this.o.size;\n    }\n    if (Math.abs(want - now) > 0.05 || !this.root.style.getPropertyValue('--od-size')) {\n      this.root.style.setProperty('--od-size', `${Math.max(8, want)}px`);\n    }\n  }\n\n  /** More drums (or a sign plate) the moment a travelling value needs them. */\n  #grow() {\n    const need = Math.min(MAX_DRUMS, Math.max(drumsFor(this.target, this.o.decimals), drumsFor(this.s.x, this.o.decimals)));\n    const signed = this.target < 0 || this.s.x < 0;\n    if (need > this.count_ || (signed && !this.signed)) this.#build();\n  }\n\n  /** And fewer once it has landed, never below the reserved `digits`. */\n  #shrink() {\n    const need = Math.min(MAX_DRUMS, Math.max(this.o.digits + this.o.decimals, drumsFor(this.target, this.o.decimals)));\n    if (need < this.count_ || (this.signed && this.target >= 0)) this.#build();\n  }\n\n  // ---------------------------------------------------------------- drawing\n\n  #paint(dt) {\n    const o = this.o;\n    const x = this.s.x;\n    const pos = drumPositions(x, this.count_, o.decimals);\n    const lsdSpeed = Math.abs(this.s.v) * 10 ** o.decimals;\n    // |x| is what the drums show, so below zero they turn the other way.\n    const dir = Math.sign(this.s.v) * (x < 0 ? -1 : 1);\n    const cap = o.maxSpin;\n    const blanks = o.zeros ? null : blankZeros(x, this.count_, o.decimals);\n    let moving = false;\n    for (const d of this.drums) {\n      const speed = lsdSpeed / 10 ** d.k;\n      const r = spin(d.phase, pos[d.k] + d.offset, speed, dir, cap, dt);\n      let want;\n      if (r.free) want = 1;\n      else {\n        // A carry is fast even when the value is slow: measure what the drum\n        // actually did this frame, so a flick over is smeared too.\n        const moved = dt > 0 && Number.isFinite(d.shown) ? Math.abs(wrapDelta(r.pos - d.shown)) / dt : 0;\n        want = d.free ? 1 : smear(Math.max(speed, moved), cap);\n      }\n      d.free = r.free;\n      d.phase = r.pos;\n      d.blur = want >= d.blur || dt === 0 ? want : d.blur + (want - d.blur) * (1 - Math.exp(-dt / 0.07));\n      if (d.blur < 0.01) d.blur = 0;\n      if (d.blur) moving = true;\n      if (!(Math.abs(r.pos - d.shown) < 1e-5)) {\n        turn(d.faces, r.pos);\n        d.shown = r.pos;\n      }\n      const b = Math.round(d.blur * 50) / 50;\n      if (b !== d.b) {\n        d.rot.style.setProperty('--b', String(b));\n        d.b = b;\n      }\n      const blank = blanks ? blanks[d.k] : false;\n      if (blank !== d.blank) {\n        d.zero.classList.toggle('od-blank', blank);\n        d.blank = blank;\n      }\n    }\n    for (const sep of this.seps) {\n      const shown = !blanks || !blanks[sep.k];\n      if (shown !== sep.shown) {\n        sep.el.classList.toggle('od-off', !shown);\n        sep.shown = shown;\n      }\n    }\n    if (this.signEl) this.signEl.classList.toggle('od-off', !(x < 0 || (x === 0 && this.target < 0)));\n    return moving;\n  }\n\n  /** Announced politely unless counting (a tally is kept current, not read out) or told not to. */\n  #live() {\n    this.text.setAttribute('aria-live', this.counting || !this.o.announce ? 'off' : 'polite');\n  }\n\n  /** Politely, and only a landed value: never a frame's worth of digits. */\n  #announce() {\n    const t = formatValue(this.target, this.style, this.o.currency + this.o.prefix, this.o.suffix);\n    if (this.text.textContent !== t) this.text.textContent = t;\n  }\n\n  // ---------------------------------------------------------------- the loop\n\n  #countTarget(now) {\n    const c = this.counting;\n    const lsd = 10 ** -this.o.decimals;\n    const steps = Math.floor((Math.abs(c.rate) * (now - c.t0)) / 1000 / lsd + 1e-9);\n    return this.#clampValue(c.base + Math.sign(c.rate) * steps * lsd);\n  }\n\n  /** Counting under reduced motion: the tally still advances, by jumps, with no frames. */\n  #restartCount() {\n    clearInterval(this.timer);\n    this.timer = 0;\n    if (!this.counting || !this.reduced) return;\n    const lsd = 10 ** -this.o.decimals;\n    const every = Math.max(100, (lsd / Math.abs(this.counting.rate)) * 1000);\n    this.timer = setInterval(() => {\n      this.target = this.#countTarget(performance.now());\n      this.s.x = this.target;\n      this.#grow();\n      this.#paint(0);\n      this.text.textContent = formatValue(this.target, this.style, this.o.currency + this.o.prefix, this.o.suffix);\n    }, every);\n  }\n\n  #frame = (t) => {\n    this.raf = 0;\n    const dt = this.last ? (t - this.last) / 1000 : 1 / 60;\n    this.last = t;\n    const o = this.o;\n    if (this.counting) {\n      const next = this.#countTarget(performance.now());\n      if (next !== this.target) {\n        this.target = next;\n        this.#grow();\n      }\n      // Kept current for anyone who reads it, announced to no one.\n      if (t - this.lastText > 1000) {\n        this.lastText = t;\n        this.text.textContent = formatValue(this.target, this.style, o.currency + o.prefix, o.suffix);\n      }\n    }\n    stepSpring(this.s, this.target, dt, o.stiffness, o.damping);\n    const done = !this.counting && landed(this.s, this.target, o.decimals);\n    if (done) {\n      this.s.x = this.target;\n      this.s.v = 0;\n    }\n    const n = Math.floor(scaled(this.s.x, o.decimals));\n    if (n !== this.lastInt) {\n      this.lastInt = n;\n      this.#tick(Math.abs(this.s.v) * 10 ** o.decimals);\n    }\n    const smeared = this.#paint(dt);\n    if (done && !smeared) {\n      this.#shrink();\n      this.#paint(0);\n      this.#announce();\n      this.#sleep();\n      return;\n    }\n    // A slow tally has landed its step and the next is a while off: sleep\n    // until it is due instead of drawing still drums at 60 Hz.\n    if (this.counting && !smeared && landed(this.s, this.target, o.decimals)) {\n      const now = performance.now();\n      const wait = nextStepAt(this.counting.t0, now, this.counting.rate, o.decimals) - now;\n      if (wait > 60) {\n        this.s.x = this.target;\n        this.s.v = 0;\n        this.#paint(0);\n        this.text.textContent = formatValue(this.target, this.style, o.currency + o.prefix, o.suffix);\n        this.#sleep();\n        this.stepTimer = setTimeout(() => { this.stepTimer = 0; this.#wake(); }, wait);\n        return;\n      }\n    }\n    if (!this.visible || document.hidden) this.#sleep();\n    else this.raf = requestAnimationFrame(this.#frame);\n  };\n\n  #wake() {\n    clearTimeout(this.stepTimer);\n    this.stepTimer = 0;\n    if (this.reduced || this.raf || !this.visible || document.hidden) return;\n    const idle = !this.counting && landed(this.s, this.target, this.o.decimals) && this.drums.every((d) => !d.blur);\n    if (idle) return;\n    this.root.dataset.state = 'running';\n    this.last = 0;\n    this.raf = requestAnimationFrame(this.#frame);\n  }\n\n  #sleep() {\n    cancelAnimationFrame(this.raf);\n    clearTimeout(this.stepTimer);\n    this.stepTimer = 0;\n    this.raf = 0;\n    this.root.dataset.state = 'asleep';\n  }\n\n  // ---------------------------------------------------------------- sound\n\n  /** The audio context may only start inside a user gesture, so wait for one. */\n  #listenForGesture() {\n    if (this.audio || this.listening) return;\n    this.listening = true;\n    addEventListener('pointerdown', this.on.gesture, true);\n    addEventListener('keydown', this.on.gesture, true);\n  }\n\n  #stopListening() {\n    if (!this.listening) return;\n    this.listening = false;\n    removeEventListener('pointerdown', this.on.gesture, true);\n    removeEventListener('keydown', this.on.gesture, true);\n  }\n\n  #armAudio() {\n    this.#stopListening();\n    try {\n      const Ctx = globalThis.AudioContext ?? globalThis.webkitAudioContext;\n      if (!Ctx || this.audio) return;\n      this.audio = new Ctx();\n      const len = Math.floor(this.audio.sampleRate * 0.016);\n      this.noise = this.audio.createBuffer(1, len, this.audio.sampleRate);\n      const ch = this.noise.getChannelData(0);\n      for (let i = 0; i < len; i += 1) ch[i] = (Math.random() * 2 - 1) * (1 - i / len) ** 4;\n    } catch { /* no audio device: the counter must still count */ }\n  }\n\n  /** A soft tick per step of the last drum, never more than one per 45 ms; a spin whirrs rather than rattles. */\n  #tick(speed) {\n    if (!this.o.sound || !this.audio || this.audio.state !== 'running') return;\n    const now = performance.now();\n    if (now - this.lastTick < 45) return;\n    this.lastTick = now;\n    try {\n      const ctx = this.audio;\n      const src = ctx.createBufferSource();\n      src.buffer = this.noise;\n      src.playbackRate.value = 0.9 + Math.random() * 0.2;\n      const band = ctx.createBiquadFilter();\n      band.type = 'bandpass';\n      band.frequency.value = 1900;\n      band.Q.value = 3.2;\n      const gain = ctx.createGain();\n      gain.gain.value = 0.16 / (1 + speed / 30);\n      src.connect(band).connect(gain).connect(ctx.destination);\n      src.start();\n    } catch { /* never let sound break the display */ }\n  }\n}\n\nexport default Odometer;\n"},{"path":"tactile/odometer/odometer.css","type":"registry:file","target":"tactile/odometer/odometer.css","content":"/* Odometer — TACTILE UI.\n   The object sizes itself from its numeral size (--od-size, set by the\n   component: filling its host in fit mode, or from the `size` option). Every\n   length below is in em of that size, so the drum geometry scales as one\n   piece. Lamp-dependent values (--od-shade, --od-spec, --od-wall, …) are\n   written by the component from the `light` option. */\n\n/* The drums are printed in Big Shoulders Bold (SIL OFL 1.1, see\n   BigShoulders-OFL.txt beside this file): the same figures on every platform.\n   `block`: until the face is in, the drums show no figures rather than a\n   fallback that jumps when it arrives. */\n@font-face {\n  font-family: 'Odometer Figures';\n  src: url('./big-shoulders-bold.woff2') format('woff2'), url('https://tactileui.dev/originals/components/odometer/big-shoulders-bold.woff2') format('woff2');\n  font-weight: 100 900;\n  font-style: normal;\n  font-display: block;\n}\n\n.od {\n  --od-size: 72px;\n  --od-face: 1.12em;   /* one face: the chord between two numerals */\n  --od-r: 1.7235em;    /* ten faces: radius = face / (2 tan 18°) */\n  --od-win: 1.56em;    /* the window shows ±27° of the drum */\n  --od-w: 0.6em;       /* drum width: a condensed figure on a narrow drum */\n  /* Printed stock is never a flat fill: a fine static grain, blended over the drum colour. */\n  --od-grain: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0.5 0.3 0.2 0 0  0.5 0.3 0.2 0 0  0.5 0.3 0.2 0 0  0 0 0 0 0.42'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E\");\n  /* Brushing: long fine streaks along the plate. */\n  --od-brushed: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='120'%3E%3Cfilter id='b'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.0022 0.95' numOctaves='3' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0.6 0.2 0.2 0 0.08  0.6 0.2 0.2 0 0.08  0.6 0.2 0.2 0 0.08  0 0 0 0 0.6'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23b)'/%3E%3C/svg%3E\");\n  position: relative;\n  display: inline-block;\n  width: max-content;\n  vertical-align: middle;\n  font-size: var(--od-size);\n  line-height: 1;\n  font-family: 'Odometer Figures', Bahnschrift, 'DIN Alternate', 'DIN Condensed', 'Barlow Semi Condensed', 'Roboto Condensed', 'Arial Narrow', sans-serif;\n  font-weight: 700;\n  font-stretch: 87.5%;\n  font-synthesis: none;\n  font-variant-numeric: lining-nums;\n  font-kerning: none;\n  -webkit-font-smoothing: antialiased;\n}\n\n/* The number, as text. Hidden from sight, read by everything else. */\n.od-text {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  margin: -1px;\n  overflow: hidden;\n  clip-path: inset(50%);\n  white-space: nowrap;\n}\n\n/* The housing: a machined plate the window is cut into. Window in the\n   middle column, a printed prefix and suffix either side, an engraved label\n   under the window. */\n.od-plate {\n  position: relative;\n  display: grid;\n  grid-template-columns: auto auto auto;\n  align-items: center;\n  padding: 0.2em 0.2em;\n  border: 0.028em solid;\n  border-color: var(--od-raise);\n  border-radius: 0.11em;\n  color: var(--od-plate-ink);\n  background:\n    var(--od-plate-sheen),\n    var(--od-brushed),\n    var(--od-metal);\n  background-origin: border-box;\n  background-size: 100% 100%, 100% 100%, 600px 120px, auto;\n  background-blend-mode: normal, normal, overlay, normal;\n  box-shadow: var(--od-plate-shadow), inset 0 0 0 0.006em rgb(0 0 0 / 0.35);\n  -webkit-user-select: none;\n  user-select: none;\n}\n/* Room at each end for a screw. */\n.od[data-bezel='slot'] .od-plate,\n.od[data-bezel='cells'] .od-plate { padding-inline: 0.42em; }\n.od-window { grid-column: 2; grid-row: 1; }\n\n/* The chamfers catch the lamp hardest at the corner nearest it (the plate's\n   edge) or farthest from it (the window's walls, which face back toward it):\n   a specular falloff laid over each side's own tone. The window's ring is\n   the plate's: an absolutely placed grid item takes the window's grid area as\n   its box, and the window itself clips its drums. */\n.od-plate::before,\n.od-plate::after {\n  content: '';\n  position: absolute;\n  z-index: 3;\n  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);\n  -webkit-mask-composite: xor;\n  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);\n  pointer-events: none;\n}\n.od-plate::before {\n  inset: -0.028em;\n  padding: 0.028em;\n  border-radius: inherit;\n  background: var(--od-raise-hot);\n}\n.od-plate::after {\n  grid-column: 2 / 3; /* an absolute item's auto end line would be the padding edge */\n  grid-row: 1 / 2;\n  inset: 0;\n  padding: 0.036em;\n  border-radius: 0.055em;\n  background: var(--od-recess-hot);\n}\n.od[data-bezel='bare'] .od-plate::before,\n.od[data-bezel='bare'] .od-plate::after,\n.od[data-bezel='cells'] .od-plate::after { display: none; }\n\n/* A finish that glows (data-glow, with --od-glow from 0 to 1) lights its figures and its engraving from within, and traces the housing's edge: the\n   glow is each part's own colour, so the signal drum glows red. Without data-glow nothing here applies. */\n.od[data-glow] .od-n,\n.od[data-glow] .od-glyph {\n  text-shadow:\n    0 0 0.05em color-mix(in srgb, currentColor calc(var(--od-glow) * 100%), transparent),\n    0 0 0.16em color-mix(in srgb, currentColor calc(var(--od-glow) * 55%), transparent);\n}\n.od[data-glow] :is(.od-prefix, .od-suffix, .od-label) {\n  text-shadow: var(--od-engrave), 0 0 0.35em color-mix(in srgb, currentColor calc(var(--od-glow) * 90%), transparent);\n}\n.od[data-glow]:not([data-bezel='bare']) .od-plate {\n  box-shadow:\n    var(--od-plate-shadow),\n    inset 0 0 0 0.006em rgb(0 0 0 / 0.35),\n    0 0 0.07em 0.006em color-mix(in srgb, var(--od-edge) calc(var(--od-glow) * 75%), transparent);\n}\n\n/* A countersunk screw: the sink cut into the plate, the domed head in it,\n   the slot across the head. */\n.od-screw {\n  position: absolute;\n  top: 50%;\n  width: 0.17em;\n  height: 0.17em;\n  margin-top: -0.085em;\n  border-radius: 50%;\n  background: color-mix(in srgb, var(--od-metal-dark) 70%, var(--od-metal));\n  box-shadow: var(--od-screw-sink);\n}\n.od-screw-l { left: calc(0.21em - 0.085em); }\n.od-screw-r { right: calc(0.21em - 0.085em); }\n.od-screw::before {\n  content: '';\n  position: absolute;\n  inset: 0.022em;\n  border-radius: 50%;\n  background:\n    radial-gradient(circle at var(--od-screw-hl), rgb(255 255 255 / 0.9) 0, rgb(255 255 255 / 0) 34%),\n    radial-gradient(circle at var(--od-screw-hl), var(--od-screw) 0, color-mix(in srgb, var(--od-screw) 55%, #000) 78%, color-mix(in srgb, var(--od-screw) 30%, #000) 100%);\n  box-shadow: var(--od-screw-shadow);\n}\n.od-screw::after {\n  content: '';\n  position: absolute;\n  left: 0.032em;\n  right: 0.032em;\n  top: 50%;\n  height: 0.024em;\n  margin-top: -0.012em;\n  border-radius: 0.01em;\n  background: rgb(0 0 0 / 0.78);\n  box-shadow: 0 0.005em 0 rgb(255 255 255 / 0.28);\n  transform: rotate(var(--od-slot, 30deg));\n}\n\n.od-prefix,\n.od-suffix {\n  color: var(--od-plate-ink);\n  text-shadow: var(--od-engrave);\n  white-space: nowrap;\n}\n.od-prefix {\n  grid-column: 1;\n  grid-row: 1;\n  position: relative;\n  top: var(--od-lift, 0);\n  font-size: 0.6em;\n  padding-inline: 0 0.2em;\n}\n.od-suffix {\n  grid-column: 3;\n  grid-row: 1;\n  align-self: end;\n  font-size: 0.24em;\n  letter-spacing: 0.14em;\n  text-transform: uppercase;\n  padding-inline: 0.55em 0;\n  margin-bottom: 0.9em;\n}\n.od-suffix.od-mark {\n  /* A symbol after the number (€, %) is set like the prefix, not as a label. */\n  position: relative;\n  top: var(--od-lift, 0);\n  align-self: center;\n  font-size: 0.6em;\n  letter-spacing: 0;\n  text-transform: none;\n  padding-inline: 0.2em 0;\n  margin-bottom: 0;\n}\n\n/* The engraved label strip: letters cut into the plate and filled with\n   paint, ruled out to the window's edges. */\n.od-label {\n  grid-column: 2;\n  grid-row: 2;\n  /* The window's width, never more: a label longer than the window must not\n     widen its column (that would open a gap inside the window). It overflows\n     both ways instead, centred. */\n  width: 0;\n  min-width: 100%;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  gap: 0.7em;\n  margin-top: 0.55em;\n  margin-bottom: -0.15em;\n  font-size: 0.2em;\n  font-weight: 700;\n  letter-spacing: 0.3em;\n  text-transform: uppercase;\n  white-space: nowrap;\n  color: var(--od-plate-ink);\n  text-shadow: var(--od-engrave);\n}\n.od-label-t { margin-right: -0.3em; } /* the tracking after the last letter is not space */\n.od-label::before,\n.od-label::after {\n  content: '';\n  flex: 1 1 0;\n  min-width: 1em;\n  height: 0.12em;\n  border-radius: 0.1em;\n  background: color-mix(in srgb, var(--od-plate-ink) 55%, transparent);\n  box-shadow: var(--od-groove);\n}\n\n/* The window: a slot in the plate, with the drums behind it. */\n.od-window {\n  position: relative;\n  display: flex;\n  height: var(--od-win);\n  padding: 0 0.045em;\n  gap: 0.04em;\n  background: #050506;\n  border: 0.036em solid;\n  border-color: var(--od-recess);\n  border-radius: 0.055em;\n  overflow: hidden;\n  box-shadow: var(--od-chamfer);\n}\n\n/* Glass over it: the lamp's reflection, the refracting edge, the window's walls. */\n.od-glass,\n.od-lens {\n  position: absolute;\n  inset: 0;\n  z-index: 2;\n  pointer-events: none;\n  border-radius: inherit;\n  background: var(--od-glass);\n  box-shadow: var(--od-wall);\n}\n.od-lens { display: none; }\n\n/* One drum: ten printed figures around an axle, seen through the window. The\n   drum's surface is the cell (a cylinder's colour does not turn); the faces\n   carry only ink, so a smeared figure can run into the next without a seam. */\n.od-cell {\n  position: relative;\n  flex: none;\n  width: var(--od-w);\n  background: var(--od-rim), var(--od-grain), var(--od-drum);\n  background-size: auto, 140px 140px, auto;\n  background-blend-mode: normal, overlay, normal;\n}\n/* Flat, with perspective: each face carries its own whole transform. */\n.od-rot {\n  position: absolute;\n  left: 0;\n  right: 0;\n  top: 50%;\n  height: var(--od-face);\n  margin-top: calc(var(--od-face) / -2);\n  perspective: 16em;\n}\n.od-face {\n  position: absolute;\n  inset: 0;\n  display: grid;\n  place-items: center;\n  backface-visibility: hidden;\n  color: var(--od-figure);\n}\n.od-ink {\n  position: relative;\n  font-size: 0.92em;\n  top: var(--od-lift, 0);\n  display: grid;\n  place-items: center;\n  opacity: var(--ink, 1);\n  transition: opacity 0.18s;\n}\n.od-blank .od-ink { opacity: 0; }\n.od-n,\n.od-m { grid-area: 1 / 1; }\n.od-n { opacity: calc(1 - var(--b, 0)); }\n/* The same figure smeared along the turn: shown as the drum speeds up. Long\n   enough that, at full speed, one figure's streak meets the next one's. */\n.od-m {\n  --s1: color-mix(in srgb, var(--od-figure) 6%, transparent);\n  --s2: color-mix(in srgb, var(--od-figure) 11%, transparent);\n  --s3: color-mix(in srgb, var(--od-figure) 16%, transparent);\n  --s4: color-mix(in srgb, var(--od-figure) 20%, transparent);\n  opacity: var(--b, 0);\n  color: transparent;\n  text-shadow:\n    0 -0.48em 0.1em var(--s1), 0 -0.4em 0.09em var(--s2), 0 -0.32em 0.08em var(--s3),\n    0 -0.24em 0.07em var(--s4), 0 -0.16em 0.06em var(--s4), 0 -0.08em 0.055em var(--s4),\n    0 0 0.05em var(--s4),\n    0 0.08em 0.055em var(--s4), 0 0.16em 0.06em var(--s4), 0 0.24em 0.07em var(--s4),\n    0 0.32em 0.08em var(--s3), 0 0.4em 0.09em var(--s2), 0 0.48em 0.1em var(--s1);\n}\n\n/* Light that does not turn: the drum rolls under it. */\n.od-cell::after,\n.od-sep::after {\n  content: '';\n  position: absolute;\n  inset: 0;\n  pointer-events: none;\n  background: var(--od-spec), var(--od-shade);\n}\n\n/* The signal drum: the classic odometer tenths. */\n.od-red {\n  --od-drum: var(--od-signal);\n  --od-figure: var(--od-signal-figure);\n}\n\n/* Fixed plates between drums: group marks, the decimal point, the sign. */\n.od-sep {\n  position: relative;\n  flex: none;\n  display: grid;\n  place-items: center;\n  width: 0.22em;\n  background: var(--od-rim), var(--od-grain), var(--od-drum);\n  background-size: auto, 140px 140px, auto;\n  background-blend-mode: normal, overlay, normal;\n  color: var(--od-figure);\n}\n.od-sign { width: 0.4em; }\n/* The currency drum: a wheel as wide as a digit, its finish a step toward its own figure (lighter on ink, darker on bone), so it reads as part of the counter yet apart from the drums that turn. */\n.od-currency {\n  width: var(--od-w);\n  background-image: var(--od-rim), var(--od-grain), linear-gradient(color-mix(in srgb, var(--od-drum) 78%, var(--od-figure)), color-mix(in srgb, var(--od-drum) 78%, var(--od-figure)));\n}\n.od-glyph { font-size: 0.92em; position: relative; top: var(--od-lift, 0); transition: opacity 0.18s, transform 0.18s; }\n.od-off .od-glyph { opacity: 0; }\n.od-sign.od-off .od-glyph { transform: rotateX(90deg); }\n\n/* A window per drum, like a tally counter. */\n.od[data-bezel='cells'] .od-window {\n  background: none;\n  border: 0;\n  overflow: visible;\n  box-shadow: none;\n  padding: 0;\n  gap: 0.1em;\n}\n.od[data-bezel='cells'] .od-glass { display: none; }\n.od[data-bezel='cells'] .od-cell {\n  overflow: hidden;\n  border: 0.03em solid;\n  border-color: var(--od-recess);\n  border-radius: 0.06em;\n  box-shadow: var(--od-chamfer);\n}\n.od[data-bezel='cells'] .od-lens { display: block; }\n.od[data-bezel='cells'] .od-sep {\n  background: none;\n  width: 0.2em;\n  color: var(--od-plate-ink);\n  text-shadow: var(--od-engrave);\n}\n.od[data-bezel='cells'] .od-sep::after { display: none; }\n\n/* No housing: the drums alone, to sit in a line of text. */\n.od[data-bezel='bare'] .od-plate {\n  background: none;\n  border: 0;\n  box-shadow: none;\n  padding: 0;\n  color: inherit;\n}\n.od[data-bezel='bare'] .od-prefix,\n.od[data-bezel='bare'] .od-suffix,\n.od[data-bezel='bare'] .od-label {\n  color: inherit;\n  text-shadow: none;\n}\n.od[data-bezel='bare'] .od-label::before,\n.od[data-bezel='bare'] .od-label::after { box-shadow: none; background: currentColor; opacity: 0.35; }\n.od[data-bezel='bare'] .od-prefix { font-size: 0.8em; padding-inline-end: 0.1em; }\n.od[data-bezel='bare'] .od-suffix:not(.od-mark) { font-size: 0.42em; margin-bottom: 0.3em; padding-inline-start: 0.3em; }\n.od[data-bezel='bare'] .od-suffix.od-mark { font-size: 0.8em; }\n.od[data-bezel='bare'] .od-window { border-width: 0.02em; border-radius: 0.08em; }\n\n@media (prefers-reduced-motion: reduce) {\n  .od-ink,\n  .od-glyph { transition: none; }\n}\n"},{"path":"tactile/odometer/BigShoulders-OFL.txt","type":"registry:file","target":"tactile/odometer/BigShoulders-OFL.txt","content":"Copyright 2019 The Big Shoulders Project Authors (https://github.com/xotypeco/big_shoulders)\n\nThis Font Software is licensed under the SIL Open Font License, Version 1.1.\nThis license is copied below, and is also available with a FAQ at:\nhttps://openfontlicense.org\n\n\n-----------------------------------------------------------\nSIL OPEN FONT LICENSE Version 1.1 - 26 February 2007\n-----------------------------------------------------------\n\nPREAMBLE\nThe goals of the Open Font License (OFL) are to stimulate worldwide\ndevelopment of collaborative font projects, to support the font creation\nefforts of academic and linguistic communities, and to provide a free and\nopen framework in which fonts may be shared and improved in partnership\nwith others.\n\nThe OFL allows the licensed fonts to be used, studied, modified and\nredistributed freely as long as they are not sold by themselves. The\nfonts, including any derivative works, can be bundled, embedded, \nredistributed and/or sold with any software provided that any reserved\nnames are not used by derivative works. The fonts and derivatives,\nhowever, cannot be released under any other type of license. The\nrequirement for fonts to remain under this license does not apply\nto any document created using the fonts or their derivatives.\n\nDEFINITIONS\n\"Font Software\" refers to the set of files released by the Copyright\nHolder(s) under this license and clearly marked as such. This may\ninclude source files, build scripts and documentation.\n\n\"Reserved Font Name\" refers to any names specified as such after the\ncopyright statement(s).\n\n\"Original Version\" refers to the collection of Font Software components as\ndistributed by the Copyright Holder(s).\n\n\"Modified Version\" refers to any derivative made by adding to, deleting,\nor substituting -- in part or in whole -- any of the components of the\nOriginal Version, by changing formats or by porting the Font Software to a\nnew environment.\n\n\"Author\" refers to any designer, engineer, programmer, technical\nwriter or other person who contributed to the Font Software.\n\nPERMISSION & CONDITIONS\nPermission is hereby granted, free of charge, to any person obtaining\na copy of the Font Software, to use, study, copy, merge, embed, modify,\nredistribute, and sell modified and unmodified copies of the Font\nSoftware, subject to the following conditions:\n\n1) Neither the Font Software nor any of its individual components,\nin Original or Modified Versions, may be sold by itself.\n\n2) Original or Modified Versions of the Font Software may be bundled,\nredistributed and/or sold with any software, provided that each copy\ncontains the above copyright notice and this license. These can be\nincluded either as stand-alone text files, human-readable headers or\nin the appropriate machine-readable metadata fields within text or\nbinary files as long as those fields can be easily viewed by the user.\n\n3) No Modified Version of the Font Software may use the Reserved Font\nName(s) unless explicit written permission is granted by the corresponding\nCopyright Holder. This restriction only applies to the primary font name as\npresented to the users.\n\n4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font\nSoftware shall not be used to promote, endorse or advertise any\nModified Version, except to acknowledge the contribution(s) of the\nCopyright Holder(s) and the Author(s) or with their explicit written\npermission.\n\n5) The Font Software, modified or unmodified, in part or in whole,\nmust be distributed entirely under this license, and must not be\ndistributed under any other license. The requirement for fonts to\nremain under this license does not apply to any document created\nusing the Font Software.\n\nTERMINATION\nThis license becomes null and void if any of the above conditions are\nnot met.\n\nDISCLAIMER\nTHE FONT SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT\nOF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE\nCOPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nINCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL\nDAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM\nOTHER DEALINGS IN THE FONT SOFTWARE.\n"},{"path":"tactile/odometer-example.html","type":"registry:file","target":"tactile/odometer-example.html","content":"<!doctype html>\n<html lang=\"en\">\n<!-- Odometer v1.1.2: Tactile UI\n     Put this file beside ./odometer/ holding odometer.mjs, odometer.css,\n     big-shoulders-bold.woff2 and BigShoulders-OFL.txt. Serve over HTTP (any\n     static server that knows .woff2). No framework, no build step, no image,\n     no other dependency. -->\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n<title>Odometer</title>\n<link rel=\"stylesheet\" href=\"./odometer/odometer.css\">\n<style>\n  body { margin: 0; min-height: 100vh; display: grid; place-items: center;\n         background: #e5ded0; color: #1b1b1d;\n         font: 15px/1.4 ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif; }\n  /* With size \"fit\" the counter fills this box and follows it as it resizes.\n     With a number it keeps that numeral size and shrinks only to fit. */\n  #counter { width: min(92vw, 960px); height: min(56vh, 420px); display: grid; place-items: center; }\n</style>\n</head>\n<body>\n<div id=\"counter\"></div>\n<script type=\"module\">\nimport { Odometer } from './odometer/odometer.mjs';\n\nconst odo = new Odometer(document.getElementById('counter'), {\n  value: 1099,\n  decimals: 0,\n  prefix: \"\",\n  currency: \"\",\n  suffix: \"\",\n  locale: \"en-US\",\n  grouping: true,\n  digits: 6,\n  zeros: true,\n  finish: \"auto\",\n  red: \"none\",\n  bezel: \"slot\",\n  stiffness: 140,\n  damping: 0.85,\n  maxSpin: 24,\n  count: 0,\n  wear: 0.35,\n  light: 315,\n  size: \"fit\",\n  label: \"\",\n  sound: false,\n});\n\n// odo.setValue(1100)                    roll to a value, carrying like a real counter\n// odo.setValue(1100, { instant: true }) jump without spinning\n// odo.count(1) / odo.count(0)           a live tally (it sleeps between slow steps), and stop it\n// odo.value, odo.update({ finish: 'bone', label: 'Seats left' }), odo.destroy()\n</script>\n</body>\n</html>"},{"path":"tactile/odometer/LICENSE","type":"registry:file","target":"tactile/odometer/LICENSE","content":"MIT License\n\nCopyright (c) 2026 Ciprian Titire\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"}],"docs":"Odometer is in tactile/odometer/. Open tactile/odometer-example.html to see it run; odometer.mjs is the class, odometer.css its look.\nLoad both or it renders unstyled: in a bundler such as Vite, import './tactile/odometer/odometer.css' next to the .mjs import (or link it in plain HTML), then construct it on an element as the example does.\nIts fonts (big-shoulders-bold.woff2) load from https://tactileui.dev until you put them next to the CSS; the piece's download has them: https://tactileui.dev/api/download/cmp.odometer.\nDocs: https://tactileui.dev/objects/odometer","meta":{"id":"cmp.odometer","version":"1.1.2","access":"free","licence":"MIT"}}