Back to the app
The code
The Most Uncomfortable Web Page by Claude Opus 5.5
Exactly as the AI wrote it. Shown as text, so nothing runs on this page.
index.html
works · auto-checked (Checked by an automated pass. Not hand-played yet.)<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>Normal Website</title>
<style>
:root{
--bg:#f4f2ec;--ink:#1f2128;--muted:#6a6d7a;--card:#ffffff;--line:#dfdde6;
--brand:#4f5de0;--brand-d:#3541b3;--wood:#9a7350;
color-scheme:light;
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
html,body{margin:0;min-height:100%}
body{background:var(--bg);color:var(--ink);font:17px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;overflow-x:hidden;-webkit-tap-highlight-color:transparent}
button{font:inherit;color:inherit;cursor:pointer;touch-action:manipulation}
#page{max-width:760px;margin:0 auto;padding:10px 16px 24px;min-height:100vh;display:flex;flex-direction:column;transform:rotate(-.3deg);transform-origin:50% 0;transition:transform 1.8s cubic-bezier(.2,.9,.2,1)}
.straight #page{transform:none}
/* ---------- top bar (the line under it is broken by one pixel) ---------- */
.topbar{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:6px 0 12px;position:relative}
.topbar::before,.topbar::after{content:"";position:absolute;bottom:0;height:1px;background:var(--line)}
.topbar::before{left:0;width:63%}
.topbar::after{right:0;width:37%;bottom:-1px;transition:bottom 1.2s}
.straight .topbar::after{bottom:0}
.logo{display:flex;align-items:center;gap:9px;font-weight:800;font-size:19px;letter-spacing:-.01em}
.mark{width:26px;height:26px;border-radius:8px 8px 8px 2px;background:var(--brand);transform:rotate(5deg);box-shadow:inset -4px -4px 0 rgba(0,0,0,.12);transition:transform 1.2s}
.drop{position:relative;top:1px;transition:top 1.2s}
.logo sup{font-size:10px;position:relative;top:-6px;left:-2px;font-weight:600}
.straight .mark{transform:none}
.straight .drop{top:0}
.nav{display:flex;gap:2px;margin-left:auto}
.nav button{background:none;border:0;min-height:44px;padding:0 12px;border-radius:10px;color:var(--muted);font-size:15px}
.nav button:nth-child(2){position:relative;top:1px}
.burger{width:46px;height:46px;border:1px solid var(--line);background:#fff;border-radius:12px 12px 12px 4px;display:flex;flex-direction:column;justify-content:center;align-items:flex-start;gap:4px;padding:0 12px;flex:none}
.burger i{display:block;height:2px;background:#3a3d4a;border-radius:2px;width:20px;transition:all 1.2s}
.burger i:nth-child(2){width:17px}
.burger i:nth-child(3){width:21px;margin-left:1px}
.burger i:nth-child(4){width:12px}
.straight .burger i{width:20px;margin-left:0}
@media (max-width:560px){.nav{display:none}}
.statusline{display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap;font-size:13.5px;color:var(--muted);padding:12px 2px 14px 3px}
.steps{display:flex;align-items:center;gap:10px}
.dots{display:inline-flex;align-items:center}
.dots i{width:9px;height:9px;border-radius:50%;background:#d2d1db;margin-right:6px;position:relative;transition:background-color .4s,top 1.2s,margin 1.2s}
.dots i.on{background:var(--brand)}
.dots i:nth-child(3){top:1px}
.dots i:nth-child(4){margin-right:8px}
.straight .dots i{top:0;margin-right:6px}
#timer{font-variant-numeric:tabular-nums}
#stage{flex:1}
/* ---------- cards & type ---------- */
.card{position:relative;z-index:0;background:var(--card);border:1px solid var(--line);border-right-width:2px;border-radius:20px 20px 20px 7px;padding:22px 19px 22px 21px;box-shadow:3px 10px 30px rgba(40,40,80,.07);transform:rotate(.45deg);animation:cardIn .5s cubic-bezier(.2,.9,.3,1) both}
@keyframes cardIn{from{opacity:0;transform:translateY(14px) rotate(.45deg)}to{opacity:1;transform:rotate(.45deg)}}
h1{font-size:clamp(30px,7vw,44px);line-height:1.1;letter-spacing:-.025em;margin:4px 0 12px}
h2{font-size:clamp(24px,5.6vw,30px);line-height:1.15;letter-spacing:-.015em;margin:2px 0 8px}
.crumbs{font-size:13px;color:var(--muted);margin:0 0 8px 1px}
.crumbs span{position:relative;top:1px;margin:0 3px}
.lede{font-size:18px;color:#3c3f4c;margin:0 0 4px}
.sub{color:#4a4d5a;margin:0 0 12px}
.fine{font-size:13px;color:var(--muted);margin:14px 0 0 3px}
.serif{font-family:Georgia,"Times New Roman",serif;font-style:italic;letter-spacing:.05em}
.w{white-space:nowrap}
.l{display:inline-block;position:relative}
.row{display:flex;flex-wrap:wrap;gap:12px;align-items:center;margin-top:10px}
.split-rule{display:flex;align-items:flex-start;height:4px;margin:2px 0 14px}
.split-rule i{height:2px;background:#e2e0ea;border-radius:2px}
.split-rule i:first-child{flex:1.6}
.split-rule i:last-child{flex:1;margin-top:1px}
.chips{display:flex;flex-wrap:wrap;gap:8px;list-style:none;padding:0;margin:14px 0 20px}
.chips li{padding:6px 13px;border:1px solid var(--line);border-radius:999px;background:#fafaff;font-size:14px;font-weight:550;color:#444756;position:relative}
.chips li:nth-child(2){top:1px}
.chips li:nth-child(3){transform:rotate(-2deg)}
.chips li:nth-child(4){border-radius:999px 999px 999px 5px}
.chips li:nth-child(5){padding-left:15px;opacity:.85}
/* ---------- buttons (the label sits one pixel low) ---------- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:54px;padding:0 26px;border:0;border-radius:15px 15px 15px 5px;background:var(--brand);color:#fff;font-size:18px;font-weight:700;letter-spacing:.005em;box-shadow:0 4px 0 var(--brand-d),0 10px 20px rgba(79,93,224,.22);transition:transform .08s,box-shadow .08s,background-color .25s;user-select:none;-webkit-user-select:none}
.btn:active{transform:translate(2px,3px);box-shadow:0 1px 0 var(--brand-d),0 4px 10px rgba(79,93,224,.2)}
.btn .t{position:relative;top:1px}
.btn .t.plain{top:0}
.btn.small{min-height:44px;padding:0 18px;font-size:16px;border-radius:12px 12px 12px 4px}
.btn.ghost{background:#fff;color:#3a3d4a;box-shadow:0 3px 0 #d6d4de;border:1.5px solid var(--line)}
.btn:disabled{opacity:.6;cursor:default}
.btn.ready{animation:ready 1.8s ease-in-out infinite}
@keyframes ready{0%,100%{box-shadow:0 4px 0 var(--brand-d),0 0 0 0 rgba(79,93,224,.35)}50%{box-shadow:0 4px 0 var(--brand-d),0 0 0 12px rgba(79,93,224,0)}}
/* ---------- cookie notices ---------- */
#layer{position:fixed;inset:0;z-index:500;pointer-events:none}
.cookie{position:absolute;pointer-events:auto;width:min(340px,calc(100vw - 24px));display:grid;grid-template-columns:44px 1fr;gap:2px 12px;padding:14px 14px 10px;background:#fff;border:1px solid #e3e1ea;border-radius:16px 16px 16px 5px;box-shadow:0 16px 40px rgba(30,30,60,.2);transform:rotate(var(--r,0deg));animation:cookieIn .42s cubic-bezier(.2,1.25,.4,1) both}
.cookie.leaving{animation:cookieOut .36s ease-in both;pointer-events:none}
.cookie-ico{grid-row:span 2;align-self:start;width:42px;height:42px;border-radius:50%;position:relative;background:radial-gradient(circle at 30% 36%,#6b4423 0 3px,transparent 3.5px),radial-gradient(circle at 63% 30%,#6b4423 0 2.5px,transparent 3px),radial-gradient(circle at 56% 64%,#6b4423 0 3px,transparent 3.5px),radial-gradient(circle at 28% 70%,#6b4423 0 2px,transparent 2.5px),radial-gradient(circle at 40% 40%,#e7b56f,#cf9550)}
.cookie-ico::after{content:"";position:absolute;width:15px;height:15px;border-radius:50%;background:#fff;top:-3px;right:-3px}
.cookie-ico.wiggle{animation:wiggle .5s ease}
.cookie-body b{display:block;font-size:16px;line-height:1.25}
.cookie-body span{display:block;font-size:14px;line-height:1.35;color:var(--muted)}
.cookie-btns{grid-column:2;display:flex;align-items:center;gap:6px;margin-top:8px}
.reject{min-height:44px;padding:0 8px;border:0;background:none;color:#9b9daa;font-size:11px;text-decoration:underline;text-underline-offset:4px}
@keyframes wiggle{25%{transform:rotate(-14deg)}70%{transform:rotate(10deg)}}
@keyframes cookieIn{from{opacity:0;transform:translateY(28px) scale(.95) rotate(var(--r,0deg))}to{opacity:1;transform:rotate(var(--r,0deg))}}
@keyframes cookieOut{to{opacity:0;transform:translateY(36px) rotate(calc(var(--r,0deg) * 3))}}
/* ---------- newsletter modal ---------- */
.skel i{display:block;height:14px;border-radius:7px;background:#ecebf2;margin:12px 0}
.overlay{position:absolute;inset:0;pointer-events:auto;background:rgba(30,30,44,.4);display:flex;padding:40px 28px;overflow:auto;animation:fadeIn .3s ease both}
.overlay.leaving{animation:fadeOut .4s ease both}
.overlay.leaving .modal{animation:modalOut .4s ease-in both}
.modal{position:relative;margin:auto;width:min(420px,100%);background:#fff;border-radius:22px 22px 22px 8px;padding:64px 22px 76px;text-align:center;box-shadow:0 26px 60px rgba(0,0,0,.28);transform:rotate(-.7deg);animation:modalIn .45s cubic-bezier(.2,1.15,.35,1) both}
.modal h2{margin:0 0 8px}
.modal p{margin:0 0 18px;color:#4a4d5a;padding:0 4px 0 7px}
@keyframes fadeIn{from{opacity:0}}
@keyframes fadeOut{to{opacity:0}}
@keyframes modalIn{from{opacity:0;transform:translateY(24px) scale(.96) rotate(-.7deg)}to{opacity:1;transform:rotate(-.7deg)}}
@keyframes modalOut{to{opacity:0;transform:translateY(30px) rotate(-3deg)}}
.envelope{position:relative;width:86px;height:58px;margin:0 auto 14px;background:#ffe6a0;border-radius:7px;box-shadow:inset 0 -3px 0 rgba(0,0,0,.05);transform:rotate(3deg)}
.envelope::before{content:"";position:absolute;left:0;top:0;border-left:43px solid transparent;border-right:43px solid transparent;border-top:32px solid #f6cf6a}
.envelope::after{content:"";position:absolute;width:14px;height:14px;border-radius:50%;background:#e9787c;left:37px;top:23px;box-shadow:0 0 0 3px #ffe6a0}
.closeb{position:absolute;display:inline-flex;align-items:center;gap:6px;min-height:44px;min-width:44px;padding:0 16px;border-radius:22px;border:1.5px solid #d4d3dd;background:#fff;color:#2a2c36;font-size:15px;font-weight:650;white-space:nowrap;box-shadow:0 4px 12px rgba(0,0,0,.1);transform:rotate(var(--r,0deg));animation:pop .38s cubic-bezier(.2,1.5,.4,1) both;z-index:2}
.closeb .x{font-size:20px;line-height:1;position:relative;top:-1px}
.closeb.gone{animation:popOut .26s ease-in both;pointer-events:none}
@keyframes pop{from{opacity:0;transform:scale(.4) rotate(var(--r,0deg))}to{opacity:1;transform:rotate(var(--r,0deg))}}
@keyframes popOut{to{opacity:0;transform:scale(.5) rotate(calc(var(--r,0deg) + 20deg))}}
/* ---------- terms ---------- */
.terms{max-height:132px;overflow:auto;border:1px solid var(--line);border-radius:12px;padding:10px 14px;background:#fbfbfd;font-size:14px;color:#454857;margin:6px 0 14px;-webkit-overflow-scrolling:touch}
.terms p{margin:0 0 7px}
.terms p:nth-child(2){padding-left:1px}
.terms p:nth-child(4){letter-spacing:.01em}
.check{display:flex;align-items:center;gap:14px;width:100%;min-height:58px;margin:8px 0;padding:10px 14px;background:#fff;border:1.5px solid var(--line);border-radius:14px;text-align:left;font-size:16px;line-height:1.3;transition:border-color .2s,background-color .2s}
.check[aria-checked="true"]{border-color:#c5c9f5;background:#f6f7ff}
.check:nth-of-type(2){margin-left:2px;width:calc(100% - 2px)}
.check .box{flex:none;position:relative;width:30px;height:30px;border-radius:8px;border:2px solid #b9bac9;background:#fff;transition:background-color .15s,border-color .15s}
.check[aria-checked="true"] .box{background:var(--brand);border-color:var(--brand)}
.check[aria-checked="true"] .box::after{content:"";position:absolute;left:9px;top:3px;width:8px;height:15px;border:solid #fff;border-width:0 3px 3px 0;transform:rotate(41deg)}
.check .lbl{position:relative;top:2px}
.check.slip .box{animation:slip .5s ease}
@keyframes slip{25%{transform:translateX(-5px) rotate(-8deg)}60%{transform:translateX(4px) rotate(4deg)}}
.dodge-zone{position:relative;height:190px;margin-top:12px}
.dodge{position:absolute;left:0;top:0;--x:0px;--y:0px;--rot:0deg;transform:translate(var(--x),var(--y)) rotate(var(--rot));transition:transform .32s cubic-bezier(.2,.9,.3,1.15),background-color .3s,box-shadow .08s;white-space:nowrap}
.dodge:active{transform:translate(var(--x),var(--y)) rotate(var(--rot)) translate(1px,3px)}
.dodge.tired{background:#7c86cf;--rot:-3deg}
.dodge.noanim{transition:none}
.dodge.shake{animation:dshake .4s ease}
@keyframes dshake{25%{transform:translate(calc(var(--x) - 7px),var(--y)) rotate(var(--rot))}75%{transform:translate(calc(var(--x) + 7px),var(--y)) rotate(var(--rot))}}
/* ---------- picture frames ---------- */
.wall{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:38px 16px;padding:32px 14px 16px;margin:6px 0 10px;border-radius:14px;background:linear-gradient(180deg,#f4efe4,#ede5d5);border:1px solid #e4dccb}
.frame{position:relative;display:block;width:100%;aspect-ratio:1/.82;padding:0;margin:0;border:8px solid var(--wood);border-radius:3px;background:#fff;box-shadow:inset 0 0 0 3px #f6efe1,0 6px 10px rgba(70,45,20,.2);transform:rotate(var(--a));transform-origin:50% -17px;transition:transform .75s cubic-bezier(.25,1.7,.45,1)}
.frame:nth-child(3n+2){margin-left:1px}
.frame .pic{position:absolute;inset:5px;border-radius:1px;pointer-events:none}
.frame::after{content:"";position:absolute;width:24px;height:24px;top:-20px;left:calc(50% - 12px);border-left:1.5px solid #8b8273;border-top:1.5px solid #8b8273;transform:rotate(45deg);pointer-events:none}
.frame::before{content:"";position:absolute;width:8px;height:8px;border-radius:50%;background:#6f6a62;top:-29px;left:calc(50% - 4px);z-index:1;box-shadow:0 1px 1px rgba(0,0,0,.3);pointer-events:none}
.frame.relapse{transition:transform 2.4s ease-in-out}
.frame.hint{animation:hint 2.6s ease-in-out infinite}
.frame.nudge{animation:nudge .45s ease}
@keyframes hint{0%,100%{box-shadow:inset 0 0 0 3px #f6efe1,0 6px 10px rgba(70,45,20,.2),0 0 0 0 rgba(79,93,224,0)}50%{box-shadow:inset 0 0 0 3px #f6efe1,0 6px 10px rgba(70,45,20,.2),0 0 0 7px rgba(79,93,224,.28)}}
@keyframes nudge{30%{transform:rotate(calc(var(--a) - 2deg))}65%{transform:rotate(calc(var(--a) + 1.2deg))}}
.tidy-status{font-weight:600;color:#4a4d5a;margin:8px 0 0}
/* ---------- progress ---------- */
.bignum{font-size:clamp(48px,13vw,72px);font-weight:800;letter-spacing:-.04em;line-height:1;font-variant-numeric:tabular-nums;margin:14px 0 4px 1px}
.bignum .pc{font-size:.45em;margin-left:3px;position:relative;top:1px;color:var(--muted)}
.bar{height:30px;border-radius:15px;background:#ecebf3;border:1px solid #dddbe7;overflow:hidden;margin:12px 0;transform:rotate(-.6deg)}
.fill{height:100%;width:0;border-radius:15px;background-color:#5865e4;background-image:linear-gradient(-45deg,rgba(255,255,255,.16) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.16) 50%,rgba(255,255,255,.16) 75%,transparent 75%,transparent);background-size:30px 30px;animation:stripes 2.2s linear infinite}
@keyframes stripes{to{background-position:30px 0}}
.pstatus{min-height:1.5em;color:#4a4d5a;font-weight:550;margin:6px 0 10px}
/* ---------- final screen (finally straight) ---------- */
.card.final{transform:none;animation-name:cardInStraight;text-align:center;padding:28px 20px;border-radius:20px;border-right-width:1px}
@keyframes cardInStraight{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:none}}
.final .btn{border-radius:15px}
.final .btn:active{transform:translateY(3px)}
.medal{position:relative;width:92px;height:92px;margin:6px auto 0;border-radius:50%;background:radial-gradient(circle at 35% 30%,#fff1bf,#f4bf52 58%,#d9962c);box-shadow:inset 0 -5px 0 rgba(0,0,0,.08),0 8px 18px rgba(205,145,40,.35);display:grid;place-items:center}
.medal::before,.medal::after{content:"";position:absolute;bottom:-34px;width:26px;height:48px;z-index:-1;clip-path:polygon(0 0,100% 0,100% 100%,50% 80%,0 100%)}
.medal::before{left:20px;background:#5865e4;transform:rotate(16deg)}
.medal::after{right:20px;background:#e9787c;transform:rotate(-16deg)}
.chk{width:20px;height:38px;border:solid #8a5a14;border-width:0 7px 7px 0;border-radius:2px;transform:translate(0,-4px) rotate(45deg)}
.thanks{font-size:clamp(30px,7.4vw,46px);line-height:1.12;letter-spacing:-.02em;margin:40px 0 10px;cursor:pointer;outline-offset:6px;border-radius:8px}
.word{white-space:nowrap}
.stray{display:inline-block;transform:rotate(-8deg) translateY(-1px);transform-origin:50% 80%;transition:transform .7s cubic-bezier(.25,1.7,.45,1)}
.stray.fixed{transform:none}
.muted{color:var(--muted);font-size:.92em}
.stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:10px;margin:20px 0 22px;text-align:left}
.stat{background:#f7f7fb;border:1px solid var(--line);border-radius:14px;padding:12px 14px}
.stat b{display:block;font-size:26px;line-height:1.1;font-variant-numeric:tabular-nums}
.stat span{font-size:13.5px;color:var(--muted)}
.center-row{justify-content:center}
.center{text-align:center;margin-left:0}
.confetti{position:absolute;inset:0;overflow:hidden;pointer-events:none}
.confetti i{position:absolute;top:-24px;border-radius:2px;opacity:.9;animation:fall linear both}
@keyframes fall{to{transform:translate(var(--dx),calc(100vh + 60px)) rotate(var(--rot))}}
/* ---------- footer, toasts, demo ---------- */
.foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px;margin-top:22px;padding-top:12px;border-top:1px solid var(--line);font-size:12.5px;color:var(--muted)}
.soundbtn{min-height:44px;padding:0 14px;border-radius:12px;border:1px solid var(--line);background:#fff;font-size:13.5px}
#toasts{position:fixed;left:0;right:0;top:calc(10px + env(safe-area-inset-top));z-index:900;display:flex;flex-direction:column;align-items:center;gap:8px;padding:0 16px;pointer-events:none}
.toast{max-width:440px;background:#24262f;color:#fff;font-size:15px;line-height:1.35;padding:11px 18px 11px 21px;border-radius:14px 14px 14px 4px;box-shadow:0 10px 26px rgba(0,0,0,.2);transform:rotate(var(--r,-.8deg));animation:toastIn .35s cubic-bezier(.2,1.2,.4,1) both}
.toast.out{animation:toastOut .4s ease both}
@keyframes toastIn{from{opacity:0;transform:translateY(-12px) rotate(var(--r,-.8deg))}to{opacity:1;transform:rotate(var(--r,-.8deg))}}
@keyframes toastOut{from{opacity:1;transform:rotate(var(--r,-.8deg))}to{opacity:0;transform:translateY(-10px) rotate(var(--r,-.8deg))}}
#finger{position:fixed;left:0;top:0;width:0;height:0;z-index:1000;pointer-events:none;display:none;transition:transform .2s cubic-bezier(.3,.7,.3,1)}
#finger .tip{position:absolute;left:-23px;top:-23px;width:46px;height:46px;border-radius:50%;background:rgba(35,38,52,.3);border:3px solid rgba(255,255,255,.95);box-shadow:0 4px 14px rgba(0,0,0,.25);transition:transform .08s,background-color .08s}
#finger.press .tip{transform:scale(.78);background:rgba(35,38,52,.45)}
#demoBadge{position:fixed;left:50%;bottom:calc(12px + env(safe-area-inset-bottom));transform:translateX(-50%) rotate(-1deg);z-index:1001;background:#24262f;color:#fff;font-size:14px;padding:9px 16px;border-radius:999px;pointer-events:none;display:none;white-space:nowrap;box-shadow:0 6px 18px rgba(0,0,0,.2)}
@media (prefers-reduced-motion: reduce){
*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}
}
</style>
</head>
<body>
<div id="page">
<header class="topbar">
<div class="logo"><span class="mark" aria-hidden="true"></span><span>Norm<span class="drop">a</span>l Website</span><sup>TM</sup></div>
<nav class="nav" aria-label="Main">
<button type="button" data-toast="You are already home.">Home</button>
<button type="button" data-toast="About us: we are a perfectly normal website.">About</button>
<button type="button" data-toast="You are still home. Twice now.">Home</button>
</nav>
<button type="button" class="burger" aria-label="Menu" data-toast="The menu is on a lunch break. It has four lines for some reason."><i></i><i></i><i></i><i></i></button>
</header>
<div class="statusline">
<div class="steps"><span class="dots" id="dots" aria-hidden="true"><i></i><i></i><i></i><i></i><i></i></span><span id="stepLabel">Step 1 of 5</span></div>
<span id="timer">Patience: 00:00</span>
</div>
<main id="stage"></main>
<footer class="foot">
<span>© 2025–2024 Normal Website Inc. All rights reserved. Some lefts, too.</span>
<button type="button" id="soundBtn" class="soundbtn">Sound: off</button>
</footer>
</div>
<div id="layer"></div>
<div id="toasts" aria-live="polite"></div>
<div id="finger" aria-hidden="true"><div class="tip"></div></div>
<div id="demoBadge">Demo · tap anywhere to try it yourself</div>
<script>
(() => {
'use strict';
/* ================= helpers ================= */
const $ = (s, r = document) => r.querySelector(s);
const $$ = (s, r = document) => Array.from(r.querySelectorAll(s));
const rand = (a, b) => a + Math.random() * (b - a);
const clamp = (v, a, b) => Math.max(a, Math.min(b, v));
const fmt = s => { s = Math.max(0, Math.floor(s)); return String(Math.floor(s / 60)).padStart(2, '0') + ':' + String(s % 60).padStart(2, '0'); };
const stageEl = $('#stage'), layer = $('#layer'), toastsEl = $('#toasts'), finger = $('#finger'), badge = $('#demoBadge');
const ABORT = { abort: true };
let SPEED = 1; // demo mode speeds up the page's own timers
const T = ms => ms / SPEED;
let TOKEN = 0; // bumps on every screen change; stale async work stops
let timers = [], cleanups = [];
let dodgeFn = null;
const S = {};
const D = { on: false, token: 0, endedAt: 0 };
function freshState() {
Object.assign(S, {
stage: -1, cookieScheduled: 0, cookieSpawned: 0, cookieAlive: 0, cookies: 0, cookiesDone: false,
closes: 0, dodges: 0, dodgeLeft: 6, nines: 0, frames: 0, pushes: 0, t0: Date.now(), endTime: 0
});
}
function later(fn, ms) { const id = setTimeout(fn, ms); timers.push(id); return id; }
function every(fn, ms) { const id = setInterval(fn, ms); timers.push(id); return id; }
function wait(ms) { const tok = TOKEN; return new Promise((res, rej) => later(() => (tok === TOKEN ? res() : rej(ABORT)), ms)); }
function on(t, ev, fn, o) { t.addEventListener(ev, fn, o); cleanups.push(() => t.removeEventListener(ev, fn, o)); }
function teardown() {
TOKEN++;
timers.forEach(id => { clearTimeout(id); clearInterval(id); });
timers = [];
cleanups.forEach(f => { try { f(); } catch (e) {} });
cleanups = [];
layer.innerHTML = '';
dodgeFn = null;
}
function tween(from, to, dur, ease, fn) {
const tok = TOKEN;
return new Promise((res, rej) => {
const t0 = performance.now();
const step = now => {
if (tok !== TOKEN) return rej(ABORT);
const k = dur <= 0 ? 1 : Math.min(1, (now - t0) / dur);
fn(from + (to - from) * ease(k));
if (k < 1) requestAnimationFrame(step); else res();
};
requestAnimationFrame(step);
});
}
/* ================= quiet, optional sound (off by default) ================= */
let AC = null, soundOn = false;
function tone(f1, f2, dur, vol) {
if (!soundOn || !AC) return;
try {
const t = AC.currentTime, o = AC.createOscillator(), g = AC.createGain();
o.type = 'sine';
o.frequency.setValueAtTime(f1, t);
o.frequency.exponentialRampToValueAtTime(f2, t + dur);
g.gain.setValueAtTime(0.0001, t);
g.gain.exponentialRampToValueAtTime(vol, t + 0.03);
g.gain.exponentialRampToValueAtTime(0.0001, t + dur);
o.connect(g); g.connect(AC.destination);
o.start(t); o.stop(t + dur + 0.05);
} catch (e) {}
}
const sfx = {
pop: () => tone(620, 470, 0.16, 0.03),
boop: () => tone(480, 360, 0.14, 0.03),
tick: () => tone(880, 840, 0.06, 0.018),
whoosh: () => tone(380, 760, 0.2, 0.022),
deflate: () => tone(520, 160, 1.1, 0.022),
chime: () => { tone(660, 660, 0.4, 0.028); setTimeout(() => tone(990, 990, 0.55, 0.022), 150); }
};
$('#soundBtn').addEventListener('click', () => {
if (!AC) { try { const C = window.AudioContext || window.webkitAudioContext; AC = C ? new C() : null; } catch (e) { AC = null; } }
if (!AC) { toast('Sound is not available here. Probably for the best.'); return; }
soundOn = !soundOn;
try { const p = AC.resume(); if (p && p.catch) p.catch(() => {}); } catch (e) {}
$('#soundBtn').textContent = soundOn ? 'Sound: on (very quiet)' : 'Sound: off';
if (soundOn) sfx.chime();
});
/* ================= toasts ================= */
function toast(msg, ms) {
ms = ms || 2800;
const t = document.createElement('div');
t.className = 'toast';
t.textContent = msg;
t.style.setProperty('--r', rand(-1.4, 0.6).toFixed(2) + 'deg');
toastsEl.appendChild(t);
while (toastsEl.children.length > 3) toastsEl.firstElementChild.remove();
setTimeout(() => { t.classList.add('out'); setTimeout(() => t.remove(), 450); }, ms / Math.min(SPEED, 1.6));
}
document.addEventListener('click', e => {
const t = e.target && e.target.closest ? e.target.closest('[data-toast]') : null;
if (t) toast(t.dataset.toast);
});
/* ================= chrome: steps, clock, title ================= */
const STEP_LABELS = ['Step 1 of 5', 'Step 2 of 5', 'Step 3 of 5', 'Step 3½ of 5', 'Step 5 of 4', 'Step 6 of 5 (bonus)'];
const TITLES = ['Normal Website', 'Normal Website (1)', 'Terms_final_FINAL (2)', 'Normal Website – Gallery', 'Processing…', 'Thank you!'];
function tickClock() {
const sec = Math.floor(((S.endTime || Date.now()) - S.t0) / 1000);
const shown = (!S.endTime && sec > 5 && sec % 9 === 8) ? sec - 2 : sec; // the clock occasionally goes backwards
$('#timer').textContent = 'Patience: ' + fmt(shown);
}
setInterval(tickClock, 1000);
function updateChrome() {
$('#stepLabel').textContent = STEP_LABELS[S.stage] || '';
$$('#dots i').forEach((d, i) => d.classList.toggle('on', i <= S.stage));
document.body.classList.toggle('straight', S.stage === 5);
document.title = TITLES[S.stage] || 'Normal Website';
tickClock();
}
/* text that is (mostly) one pixel off */
function wobble(el) {
if (!el) return;
const text = el.textContent.trim();
el.setAttribute('aria-label', text);
el.textContent = '';
let n = 0;
const words = text.split(/\s+/);
words.forEach((word, wi) => {
const w = document.createElement('span');
w.className = 'w';
w.setAttribute('aria-hidden', 'true');
for (const ch of word) {
const s = document.createElement('span');
s.className = 'l';
s.textContent = ch;
const h = (n * 37 + 11) % 17;
if (h === 3 || h === 9) s.style.top = '1px';
else if (h === 14) s.style.top = '-1px';
else if (h === 6) s.style.left = '1px';
w.appendChild(s);
n++;
}
el.appendChild(w);
if (wi < words.length - 1) el.appendChild(document.createTextNode(' '));
});
const ls = el.querySelectorAll('.l'), tall = 'ltifkdbhT';
for (let i = Math.floor(ls.length * 0.55); i < ls.length; i++) {
if (tall.indexOf(ls[i].textContent) >= 0) { ls[i].style.transform = 'rotate(5deg)'; break; }
}
}
/* ================= navigation ================= */
const STAGES = [];
function go(n) {
teardown();
S.stage = n;
stageEl.innerHTML = '';
updateChrome();
STAGES[n](stageEl);
try { window.scrollTo({ top: 0, behavior: 'smooth' }); } catch (e) { try { window.scrollTo(0, 0); } catch (e2) {} }
}
function resetAll() { teardown(); freshState(); toastsEl.innerHTML = ''; go(0); }
/* ================= 0. welcome + multiplying cookies ================= */
const COOKIES = [
['We use cookies', 'to make this website feel normal.'],
['We also use cookies', 'to remember that you accepted our cookies.'],
['This notice uses cookies', 'Accepting it also accepts them. Sorry.'],
['Cookie update', 'Your cookie preferences have changed. Please accept the change.'],
['Secondhand cookies', 'A previous notice left some cookies behind. Accept them too?'],
['Final cookie notice', 'Probably. Accept to find out.']
];
const COOKIE_MAX = COOKIES.length;
function scheduleCookies(n, delay) {
for (let k = 0; k < n; k++) {
S.cookieScheduled++;
S.cookieAlive++;
later(spawnCookie, T(delay + k * 180));
}
}
function spawnCookie() {
if (S.stage !== 0) return;
const i = S.cookieSpawned++;
const c = COOKIES[Math.min(i, COOKIES.length - 1)];
const el = document.createElement('div');
el.className = 'cookie';
el.setAttribute('role', 'dialog');
el.setAttribute('aria-label', c[0]);
el.innerHTML = `<div class="cookie-ico" aria-hidden="true"></div>
<div class="cookie-body"><b>${c[0]}</b><span>${c[1]}</span></div>
<div class="cookie-btns"><button type="button" class="btn small" data-a="accept"><span class="t">Accept</span></button><button type="button" class="reject" data-a="reject">reject</button></div>`;
el.style.setProperty('--r', (i === 0 ? -0.8 : rand(-3.4, 3.4)).toFixed(2) + 'deg');
el.style.zIndex = String(10 + i);
el.style.visibility = 'hidden';
layer.appendChild(el);
const vw = window.innerWidth, vh = window.innerHeight, w = el.offsetWidth, hh = el.offsetHeight;
const bottomGap = D.on ? 64 : 22;
let left, top;
if (i === 0) { left = (vw - w) / 2 + 3; top = vh - hh - bottomGap; }
else { left = rand(10, Math.max(10, vw - w - 10)); top = rand(Math.min(vh * 0.3, vh - hh - 70), vh - hh - 60); }
el.style.left = clamp(left, 6, Math.max(6, vw - w - 6)) + 'px';
el.style.top = clamp(top, 56, Math.max(56, vh - hh - 10)) + 'px';
el.style.visibility = '';
el.addEventListener('click', e => {
const b = e.target.closest('button[data-a]');
if (b && !el.classList.contains('leaving')) dismissCookie(el, b.dataset.a);
});
sfx.pop();
}
function dismissCookie(el, how) {
el.classList.add('leaving');
S.cookies++;
S.cookieAlive--;
sfx.boop();
setTimeout(() => el.remove(), 400);
const n = Math.min(2, COOKIE_MAX - S.cookieScheduled);
if (how === 'reject') toast('Rejection noted. We made a cookie about it.');
else if (S.cookies === 1) toast('Thank you! Unfortunately, cookies attract more cookies.');
else if (n === 0 && S.cookieAlive === 2) toast('Almost there. These are the last ones. Probably.');
if (n > 0) scheduleCookies(n, 160);
if (S.cookieAlive <= 0) {
S.cookiesDone = true;
later(() => {
toast('All cookies accepted. You now own ' + S.cookies + ' cookies.');
const sb = $('#startBtn');
if (sb) sb.classList.add('ready');
sfx.chime();
}, T(350));
}
}
STAGES[0] = root => {
root.innerHTML = `<section class="card">
<div class="crumbs">Home <span>›</span> Home <span>›</span> Welcome</div>
<h1 class="wob">Welcome to a perfectly normal website</h1>
<div class="split-rule" aria-hidden="true"><i></i><i></i></div>
<p class="lede">Everything here is completely fine, carefully aligned and <span class="serif">extremely</span> normal. Please relax and enjoy your stay.</p>
<ul class="chips"><li>Fast</li><li>Tidy</li><li>Straight</li><li>Normal</li><li>Normal</li></ul>
<div class="row"><button type="button" class="btn" id="startBtn"><span class="t">Get started</span></button></div>
<p class="fine">By continuing, you agree to continue.</p>
</section>`;
wobble($('.wob', root));
$('#startBtn', root).addEventListener('click', () => {
if (!S.cookiesDone) {
toast('Please accept the cookies first. They are still warm.');
$$('.cookie-ico').forEach(c => { c.classList.remove('wiggle'); void c.offsetWidth; c.classList.add('wiggle'); });
if (!S.cookieScheduled) scheduleCookies(1, 0);
return;
}
sfx.boop();
go(1);
});
if (!S.cookiesDone && !S.cookieScheduled) scheduleCookies(1, 800);
};
/* ================= 1. newsletter pop-up with reproducing Close buttons ================= */
const CLOSE_LABELS = ['Close', 'Close', 'Close (again)', 'Clsoe', 'Close for real', 'The actual Close'];
const CLOSE_POS = ['top:12px;right:12px', 'bottom:14px;left:14px', 'top:12px;left:12px', 'top:44%;right:-16px', 'bottom:14px;right:14px', 'top:-24px;left:calc(50% - 78px)'];
const CLOSE_TOASTS = { 1: 'That Close button had a backup.', 3: 'Close buttons are multiplying. This is normal.', 5: 'This one is the real one. We think.' };
STAGES[1] = root => {
root.innerHTML = `<section class="card">
<div class="crumbs">Home <span>›</span> Content <span>›</span> More content</div>
<h2>The content you came for</h2>
<div class="skel" aria-hidden="true"><i style="width:92%"></i><i style="width:76%"></i><i style="width:85%;margin-left:1px"></i><i style="width:58%"></i></div>
<p class="sub">Loading content....</p>
</section>`;
later(openModal, T(550));
};
function openModal() {
const ov = document.createElement('div');
ov.className = 'overlay';
ov.innerHTML = `<div class="modal" role="dialog" aria-modal="true" aria-labelledby="mTitle">
<div class="envelope" aria-hidden="true"></div>
<h2 id="mTitle">Wait! Before you continue…</h2>
<p id="mText">Subscribe to <b>Slightly Late Weekly</b>, the newsletter that arrives one day after you needed it.</p>
<button type="button" class="btn" id="subBtn"><span class="t">Subscribe</span></button>
</div>`;
layer.appendChild(ov);
const modal = $('.modal', ov);
let subbed = 0;
$('#subBtn', ov).addEventListener('click', e => {
subbed++;
const b = e.currentTarget;
if (subbed === 1) {
toast('Subscribed! Your first issue arrives yesterday.');
$('.t', b).textContent = 'Subscribed (yesterday)';
b.classList.add('ghost');
} else toast('You are already subscribed. Please close this instead.');
});
addClose(ov, modal, 0);
}
function addClose(ov, modal, i) {
const b = document.createElement('button');
b.type = 'button';
b.className = 'closeb';
b.style.cssText = CLOSE_POS[i];
b.style.setProperty('--r', (i === 0 ? 0 : rand(-5, 5)).toFixed(1) + 'deg');
b.innerHTML = (i === 0 || i === 4 ? '<span class="x" aria-hidden="true">×</span>' : '') + '<span>' + CLOSE_LABELS[i] + '</span>';
b.addEventListener('click', () => {
if (b.classList.contains('gone')) return;
b.classList.add('gone');
S.closes++;
sfx.boop();
setTimeout(() => b.remove(), 280);
if (i + 1 < CLOSE_LABELS.length) {
later(() => addClose(ov, modal, i + 1), T(150));
if (CLOSE_TOASTS[i + 1]) toast(CLOSE_TOASTS[i + 1]);
} else {
$('#mTitle', modal).textContent = 'Fine.';
$('#mText', modal).textContent = 'This pop-up will now close itself, out of embarrassment.';
const sb = $('#subBtn', modal);
if (sb) sb.style.visibility = 'hidden';
later(() => ov.classList.add('leaving'), T(1200));
later(() => go(2), T(1600));
}
});
modal.appendChild(b);
}
/* ================= 2. terms + a shy Continue button ================= */
const DODGE_LABELS = ['Continue', 'Nope', 'Too slow', 'Almost', 'Not quite', 'Okay, okay…', 'Fine. Tap me.'];
STAGES[2] = root => {
root.innerHTML = `<section class="card">
<div class="crumbs">Home <span>›</span> Legal <span>›</span> Legal again</div>
<h2 class="wob">Terms and Conditions</h2>
<div class="terms" tabindex="0" aria-label="Terms">
<p><b>1.</b> You agree that this website is normal.</p>
<p><b>2.</b> Everything here is straight, give or take a pixel.</p>
<p><b>3.</b> Cookies accepted on this website are not legally binding, only emotionally.</p>
<p><b>4.</b> The Continue button has its own terms and may not agree to yours.</p>
<p><b>5.</b> This section was left blank intentionally.</p>
<p><b>6.</b> There is no section 5.</p>
</div>
<button type="button" class="check" role="checkbox" aria-checked="false"><span class="box" aria-hidden="true"></span><span class="lbl">I have read the terms</span></button>
<button type="button" class="check" role="checkbox" aria-checked="false"><span class="box" aria-hidden="true"></span><span class="lbl">I have read the terms about reading the terms</span></button>
<button type="button" class="check" role="checkbox" aria-checked="false"><span class="box" aria-hidden="true"></span><span class="lbl">I agree to agree</span></button>
<div class="dodge-zone"><button type="button" class="btn dodge noanim" id="contBtn"><span class="t">Continue</span></button></div>
</section>`;
wobble($('.wob', root));
S.dodgeLeft = 6;
const checks = $$('.check', root);
const slipped = [false, false, false];
const isOn = c => c.getAttribute('aria-checked') === 'true';
checks.forEach((c, i) => c.addEventListener('click', () => {
const v = !isOn(c);
c.setAttribute('aria-checked', String(v));
sfx.tick();
if (v && i > 0 && !slipped[i]) {
slipped[i] = true;
const prev = checks[i - 1];
if (isOn(prev)) later(() => {
prev.setAttribute('aria-checked', 'false');
prev.classList.remove('slip'); void prev.offsetWidth; prev.classList.add('slip');
toast(i === 1 ? 'Box 1 slipped. Sorry about that.' : 'Box 2 got nervous and unticked itself.');
}, T(450));
}
}));
const zone = $('.dodge-zone', root), btn = $('#contBtn', root), lbl = $('.t', btn);
let pos = { x: 0, y: 0 }, lastDodge = 0;
const bounds = () => ({ mx: Math.max(0, zone.clientWidth - btn.offsetWidth), my: Math.max(0, zone.clientHeight - btn.offsetHeight) });
const place = (x, y) => {
const b = bounds();
pos = { x: clamp(x, 0, b.mx), y: clamp(y, 0, b.my) };
btn.style.setProperty('--x', pos.x + 'px');
btn.style.setProperty('--y', pos.y + 'px');
};
place((zone.clientWidth - btn.offsetWidth) / 2, zone.clientHeight - btn.offsetHeight - 18);
void btn.offsetWidth;
btn.classList.remove('noanim');
function dodgeFrom(px, py) {
if (S.dodgeLeft <= 0) return;
S.dodgeLeft--;
S.dodges++;
lbl.textContent = DODGE_LABELS[6 - S.dodgeLeft];
if (S.dodgeLeft === 0) btn.classList.add('tired');
const zr = zone.getBoundingClientRect(), b = bounds();
const bw = btn.offsetWidth, bh = btn.offsetHeight;
const lx = px - zr.left, ly = py - zr.top;
let best = { x: 0, y: 0 }, bestD = -1;
for (let k = 0; k < 16; k++) {
const x = rand(0, b.mx), y = rand(0, b.my);
const d = Math.hypot(x + bw / 2 - lx, y + bh / 2 - ly) + 0.35 * Math.hypot(x - pos.x, y - pos.y);
if (d > bestD) { bestD = d; best = { x, y }; }
}
place(best.x, best.y);
sfx.whoosh();
if (S.dodges === 1) toast('The Continue button is a little shy.');
if (S.dodgeLeft === 0) toast('It gave up. You may now tap it.');
}
dodgeFn = dodgeFrom;
btn.addEventListener('pointerdown', e => {
if (S.dodgeLeft > 0) { e.preventDefault(); lastDodge = performance.now(); dodgeFrom(e.clientX, e.clientY); }
});
on(document, 'pointermove', e => { // bonus for mice: it also runs when you get close
if (e.pointerType !== 'mouse' || S.dodgeLeft <= 0 || D.on) return;
const now = performance.now();
if (now - lastDodge < 380) return;
const r = btn.getBoundingClientRect();
const dx = Math.max(r.left - e.clientX, 0, e.clientX - r.right), dy = Math.max(r.top - e.clientY, 0, e.clientY - r.bottom);
if (Math.hypot(dx, dy) < 30) { lastDodge = now; dodgeFrom(e.clientX, e.clientY); }
});
on(window, 'resize', () => place(pos.x, pos.y));
btn.addEventListener('click', () => {
if (S.dodgeLeft > 0) { const r = btn.getBoundingClientRect(); dodgeFrom(r.left + r.width / 2, r.top + r.height / 2); return; }
if (!checks.every(isOn)) {
toast('Please tick all three boxes first. They miss you.');
btn.classList.remove('shake'); void btn.offsetWidth; btn.classList.add('shake');
return;
}
sfx.chime();
go(3);
});
};
/* ================= 3. crooked picture frames ================= */
const PICS = [
'radial-gradient(circle at 70% 32%, #ffd66b 0 13%, transparent 14%), linear-gradient(to top, #7cb46b 0 32%, #a8dcf5 32%)',
'radial-gradient(circle at 30% 32%, #f6f1cf 0 12%, transparent 13%), linear-gradient(#25305c, #42528f)',
'radial-gradient(ellipse at 50% 100%, #2f6db0 0 45%, transparent 46%), linear-gradient(#ffcf9e, #f7a48b)',
'linear-gradient(90deg, #f28c8c 0 33%, #f5d48b 33% 66%, #8cc7b8 66%)',
'conic-gradient(from 135deg at 50% 28%, #6d7f99 0 90deg, transparent 90deg), linear-gradient(#cfe7f7, #eef6fb)',
'radial-gradient(circle at 50% 54%, #f4a259 0 27%, transparent 28%), radial-gradient(circle at 57% 26%, #6aa84f 0 7%, transparent 8%), #fbeedb',
'repeating-linear-gradient(45deg, #b9a3e3 0 8px, #ebe3fb 8px 16px)',
'radial-gradient(circle at 25% 70%, #ff8fab 0 6%, transparent 7%), radial-gradient(circle at 58% 80%, #ffd166 0 6%, transparent 7%), radial-gradient(circle at 80% 64%, #ff8fab 0 5%, transparent 6%), linear-gradient(to top, #8bc78b 0 42%, #d6f0ff 42%)',
'radial-gradient(circle at 51.5% 50%, #2a2a2a 0 4%, transparent 4.5%), #f7f6f0'
];
const ANGLES = [-6, 4.5, -8, 5.5, -3.5, 0.8, 7, -5, 3];
STAGES[3] = root => {
root.innerHTML = `<section class="card">
<div class="crumbs">Home <span>›</span> Gallery <span>›</span> Wall</div>
<h2>Tidiness check</h2>
<p class="sub">Some of these picture frames are a bit crooked. Tap each crooked frame to straighten it.</p>
<div class="wall">${PICS.map((p, i) => `<button type="button" class="frame" style="--a:${ANGLES[i]}deg" aria-label="Picture frame ${i + 1}"><span class="pic" style="background:${p}"></span></button>`).join('')}</div>
<p class="tidy-status" id="tidyStatus" aria-live="polite">0 of 9 straight</p>
<div class="row" id="tidyRow"></div>
</section>`;
const frames = $$('.frame', root), status = $('#tidyStatus', root), row = $('#tidyRow', root);
const straight = frames.map(() => false);
let phase = 0, hinted = false, lastAct = performance.now();
const count = () => straight.filter(Boolean).length;
const update = () => {
const c = count();
status.textContent = c === 9 ? (phase === 2 ? '9 of 9 straight. Perfectly tidy. We measured.' : '9 of 9 straight. Lovely!') : c + ' of 9 straight';
if (c === 9 && phase === 0) {
phase = 1;
later(() => {
const k = 2;
straight[k] = false;
phase = 2;
hinted = false;
lastAct = performance.now();
frames[k].classList.add('relapse');
frames[k].style.transitionDuration = (2.4 / SPEED).toFixed(2) + 's';
frames[k].style.setProperty('--a', '3.5deg');
toast('Frame 3 slowly un-straightened itself. Frames do that.');
update();
}, T(1100));
} else if (c === 9 && phase === 2 && !row.firstChild) {
sfx.chime();
row.innerHTML = '<button type="button" class="btn" id="tidyBtn"><span class="t">Continue</span></button>';
$('#tidyBtn', row).addEventListener('click', () => { sfx.boop(); go(4); });
}
};
frames.forEach((f, i) => f.addEventListener('click', () => {
lastAct = performance.now();
if (straight[i]) { f.classList.remove('nudge'); void f.offsetWidth; f.classList.add('nudge'); return; }
straight[i] = true;
S.frames++;
f.classList.remove('hint', 'relapse', 'nudge');
f.style.transitionDuration = '';
f.style.setProperty('--a', '0deg');
sfx.tick();
update();
}));
every(() => {
const left = straight.map((s, i) => (s ? -1 : i)).filter(i => i >= 0);
if (hinted || phase === 1 || !left.length || left.length > 2) return;
if (performance.now() - lastAct > 6500) {
hinted = true;
left.forEach(i => frames[i].classList.add('hint'));
toast(left.length === 1 ? 'One frame is still very slightly crooked. Look closely.' : 'A couple of frames are still a little crooked.');
}
}, 1000);
};
/* ================= 4. the progress bar that slides back at 99% ================= */
const PSTAT = ['Warming up the progress bar', 'Counting pixels', 'Moving everything one pixel to the left', 'Re-reading the terms', 'Straightening the frames again', 'Asking the server nicely', 'Almost there', 'Almost almost there', 'Extremely almost there'];
STAGES[4] = root => {
root.innerHTML = `<section class="card">
<div class="crumbs">Home <span>›</span> Processing <span>›</span> Still processing</div>
<h2>Processing your patience</h2>
<p class="sub">Please do not close this page. Or do. It will not help.</p>
<div class="bignum" aria-hidden="true"><span id="pnum">0</span><span class="pc">%</span></div>
<div class="bar" id="pbar" role="progressbar" aria-label="Progress" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="fill" id="pfill"></div></div>
<p class="pstatus" id="pstat" aria-live="polite">Starting…</p>
<div class="row" id="prow"></div>
</section>`;
const num = $('#pnum', root), fill = $('#pfill', root), bar = $('#pbar', root), stat = $('#pstat', root), row = $('#prow', root);
const PS = D.on ? 7 : 1;
const hold = ms => wait(ms / Math.min(PS, 3));
let p = 0, lastInt = -1, statusLock = false;
const show = v => {
p = v;
fill.style.width = clamp(v, 0, 100) + '%';
num.textContent = v >= 100 ? '100' : v < 96 ? String(Math.floor(v)) : (Math.floor(v * 10) / 10).toFixed(1);
const f = Math.floor(v);
if (f !== lastInt) { lastInt = f; bar.setAttribute('aria-valuenow', String(f)); document.title = '(' + f + '%) Processing…'; }
if (!statusLock) stat.textContent = PSTAT[clamp(Math.floor(v / 100 * PSTAT.length), 0, PSTAT.length - 1)] + '…';
};
const easeOut = k => 1 - Math.pow(1 - k, 2.2);
const easeIO = k => (k < 0.5 ? 2 * k * k : 1 - Math.pow(-2 * k + 2, 2) / 2);
const tw = (to, ms) => tween(p, to, ms / PS, easeOut, show);
const slide = (to, ms) => tween(p, to, ms / Math.min(PS, 2.5), easeIO, show);
const say = txt => { statusLock = true; stat.textContent = txt; };
const free = () => { statusLock = false; };
(async () => {
try {
show(0);
await wait(400 / PS);
await tw(34, 900); await tw(52, 1100);
say('Thinking about it…'); await wait(600 / PS); free();
await tw(91, 1200); await tw(99, 1500);
S.nines++; say('99%! Nearly done…'); await hold(800);
say('Whoops. It slid back a little.'); sfx.deflate(); await slide(58, 1300); await hold(500); free();
await tw(93, 1500); await tw(99, 1300);
S.nines++; say('99% again! Surely this time…'); await hold(700);
say('Hold on, it is slipping.'); sfx.deflate(); await slide(88, 1000); await hold(350); free();
await tw(99, 1500);
S.nines++; say('Stuck at 99.0%. This is completely normal.');
await hold(1000);
row.innerHTML = '<button type="button" class="btn" id="pushBtn"><span class="t">Give it a gentle push</span></button>';
const pb = $('#pushBtn', row);
let busy = false;
pb.addEventListener('click', async () => {
if (busy) return;
busy = true;
S.pushes++;
sfx.tick();
try {
if (S.pushes === 1) { say('It moved! A tiny bit.'); await tw(99.4, 500); }
else if (S.pushes === 2) { say('Keep going. Gently.'); await tw(99.8, 500); }
else {
pb.disabled = true;
pb.classList.add('ghost');
await tw(100, 600);
say('100%. Huh. That basically never happens.'); sfx.chime();
await hold(900);
num.textContent = '101'; say('Oops. 101%.');
await hold(800);
num.textContent = '100'; say('Fixed. Exactly 100%. Thank you.');
await hold(1000);
go(5);
return;
}
} catch (e) { return; }
busy = false;
});
} catch (e) { /* screen changed */ }
})();
};
/* ================= 5. thank you (everything finally straight) ================= */
function confetti(n) {
try { if (window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches) return; } catch (e) {}
const box = document.createElement('div');
box.className = 'confetti';
box.setAttribute('aria-hidden', 'true');
const cols = ['#ffb3c1', '#ffd6a5', '#caffbf', '#9bf6ff', '#bdb2ff', '#fdffb6', '#a0c4ff'];
for (let i = 0; i < n; i++) {
const c = document.createElement('i');
c.style.left = rand(0, 100).toFixed(1) + '%';
c.style.background = cols[i % cols.length];
c.style.width = rand(7, 12).toFixed(1) + 'px';
c.style.height = rand(10, 16).toFixed(1) + 'px';
c.style.setProperty('--dx', rand(-80, 80).toFixed(0) + 'px');
c.style.setProperty('--rot', rand(-540, 540).toFixed(0) + 'deg');
c.style.animationDuration = rand(5, 9).toFixed(2) + 's';
c.style.animationDelay = rand(0, 2.5).toFixed(2) + 's';
box.appendChild(c);
}
layer.appendChild(box);
setTimeout(() => box.remove(), 12500);
}
STAGES[5] = root => {
S.endTime = Date.now();
tickClock();
const secs = Math.round((S.endTime - S.t0) / 1000);
const stats = [
[S.cookies, 'cookies accepted'], [S.closes, 'Close buttons closed'], [S.dodges, 'times a button ran away'],
[S.frames, 'frames straightened'], [S.nines, 'visits to 99%'], [fmt(secs), 'of pure patience']
];
root.innerHTML = `<section class="card final">
<div class="medal" aria-hidden="true"><span class="chk"></span></div>
<h1 class="thanks" id="thanks" role="button" tabindex="0">Thank you for your <span class="word"><span class="stray">p</span>atience</span>.</h1>
<p class="sub center" id="thanksSub">You made it. Everything on this page is now perfectly straight.<br><span class="muted">(Okay, one letter is not. Tap it if it bothers you.)</span></p>
<div class="stats">${stats.map(s => `<div class="stat"><b>${s[0]}</b><span>${s[1]}</span></div>`).join('')}</div>
<div class="row center-row"><button type="button" class="btn" id="againBtn"><span class="t plain">Start over</span></button></div>
<p class="fine center">This button is perfectly normal. We checked twice.</p>
</section>`;
let fixed = false;
const fix = () => {
if (fixed) { toast('It is perfectly straight now. We promise.'); return; }
fixed = true;
$('.stray', root).classList.add('fixed');
$('#thanksSub', root).innerHTML = 'There. Perfect.<br><span class="muted">Sincerely: thank you for your patience.</span>';
sfx.chime();
confetti(26);
};
const th = $('#thanks', root);
th.addEventListener('click', fix);
th.addEventListener('keydown', e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); fix(); } });
$('#againBtn', root).addEventListener('click', () => resetAll());
sfx.chime();
confetti(40);
};
/* ================= #demo: hands-free loop with a pretend finger ================= */
function dsleep(ms) {
const tok = D.token;
return new Promise((res, rej) => setTimeout(() => ((D.on && tok === D.token) ? res() : rej(ABORT)), ms));
}
function moveFinger(x, y, dur) {
dur = dur == null ? 180 : dur;
finger.style.transitionDuration = dur + 'ms';
finger.style.transform = 'translate(' + x.toFixed(1) + 'px,' + y.toFixed(1) + 'px)';
return dsleep(dur + 15);
}
async function ensureVisible(el) {
const r = el.getBoundingClientRect();
if (r.top < 8 || r.bottom > window.innerHeight - 8) {
try { el.scrollIntoView({ block: 'center', behavior: 'smooth' }); } catch (e) { el.scrollIntoView(); }
await dsleep(420);
}
}
async function fingerTap(el) {
if (!el || !el.isConnected) return;
await ensureVisible(el);
if (!el.isConnected) return;
const r = el.getBoundingClientRect();
await moveFinger(r.left + r.width / 2, r.top + r.height / 2);
if (!el.isConnected) return;
finger.classList.add('press');
await dsleep(60);
el.click();
finger.classList.remove('press');
await dsleep(30);
}
async function until(fn, ms) {
const t0 = Date.now();
let v;
while (!(v = fn())) {
if (Date.now() - t0 > ms) return null;
await dsleep(70);
}
return v;
}
async function runDemo() {
if (D.on) return;
D.on = true;
const tok = ++D.token;
SPEED = 3;
document.body.classList.add('demo');
finger.style.display = 'block';
badge.style.display = 'block';
try {
while (D.on && tok === D.token) {
resetAll();
await moveFinger(window.innerWidth * 0.5, window.innerHeight * 0.62, 0);
// 1. cookies that multiply
for (let g = 0; g < 60 && !S.cookiesDone; g++) {
const list = $$('.cookie:not(.leaving)');
const c = list[list.length - 1];
if (!c) { await dsleep(80); continue; }
await fingerTap($(S.cookies === 2 ? '[data-a=reject]' : '[data-a=accept]', c));
await dsleep(60);
}
await dsleep(220);
await fingerTap($('#startBtn'));
// 2. Close buttons that spawn Close buttons
await until(() => $('.closeb:not(.gone)'), 3000);
for (let g = 0; g < 80 && S.stage === 1; g++) {
const b = $('.closeb:not(.gone)');
if (b) { await fingerTap(b); await dsleep(60); } else await dsleep(80);
}
// 3. slippery checkboxes + the shy button
await until(() => S.stage === 2 && $('.check'), 3000);
const cs = $$('.check');
for (const i of [0, 1, 0, 2, 1]) { await fingerTap(cs[i]); await dsleep(50); }
const cb = $('#contBtn');
if (cb) {
await ensureVisible(cb);
for (let g = 0; g < 10 && S.dodgeLeft > 0; g++) {
const r = cb.getBoundingClientRect();
const x = r.left + r.width / 2, y = r.top + r.height / 2;
moveFinger(x, y, 220).catch(() => {});
await dsleep(150);
if (dodgeFn) dodgeFn(x, y);
await dsleep(150);
}
await dsleep(220);
await fingerTap(cb);
}
// 4. crooked frames
await until(() => S.stage === 3 && $('.frame'), 3000);
for (const f of $$('.frame')) await fingerTap(f);
const rel = await until(() => $('.frame.relapse'), 4000);
await dsleep(700);
if (rel) await fingerTap(rel);
const tb = await until(() => $('#tidyBtn'), 3000);
await dsleep(180);
await fingerTap(tb);
// 5. progress bar that slides back
const pb = await until(() => $('#pushBtn'), 12000);
for (let k = 0; k < 3 && pb; k++) { await fingerTap(pb); await dsleep(120); }
await until(() => S.stage === 5, 8000);
await dsleep(600);
await fingerTap($('#thanks'));
await dsleep(1600);
}
} catch (e) {
if (e !== ABORT) { try { console.error(e); } catch (e2) {} }
}
}
function endDemo() {
if (!D.on) return;
D.on = false;
D.token++;
D.endedAt = Date.now();
SPEED = 1;
document.body.classList.remove('demo');
finger.style.display = 'none';
finger.classList.remove('press');
badge.style.display = 'none';
try { if (location.hash === '#demo') history.replaceState(null, '', location.pathname + location.search); } catch (e) {}
resetAll();
toast('Demo over. Your turn. Good luck.');
}
window.addEventListener('pointerdown', e => {
if (!D.on || !e.isTrusted) return;
e.stopPropagation();
e.preventDefault();
endDemo();
}, true);
window.addEventListener('click', e => {
if (e.isTrusted && Date.now() - D.endedAt < 600) { e.stopPropagation(); e.preventDefault(); }
}, true);
window.addEventListener('keydown', e => { if (D.on && e.isTrusted) endDemo(); }, true);
window.addEventListener('hashchange', () => { if (location.hash === '#demo') runDemo(); });
/* a favicon that is, of course, slightly crooked */
try {
const c = document.createElement('canvas');
c.width = c.height = 64;
const x = c.getContext('2d');
x.translate(32, 32); x.rotate(0.13);
x.fillStyle = '#4f5de0'; x.fillRect(-22, -22, 44, 44);
x.fillStyle = '#ffffff'; x.fillRect(-9, -9, 19, 19);
const l = document.createElement('link');
l.rel = 'icon';
l.href = c.toDataURL('image/png');
document.head.appendChild(l);
} catch (e) {}
/* ================= start ================= */
freshState();
if (location.hash === '#demo') runDemo(); else go(0);
})();
</script>
</body>
</html>
