/* ── THE CARD TILTS TOWARDS YOU ─────────────────────────────────────────── * * Taufik, 23 August 2026: "for all the card, when open will have the animation * and transition style of tcg.pokemon.com/en-us/galleries/pitch-black." * * I went and read theirs rather than guessing at it. Their gallery card is * three effects stacked, and this site already had two of them: * * the diagonal sweep `cardShimmer`, a white band rotated -45deg that * crosses in the first fifth of a long cycle, with * each card in a grid started a second after the * last. public/assets/css/shine.css has done this * since the site was built — same idea, same reason. * the deepening shadow `.perspective-card--over` moves the drop shadow * out over half a second. `.acard:hover` already * does the equivalent. * THE TILT `.perspective-card` — perspective 600px, the * artwork on a transformer that rotates towards the * pointer, with a gloss that moves with it. * * The tilt is the one that was missing, and it is the one that makes their * cards feel like objects rather than pictures. This is that. * * ── IT WRITES TWO NUMBERS AND NOTHING ELSE ── * * The obvious build sets `style.transform` on the card. That fights every * other rule on this site that wants to move a card — the hover lift, the * usher's scan, the press — and last writer wins, which on a hover is * whichever ran most recently. So this sets `--tilt-x` and `--tilt-y` and * leaves the composing to CSS, where the lift and the tilt are one transform * with one source of truth. See `.acard` in shine.css. * * ── AND IT DOES NOTHING AT ALL ON A TOUCH SCREEN ── * * A tilt needs a pointer that hovers. On a phone the first tap would tilt the * card and the second would open it — a card that has to be pressed twice, * which is worse than no effect. `(hover: hover)` is the browser's own answer * to "is there a mouse", and it is asked once here rather than guessed from * the width of the screen. */ (function () { var fine = matchMedia('(hover: hover) and (pointer: fine)'); var still = matchMedia('(prefers-reduced-motion: reduce)'); if (!fine.matches || still.matches) return; /* how far it leans, in degrees, at the very corner. Theirs is subtle — the card reads as tipped, not as spun — and 7 is about where a 3:4 card at 600px of perspective stops looking like a photograph on a turntable. */ var MAX = 7; /* ── WHAT COUNTS AS A CARD ── Taufik: "for ALL the card". Read off the pages rather than guessed: .acard the chapter rails, and the four services on Smart Mobility .mobcard the drop-down cards on Smart Mobility and NEUFactory .gcard the eight arcade games .mcard the milestones on the front page .ocard the chapter openers and the SDG tiles .rcard the film reel The starter pack is left out on purpose: it is a pack of cards that already tips and fans on its own, and a second hand on it fights the first. ── AND THE PANELS A CARD OPENS INTO ── Taufik, 23 August 2026: "all these popup, make it same as the card that can be tilt and have the shining effect and shining effect mouse over". A card now turns and flies to the middle to become one of these — and then stopped being an object the moment it landed. So: .pop__panel the card popup, on the front page and every chapter .mdet__box one milestone, in full .pcardx the card that comes out of a starter pack 15 October 2026, Taufik: "this tilting annoying when want to press the share. remove this part tilting" — so the two story popups (.pop__panel, .mdet__box) no longer lean; they hold buttons people need to hit. Two panels are deliberately NOT here. The knowledge-graph stage is a working surface you DRAG, and a surface that leans away under the hand dragging it is a fight; and it is nearly the size of the window, where seven degrees stops being a tip and becomes a lurch. The film panel holds a running video with its own controls, and a light sweeping across a film somebody is watching is the definition of noise. */ var WHAT = '.acard, .mobcard, .gcard, .mcard, .ocard, .rcard,' + ' .pcardx'; var on = null; /* ── WHERE THE POINTER IS, AS A LEAN ── * Pure, and separate from the event, for one reason: it is the only part of * this file with any arithmetic in it, and a function that takes numbers and * returns numbers can be checked. See section 64 in scripts/check-wiring.js. */ function leanFor(r, cx, cy) { /* -0.5 … 0.5 from the middle of the card */ var px = (cx - r.left) / r.width - 0.5; var py = (cy - r.top) / r.height - 0.5; return { /* the top of the card leans AWAY when the pointer is at the top, which is what makes it read as tipping rather than as sliding */ x: -py * MAX * 2, y: px * MAX * 2, gx: (px + 0.5) * 100, gy: (py + 0.5) * 100, }; } /* ── WRITTEN STRAIGHT OUT, NOT BATCHED INTO A FRAME ── * * The first version collected the numbers and wrote them in * `requestAnimationFrame`, which is the textbook way to handle a * `pointermove` — and it made this feature impossible to check. Neither * browser available here paints a frame, so nothing scheduled in a frame * ever ran: the class went on, the maths was right, and every assertion * about the result came back empty. A 1,700-check suite and this one thing * shipping on hope. * * So it writes directly. The cost is a few redundant writes on a device * whose pointer outruns its screen; setting a custom property does not * force layout, and the browser coalesces `pointermove` towards the frame * rate anyway. The gain is that the numbers can be asserted. That is the * right way round for a codebase that checks everything else. */ function move(e) { var card = e.target.closest && e.target.closest(WHAT); if (!card) return; /* THE BOX IS READ BEFORE THE CLASS GOES ON, not after. It was the other way round, which was harmless while every card on the list was a card on the page — and stopped being harmless when the panels joined it. A panel is `display: none` until something opens it, so its box is 0×0; the old order marked it `is-tilting` and only then noticed there was nothing to lean, leaving the class on a hidden thing for good. */ var r = card.getBoundingClientRect(); if (!r.width || !r.height) return; if (card !== on) enter(card); var lean = leanFor(r, e.clientX, e.clientY); card.style.setProperty('--tilt-x', lean.x.toFixed(2) + 'deg'); card.style.setProperty('--tilt-y', lean.y.toFixed(2) + 'deg'); card.style.setProperty('--gloss-x', lean.gx.toFixed(1) + '%'); card.style.setProperty('--gloss-y', lean.gy.toFixed(1) + '%'); } function enter(card) { if (on && on !== card) leave(); on = card; card.classList.add('is-tilting'); } function leave() { if (!on) return; var card = on; on = null; card.classList.remove('is-tilting'); /* back to flat, and let the CSS transition carry it rather than snapping. The properties are removed a beat later so a card at rest carries no inline style at all — otherwise every card the pointer ever crossed keeps one for the life of the page. */ card.style.setProperty('--tilt-x', '0deg'); card.style.setProperty('--tilt-y', '0deg'); setTimeout(function () { if (card.classList.contains('is-tilting')) return; // came back card.style.removeProperty('--tilt-x'); card.style.removeProperty('--tilt-y'); card.style.removeProperty('--gloss-x'); card.style.removeProperty('--gloss-y'); }, 420); } /* the arithmetic, for the check suite. Nothing on the page reads it. */ window.NEU_TILT = { leanFor: leanFor, MAX: MAX }; document.addEventListener('pointermove', move, { passive: true }); document.addEventListener('pointerleave', function (e) { var card = e.target.closest && e.target.closest(WHAT); if (card && card === on) leave(); }, true); /* a card that is scrolled away from, or pressed, stops leaning */ document.addEventListener('pointerdown', leave, { passive: true }); addEventListener('scroll', function () { if (on) leave(); }, { passive: true }); /* and if the pointer leaves the window entirely, nothing is left tipped */ document.addEventListener('mouseleave', leave); })();