/* A CAMEO.
*
* Taufik, 17 October 2026: "a random moment where NEU and/or [someone] pass
* by, take one of the card, wave at the screen and show to the viewer to
* click it, then wave the screen and move away" β the FF7 desk app's idea,
* on the website. With the staff cartoons already on the site (the NEUONBOX
* board's set) and NEU, since there were no credits to draw full bodies.
*
* Every 50-110 seconds, if a row of cards is on screen and nothing is open:
* somebody rises from the bottom edge under one card, the card lifts, a
* bubble says "Have a look!", they wave, then "Bye!" and they sink away.
* Pressing them (or the card) opens the card as usual. Never with Reduce
* Motion, never while a popup or the timeline is open, never twice at once.
*/
(function () {
'use strict';
if (window.matchMedia && matchMedia('(prefers-reduced-motion: reduce)').matches) return;
var CAST = [
{ img: '/assets/img/neu-wave.png', name: 'NEU' },
{ img: '/assets/img/neu-happy.png', name: 'NEU' },
{ img: '/assets/img/people/chai-kok-chin-chibi.png', name: 'Dr KC' },
{ img: '/assets/img/people/chang-yang-loong-chibi.png', name: 'Dr YL' },
{ img: '/assets/img/people/marcus-chai-chibi.png', name: 'Marcus' },
{ img: '/assets/img/people/lim-chee-peng-chibi.png', name: 'Chee Peng' },
];
var CARDS = '.acard, .rcard, .ocard';
var busy = false, stopped = false;
/* Simple chosen (or a weak device), or the NEUONBOX: no helpers. A phone in
Full gets them β smaller (see the phone rules below) β which is what
choosing Full on a phone now means (checked on phones, 17 Oct 2026). */
function quiet() { var h = document.documentElement.classList; return h.contains('is-weak') || h.contains('is-neuonbox'); }
var css = document.createElement('style');
css.textContent =
'.cameo{position:fixed;z-index:60;width:120px;pointer-events:auto;cursor:pointer;' +
'transform:translateY(140%);transition:transform .7s cubic-bezier(.3,1.4,.5,1);}' +
'.cameo.is-up{transform:translateY(0)}' +
'.cameo img{width:120px;height:120px;border-radius:50%;object-fit:cover;display:block;' +
'box-shadow:0 14px 30px -10px rgba(0,0,0,.45);background:#eef2f7;border:3px solid #fff}' +
'.cameo.is-wave img{animation:cameo-wave .5s ease-in-out 3}' +
'@keyframes cameo-wave{0%,100%{transform:rotate(0)}25%{transform:rotate(-9deg)}75%{transform:rotate(9deg)}}' +
'.cameo__hand{position:absolute;right:-14px;top:18px;font-size:34px;transform-origin:70% 90%;' +
'animation:cameo-hand .45s ease-in-out infinite alternate}' +
'@keyframes cameo-hand{from{transform:rotate(-20deg)}to{transform:rotate(20deg)}}' +
'.cameo__say{position:absolute;bottom:128px;left:50%;transform:translateX(-50%);white-space:nowrap;' +
'background:#fff;color:#16202e;font:700 .9rem Inter,sans-serif;padding:.45rem .8rem;border-radius:14px;' +
'box-shadow:0 10px 24px -10px rgba(0,0,0,.4)}' +
'.cameo__say:after{content:"";position:absolute;left:50%;bottom:-6px;margin-left:-6px;' +
'border:6px solid transparent;border-bottom:0;border-top-color:#fff}' +
'.cameo__name{display:block;text-align:center;margin-top:4px;font:700 .72rem Inter,sans-serif;' +
'color:#fff;text-shadow:0 1px 4px rgba(0,0,0,.6)}' +
'.is-cameo-card{transform:translateY(-22px) scale(1.05)!important;' +
'box-shadow:0 0 0 3px #0b63ff,0 30px 60px -20px rgba(11,99,255,.6)!important;transition:transform .5s,box-shadow .5s!important;z-index:5}';
document.head.appendChild(css);
function somethingOpen() {
return !!document.querySelector('.pop:not([hidden]), .mdet:not([hidden]), .mstone:not([hidden]), [data-reelopen]:not([hidden]).is-open, .is-panelled');
}
function visibleCard() {
var h = innerHeight, w = innerWidth;
var list = [].slice.call(document.querySelectorAll(CARDS)).filter(function (c) {
var r = c.getBoundingClientRect();
if (r.width < 80) return false;
/* MOSTLY on screen is enough: a chapter row's cards are nearly always cut
by the screen's edge, and "fully" left the helper with nothing to take
(Taufik: "the avatar only ask to scroll down? not showing the cards?") */
var vw = Math.min(r.right, w) - Math.max(r.left, 0), vh = Math.min(r.bottom, h) - Math.max(r.top, 70);
return vw > r.width * 0.6 && vh > r.height * 0.6;
});
return list.length ? list[Math.floor(Math.random() * list.length)] : null;
}
function play() {
if (stopped || busy || document.hidden || somethingOpen() || quiet()) return;
var card = visibleCard();
if (!card) return;
busy = true;
var who = CAST[Math.floor(Math.random() * CAST.length)];
var el = document.createElement('div');
el.className = 'cameo';
el.setAttribute('role', 'button');
el.setAttribute('aria-label', who.name + ' says: have a look at this card');
el.innerHTML = '
';
el.querySelector('img').src = who.img;
el.querySelector('.cameo__name').textContent = who.name;
var say = el.querySelector('.cameo__say');
say.textContent = 'Have a look! π';
document.body.appendChild(el);
/* follow the card β the film row slides on its own */
var raf;
(function stick() {
var r = card.getBoundingClientRect();
el.style.left = Math.round(r.left + r.width / 2 - 60) + 'px';
el.style.bottom = Math.max(8, Math.round(innerHeight - r.bottom - 150)) + 'px';
raf = requestAnimationFrame(stick);
})();
el.addEventListener('click', function () { done(); card.click(); });
var t = [];
function done() {
t.forEach(clearTimeout);
cancelAnimationFrame(raf);
card.classList.remove('is-cameo-card');
el.classList.remove('is-up');
setTimeout(function () { el.remove(); busy = false; }, 700);
}
t.push(setTimeout(function () { el.classList.add('is-up'); }, 30));
t.push(setTimeout(function () { card.classList.add('is-cameo-card'); el.classList.add('is-wave'); }, 700));
t.push(setTimeout(function () {
el.classList.remove('is-wave');
say.textContent = 'Bye! ';
var hand = document.createElement('span');
hand.className = 'cameo__hand'; hand.textContent = 'π';
el.appendChild(hand);
}, 5200));
t.push(setTimeout(done, 6800));
}
/* ββ THE WALKER: a full-body character (17 Oct 2026) ββ
Six poses cut from a Gemini sheet in the NEUONBOX style:
1,2 walk Β· 3 hold the card Β· 4 point at it Β· 5 wave Β· 6 leave waving.
She walks in along the bottom of the screen to below a card, holds
one up and points ("Have a look!"), waves, and walks off the far side. */
/* ββ THE NAI BOX LOOK (Taufik, 22 Oct 2026: "make it smaller, and cute like
NEUON BOX APP") ββ The walkers are now the NAI Box wall screen's own
full-body chibis (big head, short body), two pictures each, both cut and
shrunk into img/cameo/full: -walk (mid-stride, facing right) and
-bye (hand up β the wave, and the hand that touches the screen).
They walk the NAI Box way: one picture and a light bob, not a drawn cycle.
The l-keys are ready-made NAI Box looks, not real people. Prof Lim has no
NAI Box full body yet, so he is out until one is drawn. */
var WALKERS = [{ key: 'neu', name: 'NEU' }, { key: 'neu', name: 'NEU' }, { key: 'kc', name: 'Dr KC' }, { key: 'yl', name: 'Dr YL' },
{ key: 'marcus', name: 'Marcus' }, { key: 'l01', name: 'NEUON' }, { key: 'l12', name: 'NEUON' }, { key: 'l19', name: 'NEUON' }, { key: 'l22', name: 'NEUON' }];
/* ββ AND ELSEWHERE ON THE PAGE TOO (Taufik, 17 Oct 2026: "it can appear at
other section even though the screen is at a different section") ββ
Up to two walkers out at once: one where the visitor is looking, and
sometimes one further up or down the page, so scrolling there can find
one already mid-walk. Any card that sits fully across the width counts. */
var walking = 0, WHERE = [];
/* ββ TALKING TO THEMSELVES (Taufik, 17 Oct 2026: "when walking, it's talking
to itself β¦ makes viewing it feel like it's alive. randomize it") ββ
A line now and then while they walk, never the same one twice running. */
var MUTTER = ['La la la π΅', 'Neu~ neu~ neu~', 'Hmmβ¦ what to pick? π€', 'Ooh, shiny! β¨', 'Jom! π', 'So many storiesβ¦',
'Dum di dum πΆ', 'Where was I going again?', "Donβt mind meβ¦", 'Sarawak boleh! πͺ', 'Is that a card I see? π',
'Hmm hmm hmm π΅', 'Today feels like a good day βοΈ', 'Did someone say AI? π€', 'Just passing through!', 'Wah, cantik! π',
'One step, two stepβ¦', 'Nearly thereβ¦', 'I could walk all day πΆ', 'Psstβ¦ keep scrolling π', 'Beep boopβ¦ just kidding π',
'Hello, hello! π', "Whatβs new here?", 'Ooh, which one, which oneβ¦', 'Tra la la π΅', 'Coffee later? β',
'Kuching weather today βοΈ', 'I love this page π', "Shhβ¦ Iβm on a mission π΅οΈ", 'Rain or shine, still walking π¦οΈ',
'Looking for something goodβ¦', 'Hmmβ¦ this one? That one?', 'Hornbills fly, I walk π¦', 'Neu neu neu π', 'Weeeeβ¦ oh wait, walking',
'So much to see!', 'Is anyone watching? π', 'Hehe π', 'Off we go!', 'Hmm, smells like progress',
'Data, data everywhere π', "Letβs find you something nice", 'Almost picked oneβ¦', 'I think I like this one',
'Walking, walkingβ¦ πΆ', 'Selamat datang! π', 'Oops, nearly tripped π
', 'Look busy, look busyβ¦', 'A little stroll πΏ', 'Ready when you are!'];
var lastSaid = -1;
function mutter() { var i; do { i = Math.floor(Math.random() * MUTTER.length); } while (i === lastSaid); lastSaid = i; return MUTTER[i]; }
function anyCard() {
var w = innerWidth;
var list = [].slice.call(document.querySelectorAll(CARDS)).filter(function (c) {
var r = c.getBoundingClientRect();
return r.width > 80 && r.left > 20 && r.right < w - 20 && WHERE.indexOf(c) < 0 &&
(r.bottom < 0 || r.top > innerHeight); // somewhere off the screen
});
return list.length ? list[Math.floor(Math.random() * list.length)] : null;
}
/* ββ A SCREEN WITH NO CARDS (Taufik, 17 Oct 2026, of a chapter page's
opener: "these pages no avatar/helper?") ββ Helpers only came where a
card row was on screen, and the top of every chapter page has none. Now
they stroll across that screen too, without a card: a wave and a nudge
to scroll on. An invisible marker near the foot of the visible screen,
inside its section, stands in for the card. */
function spotHere() {
var at = document.elementFromPoint(innerWidth / 2, innerHeight / 2);
var sec = at && at.closest('section');
if (!sec) return null;
if (getComputedStyle(sec).position === 'static') sec.style.position = 'relative';
var sr = sec.getBoundingClientRect();
var d = document.createElement('div');
d.className = 'cameo-spot';
d.style.cssText = 'position:absolute;left:50%;width:1px;height:1px;pointer-events:none;top:' +
Math.round(Math.min(sr.height - 60, innerHeight - 120 - sr.top)) + 'px';
sec.appendChild(d);
return d;
}
function walk(elsewhere) {
if (stopped || walking >= 1 || document.hidden || somethingOpen() || quiet()) return;
var card = elsewhere ? anyCard() : (visibleCard() || spotHere());
var spot = card && card.classList.contains('cameo-spot');
if (!card || WHERE.indexOf(card) > -1) return;
/* one helper per section: two on the same floor walk into each other */
var secOf = function (c) { return c.closest('section') || c.parentElement; };
if (WHERE.some(function (c) { return secOf(c) === secOf(card); })) return;
walking++; WHERE.push(card);
var who = WALKERS[Math.floor(Math.random() * WALKERS.length)];
var WALK = '/assets/img/cameo/full/' + who.key + '-walk.webp', BYE = '/assets/img/cameo/full/' + who.key + '-bye.webp';
/* every old pose number now means one of the two pictures: 5 and 6 (wave,
leave waving) the hand-up one, the rest the walk */
var P = function (n) { return n >= 5 ? BYE : WALK; };
var W = function () { return WALK; };
new Image().src = WALK; new Image().src = BYE;
var el = document.createElement('div');
el.className = 'walker is-walking';
el.setAttribute('role', 'button');
el.setAttribute('aria-label', 'Have a look at this card');
el.innerHTML = '
';
var img = el.querySelector('img'), say = el.querySelector('.cameo__say');
img.src = W(1);
document.body.appendChild(el);
var r = card.getBoundingClientRect();
var target = Math.round(r.left + r.width / 2 - 40);
var chatT = 0, chatOn = false, nextChat = 700 + Math.random() * 1500;
var x = -140, step = 0, beat = 0, shown = 0, timers = [], raf, phase = 'in';
el.style.left = x + 'px';
var last = performance.now();
/* SHE STANDS ON THE SECTION, NOT ON THE SCREEN (Taufik, 17 Oct 2026:
"when i move to different section, the helper showing different
section image"). Placed in the page, feet just under the card row she
took the card from, so scrolling on leaves her with her section, and a
visitor who scrolls there later finds her still at it. */
function stand() {
/* feet on the FLOOR of the section, not under the card: in the ring
sections the cards float mid-air, and so did she (Taufik: "make the
helper walk at the bottom of the section β¦ looks weird it walk in the
middle") */
if (phase === 'drag') return true; // in the visitor's hand
var sec = floor || card.closest('section') || card.parentElement;
var r = sec.getBoundingClientRect();
/* a section taller than the screen (the hero runs for several) has its
floor screens away: there she stands at the foot of the card row,
where the visitor is looking */
var tall = sec.offsetHeight > innerHeight * 1.1;
var lim = (floor || fell) ? (tall && dropFeet ? dropFeet - scrollY : r.bottom) : tall ? card.getBoundingClientRect().bottom + 40 : r.bottom;
var want = lim + scrollY - 44 - el.offsetHeight;
/* FALLING, NOT JUMPING (Taufik, 17 Oct 2026: "make the avatar stop
moving if user scroll, then β¦ drop to below slowly. currently if i
scroll it force it to go down"). In a tall section a scroll used to
snap them to the new spot; now they freeze, say Weee, and float down. */
if (falling) {
/* kept as a real number, not read back off the rounded style: near
the end each step is under half a pixel, rounding swallowed it and
they hung a few pixels short of the floor saying Weee for ever */
var cur = fallTop == null ? (parseFloat(el.style.top) || want) : fallTop;
if (want < cur) want = cur; // they fall, never float up
/* by the clock, like the walk: eased, but never slower than 0.25 px a
millisecond, so a slow phone or a busy tab still lands in a second */
var nowF = performance.now(), dtF = Math.min(100, nowF - (fallAt || nowF)); fallAt = nowF;
cur += Math.min(want - cur, Math.max((want - cur) * (1 - Math.exp(-dtF / 260)), 0.25 * dtF));
fallTop = cur;
el.style.top = Math.round(cur) + 'px';
if (want - cur < 1.5 && performance.now() - scrolledAt > 450) { el.style.top = Math.round(want) + 'px'; fallTop = null; fallAt = 0; land(); }
return true;
}
if (fell && want < (parseFloat(el.style.top) || 0)) return true;
el.style.top = Math.round(want) + 'px';
return true;
}
var falling = false, fell = false, scrolledAt = 0, fallImg = '', fallTop = null, fallAt = 0;
function onScroll() {
if (phase === 'drag' || phase === 'bye') return;
var sec = floor || card.closest('section') || card.parentElement;
if (!sec || sec.offsetHeight <= innerHeight * 1.1) return;
var fr = sec.getBoundingClientRect();
var feet = scrollY + Math.min(fr.bottom, innerHeight - 30) + 44;
if (feet <= dropFeet && fell) { scrolledAt = performance.now(); return; }
dropFeet = Math.max(dropFeet, feet); scrolledAt = performance.now();
if (!falling) {
falling = true; fell = true; fallTop = null; fallAt = 0;
if (phase === 'in' || phase === 'out') { fallImg = phase; phase = 'fall'; img.src = P(5); el.classList.remove('is-walking'); }
say.hidden = false; say.textContent = 'Weee! π';
img.style.transition = 'transform .3s'; img.style.transform = 'rotate(-6deg)';
}
}
function land() {
falling = false; img.style.transform = '';
el.classList.add('is-landing');
timers.push(setTimeout(function () {
el.classList.remove('is-landing'); say.hidden = true;
if (fallImg) { phase = fallImg; fallImg = ''; step = 0; shown = 0; el.classList.add('is-walking'); }
}, 500));
}
addEventListener('scroll', onScroll, { passive: true });
/* ββ THE OFF-MAP MARKER (Taufik, 17 Oct 2026: "an indication/arrow showing
it has appeared at either top/bottom β¦ like in game, showing something
out of the map") ββ While a walker is above or below the screen, a
round badge with their face and an arrow sits at that edge, level with
them; pressing it scrolls there. */
var mark = document.createElement('button');
mark.type = 'button'; mark.className = 'walker__mark'; mark.hidden = true;
mark.setAttribute('aria-label', who.name + ' is somewhere else on the page β go there');
var markImg = document.createElement('img'); markImg.alt = ''; markImg.src = P(5);
var markArrow = document.createElement('b');
mark.appendChild(markImg); mark.appendChild(markArrow);
/* to the helper's SECTION, not to the helper: the front page snaps section
by section, and stopping at the helper left it between two snap points β
when the helper then left, the browser re-snapped, often to the section
before (Taufik: "make the page remain at the section the helper leave") */
mark.addEventListener('click', function () {
/* LAND ON THE HELPER, not merely in their section (Taufik, 17 Oct 2026:
"after click the icon need to scroll to see avatar"). A screen-tall
section snaps to its top, which is where the helper is anyway. A TALLER
one β the hero runs for several screens β scrolls freely inside, so
the page goes straight to where the helper stands, feet near the foot
of the screen. */
var sec = card.closest('section');
if (!sec || sec.offsetHeight <= innerHeight * 1.1) {
(sec || el).scrollIntoView({ behavior: 'smooth', block: sec ? 'start' : 'center' });
} else {
var r = el.getBoundingClientRect();
window.scrollTo({ top: Math.max(0, scrollY + r.bottom - innerHeight + 70), behavior: 'smooth' });
}
});
document.body.appendChild(mark);
function marker() {
var r = el.getBoundingClientRect();
var seen = Math.min(r.bottom, innerHeight) - Math.max(r.top, 0);
var off = seen < r.height * 0.4; // most of them is out of view
var up = off && r.top + r.height / 2 < innerHeight / 2, down = off && !up;
if (!up && !down) { mark.hidden = true; return; }
mark.hidden = false;
mark.classList.toggle('is-up', up); mark.classList.toggle('is-down', down);
markArrow.textContent = up ? 'β²' : 'βΌ';
mark.style.left = Math.min(innerWidth - 60, Math.max(8, Math.round(r.left + r.width / 2 - 26))) + 'px';
}
function frame(now) {
if (!stand()) { finish(); return; }
marker();
/* by the clock, not by the frame: a throttled tab still walks */
var dt = Math.min(200, (now || performance.now()) - last); last = now || performance.now();
/* A REAL WALK (Taufik, 17 Oct 2026: "the leg show left right left right,
the body show front back front back"). Eight drawn frames of a walk
cycle β contact, down, passing, up, then the other leg β played at
nine a second while the figure moves at the pace one stride covers,
so the feet do not skate. No hop, no tilt: the drawings do it. */
if (phase === 'in' || phase === 'out') {
x += 0.07 * dt * ((img.offsetHeight || 110) / 110); // smaller on a phone, shorter stride
el.style.left = Math.round(x + scrollX) + 'px';
step += dt;
/* the bob is CSS (.is-walking > img), as on the NAI Box board */
/* the "down" frames (2 and 6) of most sheets drop the head 13-24 px β a
dip that big every other step reads as a limp β so those walkers use
the other six (Taufik: "NEU still look like its limping") */
if (shown !== 1) { shown = 1; img.src = W(); }
/* a mumble every few seconds while walking, for a couple of seconds */
chatT += dt;
if (!chatOn && chatT > nextChat) { chatOn = true; chatT = 0; say.hidden = false; say.textContent = talk(); }
else if (chatOn && chatT > 1900) { chatOn = false; chatT = 0; nextChat = 1600 + Math.random() * 2600; say.hidden = true; }
if (phase === 'in' && x >= target) { phase = 'stay'; el.classList.remove('is-walking'); chatOn = false; say.hidden = true; show(); }
if (phase === 'out' && x > innerWidth + 20) { finish(); return; }
}
raf = requestAnimationFrame(frame);
}
/* the card in their hands is THIS card: its picture and its title */
var pic = card.querySelector('img'), held = document.createElement('span');
held.className = 'walker__held';
var heldImg = document.createElement('img');
heldImg.alt = '';
if (pic) heldImg.src = pic.currentSrc || pic.src; else heldImg.hidden = true;
var heldT = document.createElement('b');
heldT.textContent = (card.dataset.name || ((card.querySelector('strong, h3, h2, [class*=title]') || {}).textContent) || '').trim().slice(0, 40);
/* ββ TOUCH, AND IT POPS (Taufik, 22 Oct 2026: "make it they touch the
screen then it pops-up above them [... animation of something like
advertisement use to do that have pop effect]") ββ No card in the
hands any more: they stop, put a hand up to the glass (a ripple where
it lands), and the card bursts out above their head β from nothing to
too big, back, a wobble, settled β on a spinning starburst with a few
sparkles, a "Tap to open" ribbon on it. It goes the same way, in
reverse and quicker, before they wave and walk on. */
var pop = document.createElement('span');
pop.className = 'walker__pop';
pop.appendChild(heldImg); pop.appendChild(heldT);
var ribbon = document.createElement('i'); ribbon.className = 'walker__ribbon'; ribbon.textContent = 'Tap to open π';
pop.appendChild(ribbon);
var burst = document.createElement('span'); burst.className = 'walker__burst';
held.appendChild(burst);
for (var sp = 0; sp < 6; sp++) {
var spark = document.createElement('span'); spark.className = 'walker__spark';
spark.style.setProperty('--a', (sp * 60 + 20) + 'deg'); spark.style.animationDelay = (0.25 + sp * 0.04) + 's';
spark.textContent = sp % 2 ? 'β¦' : 'β
';
held.appendChild(spark);
}
held.appendChild(pop);
held.hidden = true;
el.appendChild(held);
function hold(n) {
if (!n) {
if (held.hidden || held.classList.contains('is-going')) return;
held.classList.add('is-going');
setTimeout(function () { held.hidden = true; held.classList.remove('is-going'); }, 320);
return;
}
held.classList.remove('is-going');
held.hidden = false;
/* kept on the screen: a walker near the edge would push half of it off */
held.style.marginLeft = '0px';
var hr = held.getBoundingClientRect();
var shift = Math.max(8 - hr.left, Math.min(0, innerWidth - 8 - hr.right));
held.style.marginLeft = shift + 'px';
}
function tap() {
var t = document.createElement('span'); t.className = 'walker__tap';
el.appendChild(t);
setTimeout(function () { t.remove(); }, 900);
}
/* β¦and sometimes about where they are (Taufik: "or maybe it can say
something about that section or cards"): the card they are heading for,
or the section's own heading */
function talk() {
if (Math.random() < 0.45) {
var cut = function (t) { t = String(t || '').replace(/s+/g, ' ').trim(); return t.length > 34 ? t.slice(0, 33) + 'β¦' : t; };
var t = spot ? '' : cut(heldT.textContent);
var sec = card.closest('section');
var hh = sec && sec.querySelector('h1, h2');
var h = cut(hh && hh.textContent);
var opts = [];
if (t) opts.push('Ooh, β' + t + 'ββ¦', 'β' + t + 'β β seen this one?', 'I like β' + t + 'β π', 'Psstβ¦ β' + t + 'β π', 'Heading for β' + t + 'ββ¦');
if (h) opts.push('Ah, β' + h + 'ββ¦', 'This bit: β' + h + 'β', 'β' + h + 'β β my favourite part', 'Hmm, β' + h + 'ββ¦ interesting');
if (opts.length) return opts[Math.floor(Math.random() * opts.length)];
}
return mutter();
}
function show() {
if (spot) { // no card here: wave, nudge, go
img.src = P(5); say.hidden = false; say.textContent = 'Hi! Scroll down to see more π';
timers.push(setTimeout(function () {
say.hidden = true; img.src = P(6);
timers.push(setTimeout(function () { step = 0; shown = 0; el.classList.add('is-walking'); phase = 'out'; }, 700));
}, 3600));
return;
}
/* THE CARD SHE IS STANDING UNDER. A film row slides on its own while she
walks, so the card she set out for is often somewhere else by now;
the one that pops is whichever card is nearest above her hand. */
var me = el.getBoundingClientRect(), mid = me.left + me.width / 2, best = null, bd = 1e9;
[].slice.call(document.querySelectorAll(CARDS)).forEach(function (c) {
var cr = c.getBoundingClientRect();
if (cr.width < 80 || cr.bottom < 70 || cr.top > innerHeight || cr.top > me.bottom) return;
var d = Math.abs(cr.left + cr.width / 2 - mid) + Math.abs(cr.bottom - me.top) * 0.5;
if (d < bd) { bd = d; best = c; }
});
if (best && best !== card) {
WHERE = WHERE.map(function (c) { return c === card ? best : c; });
card = best;
var bp = card.querySelector('img');
if (bp) { heldImg.hidden = false; heldImg.src = bp.currentSrc || bp.src; } else heldImg.hidden = true;
heldT.textContent = (card.dataset.name || ((card.querySelector('strong, h3, h2, [class*=title]') || {}).textContent) || '').trim().slice(0, 40);
}
/* hand up to the glass, a tap, and POP */
img.src = P(5); el.classList.add('is-touch');
timers.push(setTimeout(tap, 250));
timers.push(setTimeout(function () { el.classList.remove('is-touch'); card.classList.add('is-cameo-card'); hold(1); }, 520));
timers.push(setTimeout(function () { hold(0); card.classList.remove('is-cameo-card'); say.hidden = false; say.textContent = 'Bye! π'; }, 5600));
timers.push(setTimeout(function () {
say.hidden = true; card.classList.remove('is-cameo-card');
/* a last look back and wave, then the walk carries them off */
img.src = P(6);
timers.push(setTimeout(function () { step = 0; shown = 0; el.classList.add('is-walking'); phase = 'out'; }, 700));
}, 7000));
}
function finish() {
timers.forEach(clearTimeout); cancelAnimationFrame(raf);
removeEventListener('scroll', onScroll);
card.classList.remove('is-cameo-card'); el.remove(); mark.remove();
if (spot && card.parentNode) card.parentNode.removeChild(card);
walking = Math.max(0, walking - 1); WHERE = WHERE.filter(function (c) { return c !== card; });
}
/* ββ PICK THEM UP (Taufik, 17 Oct 2026: "user can click and pick the
avatar and move it around β¦ like FF7 DESK β¦ only when they click the
CARD it holds then open the card. if click the avatar will not open the
card") ββ
The card in their hands opens it; nothing else does. Press and drag the
helper to carry them β they wave while you hold them β and let go: they
drop onto the floor of whatever section is under them, wave, and walk
off from there. */
var floor = null, drag = null, dropFeet = 0;
held.style.pointerEvents = 'none'; // only the card itself (.walker__pop) takes the press
held.addEventListener('click', function (e) { e.stopPropagation(); finish(); card.click(); });
el.addEventListener('pointerdown', function (e) {
if (e.button || el.classList.contains('is-flying') || e.target.closest('.walker__stop, .walker__held')) return;
e.preventDefault();
var r = el.getBoundingClientRect();
drag = { dx: e.clientX - r.left, dy: e.clientY - r.top, x0: e.clientX, y0: e.clientY, moved: false };
try { el.setPointerCapture(e.pointerId); } catch (er) {}
});
el.addEventListener('pointermove', function (e) {
if (!drag) return;
if (!drag.moved && Math.abs(e.clientX - drag.x0) + Math.abs(e.clientY - drag.y0) < 6) return;
if (!drag.moved) {
drag.moved = true;
timers.forEach(clearTimeout); timers = [];
phase = 'drag'; falling = false; fallImg = ''; img.style.transform = ''; hold(0); say.hidden = true;
card.classList.remove('is-cameo-card');
el.classList.remove('is-walking'); el.classList.add('is-carried');
img.src = P(5);
say.hidden = false; say.textContent = 'Weee! π';
/* BY THE SCRUFF (Taufik: "look like cat being carried by the neck β¦
make the avatar look happy"): the hold point jumps to the top of the
head, under a pinching hand, and the body hangs from there */
drag.dx = el.offsetWidth / 2; drag.dy = 8;
drag.vx = 0; drag.vy = 0; drag.px = e.clientX; drag.py = e.clientY; drag.ang = 0; drag.av = 0; drag.leg = 0; drag.lv = 0; drag.sq = 0;
/* THE LITTLE DETAILS (Taufik, 17 Oct 2026: "small movement showing the
motion of swing of body, and the leg move/fidget a little β¦ its the
details to make it feel real"). The body is a spring, so it overshoots
and settles instead of easing to a stop; it never quite hangs still,
breathing a degree either way. The legs are a second copy of the same
picture cut at the hip: they trail the swing a beat behind and kick
gently on their own, and a sharp tug up or down stretches the body a
touch. */
var hip = 0.62, legs = img.cloneNode();
legs.className = 'walker__legs';
legs.style.cssText = 'position:absolute;pointer-events:none;left:' + img.offsetLeft + 'px;top:' + img.offsetTop + 'px;width:' + img.offsetWidth + 'px;height:' + img.offsetHeight + 'px;transform-origin:50% 2%';
/* a soft seam, not a cut (Taufik: "look like it cut in half"): the
two halves fade into each other over a band at the hip, so a leg
swinging a few degrees never shows a line */
var fade = 'linear-gradient(to bottom, transparent ' + (hip * 100 - 7) + '%, #000 ' + (hip * 100 + 3) + '%)';
legs.style.webkitMaskImage = legs.style.maskImage = fade;
/* the top stays solid through the band, so the fade never shows the page through him; the legs, drawn on top, fade in over it */
img.style.webkitMaskImage = img.style.maskImage = 'linear-gradient(to bottom, #000 ' + (hip * 100 + 3) + '%, transparent ' + (hip * 100 + 3) + '%)';
el.insertBefore(legs, img.nextSibling);
drag.unhang = function () { img.style.transform = ''; img.style.webkitMaskImage = img.style.maskImage = ''; legs.remove(); };
var t0 = performance.now(), hipPx = img.offsetHeight * (hip - 0.02);
var swing = function (now) {
if (!drag || !drag.moved) return;
var t = ((now || performance.now()) - t0) / 1000;
var target = Math.max(-35, Math.min(35, -drag.vx * 2.2)) + Math.sin(t * 2.6) * 1.2; // out against the pull, and breathing
drag.av += (target - drag.ang) * 0.09; drag.av *= 0.86; drag.ang += drag.av; // a spring: overshoot, settle
drag.vx *= 0.85;
/* legs trail the body, plus a small kick of their own */
var lt = -drag.av * 1.2 + Math.sin(t * 5.3) * 1.8 + Math.sin(t * 8.9 + 1) * 0.8;
drag.lv += (lt - drag.leg) * 0.12; drag.lv *= 0.8; drag.leg += drag.lv;
drag.leg = Math.max(-6, Math.min(6, drag.leg));
drag.sq += (Math.max(-0.05, Math.min(0.05, drag.vy * 0.004)) - drag.sq) * 0.2; drag.vy *= 0.8;
var body = 'rotate(' + drag.ang.toFixed(2) + 'deg) scaleY(' + (1 + drag.sq).toFixed(3) + ')';
img.style.transform = body;
legs.style.transform = body + ' translateY(' + hipPx.toFixed(1) + 'px) rotate(' + drag.leg.toFixed(2) + 'deg) translateY(' + (-hipPx).toFixed(1) + 'px)';
requestAnimationFrame(swing);
};
requestAnimationFrame(swing);
}
drag.vx = e.clientX - drag.px; drag.px = e.clientX;
drag.vy = e.clientY - drag.py; drag.py = e.clientY;
/* the last ~150 ms of the finger, for the throw */
var nowS = performance.now();
(drag.s = drag.s || []).push({ x: e.clientX, y: e.clientY, t: nowS });
while (drag.s.length > 2 && nowS - drag.s[0].t > 150) drag.s.shift();
x = e.clientX - drag.dx + scrollX;
el.style.left = Math.round(x) + 'px';
el.style.top = Math.round(e.clientY - drag.dy + scrollY) + 'px';
x -= scrollX;
});
el.addEventListener('pointerup', function (e) {
if (!drag) return;
var was = drag; drag = null;
if (!was.moved) return; // a plain click on the helper does nothing
if (was.unhang) was.unhang();
el.classList.remove('is-carried'); img.style.transform = ''; say.hidden = true;
/* the floor of the section under the drop */
el.style.visibility = 'hidden';
var under = document.elementFromPoint(e.clientX, e.clientY);
el.style.visibility = '';
floor = (under && under.closest('section')) || floor;
/* in a section taller than the screen the floor is screens away: fall to
the bottom of what the visitor can see instead (Taufik: "why is it not
dropping?" β landing where let go left them hanging in mid-air) */
var fr = floor ? floor.getBoundingClientRect() : null;
dropFeet = scrollY + Math.min(fr ? fr.bottom : innerHeight, innerHeight - 30) + 44;
/* ββ FLICK THEM (Taufik, 22 Oct 2026: "able to be flick after being pick
up, same like NEU HI") ββ The NAI Box board's throw: let go while
moving and they FLY with the finger's speed over the last ~80 ms
(capped), under gravity, spinning the way they were thrown, bouncing
off the sides and the top of the screen and losing speed each time,
and come down on the floor. A hard throw or a bounce leaves them
dizzy ("@_@") for a moment before they carry on. A slow let-go just
drops them, as before. */
var s = was.s || [], vx = 0, vy = 0;
if (s.length > 1) {
var lastS = s[s.length - 1], firstS = s[0];
for (var k = 0; k < s.length; k++) { if (lastS.t - s[k].t <= 80) { firstS = s[k]; break; } }
var dS = (lastS.t - firstS.t) / 1000;
if (dS > 0.01 && performance.now() - lastS.t < 120) { vx = (lastS.x - firstS.x) / dS; vy = (lastS.y - firstS.y) / dS; }
}
var spd = Math.hypot(vx, vy), MAXV = 2600;
if (spd > MAXV) { vx *= MAXV / spd; vy *= MAXV / spd; spd = MAXV; }
if (spd > 350) { fly(vx, vy, spd > 1100); return; }
landed(false);
});
function floorTop() {
var sec = floor || card.closest('section') || card.parentElement;
var r = sec.getBoundingClientRect();
var tall = sec.offsetHeight > innerHeight * 1.1;
var lim = tall && dropFeet ? dropFeet - scrollY : r.bottom;
return lim + scrollY - 44 - el.offsetHeight;
}
function fly(vx, vy, hard) {
phase = 'drag'; // nothing else moves them while they fly
el.classList.add('is-flying');
img.src = P(5);
say.hidden = false; say.textContent = hard ? 'Wheeeee! π' : 'Whoa! π';
var px = parseFloat(el.style.left) || 0, py = parseFloat(el.style.top) || 0;
var th = 0, om = Math.max(-720, Math.min(720, vx * 0.45)), bounces = 0, t0 = performance.now(), lastF = t0;
var G = 2600, KEEP = 0.6;
(function air(now) {
if (!el.isConnected) return;
var dt = Math.min(0.05, Math.max(0, (now - lastF) / 1000)); lastF = now;
vy += G * dt; px += vx * dt; py += vy * dt;
th += om * dt; om *= Math.pow(0.6, dt);
var w = el.offsetWidth, minX = scrollX, maxX = scrollX + innerWidth - w, minY = scrollY + 64;
if (px < minX) { px = minX; vx = Math.abs(vx) * KEEP; vy *= KEEP; om = -om * KEEP; bounces++; }
if (px > maxX) { px = maxX; vx = -Math.abs(vx) * KEEP; vy *= KEEP; om = -om * KEEP; bounces++; }
if (py < minY) { py = minY; vy = Math.abs(vy) * KEEP; vx *= KEEP; bounces++; }
var ground = floorTop();
if ((vy > 0 && py >= ground) || now - t0 > 6000) {
el.style.top = Math.round(ground) + 'px'; el.style.left = Math.round(px) + 'px';
x = px - scrollX;
img.style.transform = '';
el.classList.remove('is-flying');
landed(hard || bounces > 0);
return;
}
el.style.left = Math.round(px) + 'px'; el.style.top = Math.round(py) + 'px';
img.style.transform = 'rotate(' + th.toFixed(1) + 'deg)';
requestAnimationFrame(air);
})(t0);
}
function landed(dizzy) {
el.classList.add('is-landing');
phase = 'stay'; stand();
if (dizzy) {
el.classList.add('is-dizzy');
say.hidden = false; say.textContent = Math.random() < 0.5 ? '@_@' : 'Wheeeβ¦ π΅βπ«';
}
var wait = dizzy ? 1400 : 0;
timers.push(setTimeout(function () { el.classList.remove('is-landing', 'is-dizzy'); say.hidden = false; say.textContent = 'That was fun! See you soon! π'; }, 380 + wait));
timers.push(setTimeout(function () {
say.hidden = true; img.src = P(6);
timers.push(setTimeout(function () { step = 0; shown = 0; el.classList.add('is-walking'); phase = 'out'; }, 600));
}, 1800 + wait));
}
/* PRESENTING? One press and they stay away until the page is reloaded
(Taufik, 17 Oct 2026: "have a button β¦ so the animation stop/pause and
not appear, until the page being refresh") */
var stop = document.createElement('button');
stop.type = 'button'; stop.className = 'walker__stop';
stop.textContent = 'π Goodbye helpers';
/* GOODBYE, NOT A SWITCH (Taufik, 17 Oct 2026): they wave and fade away, and
stay away until the page is reloaded; any other helper out on the page
goes the same way */
stop.addEventListener('click', function (e) {
e.stopPropagation(); stopped = true;
document.querySelectorAll('.walker').forEach(function (w) { if (w._bye) w._bye(); });
});
el._bye = function () {
timers.forEach(clearTimeout); timers = []; phase = 'stay'; hold(0);
card.classList.remove('is-cameo-card'); el.classList.remove('is-walking');
img.src = P(5); say.hidden = false; say.textContent = 'Bye bye! π';
stop.remove(); el.classList.add('is-bye');
setTimeout(finish, 1600);
};
el.appendChild(stop);
raf = requestAnimationFrame(frame);
}
var css2 = document.createElement('style');
css2.textContent = '.walker{position:absolute;z-index:80;width:auto;cursor:pointer}' +
'.walker>img{height:110px;width:auto;display:block;filter:drop-shadow(0 10px 14px rgba(0,0,0,.35))}' +
'.walker .cameo__say{bottom:auto;top:-44px}' +
'.walker{cursor:grab;touch-action:none;user-select:none}.walker.is-carried{cursor:grabbing;z-index:95}' +
'.walker.is-carried>img{transform-origin:50% 2%;filter:drop-shadow(0 26px 20px rgba(0,0,0,.3))}' +
'.walker.is-carried::before{content:"π€";position:absolute;left:50%;top:-30px;transform:translateX(-50%) rotate(180deg);font-size:34px;z-index:2;pointer-events:none}' +
'.walker.is-carried .cameo__say{top:-70px}' +
'.walker.is-bye{transition:opacity .9s ease .7s,transform .9s ease .7s;opacity:0;transform:translateY(-14px)}.walker.is-bye>img{animation:cameo-wave .5s ease-in-out 3}' + '.walker.is-landing{transition:top .35s cubic-bezier(.5,1.6,.6,1)}' +
'.walker.is-landing>img{transform-origin:50% 100%;animation:walker-squash .4s ease-out}' +
'@keyframes walker-squash{0%{transform:scale(1.15,.8)}50%{transform:scale(.94,1.06)}100%{transform:scale(1)}}' +
'.walker.is-dizzy>img{transform-origin:50% 100%;animation:walker-dizzy .35s ease-in-out .4s 4 alternate}' +
'@keyframes walker-dizzy{from{transform:rotate(-6deg)}to{transform:rotate(6deg)}}' +
'.walker.is-landing.is-dizzy>img{animation:walker-squash .4s ease-out,walker-dizzy .35s ease-in-out .4s 4 alternate}' +
'.walker.is-flying{cursor:grabbing}.walker.is-flying>img{filter:drop-shadow(0 22px 18px rgba(0,0,0,.28))}.walker>img{-webkit-user-drag:none}' +
'@media (max-width:640px){.walker>img{height:80px!important}.walker__pop{width:170px!important}.walker__held{left:calc(50% - 85px)!important}.walker .cameo__say{font-size:.75rem;top:-36px}' +
'.walker__stop{font-size:.66rem;padding:.25rem .55rem}.walker__mark{width:42px;height:42px}.cameo,.cameo img{width:84px;height:84px}}' +
'.walker__mark{position:fixed;z-index:90;width:52px;height:52px;border-radius:50%;border:3px solid #0b63ff;background:#fff;padding:0;cursor:pointer;' +
'box-shadow:0 8px 22px -6px rgba(11,99,255,.6);animation:walker-ping 1.4s ease-in-out infinite}' +
'.walker__mark[hidden]{display:none}.walker__mark img{width:100%;height:100%;border-radius:50%;object-fit:cover;object-position:50% 8%}' +
'.walker__mark b{position:absolute;left:50%;transform:translateX(-50%);color:#0b63ff;font-size:14px;line-height:1}' +
'.walker__mark.is-up{top:78px}.walker__mark.is-up b{top:-17px}.walker__mark.is-down{bottom:64px}.walker__mark.is-down b{bottom:-17px}' +
'@keyframes walker-ping{0%,100%{transform:scale(1)}50%{transform:scale(1.08)}}' + '.walker.is-walking>img{animation:walker-bob .325s ease-in-out infinite alternate}' +
'@keyframes walker-bob{from{transform:translateY(0) rotate(-1.5deg)}to{transform:translateY(-4px) rotate(1.5deg)}}' +
'.walker.is-touch>img{transform:rotate(-4deg) scale(1.04);transition:transform .25s}' +
'.walker__held{position:absolute;left:calc(50% - 110px);bottom:calc(100% + 30px);width:220px;pointer-events:none;z-index:3}' +
'.walker__held[hidden]{display:none}' +
'.walker__pop{position:relative;display:flex;flex-direction:column;width:220px;overflow:hidden;background:#fff;border-radius:14px;' +
'box-shadow:0 0 0 3px #0b63ff,0 18px 40px -10px rgba(6,12,22,.55);transform-origin:50% 100%;cursor:pointer;pointer-events:auto;' +
'animation:walker-pop .62s cubic-bezier(.2,.9,.3,1.4) both}' +
'.walker__pop img{width:100%;aspect-ratio:16/10;object-fit:cover;display:block}' +
'.walker__pop b{font:800 12px/1.25 Inter,sans-serif;color:#16202e;padding:5px 8px 2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}' +
'.walker__ribbon{font:800 11px/1 Inter,sans-serif;font-style:normal;color:#fff;background:#0b63ff;margin:4px 8px 8px;padding:5px 8px;border-radius:999px;align-self:flex-start;' +
'animation:walker-nudge 1s ease-in-out .7s infinite}' +
'@keyframes walker-pop{0%{transform:scale(0) rotate(-14deg);opacity:0}45%{transform:scale(1.2) rotate(5deg);opacity:1}' +
'65%{transform:scale(.9) rotate(-3deg)}80%{transform:scale(1.06) rotate(1deg)}100%{transform:scale(1) rotate(0)}}' +
'@keyframes walker-nudge{0%,100%{transform:scale(1)}50%{transform:scale(1.1)}}' +
'.walker__burst{position:absolute;left:50%;top:50%;width:340px;height:340px;margin:-170px 0 0 -170px;border-radius:50%;pointer-events:none;' +
'background:repeating-conic-gradient(rgba(255,206,64,.55) 0 10deg,transparent 10deg 24deg);' +
'-webkit-mask:radial-gradient(circle,#000 20%,transparent 68%);mask:radial-gradient(circle,#000 20%,transparent 68%);' +
'animation:walker-burst-in .5s ease-out both,walker-spin 6s linear infinite}' +
'@keyframes walker-burst-in{from{opacity:0;transform:scale(.2)}to{opacity:1}}' +
'@keyframes walker-spin{to{rotate:360deg}}' +
'.walker__spark{position:absolute;left:50%;top:50%;font-size:18px;color:#ffce40;pointer-events:none;text-shadow:0 0 8px rgba(255,206,64,.9);' +
'animation:walker-spark .7s ease-out both}' +
'@keyframes walker-spark{0%{transform:translate(-50%,-50%) rotate(var(--a)) translateY(0) scale(.3);opacity:0}' +
'40%{opacity:1}100%{transform:translate(-50%,-50%) rotate(var(--a)) translateY(-150px) scale(1);opacity:0}}' +
'.walker__held.is-going .walker__pop{animation:walker-unpop .3s ease-in both}.walker__held.is-going .walker__burst{opacity:0;transition:opacity .25s}' +
'@keyframes walker-unpop{0%{transform:scale(1)}35%{transform:scale(1.08)}100%{transform:scale(0) rotate(10deg);opacity:0}}' +
'.walker__tap{position:absolute;left:12%;top:2%;width:28px;height:28px;margin:-14px 0 0 -14px;border-radius:50%;pointer-events:none;' +
'border:3px solid #0b63ff;animation:walker-tap .45s ease-out 2}' +
'@keyframes walker-tap{from{transform:scale(.3);opacity:1}to{transform:scale(2.2);opacity:0}}' +
'.walker__stop{position:absolute;left:50%;bottom:-2px;transform:translate(-50%,100%);white-space:nowrap;border:0;border-radius:999px;' +
'background:rgba(22,32,46,.85);color:#fff;font:700 .72rem Inter,sans-serif;padding:.3rem .7rem;cursor:pointer}' +
'.walker{padding-bottom:0}' +
'@keyframes cameo-spin{from{transform:rotateY(0)}to{transform:rotateY(360deg)}}' +
'.is-cameo-spin{animation:cameo-spin .7s ease-in-out}' + '.walker .cameo__say[hidden]{display:none}';
document.head.appendChild(css2);
var popper = play;
play = function () {
/* walkers only: the round head-and-shoulders pop-up is gone (Taufik,
17 Oct 2026: "this one. remove it") */
walk(false);
/* one helper at a time: two together made the page lag (Taufik, 17 Oct 2026) */
};
function next() { setTimeout(function () { play(); next(); }, 20000 + Math.random() * 25000); }
/* the first one a little sooner, so a visitor actually meets it */
setTimeout(play, 8000);
next();
window.NEUCameo = function () { play(); }; // for trying it from the console
window.NEUWalk = function (elsewhere) { walk(!!elsewhere); };
})();