`).join('');
const tiles = [...$('f4hl').children].map((el, i) => ({ el, bad: HEALTH[i][1] === 'bad', ic: el.querySelector('.ht-ic'), st: el.querySelector('.ht-st') }));
$('f4title').innerHTML = 'Shows you what needs attention'.split(' ').map((w) => `${w}`).join(' ') + ' ' + 'Where an opportunity is taking shape'.split(' ').map((w) => `${w}`).join(' ') + '';
const words = [...$('f4title').querySelectorAll('span')].filter((s) => !s.classList.contains('l2'));
const labs = [...document.querySelectorAll('#f4scene .f4-lab')];
let seed = 9; const rnd = () => (seed = (seed * 16807) % 2147483647) / 2147483647;
const NODES = Array.from({ length: 0 }, () => ({ x: rnd() * 1920, y: rnd() * 1080, ph: rnd() * 6.28, r: 1 + rnd() * 2 }));
const ng = $('f4net').getContext('2d');
function drawNet(t) {
SweedBG(ng);
const P = NODES.map((n) => [n.x + Math.sin(t * .25 + n.ph) * 18, n.y + Math.cos(t * .2 + n.ph) * 14, n.r]);
ng.lineWidth = 1;
for (let i = 0; i < P.length; i++) for (let j = i + 1; j < P.length; j++) { const d = Math.hypot(P[i][0] - P[j][0], P[i][1] - P[j][1]); if (d < 240) { ng.strokeStyle = `rgba(145,225,221,${(.11 * (1 - d / 240)).toFixed(3)})`; ng.beginPath(); ng.moveTo(P[i][0], P[i][1]); ng.lineTo(P[j][0], P[j][1]); ng.stroke() } }
P.forEach((p) => { ng.fillStyle = 'rgba(170,235,228,.3)'; ng.beginPath(); ng.arc(p[0], p[1], p[2], 0, 6.283); ng.fill() });
}
const scene = $('f4scene');
function render(t) {
scene.style.transform = `scale(${(1 + .025 * (-(Math.cos(Math.PI * t / DUR) - 1) / 2)).toFixed(4)})`;
words.forEach((w, i) => { const s = i < 5 ? i * .05 : .25 + (i - 5) * .05, e = out(clamp((t - s) / .6)); w.style.opacity = e.toFixed(3); w.style.transform = `translateY(${((1 - e) * 28).toFixed(1)}px)` });
labs.forEach((l, i) => { const e = out(clamp((t - .4 - i * .2) / .5)); l.style.opacity = e.toFixed(3) });
// stack: depth = how many newer cards have arrived (smooth); deeper = higher, smaller, darker
let count = 0;
cards.forEach((c, i) => {
let d = 0; for (let j = i + 1; j < cards.length; j++) d += cards[j].first ? 1 : io(clamp((t - cards[j].tIn) / SLIDE));
const e = out(clamp((t - c.tIn) / .55));
const y = FRONT_B - 176 + d * STEP - (1 - e) * 90, s = (1 - SCALE * d) * (1 + .05 * (1 - e));
const o = clamp((t - c.tIn) / .15) * clamp(1 - (d - 4) / 1);
c.el.style.opacity = o.toFixed(3);
c.el.style.transform = `translateY(${y.toFixed(1)}px) scale(${Math.max(.4, s).toFixed(4)})`;
c.dim.style.opacity = Math.min(.7, d * .2).toFixed(3);
c.ring.style.opacity = c.first ? 0 : (clamp((t - c.tIn) / .2) * (1 - clamp((t - c.tIn - .7) / .6))).toFixed(3);
if (t >= c.tIn) count++;
});
$('f4cnt').textContent = Math.max(3, count);
tiles.forEach((h, i) => {
const e = out(clamp((t - .8 - (i % 3) * .08 - Math.floor(i / 3) * .1) / .5));
let sc = .9 + .1 * e;
if (h.bad && t > 1.5) {
const ph = ((t + i * .3) % 1.1) / 1.1;
h.el.style.background = `rgb(255,${Math.round(244 - 14 * Math.sin(Math.PI * ph))},${Math.round(245 - 14 * Math.sin(Math.PI * ph))})`;
h.el.style.boxShadow = `0 0 0 ${(ph * 12).toFixed(1)}px rgba(229,72,77,${(.45 * (1 - ph)).toFixed(3)}),0 20px 50px -24px rgba(0,0,0,.6)`;
h.st.style.boxShadow = `0 0 0 ${(ph * 8).toFixed(1)}px rgba(229,72,77,${(.45 * (1 - ph)).toFixed(3)})`;
}
h.el.style.opacity = e.toFixed(3); h.el.style.transform = `scale(${sc.toFixed(4)})`;
});
drawNet(t);
}
let t = 0, last = 0; const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches; if (reduce) t = 5.8;
function loop(now) { const dt = last ? (now - last) / 1000 : 0; last = now; if (!reduce) { t += dt; if (t >= DUR) t = 0 } render(t); requestAnimationFrame(loop) }
const vp = $('f4vp'), stage = $('f4stage');
new ResizeObserver(() => { stage.style.transform = `scale(${vp.clientWidth / 1920})` }).observe(vp);
(window.FR = window.FR || []).push({ stage, DUR, render });
})();
/*@@SBL-NEXT-SCRIPT@@*/
/* ── frame 1:09: pinned decision on top, the story scrolls under it ── */
(() => {
const DUR = 7, $ = (id) => document.getElementById(id);
const clamp = (v, a = 0, b = 1) => Math.min(b, Math.max(a, v));
const out = (p) => 1 - Math.pow(1 - p, 5), io = (p) => p < .5 ? 4 * p * p * p : 1 - Math.pow(-2 * p + 2, 3) / 2;
const CHECKS = [['Is it unusual, or noise?', 'Second-purchase rate 29% vs a 41% baseline for the cohort'], ['Where is it?', 'Repeat ladder: the step 1→2 lost 12 pp'], ['What changed around it?', '62% of the cohort came on the first-visit offer'], ['How do peers compare?', 'You are at P38'], ['What would confirm it?', 'The September cohort at 36% or more at day 30']];
$('f5checks').innerHTML = CHECKS.map(([q, a]) => `
✓${q}${a}
`).join('');
const checks = [...$('f5checks').children];
const DRV = [['Offer-only newcomers', 'Came for the discount, no reason to return', 68, '#8b5cf6'], ['No follow-up message', 'Nothing sent between visit 1 and 2', 21, '#3b82f6'], ['Seasonal dip', 'August is usually a little lower', 11, '#a3a6b5']];
$('f5drv').innerHTML = DRV.map(([n, s, w, c]) => `
${n}${s}
0%
`).join('');
const drv = [...$('f5drv').children].map((el) => ({ b: el.querySelector('b'), i: el.querySelector('i') }));
const chain = [...$('f5chain').children];
/* chart */
const H = [58, 57.4, 58.8, 57, 55.6, 55.2, 56.3, 57, 57.3, 57.2, 55.8, 54.0];
const X = (i) => 90 + i * 96, Y = (v) => 270 - (v - 50) / 10 * 240;
const hist = H.map((v, i) => (i ? 'L' : 'M') + X(i) + ' ' + Y(v).toFixed(1)).join(' ');
const xe = X(11), xd = 1360;
$('f5svg').innerHTML = `
60%50%Oct ’25Today · Oct 22Nov 30Target 58%59.6%51.3%`;
const dash = (id) => { const p = $(id), L = p.getTotalLength(); p.style.strokeDasharray = `${L} ${L}`; return { p, L } };
const ph = dash('f5hist'), pu = dash('f5up'), pd = $('f5down'), ends = $('f5ends'), area = $('f5area'), now = $('f5now');
/* scroll stops: section tops inside the track */
const track = $('f5track'), view = $('f5view'), thumb = $('f5thumb'), rail = $('f5rail');
let STOPS = null;
const measure = () => {
const maxS = track.offsetHeight - view.clientHeight;
STOPS = [0, $('f5s2').offsetTop - 30, $('f5s3').offsetTop - 30, Math.min(maxS, $('f5s4').offsetTop - 30)];
rail.style.height = ($('f5s4').offsetTop - 56 + 20) + 'px';
};
const MOVES = [[2.3, 2.9, 0, 1], [4.0, 4.6, 1, 2], [6.0, 6.5, 2, 3]];
const scrollAt = (t) => { let y = STOPS[0]; MOVES.forEach(([a, b, f, to]) => { if (t >= a) y = STOPS[f] + (STOPS[to] - STOPS[f]) * io(clamp((t - a) / (b - a))) }); return y };
$('f5title').innerHTML = 'It recommends your next move'.split(' ').map((w) => `${w}`).join(' ') + ' ' + 'and explains why'.split(' ').map((w) => `${w}`).join(' ') + '';
const words = [...$('f5title').querySelectorAll('span')].filter((s) => !s.classList.contains('l2'));
let seed = 17; const rnd = () => (seed = (seed * 16807) % 2147483647) / 2147483647;
const NODES = Array.from({ length: 0 }, () => ({ x: rnd() * 1920, y: rnd() * 1080, ph: rnd() * 6.28, r: 1 + rnd() * 2 }));
const ng = $('f5net').getContext('2d');
function drawNet(t) {
SweedBG(ng);
const P = NODES.map((n) => [n.x + Math.sin(t * .25 + n.ph) * 18, n.y + Math.cos(t * .2 + n.ph) * 14, n.r]);
ng.lineWidth = 1;
for (let i = 0; i < P.length; i++) for (let j = i + 1; j < P.length; j++) { const d = Math.hypot(P[i][0] - P[j][0], P[i][1] - P[j][1]); if (d < 240) { ng.strokeStyle = `rgba(145,225,221,${(.11 * (1 - d / 240)).toFixed(3)})`; ng.beginPath(); ng.moveTo(P[i][0], P[i][1]); ng.lineTo(P[j][0], P[j][1]); ng.stroke() } }
P.forEach((p) => { ng.fillStyle = 'rgba(170,235,228,.3)'; ng.beginPath(); ng.arc(p[0], p[1], p[2], 0, 6.283); ng.fill() });
}
const show = (el, dt, dy = 24, dur = .5, dx = 0) => { const e = out(clamp(dt / dur)); el.style.opacity = e.toFixed(3); el.style.transform = `translate(${((1 - e) * dx).toFixed(1)}px,${((1 - e) * dy).toFixed(1)}px)`; return e };
function render(t) {
if (!STOPS) measure();
$('f5scene').style.transform = `scale(${(1 + .02 * (-(Math.cos(Math.PI * t / DUR) - 1) / 2)).toFixed(4)})`;
words.forEach((w, i) => show(w, t - (i < 5 ? i * .06 : .3 + (i - 5) * .08), 28, .6));
show($('f5sw'), t - .35, 60, .6);
show($('f5hero'), t - .7, 16);
// scroll
const y = scrollAt(t), maxS = track.offsetHeight - view.clientHeight;
track.style.transform = `translateY(${(-y).toFixed(1)}px)`;
const vh = view.clientHeight - 20, th = vh * view.clientHeight / track.offsetHeight;
thumb.style.height = th.toFixed(1) + 'px'; thumb.style.top = ((vh - th) * (maxS ? y / maxS : 0)).toFixed(1) + 'px';
rail.style.transform = `scaleY(${io(clamp((t - .9) / 5.4)).toFixed(4)})`;
// 1 · checks tick down the timeline
show($('f5s1'), t - .9, 16);
checks.forEach((c, i) => show(c, t - 1.1 - i * .22, 0, .35, -16));
// 2 · weights, then the chain of causes
drv.forEach((d, i) => { const f = io(clamp((t - 2.8 - i * .25) / .7)); d.i.style.width = (DRV[i][2] * f) + '%'; d.b.textContent = Math.round(DRV[i][2] * f) + '%' });
chain.forEach((c, i) => show(c, t - 3.45 - i * .1, 0, .35, -12));
// 3 · trend + forecast fork
const fh = io(clamp((t - 4.45) / .8)); ph.p.style.strokeDashoffset = (ph.L * (1 - fh)).toFixed(1); area.style.opacity = (.1 * fh * fh).toFixed(3);
now.style.opacity = clamp((t - 5.25) / .2);
pd.style.opacity = clamp((t - 5.3) / .4).toFixed(3);
const fu = io(clamp((t - 5.35) / .6)); pu.p.style.strokeDashoffset = (pu.L * (1 - fu)).toFixed(1);
ends.style.opacity = clamp((t - 5.85) / .3).toFixed(3);
// 4 · decision: the pinned button answers
const pb = t > 6.4 ? (Math.sin((t - 6.4) * 8) + 1) / 2 : 0;
$('f5btn').style.boxShadow = `0 0 0 ${(pb * 8).toFixed(1)}px rgba(217,70,239,${(.3 * pb).toFixed(2)}),0 10px 24px -10px rgba(124,92,240,.7)`;
drawNet(t);
}
let t = 0, last = 0; const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches; if (reduce) t = 5.9;
const FZ = parseFloat(new URLSearchParams(location.search).get('t')); if (!isNaN(FZ)) t = FZ; // ?t=4.5 freezes the preview for review
function loop(n) { const dt = last ? (n - last) / 1000 : 0; last = n; if (!reduce && isNaN(FZ)) { t += dt; if (t >= DUR) t = 0 } render(t); requestAnimationFrame(loop) }
const vp = $('f5vp'), stage = $('f5stage');
new ResizeObserver(() => { stage.style.transform = `scale(${vp.clientWidth / 1920})`; STOPS = null }).observe(vp);
(window.FR = window.FR || []).push({ stage, DUR, render });
})();
/*@@SBL-NEXT-SCRIPT@@*/
/* ── frame 1:13: one goal → segment + challenge → launch ── */
(() => {
const DUR = 6, $ = (id) => document.getElementById(id);
const clamp = (v, a = 0, b = 1) => Math.min(b, Math.max(a, v));
const out = (p) => 1 - Math.pow(1 - p, 5), io = (p) => p < .5 ? 4 * p * p * p : 1 - Math.pow(-2 * p + 2, 3) / 2;
// RFM grid: rows = frequency (top high), cols = recency (left = long ago). At risk = high F, low R.
const AT = new Set(['0-0', '0-1', '1-0', '1-1', '2-0']);
$('f6rfm').innerHTML = Array.from({ length: 25 }, (_, k) => ``).join('');
const cells = [...$('f6rfm').children].filter((c) => AT.has(c.dataset.k));
const L = $('f6l'), R = $('f6r'), LL = L.getTotalLength(), RL = R.getTotalLength();
[L, R].forEach((p) => { const n = p.getTotalLength(); p.style.strokeDasharray = `${n} ${n}` });
const dl = $('f6dl'), dr = $('f6dr');
const TASKS = [
['Make 3 separate purchases on 3 different days', ''],
['Spend at least $49 each visit', ''],
['Leave a Google Review for the local store', '']
];
const tcard = (k) => { const [txt, ic] = TASKS[k % 3], n = k % 3; return `
Full from 4 pm, 5 days a week · 60% of online drop-off happens here
${days.map((d) => `${d}`).join('')}
${hrs.map((h, r) => `${h}` + days.map((d, c) => { const full = r >= 3 && c < 5, hot = full && r === 3; return `` }).join('')).join('')}
${[['risk', 'as of this morning', 'Wicker Park: 23% of regulars find favourites out', '31 of their 120 favourites have no par level', '$5–8k', 'at risk in 90 days', 'Set pars on 31 items'], ['opportunity', 'as of this morning', '11,400 adults near Evanston aren’t customers yet', 'No store within 2 miles of three neighbourhoods', '$120–180k', 'est. to gain in year one', 'Plan a campaign']]
.map(([p, a, t, sub, v, vs, b], i) => `
Green Wednesday Re-engagement ChallengeReady for you
SegmentRFM At Risk · ${reel('2,340', T + 600)} customersBought often, haven’t been back in 45+ days · Recency 45+ days · Spend $70+ avg
ChallengeGreen Wednesday Challenge3 purchases on 3 different days · At least $49 each visit · Leave a Google review
→ Launch plan✓ In Actions${CURSOR.replace('AT', T + 1400)}Pause any time in Actions
`
const why = (T) => `
${pill('anomaly')}HighCustomers · Logan Square
Fewer August newcomers return to Logan Square: 41% → 29%
${reel('$6–9k', T + 300)} est. to gain in 90 daysReward second visits
Why · share of the 12 pp drop
${[['Offer-only newcomers', 'came for the discount', 68], ['No follow-up message', 'nothing between visits 1 and 2', 21], ['Seasonal dip', 'August is usually lower', 11]]
.map(([a, b, v], i) => `
If you launch${reel('$54–90k', T + 2700)} est.59.6% by Nov 30, above target
If nothing changes−${reel('$15–30k', T + 2900)} lostslides to 51.3%
`
// ── what each Brain shows (prototype data; tab = the prototype's area tab) ──
const K_OPS = [['Checkout wait time', '4.8 min', 'SLA 5.0 min', '· held'], ['Shrink and variance', '1.4%', '0.4 pp over', '1.0% limit'], ['Delivery on-time rate', '91.0%', '−3.0 pp', 'vs Sep 2025'], ['Troubleshooting & manual time', '11.0%', '6.0 pp over', '5.0% limit']]
const STAGES = [
(T) => pulse({ tab: 'sales', q: 'Am I selling more and earning more?', title: 'Net sales', metric: '$11.58M', tone: 'good', sub: 'Up 9.4% vs Sep 2025. Close to goal. Ahead of 44% of similar stores. 5 decisions here, worth', est: '$76–95k est.', act: ['$12.22M', 'by Dec · +$178k'], base: ['$12.04M'] }, T)
+ insight({ p: 'benchmark', asof: 'as of Oct 22', t: 'Baskets hold 1.3 fewer items than at peers', s: 'Accessories go in 27% of baskets vs 38% at peers', v: '$18–26k', est: 1, vs: 'to gain a month', btn: 'Suggest add-ons', tag: 'A gap in every basket, priced' }, T + 3200),
(T) => live({ label: 'Message clicks', n: 120, seed: 7, k: [['Marketing ROI by channel', '2.1×', '70% of 3.0×', 'pace to goal'], ['Customer communications', '57', '13 below', 'target 70–100'], ['Loyalty engagement', '31.0%', '78% of 40.0%', 'pace to goal'], ['Online discoverability', '58', '12 below', 'target 70–100']] }, T)
+ insight({ p: 'task', asof: 'as of today, 6:00 am', t: '4 campaign drafts are ready; 1 weak journey paused', s: 'The paused journey converted 3 per 1,000 vs 15 at benchmark', v: '$9–14k', est: 1, vs: 'to gain in 30 days', btn: 'Review 4 drafts', tag: 'Drafted overnight, waiting for you' }, T + 2200),
(T) => pulse({ tab: 'customers', q: 'Who are my customers, are they coming back, and how long do they stay?', title: 'Active customers', metric: '131,400', tone: 'good', sub: 'Up 1.9% vs prior 90 days. Ahead of 58% of similar stores. 7 decisions here, worth', est: '$144–229k est.', act: ['138,153', 'by Dec · +2,212'], base: ['135,941'] }, T)
+ insight({ p: 'risk', asof: 'as of Oct 22', t: '412 top customers haven’t visited in 45+ days', s: 'Nobody has messaged them in 90 days', v: '$60–100k', est: 1, vs: 'to win back in 60 days', btn: 'Review win-back draft', tag: 'Your best customers, slipping away' }, T + 3200),
(T) => live({ label: 'Orders', n: 114, seed: 31, k: K_OPS }, T)
+ insight({ p: 'risk', asof: 'as of this morning', t: 'Only 48% of Newark baskets are tied to a customer', s: 'Guest checkout is on by default; two budtenders rarely look customers up', v: '$3–6k', est: 1, vs: 'to gain a month', btn: 'Prompt sign-ups', tag: 'Every counter, every screen, one place' }, T + 2200),
(T) => head(T) + chat({ lines: ['Net sales −11% vs expected Tue–Thu · $38k, the last 3 days', '412 top-20% customers have not visited in 45+ days · $60–100k', 'Evanston: 11,400 reachable adults are not customers yet · $120–180k', 'Customers stay 7.4 months vs 9.1 at peers · $60–90k', 'Lab results expire for 9 active SKUs in 6 days · $9.6k'] }, T + 1200),
(T) => shelf({ rows: [['Flower', 38, 34], ['Vapes', 18, 22], ['Edibles', 12, 14], ['Pre-rolls', 17, 12], ['Concentrates', 9, 14], ['Other', 6, 4]], k: [['SKU productivity', '$6.3k', '90% of $7k', 'pace to goal'], ['Category mix vs state peers', '0.94', '−0.03', 'vs prior month'], ['Assortment index vs. market', '74', '−2', 'vs prior month'], ['Product fit for repeat', '71', '9 below', 'target 80–100']] }, T)
+ insight({ p: 'opportunity', asof: 'as of Oct 22', t: 'Concentrates 9% of sales vs 14% at peers', s: '4 of the state’s top-10 brands are not on your menu', v: '$12–20k', est: 1, vs: 'a month after 90 days', btn: 'Add 4 top brands', tag: 'What your shelf is missing' }, T + 2600),
(T) => pulse({ tab: 'operations', q: 'Is the floor running right?', title: 'Labour % of sales', metric: '24.5%', tone: 'good', sub: 'Up 0.7 pp vs Sep 2025. Ahead of 42% of similar stores. 18 decisions here, worth', est: '$77–117k est.', act: ['23.4%', 'by Dec · −1.2 pp'], base: ['24.6%'] }, T)
+ insight({ p: 'forecast', asof: 'as of Oct 22', t: 'Saturday traffic +15%, more than the schedule covers', s: 'The Brain expects 1,180–1,260 sales; the schedule covers about 1,050', v: '$7–11k', est: 1, loss: 1, vs: 'at risk Saturday', btn: 'Add Saturday hours', tag: 'Saturday, seen on Wednesday' }, T + 3200),
(T) => table({ rows: [['Blue Dream 3.5g', 'Wicker Park', '1 day left', 'No order open'], ['Mango gummies 100mg', 'Lakeview', '1 day left', 'No order open'], ['Wedding Cake 3.5g', 'Wicker Park', '2 days left', 'On order, arrives Tue'], ['Sour Diesel pre-roll 1g', 'Lakeview', '3 days left', 'No order open']], k: [['Cash in inventory', '$2.90M', '$500k over', '$2.40M limit'], ['Stock-out rate by class', '3.1%', '1.1 pp over', '2.0% limit'], ['Aged stock $', '$386k', '$136k over', '$250k limit'], ['Received vs. sold', '83.0%', '−21.0 pp', 'vs prior 3 weeks']] }, T)
+ insight({ p: 'task', asof: 'as of today, 6:00 am', t: 'Orders for 4 vendors drafted; 2 need your approval', s: 'Heartland delivers Tuesday, so its order is due today', v: '$14k', vs: 'cash in the 2 orders', btn: 'Approve the orders', tag: 'Orders written before the shelf runs empty' }, T + 2400),
(T) => slots(T) + insight({ p: 'opportunity', asof: 'as of Oct 22', t: 'Online conversion 2.1% vs 3.4% at peers: delivery slots full', s: '60% of drop-off is at delivery slots: full from 4 pm 5 days a week', v: '$9–14k', est: 1, vs: 'to gain a month', btn: 'Add delivery slots', tag: 'The missed window, before it’s missed' }, T + 2000),
(T) => gauge(T) + insight({ p: 'risk', asof: 'as of this morning', t: 'Lab results expire in 6 days: 9 products, 3 bestsellers', s: 'Without new results they come off the menu on Oct 28', v: '$9.6k', loss: 1, vs: 'at risk in 14 days', btn: 'Request lab results', tag: 'Caught six days early' }, T + 2200),
]
Object.assign(STAGES, { c1: io, c2: learned, c3: market, c4: att, c5: plan, c6: why, c7: predict })
const INS = [
{ p: 'benchmark', asof: 'as of Oct 22', t: 'Baskets hold 1.3 fewer items than at peers', s: 'Accessories go in 27% of baskets vs 38% at peers', v: '$18–26k', est: 1, vs: 'to gain a month', btn: 'Suggest add-ons' },
{ p: 'task', asof: 'as of today, 6:00 am', t: '4 campaign drafts are ready; 1 weak journey paused', s: 'The paused journey converted 3 per 1,000 vs 15 at benchmark', v: '$9–14k', est: 1, vs: 'to gain in 30 days', btn: 'Review 4 drafts' },
{ p: 'risk', asof: 'as of Oct 22', t: '412 top customers haven’t visited in 45+ days', s: 'Nobody has messaged them in 90 days', v: '$60–100k', est: 1, vs: 'to win back in 60 days', btn: 'Review win-back draft' },
{ p: 'risk', asof: 'as of this morning', t: 'Only 48% of Newark baskets are tied to a customer', s: 'Guest checkout is on by default; two budtenders rarely look customers up', v: '$3–6k', est: 1, vs: 'to gain a month', btn: 'Prompt sign-ups' },
null,
{ p: 'opportunity', asof: 'as of Oct 22', t: 'Concentrates 9% of sales vs 14% at peers', s: '4 of the state’s top-10 brands are not on your menu', v: '$12–20k', est: 1, vs: 'a month after 90 days', btn: 'Add 4 top brands' },
{ p: 'forecast', asof: 'as of Oct 22', t: 'Saturday traffic +15%, more than the schedule covers', s: 'The Brain expects 1,180–1,260 sales; the schedule covers about 1,050', v: '$7–11k', est: 1, loss: 1, vs: 'at risk Saturday', btn: 'Add Saturday hours' },
{ p: 'task', asof: 'as of today, 6:00 am', t: 'Orders for 4 vendors drafted; 2 need your approval', s: 'Heartland delivers Tuesday, so its order is due today', v: '$14k', vs: 'cash in the 2 orders', btn: 'Approve the orders' },
{ p: 'opportunity', asof: 'as of Oct 22', t: 'Online conversion 2.1% vs 3.4% at peers: delivery slots full', s: '60% of drop-off is at delivery slots: full from 4 pm 5 days a week', v: '$9–14k', est: 1, vs: 'to gain a month', btn: 'Add delivery slots' },
{ p: 'risk', asof: 'as of this morning', t: 'Lab results expire in 6 days: 9 products, 3 bestsellers', s: 'Without new results they come off the menu on Oct 28', v: '$9.6k', loss: 1, vs: 'at risk in 14 days', btn: 'Request lab results' },
]
INS.forEach((n, k) => { STAGES['m' + k] = n ? (T) => insight(n, T, 'solo') : (T) => chat({ lines: ['Net sales −11% vs expected Tue–Thu · $38k', '412 top-20% customers not seen in 45+ days · $60–100k', 'Evanston: 11,400 adults not customers yet · $120–180k'] }, T, 'solo') })
// ── mount and play ──
// spec order 0:48 connects, 0:55 learns, 0:58 market, 1:03 insights, 1:09 explains, 1:13 action plan, 1:19 gains
const SCENE = ['c1', 'c2', 'c3', 'c4', 'c6', 'c5', 'c7']
const FR = window.FR || []
FR.forEach((f, i) => {
const st = $(`.stage[data-k="${SCENE[i]}"]`), vp = f.stage && f.stage.closest('.vs-viewport'); if (!st || !vp) return
st.dataset.scene = i; st.innerHTML = ''; const box = st.firstChild; box.appendChild(vp)
f.box = box; f.vp = vp; f.crop = null; f.t = 0; f.done = false; f.free = ['c1', 'c2', 'c3'].includes(SCENE[i]) // the cards keep streaming
})
// the part of the 1920×1080 frame the interface uses (title hidden), measured on the scene's last pose
const measure = (f) => {
f.stage.style.transform = 'scale(1)'
const sr = f.stage.getBoundingClientRect(), k = sr.width / 1920; if (!k) return null
let x0 = 1920, y0 = 1080, x1 = 0, y1 = 0
for (const u of [.25, .4, .55, .7, .85, .97]) { f.render(f.DUR * u); $$('*', f.stage).forEach((e) => {
if (e.closest('[class$="-title"],.vs-title,canvas,svg.sb-brain:not(.sb-lock)') || e.children.length > 6) return
const r0 = e.getBoundingClientRect(), cs = getComputedStyle(e); let r = { left: r0.left, top: r0.top, right: r0.right, bottom: r0.bottom }
// only the part a clipping parent inside the scene actually shows
for (let q = e.parentElement; q && q !== f.stage; q = q.parentElement) { const o = getComputedStyle(q).overflow; if (o === 'visible') continue; const c = q.getBoundingClientRect(); r = { left: Math.max(r.left, c.left), top: Math.max(r.top, c.top), right: Math.min(r.right, c.right), bottom: Math.min(r.bottom, c.bottom) } }
r.width = r.right - r.left; r.height = r.bottom - r.top; if (r.width < 4 || r.height < 4 || (r.width / k > 1700 && r.height / k > 900) || +cs.opacity < .05 || cs.visibility === 'hidden') return
x0 = Math.min(x0, (r.left - sr.left) / k); y0 = Math.min(y0, (r.top - sr.top) / k); x1 = Math.max(x1, (r.right - sr.left) / k); y1 = Math.max(y1, (r.bottom - sr.top) / k)
}) }
f.render(0)
const pad = 36; x0 = Math.max(0, x0 - pad); y0 = Math.max(0, y0 - pad); x1 = Math.min(1920, x1 + pad); y1 = Math.min(1080, y1 + pad)
return x1 > x0 && y1 > y0 ? { x: x0, y: y0, w: x1 - x0, h: y1 - y0 } : { x: 0, y: 0, w: 1920, h: 1080 }
}
const fit = (f) => {
const W = f.box.clientWidth; if (!W) return
f.vp.style.width = '1920px'; if (!f.crop) f.crop = measure(f) || { x: 0, y: 0, w: 1920, h: 1080 }
const c = f.crop, s = W / c.w
f.vp.style.width = (1920 * s) + 'px'; f.vp.style.marginLeft = (-c.x * s) + 'px'; f.vp.style.marginTop = (-c.y * s) + 'px'; f.box.style.height = (c.h * s) + 'px'; f.stage.style.transform = `scale(${s})`
f.render(f.t)
}
// each scene plays once and stops on its fullest moment, so nothing on it disappears again (the cards in the first one keep streaming)
const HOLD = { c4: 5.25, c6: 4, c5: 4.6, c7: 5.5 }
const run = (f) => { if (f.raf || f.done) return; const t0 = performance.now() - f.t * 1000
const step = (now) => { if (!f.on) { f.raf = 0; return } const e = (now - t0) / 1000
if (!f.free && e >= f.hold) { f.t = f.hold; f.render(f.t); f.done = true; f.raf = 0; return }
f.t = e; f.render(f.t); f.raf = requestAnimationFrame(step) }
f.raf = requestAnimationFrame(step) }
FR.forEach((f) => { if (!f.box) return
new ResizeObserver(() => fit(f)).observe(f.box)
f.hold = HOLD[f.box.parentElement.dataset.k] ?? f.DUR * .6
if (reduce) { f.t = f.free ? f.DUR * .6 : f.hold; f.done = true; return }
new IntersectionObserver(([e]) => { f.on = e.isIntersecting; if (f.on) run(f) }, { threshold: .15 }).observe(f.box)
})
// glints on the brain, as on the film's figures: comets with an 8-step white tail run along the contour, fading in and out.
// A canvas sits over the svg inside its parent, so it follows every transform the scene puts on the brain.
const glint = (svg, n = 6) => {
if (!svg || reduce) return
const host = svg.parentElement; if (getComputedStyle(host).position === 'static') host.style.position = 'relative'
const cv = document.createElement('canvas'); cv.setAttribute('aria-hidden', 'true'); cv.className = 'glc'
cv.style.cssText = 'position:absolute;left:0;top:0;width:0;height:0;pointer-events:none;display:block;transform:none'; svg.after(cv)
const g = cv.getContext('2d'), NS = 'http://www.w3.org/2000/svg', hsh = (i, k) => { const x = Math.sin(i * 127.1 + k * 311.7) * 43758.5453; return x - Math.floor(x) }
const probe = document.createElementNS(NS, 'path'); probe.setAttribute('fill', 'none'); svg.appendChild(probe)
const VBW = svg.viewBox.baseVal && svg.viewBox.baseVal.width || 197
const PL = [...svg.querySelectorAll('path')].filter((p) => p !== probe && (p.getAttribute('stroke') || 'none') !== 'none').flatMap((p) => (p.getAttribute('d').match(/M[^M]*/g) || []).map((d) => { probe.setAttribute('d', d)
const Ln = probe.getTotalLength(), m = Math.max(2, Math.round(Ln / 2)), pts = [], cum = [0]
for (let i = 0; i <= m; i++) { const q = probe.getPointAtLength(Ln * i / m); pts.push([q.x, q.y]); if (i) cum.push(cum[i - 1] + Math.hypot(q.x - pts[i - 1][0], q.y - pts[i - 1][1])) }
return { pts, cum, L: cum[m] } })).filter((q) => q.L > 24)
probe.setAttribute('d', 'M0 0')
const at = (pl, s) => { s = Math.max(0, Math.min(pl.L, s)); let k = 1; while (k < pl.cum.length - 1 && pl.cum[k] < s) k++; const f = (s - pl.cum[k - 1]) / ((pl.cum[k] - pl.cum[k - 1]) || 1); return [pl.pts[k - 1][0] + (pl.pts[k][0] - pl.pts[k - 1][0]) * f, pl.pts[k - 1][1] + (pl.pts[k][1] - pl.pts[k - 1][1]) * f] }
let on = false, raf = 0, bw = 0
const draw = (now) => { raf = on ? requestAnimationFrame(draw) : 0
const sr = svg.getBoundingClientRect(), lw = svg.clientWidth || 1, sc = sr.width / lw; if (!sr.width) return
const hr = host.getBoundingClientRect(), w = lw, h = sr.height / sc, pad = w * .14, x = (sr.left - hr.left) / sc - pad, y = (sr.top - hr.top) / sc - pad, cw = w + 2 * pad, ch = h + 2 * pad
Object.assign(cv.style, { left: x + 'px', top: y + 'px', width: cw + 'px', height: ch + 'px' })
const d = Math.min(devicePixelRatio || 1, 2) * sc, W = Math.round(cw * d)
if (Math.abs(W - bw) > bw * .08) { bw = W; cv.width = W; cv.height = Math.round(ch * d) }
const dd = cv.width / cw; g.setTransform(dd, 0, 0, dd, 0, 0); g.clearRect(0, 0, cw, ch); g.lineCap = 'round'
const k = w / VBW, P = (q) => [pad + q[0] * k, pad + q[1] * k], T = now / 1000
for (let c = 0; c < n; c++) { const D = 1.1 + hsh(c, 41) * .8, ph = T / D + hsh(c, 42), sl = Math.floor(ph), u = ph - sl, pl = PL[Math.floor(hsh(sl * 13 + c, 43) * PL.length)]
const run = Math.min(pl.L, 150), s0 = hsh(sl * 7 + c, 44) * (pl.L - run), tail = 46, head = s0 + u * (run + tail), fade = Math.min(1, u * 6, (1 - u) * 5)
const t0 = Math.max(s0, head - tail), t1 = Math.min(s0 + run, head); if (t1 - t0 < 1) continue
const pts = []; for (let q = 0; q <= 16; q++) pts.push(P(at(pl, t0 + (t1 - t0) * q / 16)))
const A = pts[0], B = pts[pts.length - 1], lg = g.createLinearGradient(A[0], A[1], B[0], B[1])
lg.addColorStop(0, 'rgba(255,255,255,0)'); lg.addColorStop(1, `rgba(255,255,255,${(.95 * fade).toFixed(3)})`)
g.strokeStyle = lg; g.lineWidth = 6.2 * k * .7; g.beginPath(); pts.forEach((p, i) => i ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); g.stroke() } }
new IntersectionObserver(([e]) => { on = e.isIntersecting; if (on && !raf) raf = requestAnimationFrame(draw) }).observe(svg)
}
glint($('.mark svg'))
{ const c = $('.stage[data-k="c1"] .c1-sph canvas'); if (false && c && window.SweedSphere) SweedSphere(c, { nodes: 190, threshold: .33, radius: .29, signals: 0, glow: false, comets: 5, pale: true, spin: .06, tail: .2, cdur: 3.2 }) }
glint($('.stage[data-k="c2"] .f2-brain > .sb-brain'))
// «Generic AI answers questions»: the Sweed Brain background (the film's field: nodes, links by distance, glints running link to link)
;(() => { const band = $('.genband'), cv = band && $('.gnet', band); if (!cv) return
const g = cv.getContext('2d'), hsh = (i, k) => { const x = Math.sin(i * 127.1 + k * 311.7) * 43758.5453; return x - Math.floor(x) }
let W = 0, H = 0, N = [], on = false, raf = 0
const size = () => { const r = cv.getBoundingClientRect(), d = Math.min(devicePixelRatio || 1, 2); W = r.width; H = r.height; cv.width = Math.round(W * d); cv.height = Math.round(H * d); g.setTransform(d, 0, 0, d, 0, 0)
const n = Math.round(Math.min(110, Math.max(36, W * H / 17000)))
N = Array.from({ length: n }, (_, i) => ({ x: hsh(i, 1) * W, y: hsh(i, 2) * H, ph: hsh(i, 3) * 6.28, r: hsh(i, 4) < .12 ? 2.6 : 1 + hsh(i, 5) * 1.2, hub: hsh(i, 4) < .12 }))
if (!raf) draw(performance.now()) }
const LK = 175, TEAL = '84,200,212'
const draw = (now) => { raf = on && !reduce ? requestAnimationFrame(draw) : 0; const T = now / 1000
g.clearRect(0, 0, W, H)
const P = N.map((n) => [n.x + Math.sin(T * .22 + n.ph) * 22, n.y + Math.cos(T * .18 + n.ph) * 16])
g.lineWidth = 1
for (let i = 0; i < P.length; i++) for (let j = i + 1; j < P.length; j++) { const dx = P[i][0] - P[j][0], dy = P[i][1] - P[j][1]; if (dx > LK || dx < -LK) continue; const d = Math.hypot(dx, dy); if (d >= LK) continue
g.strokeStyle = `rgba(${TEAL},${(.34 * (1 - d / LK)).toFixed(3)})`; g.beginPath(); g.moveTo(P[i][0], P[i][1]); g.lineTo(P[j][0], P[j][1]); g.stroke() }
N.forEach((n, i) => { const [x, y] = P[i]
if (n.hub) { const rg = g.createRadialGradient(x, y, 0, x, y, 14); rg.addColorStop(0, `rgba(${TEAL},.35)`); rg.addColorStop(1, `rgba(${TEAL},0)`); g.fillStyle = rg; g.fillRect(x - 14, y - 14, 28, 28) }
g.fillStyle = n.hub ? 'rgba(190,245,245,.95)' : `rgba(${TEAL},.8)`; g.beginPath(); g.arc(x, y, n.r, 0, 6.283); g.fill() })
// glints: a short comet runs link after link, about five hops, then fades
g.lineCap = 'round'
for (let k = 0; k < 9; k++) { const D = 1.6 + hsh(k, 6) * 1.1, ph = T / D + hsh(k, 7), sl = Math.floor(ph), u = ph - sl
let a = Math.floor(hsh(sl * 31 + k, 8) * P.length); const th = hsh(sl * 17 + k, 9) * 6.283, dxp = Math.cos(th), dyp = Math.sin(th), pts = [P[a]]
for (let hop = 0; hop < 5; hop++) { let best = -1, bs = .2
for (let m = 0; m < P.length; m++) { if (m === a) continue; const sx = P[m][0] - P[a][0], sy = P[m][1] - P[a][1], l = Math.hypot(sx, sy); if (l >= LK || !l) continue; const dt = (sx * dxp + sy * dyp) / l; if (dt > bs) { bs = dt; best = m } }
if (best < 0) break; a = best; pts.push(P[a]) }
if (pts.length < 2) continue
const seg = []; let L = 0; for (let i = 1; i < pts.length; i++) { const l = Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]); seg.push(l); L += l }
const tail = 90, head = u * (L + tail), at = (q) => { q = Math.max(0, Math.min(L, q)); let i = 0; while (i < seg.length - 1 && q > seg[i]) { q -= seg[i]; i++ } const f = seg[i] ? Math.min(1, q / seg[i]) : 0; return [pts[i][0] + (pts[i + 1][0] - pts[i][0]) * f, pts[i][1] + (pts[i + 1][1] - pts[i][1]) * f] }
const fade = Math.min(1, u * 6, (1 - u) * 5)
for (let q = 0; q < 8; q++) { const s0 = head - tail * (1 - q / 8), s1 = head - tail * (1 - (q + 1) / 8); if (s1 < 0 || s0 > L) continue; const p0 = at(s0), p1 = at(s1)
g.strokeStyle = q > 5 ? `rgba(255,255,255,${(fade * (q + 1) / 8).toFixed(3)})` : `rgba(170,240,240,${(fade * (q + 1) / 8).toFixed(3)})`; g.lineWidth = 1.2 + 2 * (q + 1) / 8; g.beginPath(); g.moveTo(p0[0], p0[1]); g.lineTo(p1[0], p1[1]); g.stroke() }
if (head <= L) { const hp = at(head), rg = g.createRadialGradient(hp[0], hp[1], 0, hp[0], hp[1], 9); rg.addColorStop(0, `rgba(255,255,255,${fade.toFixed(3)})`); rg.addColorStop(1, 'rgba(170,240,240,0)'); g.fillStyle = rg; g.fillRect(hp[0] - 9, hp[1] - 9, 18, 18) } } }
new ResizeObserver(size).observe(cv)
new IntersectionObserver(([e]) => { on = e.isIntersecting; if (on && !raf) raf = requestAnimationFrame(draw) }).observe(band)
})()
// «Generic AI answers questions»: the logo, then each line, come up calmly one after another; then a light passes over «Sweed Brain»
;(() => { const gen = $('.genband .gen'); if (!gen || reduce) return
gen.classList.remove('rv'); [...gen.children].forEach((el, i) => el.style.setProperty('--d', (i * 280) + 'ms'))
gen.style.setProperty('--shine', (gen.children.length * 280 + 900) + 'ms')
new IntersectionObserver(([e], o) => { if (e.isIntersecting) { gen.classList.add('go'); o.disconnect() } }, { threshold: .35 }).observe(gen)
})()
glint($('.genlogo svg'), 5)
glint($('.gtet .gbrain svg'), 5)
glint($('.flow-mark svg'), 5)
const beats = $$('.beat,.bcard')
beats.forEach((b) => { const st = $('.stage', b); if (st && st.dataset.scene == null) st.innerHTML = '
' + STAGES[st.dataset.k](0) + '
' })
// Brains panel: each Brain's own live screen on top of its panel, everything shown at once
;(() => { const w = $('.bxw'); if (!w) return; if (!w.dataset.v) return
$$('.bxv .stage', w).forEach((st) => { st.innerHTML = '
' + STAGES[st.dataset.k](0) + '
'; $$('[data-at]', st).forEach((e) => e.classList.add('on')) }) })()
const timers = new WeakMap()
const tick = (bars) => { const is = [...bars.children]; const hs = is.map((i) => i.style.getPropertyValue('--h')); hs.shift(); hs.push((.35 + Math.random() * .6).toFixed(2)); is.forEach((i, k) => i.style.setProperty('--h', hs[k])) }
const play = (b) => {
if (reduce) { $$('[data-at]', b).forEach((e) => e.classList.add('on')); return }
$$('[data-at]', b).forEach((e) => setTimeout(() => e.classList.add('on'), +e.dataset.at * .7))
}
const seen = new IntersectionObserver((es) => es.forEach((e) => {
const b = e.target
if (e.isIntersecting && !b.classList.contains('in')) { b.classList.add('in'); play(b) }
// the live bars tick only while their beat is on screen
const bars = $('[data-live]', b); if (!bars || reduce) return
clearInterval(timers.get(b))
if (e.isIntersecting) timers.set(b, setInterval(() => { if (bars.classList.contains('on')) { bars.classList.add('tick'); tick(bars) } }, 1600))
}), { threshold: .3 })
beats.forEach((b) => seen.observe(b))
})()