diff --git a/scripts/check-site-glyphs.mjs b/scripts/check-site-glyphs.mjs
new file mode 100644
index 0000000..b3ae870
--- /dev/null
+++ b/scripts/check-site-glyphs.mjs
@@ -0,0 +1,227 @@
+// Fails when the site shows a character that none of its self-hosted fonts contain.
+// Such a character falls back to whatever font the visitor's device has, so it can
+// come out in another size or style on each phone. Run: node scripts/check-site-glyphs.mjs
+//
+// It serves site/, walks the page in Chromium at desktop and phone sizes (with a
+// touch screen, so the touch wording is checked too) through every story step and
+// panel, and checks each rendered character against the cmap of the @font-face file
+// its font-family list would use.
+import { createServer } from "node:http";
+import { readFileSync, existsSync, statSync } from "node:fs";
+import { extname, join, normalize } from "node:path";
+import { brotliDecompressSync } from "node:zlib";
+import { chromium } from "playwright-core";
+
+const SITE = new URL("../site/", import.meta.url).pathname;
+
+/* ---------- the characters a woff2 file maps ---------- */
+function readBase128(bytes, at) {
+ let value = 0;
+ for (let n = 0; n < 5; n++) {
+ const b = bytes[at.pos++];
+ value = value * 128 + (b & 0x7f);
+ if (!(b & 0x80)) return value;
+ }
+ throw new Error("bad UIntBase128");
+}
+
+function woff2Codepoints(path) {
+ const file = readFileSync(path);
+ if (file.toString("latin1", 0, 4) !== "wOF2") throw new Error(`${path} is not woff2`);
+ const numTables = file.readUInt16BE(12);
+ const compressedSize = file.readUInt32BE(20);
+ const at = { pos: 48 };
+ const tables = [];
+ for (let t = 0; t < numTables; t++) {
+ const flags = file[at.pos++];
+ const tagIndex = flags & 0x3f;
+ if (tagIndex === 63) at.pos += 4;
+ const version = flags >> 6;
+ const origLength = readBase128(file, at);
+ const glyfOrLoca = tagIndex === 10 || tagIndex === 11;
+ const transformed = glyfOrLoca ? version !== 3 : version !== 0;
+ const length = transformed ? readBase128(file, at) : origLength;
+ tables.push({ tagIndex, length });
+ }
+ const sfnt = brotliDecompressSync(file.subarray(at.pos, at.pos + compressedSize));
+ let offset = 0;
+ for (const table of tables) {
+ if (table.tagIndex === 0) return cmapCodepoints(sfnt, offset);
+ offset += table.length;
+ }
+ throw new Error(`${path} has no cmap`);
+}
+
+function cmapCodepoints(buf, cmap) {
+ const points = new Set();
+ const count = buf.readUInt16BE(cmap + 2);
+ for (let r = 0; r < count; r++) {
+ const sub = cmap + buf.readUInt32BE(cmap + 4 + r * 8 + 4);
+ const format = buf.readUInt16BE(sub);
+ if (format === 4) {
+ const segs = buf.readUInt16BE(sub + 6) / 2;
+ const ends = sub + 14, starts = ends + segs * 2 + 2, deltas = starts + segs * 2, ranges = deltas + segs * 2;
+ for (let s = 0; s < segs; s++) {
+ const end = buf.readUInt16BE(ends + s * 2), start = buf.readUInt16BE(starts + s * 2);
+ const delta = buf.readInt16BE(deltas + s * 2), rangeAt = ranges + s * 2, range = buf.readUInt16BE(rangeAt);
+ for (let c = start; c <= end && c !== 0xffff; c++) {
+ const glyph = range === 0 ? (c + delta) & 0xffff : buf.readUInt16BE(rangeAt + range + (c - start) * 2);
+ if (glyph) points.add(c);
+ }
+ }
+ } else if (format === 12) {
+ const groups = buf.readUInt32BE(sub + 12);
+ for (let g = 0; g < groups; g++) {
+ const start = buf.readUInt32BE(sub + 16 + g * 12), end = buf.readUInt32BE(sub + 20 + g * 12);
+ for (let c = start; c <= end; c++) points.add(c);
+ }
+ }
+ }
+ return points;
+}
+
+/* ---------- which font a character in a given font-family list lands in ---------- */
+const inRanges = (ranges, c) => !ranges || ranges.some(([a, b]) => c >= a && c <= b);
+
+function makeResolver(faces) {
+ const cmaps = new Map();
+ const cmapOf = face => {
+ if (!cmaps.has(face.file)) cmaps.set(face.file, woff2Codepoints(join(SITE, face.file)));
+ return cmaps.get(face.file);
+ };
+ // The face of a family closest to the weight asked for, as the browser picks it.
+ const faceFor = (family, weight) => {
+ const own = faces.filter(f => f.family === family);
+ const distance = f => (weight >= f.weight[0] && weight <= f.weight[1] ? 0 : Math.min(Math.abs(weight - f.weight[0]), Math.abs(weight - f.weight[1])));
+ return own.sort((a, b) => distance(a) - distance(b));
+ };
+ // The self-hosted font that draws c, or null when the device's own fallback would.
+ return (c, families, weight) => {
+ for (const family of families) {
+ const candidates = faceFor(family, weight).filter(f => inRanges(f.ranges, c));
+ if (!candidates.length) {
+ if (faces.some(f => f.family === family)) continue;
+ return null;
+ }
+ if (cmapOf(candidates[0]).has(c)) return candidates[0].file;
+ }
+ return null;
+ };
+}
+
+/* ---------- the page ---------- */
+const TYPES = { ".html": "text/html", ".css": "text/css", ".js": "text/javascript", ".svg": "image/svg+xml", ".woff2": "font/woff2", ".png": "image/png", ".jpg": "image/jpeg" };
+const server = createServer((req, res) => {
+ let path = normalize(join(SITE, decodeURIComponent(new URL(req.url, "http://x").pathname)));
+ if (!path.startsWith(SITE) || !existsSync(path)) { res.writeHead(404).end(); return; }
+ if (statSync(path).isDirectory()) path = join(path, "index.html");
+ res.writeHead(200, { "content-type": TYPES[extname(path)] || "application/octet-stream" });
+ res.end(readFileSync(path));
+});
+await new Promise(done => server.listen(0, "127.0.0.1", done));
+const url = `http://127.0.0.1:${server.address().port}/`;
+
+// Every rendered text run on the page now: its text, font-family list and weight.
+function collectRuns() {
+ const runs = [];
+ const families = s => s.fontFamily.split(",").map(f => f.trim().replace(/^["']|["']$/g, ""));
+ const visible = el => el.checkVisibility ? el.checkVisibility({ visibilityProperty: true }) : true;
+ const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
+ for (let n = walker.nextNode(); n; n = walker.nextNode()) {
+ const el = n.parentElement;
+ if (!n.data.trim() || !el || !visible(el) || el.closest("script, style")) continue;
+ const s = getComputedStyle(el);
+ runs.push({ text: n.data, families: families(s), weight: +s.fontWeight, where: el.className || el.tagName.toLowerCase() });
+ }
+ for (const el of document.querySelectorAll("*")) {
+ for (const pseudo of ["::before", "::after"]) {
+ const s = getComputedStyle(el, pseudo);
+ const m = s.content.match(/^"(.+)"$/);
+ if (m && visible(el)) runs.push({ text: m[1], families: families(s), weight: +s.fontWeight, where: `${el.className || el.tagName.toLowerCase()}${pseudo}` });
+ }
+ }
+ return runs;
+}
+
+function readFaces() {
+ const faces = [];
+ for (const sheet of document.styleSheets) {
+ for (const rule of sheet.cssRules) {
+ if (!(rule instanceof CSSFontFaceRule)) continue;
+ const st = rule.style;
+ const weight = (st.getPropertyValue("font-weight") || "400").split(/\s+/).map(Number);
+ const range = st.getPropertyValue("unicode-range");
+ faces.push({
+ family: st.getPropertyValue("font-family").replace(/^["']|["']$/g, ""),
+ weight: [weight[0], weight[1] ?? weight[0]],
+ file: st.getPropertyValue("src").match(/url\("?([^")]+)"?\)/)[1].replace(location.origin + "/", ""),
+ ranges: range ? range.split(",").map(r => r.trim().replace(/^U\+/i, "").split("-").map(h => parseInt(h, 16))).map(([a, b]) => [a, b ?? a]) : null,
+ });
+ }
+ }
+ return faces;
+}
+
+const browser = await chromium.launch();
+const runs = [];
+let faces;
+const VIEWS = [
+ { name: "desktop", viewport: { width: 1440, height: 900 } },
+ { name: "phone", viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true },
+];
+for (const view of VIEWS) {
+ const page = await browser.newPage(view);
+ const errors = [];
+ page.on("pageerror", e => errors.push(e.message));
+ await page.goto(url);
+ await page.evaluate(() => document.fonts.ready);
+ faces ??= await page.evaluate(readFaces);
+ const grab = async label => { for (const r of await page.evaluate(collectRuns)) runs.push({ ...r, view: `${view.name} ${label}` }); };
+ await grab("top");
+ const steps = await page.evaluate(() => __story.steps.length);
+ for (let i = 0; i < steps; i++) {
+ await page.evaluate(i => __story.steps[i].scrollIntoView({ block: "center" }), i);
+ await page.waitForFunction(i => __story.settled() && __story.active() === i, i, { timeout: 10000 }).catch(() => {});
+ await page.waitForTimeout(150);
+ await grab(`step ${i + 1}`);
+ // Open what each step's panel can show: every lint reason and every trim.
+ for (const sel of ["#storyNote .vk-lint.is-on", "#storyNote [data-trim]"]) {
+ const count = await page.locator(sel).count();
+ for (let k = 0; k < count; k++) {
+ await page.evaluate(([sel, k]) => document.querySelectorAll(sel)[k].click(), [sel, k]);
+ await page.waitForTimeout(100);
+ await grab(`step ${i + 1} after ${sel}`);
+ }
+ }
+ }
+ await page.evaluate(() => document.querySelector(".step:not([hidden]) .step-clip").click());
+ await grab("clip open");
+ if (errors.length) throw new Error(`page errors at ${view.name}: ${errors.join("; ")}`);
+ await page.close();
+}
+await browser.close();
+server.close();
+
+const resolve = makeResolver(faces);
+const missing = new Map();
+const usage = new Map();
+for (const run of runs) {
+ for (const ch of run.text) {
+ const c = ch.codePointAt(0);
+ if (c === 0x0a || c === 0x09 || c === 0x0d) continue;
+ const file = resolve(c, run.families, run.weight);
+ if (file) { usage.set(file, (usage.get(file) || 0) + 1); continue; }
+ const key = `U+${c.toString(16).toUpperCase().padStart(4, "0")} ${ch} in ${run.families[0]} ${run.weight}`;
+ if (!missing.has(key)) missing.set(key, new Set());
+ missing.get(key).add(`${run.where} (${run.view})`);
+ }
+}
+
+console.log(`checked ${runs.length} text runs; characters per font file:`);
+for (const [file, n] of usage) console.log(` ${file}: ${n}`);
+if (missing.size) {
+ console.log(`\n${missing.size} characters fall back to the device's own fonts:`);
+ for (const [key, where] of missing) console.log(` ${key}: ${[...where].slice(0, 3).join("; ")}`);
+ process.exit(1);
+}
+console.log("every character is in the self-hosted font it is set in");
diff --git a/site/index.html b/site/index.html
index 6911713..1747f02 100644
--- a/site/index.html
+++ b/site/index.html
@@ -35,11 +35,19 @@
+
+
+
+
+
+
+
+
@@ -49,7 +57,7 @@
Find the word.
- Hover a dotted word and press ← → , or tap it.
+ Hover a dotted word and press , or click it. Tap the dotted word to try another.
Keep several versions of a word, sentence or paragraph in your note. Swap between them to read each one in place.
Install in Obsidian
@@ -81,7 +89,7 @@
Try it
-
Each step below does one thing to this note. You can click anything in it.
+
Each step below does one thing to this note. You can click anything in it.
@@ -93,44 +101,44 @@
Try it
Versions, in place
Keep another version of a word, a sentence or a paragraph. Swap between them to read each one in place.
- try: click an underlined word
- In Obsidian: ⌘J · watch it
+ try: click an underlined word
+ In Obsidian: J · watch it
Fade, don’t delete
- Fade a sentence instead of deleting it. It stays readable, leaves the word count, and comes back with a click.
- try: click the faded line
- In Obsidian: ⌘. then G · watch it
+ Fade a sentence instead of deleting it. It stays readable, leaves the word count, and comes back with a click.
+ try: click the faded line
+ In Obsidian: . then G · watch it
Keep what you cut
Move a line to Overflow, a side panel kept with the note. Put it back when it fits.
- try: click the ‸ to put it back
- In Obsidian: ⌘. then S · watch it
+ try: click the to put it back
+ In Obsidian: . then S · watch it
Ideas when you’re stuck
Ask AI for a few other ways to say a word or a sentence. They sit next to your own versions, marked with a robot, and you decide what fits. Your note only changes when you pick one.
- try: pick a robot version
- In Obsidian: ⌘⇧J · watch it
+ try: pick a robot version
+ In Obsidian: J · watch it
Lint when you ask
Check your note for hedging, wordy phrases, passive voice and AI-sounding lines. Edit the rules or write your own.
- try: click a wavy line
- In Obsidian: ⌘. then L · watch it
+ try: click a wavy line
+ In Obsidian: . then L · watch it
The Lab
Ask a model to mark typos and weak sentences, or to strike what it would cut. You keep or cut each one.
- try: click a struck phrase
- In Obsidian: ⌘. then T · watch it
+ try: click a struck phrase
+ In Obsidian: . then T · watch it
Read it clean
Hide every marker and read your note the way a reader will.
- try: switch it off
- In Obsidian: ⌘. then R · watch it
+ try: switch it off
+ In Obsidian: . then R · watch it
@@ -144,8 +152,8 @@
Get Vikalp
Install in Obsidian
- 1. In Obsidian, open Settings → Community plugins and search for Vikalp.
- 2. Put the cursor on a word and press ⌘J .
+ 1. In Obsidian, open Settings, then Community plugins, and search for Vikalp.
+ 2. Put the cursor on a word and press J .
3. For AI features, add a key for OpenRouter, Anthropic or OpenAI, or run a model locally with Ollama or LM Studio. Everything else works offline.
@@ -165,6 +173,7 @@ Get Vikalp
+
diff --git a/site/note.js b/site/note.js
index 891149d..fa5c6fb 100644
--- a/site/note.js
+++ b/site/note.js
@@ -4,7 +4,11 @@
createSpan(el, versions, opts) turns an element into a span with versions.
versions: ['a', 'b', 'ai:c'] (an "ai:" prefix marks an AI version)
- opts: { kind, onChange(span), onEnter(span), onLeave(span), disabled() }
+ opts: { kind, glide, onChange(span), onEnter(span), onLeave(span), disabled() }
+ With glide, a swap eases the span's width from the old version to the new one,
+ so the text after it moves along instead of jumping. For a span on one line.
+ A swap fires a bubbling "vk-swap" event on el right away, inside the click or
+ key press that caused it. Only the visitor swaps; nothing in the note does.
createNote(host, data) renders a note and wires every interaction.
data: { title, paragraphs: [[segment, ...], ...] }
@@ -34,12 +38,14 @@ window.Vikalp = (() => {
};
const EASE = 'cubic-bezier(.2, .7, .2, 1)';
const robot = () => ' ';
+ const tap = matchMedia('(hover: none)').matches ? 'Tap' : 'Click';
document.body.insertAdjacentHTML('afterbegin', `
+
`);
- /* ← → go to the focused span, or else the hovered one */
+ /* Left and right arrows go to the focused span, or else the hovered one */
let hovered = null;
document.addEventListener('keydown', e => {
if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return;
@@ -66,7 +72,8 @@ window.Vikalp = (() => {
el.innerHTML = ' ';
const text = el.querySelector('.vk-v-text');
const dots = el.querySelector('.vk-dots');
- let timer = 0;
+ let timer = 0, widthAnim = null;
+ if (opts.glide) el.classList.add('vk-glide');
const paintDots = () => {
dots.innerHTML = versions.map((v, k) => ` `).join('');
@@ -86,7 +93,9 @@ window.Vikalp = (() => {
if (k === span.i) return;
span.prev = span.i;
span.i = k;
+ el.dispatchEvent(new CustomEvent('vk-swap', { bubbles: true }));
paintDots();
+ if (opts.glide) { glide(); return; }
const d = ms('--dur-fast');
clearTimeout(timer);
const done = () => { paintText(); text.classList.remove('is-swapping'); opts.onChange && opts.onChange(span); };
@@ -94,6 +103,32 @@ window.Vikalp = (() => {
text.classList.add('is-swapping');
timer = setTimeout(done, d);
};
+ // The old version lifts out on top while the new one settles in below it, and
+ // the slot between them eases to the new width. A swap during a swap starts
+ // from wherever the width and the fading text are, so nothing jumps.
+ function glide() {
+ const d = ms('--dur-glide');
+ const from = el.getBoundingClientRect().width;
+ const leaving = text.cloneNode(true);
+ leaving.className = 'vk-v-out';
+ leaving.style.opacity = getComputedStyle(text).opacity;
+ if (widthAnim) widthAnim.cancel();
+ text.getAnimations().forEach(a => a.cancel());
+ el.querySelectorAll('.vk-v-out').forEach(o => o.remove());
+ el.style.width = '';
+ paintText();
+ opts.onChange && opts.onChange(span);
+ if (!d) return;
+ const to = el.getBoundingClientRect().width;
+ el.prepend(leaving);
+ const lift = '-0.16em', settle = '0.16em';
+ leaving.animate([{ transform: 'none' }, { opacity: 0, transform: `translateY(${lift})` }], { duration: d * 0.45, easing: 'ease-out', fill: 'forwards' })
+ .finished.then(() => leaving.remove(), () => leaving.remove());
+ text.animate([{ opacity: 0, transform: `translateY(${settle})` }, { opacity: 1, transform: 'none' }], { duration: d * 0.6, delay: d * 0.4, easing: EASE, fill: 'backwards' });
+ widthAnim = el.animate([{ width: from + 'px' }, { width: to + 'px' }], { duration: d, easing: EASE });
+ widthAnim.finished.then(() => { widthAnim = null; }, () => {});
+ }
+
span.step = d => span.set(span.i + d);
span.pick = k => span.set(k);
span.add = v => { versions.push(v); paintDots(); };
@@ -307,7 +342,7 @@ window.Vikalp = (() => {
return r;
}
- // a cut line: in the text, or in Overflow with a red ‸ where it was
+ // a cut line: in the text, or in Overflow with a red caret where it was
r.type = 'cut';
r.live = false;
r.on = false;
@@ -319,7 +354,7 @@ window.Vikalp = (() => {
r.state = state;
el.className = state === 'back' ? 'vk-cut-back' : '';
el.innerHTML = r.on
- ? '‸ '
+ ? ' '
: esc(seg.cut);
}
const caret = el.querySelector('.vk-caret');
@@ -332,8 +367,8 @@ window.Vikalp = (() => {
/* Moving a line to Overflow and back. One motion at a time: the line
leaves as a card that flies to Overflow, then its paragraph closes
- around a ‸. Going back, the paragraph opens a space for the line while
- the card flies to the ‸ and shrinks into it; only once the card is gone
+ around a caret. Going back, the paragraph opens a space for the line while
+ the card flies to the caret and shrinks into it; only once the card is gone
does the line fade in, so the two copies never show at once. */
// Where the line starts in the text, kept inside the note so the card never hangs over the panel.
function spot(el, width) {
@@ -353,7 +388,7 @@ window.Vikalp = (() => {
const left = Math.max(box.left - inset, Math.min(rows[0].left - inset, box.right - size.width + inset));
return { left, top: rows[rows.length - 1].bottom - size.height };
}
- // Where the ‸ stood: the restored line's first character, less the card's inset.
+ // Where the caret stood: the restored line's first character, less the card's inset.
function caretSpot(el, card) {
const row = el.getClientRects()[0];
const style = getComputedStyle(card);
@@ -412,7 +447,7 @@ window.Vikalp = (() => {
}
function renderLint() {
const r = note.lintShown;
- if (!r || !r.live()) { lintBox.innerHTML = ' Click a wavy line to see why it’s marked.
'; return; }
+ if (!r || !r.live()) { lintBox.innerHTML = `
${tap} a wavy line to see why it’s marked.
`; return; }
lintBox.innerHTML = `
${esc(r.seg.rule)}
${esc(r.seg.why)}
` +
(r.seg.fix ? `
` : '');
}
@@ -420,7 +455,7 @@ window.Vikalp = (() => {
host.querySelectorAll('[data-trim]').forEach(b => b.setAttribute('aria-pressed', String(+b.dataset.trim === note.trim)));
const struck = recs.filter(r => r.type === 'strike' && r.struck());
const before = after + struck.reduce((n, r) => n + countWords(r.seg.strike), 0);
- host.querySelector('.vk-trimnums').textContent = note.trim ? `${before} → ${after} words` : 'Pick a trim to see what a model would cut.';
+ host.querySelector('.vk-trimnums').textContent = note.trim ? `${before} words, cut to ${after}` : 'Pick a trim to see what a model would cut.';
}
panel.addEventListener('click', e => {
@@ -447,8 +482,8 @@ window.Vikalp = (() => {
host.querySelector('.vk-wc').textContent = plural(count, 'word', 'words');
host.querySelector('.vk-state').textContent = extra.length ? ' · ' + extra.join(' · ') : '';
host.querySelector('.vk-fadebox').textContent = faded
- ? 'The faded line stays in the note and leaves the word count. Tap it to bring it back.'
- : 'The line is back in the word count. Tap it to fade it again.';
+ ? `The faded line stays in the note and leaves the word count. ${tap} it to bring it back.`
+ : `The line is back in the word count. ${tap} it to fade it again.`;
renderVersions();
renderOverflow();
renderLint();
diff --git a/site/page.js b/site/page.js
index a03fc83..de9cdb2 100644
--- a/site/page.js
+++ b/site/page.js
@@ -1,4 +1,4 @@
-/* Page wiring: the theme toggle, the hero word, the scroll story and the clip lightbox. */
+/* Page wiring: the theme toggle, the swap sound, the hero word, the scroll story and the clip lightbox. */
(() => {
const root = document.documentElement;
const theme = () => (root.dataset.theme === 'dark' ? 'dark' : 'light');
@@ -7,14 +7,22 @@
const wait = d => new Promise(done => setTimeout(done, d));
/* ---------- theme toggle ---------- */
- const themeLabel = document.getElementById('themeLabel');
- const paintThemeLabel = () => { themeLabel.textContent = theme() === 'dark' ? 'Light' : 'Dark'; };
- document.getElementById('themeBtn').addEventListener('click', () => {
+ // The button shows where it goes: a sun in dark mode, a moon in light mode.
+ const themeBtn = document.getElementById('themeBtn');
+ const paintThemeBtn = () => {
+ const label = `Switch to ${theme() === 'dark' ? 'light' : 'dark'} theme`;
+ themeBtn.setAttribute('aria-label', label);
+ themeBtn.title = label;
+ };
+ themeBtn.addEventListener('click', () => {
root.dataset.theme = theme() === 'dark' ? 'light' : 'dark';
try { localStorage.setItem('vk-theme', root.dataset.theme); } catch (e) {}
});
- new MutationObserver(paintThemeLabel).observe(root, { attributes: true, attributeFilter: ['data-theme'] });
- paintThemeLabel();
+ new MutationObserver(paintThemeBtn).observe(root, { attributes: true, attributeFilter: ['data-theme'] });
+ paintThemeBtn();
+
+ /* ---------- a soft tap when the visitor swaps a version ---------- */
+ document.addEventListener('vk-swap', () => VikalpSound.play());
/* ---------- hero: one word, its other versions pencilled above it ---------- */
const heroAlts = document.getElementById('heroAlts');
@@ -30,7 +38,7 @@
return [b];
}));
};
- paintAlts(Vikalp.createSpan(document.getElementById('heroWord'), ['right', 'exact', 'plain', 'true'], { onChange: paintAlts }));
+ paintAlts(Vikalp.createSpan(document.getElementById('heroWord'), ['right', 'exact', 'plain', 'true'], { glide: true, onChange: paintAlts }));
/* ---------- the story's note ---------- */
const noteHost = document.getElementById('storyNote');
@@ -168,8 +176,12 @@
const frame = noteHost.querySelector('.vk-frame');
let active = -1, raf = 0;
+ // Touch screens tap rather than click. Only text is rewritten, so icons in a hint stay.
if (matchMedia('(hover: none)').matches) {
- document.querySelectorAll('.step-try').forEach(p => { p.textContent = p.textContent.replace(/\bclick\b/g, 'tap'); });
+ document.querySelectorAll('.say-tap').forEach(p => {
+ const walker = document.createTreeWalker(p, NodeFilter.SHOW_TEXT);
+ for (let n = walker.nextNode(); n; n = walker.nextNode()) n.data = n.data.replace(/\bclick\b/g, 'tap').replace(/\bClick\b/g, 'Tap');
+ });
}
// The phone caption: a copy of each phone step, stacked in one cell so the
diff --git a/site/sound.js b/site/sound.js
new file mode 100644
index 0000000..95f4f9e
--- /dev/null
+++ b/site/sound.js
@@ -0,0 +1,65 @@
+/* A soft wooden tap when the visitor swaps a version: a short rounded knock with a
+ little paper on top, about 60 ms, peaking near -18 dBFS. Synthesised, so there is
+ no file to load.
+
+ window.VikalpSound = { play() }
+ play() taps once, at most every 60 ms, with a 3% change in pitch either way so
+ repeats don't sound mechanical. Call it only from the visitor's own click or key
+ press: browsers start audio only then, and the page never plays sound by itself. */
+window.VikalpSound = (() => {
+ const GAIN = 0.145;
+ let ctx = null, last = -Infinity, noise = null;
+
+ function envelope(t, attack, decay, peak) {
+ const g = ctx.createGain();
+ g.gain.setValueAtTime(0, t);
+ g.gain.linearRampToValueAtTime(peak, t + attack);
+ g.gain.exponentialRampToValueAtTime(0.0001, t + attack + decay);
+ return g;
+ }
+
+ function tap(pitch) {
+ const t = ctx.currentTime + 0.005;
+ const out = ctx.createGain();
+ out.gain.value = GAIN;
+ const warm = ctx.createBiquadFilter();
+ warm.type = 'lowpass';
+ warm.frequency.value = 2600;
+ warm.connect(out).connect(ctx.destination);
+
+ const knock = ctx.createOscillator();
+ knock.frequency.setValueAtTime(620 * pitch, t);
+ knock.frequency.exponentialRampToValueAtTime(410 * pitch, t + 0.03);
+ knock.connect(envelope(t, 0.002, 0.075, 0.8)).connect(warm);
+ knock.start(t);
+ knock.stop(t + 0.1);
+
+ noise ??= (() => {
+ const b = ctx.createBuffer(1, Math.ceil(ctx.sampleRate * 0.02), ctx.sampleRate);
+ const d = b.getChannelData(0);
+ for (let i = 0; i < d.length; i++) d[i] = Math.random() * 2 - 1;
+ return b;
+ })();
+ const paper = ctx.createBufferSource();
+ paper.buffer = noise;
+ const band = ctx.createBiquadFilter();
+ band.type = 'bandpass';
+ band.frequency.value = 2000 * pitch;
+ band.Q.value = 0.7;
+ paper.connect(band).connect(envelope(t, 0.001, 0.012, 0.35)).connect(warm);
+ paper.start(t);
+ }
+
+ function play() {
+ const now = performance.now();
+ if (now - last < 60) return;
+ last = now;
+ try {
+ ctx ??= new AudioContext();
+ if (ctx.state === 'suspended') ctx.resume();
+ tap(1 + (Math.random() * 2 - 1) * 0.03);
+ } catch (e) {}
+ }
+
+ return { play };
+})();
diff --git a/site/style.css b/site/style.css
index 77e1da9..9668bcf 100644
--- a/site/style.css
+++ b/site/style.css
@@ -65,6 +65,7 @@
--dur-fast: 140ms; /* version crossfade */
--dur: 220ms; /* hovers, small fades */
--dur-slow: 420ms; /* each story change */
+ --dur-glide: 260ms; /* the hero word's slot easing to a new width */
--ease: cubic-bezier(.2, .7, .2, 1);
}
:root[data-theme="dark"] {
@@ -97,10 +98,10 @@
--grain-blend: soft-light;
}
@media (prefers-reduced-motion: reduce) {
- :root { --dur-fast: 0ms; --dur: 0ms; --dur-slow: 0ms; }
+ :root { --dur-fast: 0ms; --dur: 0ms; --dur-slow: 0ms; --dur-glide: 0ms; }
}
/* the story skipping past several steps at once */
-:root.vk-instant { --dur-fast: 0ms; --dur: 0ms; --dur-slow: 0ms; }
+:root.vk-instant { --dur-fast: 0ms; --dur: 0ms; --dur-slow: 0ms; --dur-glide: 0ms; }
/* ---------- page ---------- */
* { box-sizing: border-box; }
@@ -123,9 +124,20 @@ a { color: inherit; }
.wrap--wide { max-width: var(--col-wide); }
.hand { font: 400 var(--hand-size)/1.1 var(--hand); letter-spacing: 0.02em; color: var(--blue); }
.keys { white-space: nowrap; }
+/* Every key is the same height and sits on the text's baseline, whether it holds a letter or an icon. */
kbd {
- font: 400 var(--step--2)/1 var(--mono); color: var(--ink-2);
- border: 1px solid var(--rule-strong); border-radius: 2px; padding: 2px 5px; white-space: nowrap;
+ display: inline-block; min-width: 1.9em; text-align: center; vertical-align: baseline;
+ font: 400 var(--step--2)/1.45 var(--mono); color: var(--ink-2);
+ border: 1px solid var(--rule-strong); border-radius: 2px; padding: 0 5px; white-space: nowrap;
+}
+/* icons drawn in place of characters the fonts don't have, sized to the text around them */
+.ic { display: inline-block; width: 0.95em; height: 0.95em; vertical-align: -0.12em; overflow: visible; }
+kbd .ic + .ic { margin-left: 1px; }
+.step-try .ic-caret { color: var(--red); width: 0.7em; height: 0.7em; vertical-align: 0; }
+.hint .for-touch { display: none; }
+@media (hover: none) {
+ .hint .for-touch { display: inline; }
+ .hint .for-pointer { display: none; }
}
/* ---------- top bar ---------- */
@@ -133,12 +145,20 @@ kbd {
.wordmark { font: 700 22px/1 var(--mono); letter-spacing: -0.01em; text-decoration: none; display: inline-flex; align-items: baseline; gap: 10px; }
.wordmark small { font: 300 19px/1 var(--hand-deva); color: var(--blue); transform: rotate(-4deg) translateY(-3px); display: inline-block; }
.theme-btn {
- font: 400 var(--step--1)/1 var(--mono); color: var(--ink-2); background: none; border: 1px solid var(--rule-strong);
- padding: 8px 12px; border-radius: 2px; cursor: pointer; display: inline-flex; gap: 8px; align-items: center;
+ position: relative; width: 38px; height: 38px; padding: 0; flex: none;
+ color: var(--ink-2); background: none; border: 1px solid var(--rule-strong); border-radius: 2px; cursor: pointer;
transition: color var(--dur), border-color var(--dur);
}
.theme-btn:hover { color: var(--ink); border-color: var(--ink-2); }
-.theme-btn svg { width: 14px; height: 14px; }
+/* both icons sit in one place; switching crossfades and turns them a little. The page itself flips at once. */
+.theme-btn svg {
+ position: absolute; inset: 0; margin: auto; width: 18px; height: 18px;
+ transition: opacity 160ms var(--ease), transform 160ms var(--ease);
+}
+.theme-btn .theme-sun, :root[data-theme="dark"] .theme-btn .theme-moon { opacity: 0; transform: rotate(-45deg); }
+:root[data-theme="dark"] .theme-btn .theme-sun { opacity: 1; transform: none; }
+@media (prefers-reduced-motion: reduce) { .theme-btn svg { transition: none; } }
+@media (max-width: 860px), (pointer: coarse) { .theme-btn { width: 44px; height: 44px; } }
/* ---------- hero ---------- */
.hero { padding-block: clamp(48px, 8vh, 88px) clamp(64px, 10vh, 112px); }
@@ -174,6 +194,9 @@ h1 .line { display: block; }
/* the hero word is a note span, scaled up */
h1 .vk-v { text-decoration-thickness: 3px; text-underline-offset: 0.16em; text-decoration-skip-ink: none; }
h1 .vk-anchor .vk-dots { top: calc(100% + 0.06em); gap: 6px; right: 0.04em; }
+/* the slot's underline and dots where the text's own underline and dots were */
+h1 .vk-glide::after { height: 3px; bottom: calc(0.28em - 3px); }
+h1 .vk-glide .vk-anchor { bottom: 0.1em; }
h1 .vk-dots i { width: 9px; height: 9px; border-width: 1.5px; }
h2 { font: 700 var(--step-3)/1.15 var(--mono); letter-spacing: -0.025em; margin: 0; }
@@ -302,7 +325,7 @@ h2 { font: 700 var(--step-3)/1.15 var(--mono); letter-spacing: -0.025em; margin:
.install-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; }
.install-steps li { display: grid; grid-template-columns: 2.4ch 1fr; gap: 14px; font: 400 18px/1.6 var(--mono); }
.install-steps b { color: var(--blue); }
-.install-steps kbd { font: inherit; font-weight: 700; color: inherit; border: 0; padding: 0; }
+.install-steps kbd { display: inline; min-width: 0; font: inherit; font-weight: 700; color: inherit; border: 0; padding: 0; }
footer.wrap { padding-block: 48px 56px; font: 400 var(--step--1)/1.5 var(--mono); color: var(--ink-3); }
footer .end { margin: 0 0 28px; letter-spacing: 0.6em; }
@@ -320,6 +343,8 @@ footer a:hover { color: var(--ink); text-decoration-color: var(--blue); }
.alts { font-size: 24px; }
h1 .vk-dots i { width: 6px; height: 6px; border-width: 1px; }
h1 .vk-anchor .vk-dots { gap: 4px; top: calc(100% + 0.06em); }
+ h1 .vk-glide::after { bottom: calc(0.41em - 3px); }
+ h1 .vk-glide .vk-anchor { bottom: 0.21em; }
.kicker { font-size: 14px; margin-bottom: 20px; }
.lede { font-size: 18px; margin-top: 28px; }
.actions { margin-top: 28px; }
@@ -375,6 +400,17 @@ footer a:hover { color: var(--ink); text-decoration-color: var(--blue); }
.vk-v:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.vk-v-text { transition: opacity var(--dur-fast) ease-out; }
.vk-v-text.is-swapping { opacity: 0; }
+/* a gliding span: one line whose box eases between widths. The underline and dots
+ belong to the box, so they follow it; the leaving version sits on top of the new one. */
+.vk-glide { display: inline-block; position: relative; white-space: nowrap; vertical-align: baseline; text-decoration: none; }
+.vk-glide .vk-v-text { display: inline-block; }
+.vk-glide .vk-v-out { position: absolute; left: 0; top: 0; pointer-events: none; }
+.vk-glide::after {
+ content: ""; position: absolute; left: 0; right: 0; bottom: var(--glide-line, 0.12em); height: 1.5px;
+ background: var(--blue-soft); transition: background-color var(--dur-slow) var(--ease);
+}
+.vk-glide:hover::after, .vk-glide:focus-visible::after, .vk-glide.is-active::after { background: var(--blue); }
+.vk-glide .vk-anchor { position: absolute; right: 0; top: 0; bottom: 0; }
/* an empty inline anchor: unlike an inline-block, it adds no line break before trailing punctuation */
.vk-anchor { position: relative; }
.vk-anchor .vk-dots { position: absolute; right: 0; top: calc(100% + 0.22em); }
@@ -400,9 +436,10 @@ footer a:hover { color: var(--ink); text-decoration-color: var(--blue); }
.vk-strike.is-armed { cursor: pointer; }
.vk-strike.is-struck { color: var(--ink-2); background-size: 100% 2px; }
.vk-caret {
- font: 400 1.3em/1 var(--hand); color: var(--red); background: none; border: 0; padding: 0 0.2em; margin: 0 -0.1em; cursor: pointer; vertical-align: -0.15em;
+ font: inherit; line-height: 1; color: var(--red); background: none; border: 0; padding: 0 0.15em; margin: 0 -0.05em; cursor: pointer;
transition: opacity var(--dur-slow);
}
+.vk-caret svg { display: inline-block; width: 0.85em; height: 0.85em; vertical-align: -0.05em; }
/* blue pencil: lint marks */
.vk-lint {