Lava lamp v1 · Codex CLI25.11.2026 11:41
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"><meta name="theme-color" content="#1a1024"><title>Lava Lamp</title><style> * { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; } :root { --desk-h: 20dvh; --glass-w: clamp(132px, 40vw, 176px); --glass-h: clamp(280px, 50dvh, 460px); } html, body { height: 100%; } body { font-family: ui-rounded, "SF Pro Rounded", -apple-system, "Segoe UI", Roboto, sans-serif; background: #140d1e; overflow: hidden; display: flex; justify-content: center; } .stage { position: relative; width: 100%; max-width: 480px; height: 100dvh; overflow: hidden; background: radial-gradient(120% 60% at 50% 0%, #2b1a3e 0%, #1c1228 55%, #140d1e 100%); } .wall-art { position: absolute; top: 8%; left: 50%; transform: translateX(-50%); text-align: center; letter-spacing: 0.35em; color: #4a3a5c; font-size: 11px; font-weight: 600; text-transform: uppercase; user-select: none; } .glow { position: absolute; left: 50%; top: 44%; width: 130vw; max-width: 560px; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(circle, rgba(255, 158, 64, 0.85) 0%, rgba(255, 120, 40, 0.28) 38%, transparent 68%); opacity: 0; transition: opacity 1.4s ease; pointer-events: none; mix-blend-mode: screen; } body.on .glow { opacity: 0.55; } .lamp { position: absolute; left: 50%; bottom: calc(var(--desk-h) - 6px); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; user-select: none; } .cap { width: 46%; height: 26px; border-radius: 12px 12px 4px 4px; background: linear-gradient(180deg, #d8dbe2 0%, #9aa0ab 45%, #565b66 100%); box-shadow: inset 0 2px 2px rgba(255,255,255,0.7), inset 0 -3px 4px rgba(0,0,0,0.45); z-index: 3; margin-bottom: -6px; } .neck { width: 30%; height: 14px; background: linear-gradient(180deg, #8f95a0, #3c4049); z-index: 3; margin-bottom: -4px; } .glass-wrap { position: relative; width: var(--glass-w); height: var(--glass-h); border-radius: calc(var(--glass-w) * 0.42); overflow: hidden; background: #171421; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14), inset 0 -14px 28px rgba(0,0,0,0.55); z-index: 2; } .liquid-low, .liquid-high { position: absolute; inset: 0; transition: opacity 1.2s ease; } .liquid-low { background: linear-gradient(180deg, #2c3542 0%, #1a212c 100%); opacity: 1; } .liquid-high { background: linear-gradient(180deg, #4b2a63 0%, #2a1540 100%); opacity: 0; } body.on .liquid-low { opacity: 0; } body.on .liquid-high { opacity: 1; } #wax { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); filter: blur(11px) contrast(22) saturate(1.15); will-change: contents; } .shine { position: absolute; top: 0; bottom: 0; left: 14%; width: 18%; border-radius: 999px; background: linear-gradient(180deg, rgba(255,255,255,0.34), rgba(255,255,255,0.05) 60%, rgba(255,255,255,0.14)); filter: blur(1px); z-index: 4; pointer-events: none; } .glass-edge { position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 2px 0 6px rgba(255,255,255,0.12), inset -6px 0 12px rgba(0,0,0,0.4), 0 0 26px rgba(255,150,60,0); transition: box-shadow 1.4s ease; z-index: 5; pointer-events: none; } body.on .glass-edge { box-shadow: inset 2px 0 6px rgba(255,255,255,0.16), inset -6px 0 12px rgba(0,0,0,0.4), 0 0 34px rgba(255,150,60,0.35); } .base { width: calc(var(--glass-w) * 1.22); height: clamp(48px, 7dvh, 68px); border-radius: 22px 22px 12px 12px; background: linear-gradient(180deg, #e3e6ec 0%, #a4aab5 38%, #585d68 78%, #3a3e47 100%); box-shadow: inset 0 3px 3px rgba(255,255,255,0.75), inset 0 -6px 8px rgba(0,0,0,0.5), 0 10px 18px rgba(0,0,0,0.5); z-index: 3; margin-top: -8px; display: flex; justify-content: center; align-items: center; } .base .dot { width: 14px; height: 14px; border-radius: 50%; background: #3a3f4a; box-shadow: inset 0 1px 2px rgba(0,0,0,0.8); transition: all 0.8s ease; } body.on .base .dot { background: #ffbb55; box-shadow: 0 0 12px 3px rgba(255,170,70,0.9), inset 0 1px 1px rgba(255,255,255,0.8); } .desk { position: absolute; left: 0; right: 0; bottom: 0; height: var(--desk-h); background: linear-gradient(180deg, #7b4f2e 0%, #5c3a20 45%, #3f2614 100%); box-shadow: inset 0 3px 4px rgba(255,220,170,0.22), inset 0 -10px 24px rgba(0,0,0,0.5); z-index: 1; } .desk::after { content: ""; position: absolute; top: -5px; left: 0; right: 0; height: 5px; background: linear-gradient(180deg, #a8764c, #5c3a20); border-radius: 3px; } .lamp-shadow { position: absolute; left: 50%; bottom: calc(var(--desk-h) - 14px); transform: translateX(-50%); width: calc(var(--glass-w) * 1.7); height: 20px; border-radius: 50%; background: radial-gradient(ellipse at center, rgba(0,0,0,0.55), transparent 70%); z-index: 1; pointer-events: none; } .controls { position: absolute; bottom: calc(var(--desk-h) * 0.28); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; z-index: 6; } .switch { position: relative; width: 92px; height: 46px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.22); background: linear-gradient(180deg, #2a2433, #171320); box-shadow: inset 0 2px 6px rgba(0,0,0,0.7), 0 2px 6px rgba(0,0,0,0.4); cursor: pointer; padding: 0; transition: background 0.5s ease, box-shadow 0.5s ease; -webkit-user-select: none; user-select: none; touch-action: manipulation; } .switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(180deg, #f2f3f6, #b9bec9); box-shadow: 0 3px 6px rgba(0,0,0,0.55), inset 0 1px 1px rgba(255,255,255,0.9); transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.5s ease; } body.on .switch { background: linear-gradient(180deg, #5c3a14, #40260a); box-shadow: inset 0 2px 6px rgba(0,0,0,0.7), 0 2px 14px rgba(255,150,60,0.4); } body.on .switch::after { transform: translateX(46px); background: linear-gradient(180deg, #ffd9a0, #ff9d45); box-shadow: 0 0 14px 3px rgba(255,170,70,0.75), inset 0 1px 1px rgba(255,255,255,0.9); } .switch:focus-visible { outline: 2px solid #ffb060; outline-offset: 3px; } .switch-label { font-size: 10px; letter-spacing: 0.3em; color: #8d829e; text-transform: uppercase; font-weight: 600; } body.on .switch-label { color: #e8a759; } @media (max-height: 560px) { :root { --glass-h: 34dvh; --desk-h: 24dvh; } .wall-art { display: none; } .base { height: 40px; } .cap { height: 20px; } .switch { width: 82px; height: 40px; } .switch::after { width: 32px; height: 32px; } body.on .switch::after { transform: translateX(40px); } .glow { width: 95vw; } } @media (max-height: 640px) { .glass-edge { box-shadow: inset 2px 0 6px rgba(255,255,255,0.12), inset -6px 0 12px rgba(0,0,0,0.4); } .glow { width: 100vw; } }</style></head><body class="on"> <main class="stage"> <div class="wall-art">dream light</div> <div class="glow" id="glow"></div> <div class="desk"></div> <div class="lamp-shadow"></div> <div class="lamp"> <div class="cap"></div> <div class="neck"></div> <div class="glass-wrap" id="glassWrap"> <div class="liquid-low"></div> <div class="liquid-high"></div> <canvas id="wax"></canvas> <div class="shine"></div> <div class="glass-edge"></div> </div> <div class="base"><div class="dot"></div></div> </div> <div class="controls"> <button class="switch" id="switch" role="switch" aria-checked="true" aria-label="Turn the lamp on or off"></button> <span class="switch-label" id="switchLabel">Lamp on</span> </div> </main><script>(() => { const wrap = document.getElementById('glassWrap'); const canvas = document.getElementById('wax'); const ctx = canvas.getContext('2d'); const glow = document.getElementById('glow'); const btn = document.getElementById('switch'); const label = document.getElementById('switchLabel'); const TAU = Math.PI * 2; let W = 0, H = 0, DPR = 1; let blobs = []; let on = true; let last = performance.now(); let waxColor = [255, 158, 64]; const WARM = [255, 158, 64]; // amber wax const COLD = [126, 118, 148]; // dusky lilac wax function resize() { const rect = wrap.getBoundingClientRect(); DPR = Math.min(2, window.devicePixelRatio || 1); W = Math.max(40, Math.round(rect.width)); H = Math.max(40, Math.round(rect.height)); canvas.width = Math.round((W + 16) * DPR); canvas.height = Math.round((H + 16) * DPR); ctx.setTransform(DPR, 0, 0, DPR, 0, 0); // keep blobs inside on resize for (const b of blobs) { b.x = Math.min(Math.max(b.x, b.r), W - b.r); b.y = Math.min(Math.max(b.y, b.r), H - b.r); } } function spawn(n) { blobs = []; for (let i = 0; i < n; i++) { blobs.push({ x: W * (0.25 + Math.random() * 0.5), y: H * (0.2 + Math.random() * 0.6), r: 22 + Math.random() * 16, warmth: 0.4 + Math.random() * 0.6, vy: 0, vx: 0, phase: Math.random() * TAU, speed: 0.7 + Math.random() * 0.45, bornAt: performance.now(), cooldownUntil: 0 }); } } function split(b) { const r = Math.sqrt(b.r * b.r / 2) * 0.98; const ox = Math.min(r * 0.75, W * 0.3); blobs.push({ x: b.x - ox, y: b.y + (Math.random() - 0.5) * 10, r: r * (0.9 + Math.random() * 0.2), warmth: b.warmth, vy: 20, vx: -18 - Math.random() * 14, phase: Math.random() * TAU, speed: 0.7 + Math.random() * 0.45, bornAt: performance.now(), cooldownUntil: performance.now() + 2200 }); blobs.push({ x: b.x + ox, y: b.y + (Math.random() - 0.5) * 10, r: r * (0.9 + Math.random() * 0.2), warmth: b.warmth, vy: 20, vx: 18 + Math.random() * 14, phase: Math.random() * TAU, speed: 0.7 + Math.random() * 0.45, bornAt: performance.now(), cooldownUntil: performance.now() + 2200 }); } function tick(now) { const dt = Math.min(1 / 30, (now - last) / 1000); last = now; const t = now / 1000; // wax color lerp (lamp state feedback) const target = on ? WARM : COLD; const k = 1 - Math.exp(-dt * 2.2); for (let i = 0; i < 3; i++) waxColor[i] += (target[i] - waxColor[i]) * k; const maxR = Math.min(Math.max(W * 0.34, 34), 60); const maxMergeR = Math.min(W * 0.44, 74); for (const b of blobs) { const targetWarmth = on ? 0.72 + 0.28 * Math.sin(t * 0.35 + b.phase) : 0.02; b.warmth += (targetWarmth - b.warmth) * Math.min(1, dt * b.speed); const buoy = (0.42 - b.warmth) * 420; b.vy += buoy * dt; b.vy *= Math.exp(-dt * 1.9); b.vy = Math.max(-150, Math.min(165, b.vy)); const sway = Math.sin(t * 0.55 + b.phase) * 15; b.vx += (sway - b.vx) * Math.min(1, dt * 1.6); b.y += b.vy * dt; b.x += b.vx * dt; const left = b.r + 4, right = W - b.r - 4; if (left >= right) { b.x = W / 2; b.vx = 0; } else { if (b.x < left) { b.x = left; b.vx = Math.abs(b.vx) * 0.4; } if (b.x > right) { b.x = right; b.vx = -Math.abs(b.vx) * 0.4; } } const top = b.r + 4, bottom = H - b.r - 4; if (b.y < top) { b.y = top; b.vy = Math.max(0, b.vy); } if (b.y > bottom) { b.y = bottom; b.vy = Math.min(0, b.vy) * 0.3; } } // merge touching blobs (area conservation) for (let i = 0; i < blobs.length; i++) { for (let j = i + 1; j < blobs.length; j++) { const a = blobs[i], b = blobs[j]; const now2 = performance.now(); if (now2 < a.cooldownUntil || now2 < b.cooldownUntil) continue; const dx = a.x - b.x, dy = a.y - b.y; const d = Math.hypot(dx, dy); const m = a.r * a.r + b.r * b.r; if (d < (a.r + b.r) * 0.44 && Math.sqrt(m) <= maxMergeR) { const ma = a.r * a.r, mb = b.r * b.r; const merged = { x: (a.x * ma + b.x * mb) / m, y: (a.y * ma + b.y * mb) / m, r: Math.sqrt(m), warmth: (a.warmth * ma + b.warmth * mb) / m, vy: (a.vy * ma + b.vy * mb) / m, vx: 0, phase: Math.random() * TAU, speed: Math.max(a.speed, b.speed), bornAt: now2, cooldownUntil: now2 + 1000 }; blobs.splice(j, 1); blobs[i] = merged; j--; } } } // split oversized blobs for (let i = blobs.length - 1; i >= 0; i--) { const b = blobs[i]; const now2 = performance.now(); if (b.r > maxR && now2 > b.cooldownUntil && blobs.length < 14) { split(b); blobs.splice(i, 1); } } // clamp any blobs disturbed by merge/split for (const b of blobs) { const left = b.r + 4, right = W - b.r - 4; if (left >= right) { b.x = W / 2; } else b.x = Math.max(left, Math.min(right, b.x)); const top = b.r + 4, bottom = H - b.r - 4; if (top >= bottom) { b.y = H / 2; } else b.y = Math.max(top, Math.min(bottom, b.y)); } // draw wax layer ctx.clearRect(0, 0, W + 16, H + 16); ctx.save(); ctx.translate(8, 8); const c = waxColor; ctx.fillStyle = `rgb(${c[0] | 0},${c[1] | 0},${c[2] | 0})`; for (const b of blobs) { ctx.beginPath(); ctx.arc(b.x, b.y, b.r, 0, TAU); ctx.fill(); } ctx.restore(); // subtle light flicker if (on) { const flick = 0.55 + Math.sin(t * 6.3) * 0.028 + Math.sin(t * 11.7 + 2) * 0.02; glow.style.opacity = flick.toFixed(3); } requestAnimationFrame(tick); } btn.addEventListener('click', () => { on = !on; document.body.classList.toggle('on', on); btn.setAttribute('aria-checked', String(on)); label.textContent = on ? 'Lamp on' : 'Lamp off'; if (!on) glow.style.opacity = '0'; }); const ro = new ResizeObserver(() => { const hadBlobs = blobs.length > 0; resize(); if (!hadBlobs && blobs.length === 0) spawn(9); }); ro.observe(wrap); resize(); spawn(9); requestAnimationFrame(tick);})();</script></body></html>