HEL-822: land HEL-821 A1+A2 source onto PR#4 base (db571ba)
- 13 modified / 8 added / 1 deleted per CHANGES.json (author package 76bc120b) - docs/requirements v1.10 + prototypes/hel-799 + PROVENANCE from bundle, verified byte-identical to63799f0- AGENTS.md + scripts/check_requirements.py restored from governance commit63799f0Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
Vendored
+163
@@ -0,0 +1,163 @@
|
||||
'use strict';
|
||||
// ── Ambient life of the room (drawn, never taken from her photo). ──
|
||||
// Rain: falls only inside each still's window panes; city windows blink; a few drops slide down the glass.
|
||||
const Rain = (() => {
|
||||
const html = document.documentElement;
|
||||
const reduced = matchMedia('(prefers-reduced-motion: reduce)');
|
||||
const still = () => reduced.matches || html.classList.contains('no-motion');
|
||||
const COLORS = {moon: [190, 210, 255], fog: [228, 204, 255]};
|
||||
// Plate px. clip: the glass; city: where lit windows may blink.
|
||||
const CFG = {
|
||||
room: {clip: [655, 0, 545, 545], city: [660, 215, 530, 320], n: 110, seed: 11},
|
||||
talk: {clip: [0, 0, 640, 600], city: [0, 200, 640, 360], n: 150, seed: 7}
|
||||
};
|
||||
const S = {};
|
||||
let mix = 0, mixFrom = 0, mixTo = 0, mixStart = 0, visible = {room: true, talk: false}, dirty = true, lastDraw = 0, res = 0;
|
||||
const rng = seed => () => (seed = (seed * 16807) % 2147483647) / 2147483647;
|
||||
function build(name, scale) {
|
||||
const c = CFG[name], cv = document.querySelector(`#plate-${name} canvas.rain`), r = rng(c.seed);
|
||||
cv.width = 1600 * scale; cv.height = 1000 * scale;
|
||||
const ctx = cv.getContext('2d');
|
||||
const [x, y, w, h] = c.clip;
|
||||
const streaks = Array.from({length: c.n}, () => ({x: x + r() * (w + 60), y: y + r() * h, len: 10 + r() * 24, spd: 520 + r() * 420, a: .07 + r() * .17}));
|
||||
const lights = Array.from({length: 30}, () => ({x: c.city[0] + r() * c.city[2], y: c.city[1] + r() * c.city[3], p: r() * 6.28, f: .25 + r() * .7, warm: r() > .35}));
|
||||
const slides = Array.from({length: 4}, () => ({x: x + r() * w, y: y + r() * h, spd: 6 + r() * 14, r: 1.6 + r() * 1.4}));
|
||||
// Static droplets on the glass, rendered once.
|
||||
const drops = document.createElement('canvas'); drops.width = cv.width; drops.height = cv.height;
|
||||
const d = drops.getContext('2d'); d.scale(scale, scale);
|
||||
for (let i = 0; i < 70; i++) {
|
||||
const px = x + r() * w, py = y + r() * h, rr = 1 + r() * 2.4, g = d.createRadialGradient(px - rr * .3, py - rr * .3, 0, px, py, rr);
|
||||
g.addColorStop(0, 'rgba(230,240,255,.45)'); g.addColorStop(1, 'rgba(160,190,255,0)');
|
||||
d.fillStyle = g; d.beginPath(); d.arc(px, py, rr, 0, 7); d.fill();
|
||||
}
|
||||
S[name] = {cv, ctx, c, streaks, lights, slides, drops, scale};
|
||||
}
|
||||
function paint(name, dt, now) {
|
||||
const s = S[name]; if (!s) return;
|
||||
const {ctx, c, scale} = s, [x, y, w, h] = c.clip;
|
||||
const col = COLORS.moon.map((m, i) => Math.round(m + (COLORS.fog[i] - m) * mix));
|
||||
ctx.setTransform(scale, 0, 0, scale, 0, 0);
|
||||
ctx.clearRect(x - 2, y - 2, w + 4, h + 4);
|
||||
ctx.save(); ctx.beginPath(); ctx.rect(x, y, w, h); ctx.clip();
|
||||
// City windows: slow blink, warm or cool.
|
||||
for (const l of s.lights) {
|
||||
const a = Math.max(0, Math.sin(l.p + now / 1000 * l.f)) * .55;
|
||||
if (a < .02) continue;
|
||||
ctx.fillStyle = l.warm ? `rgba(255,214,150,${a.toFixed(3)})` : `rgba(${col[0]},${col[1]},${col[2]},${(a * .8).toFixed(3)})`;
|
||||
ctx.fillRect(l.x, l.y, 2.2, 2.6);
|
||||
}
|
||||
ctx.lineWidth = .8; ctx.lineCap = 'round';
|
||||
for (const k of s.streaks) {
|
||||
k.y += k.spd * dt; k.x -= k.spd * dt * .18;
|
||||
if (k.y > y + h) { k.y = y - k.len; k.x = x + Math.random() * (w + 60); }
|
||||
ctx.strokeStyle = `rgba(${col[0]},${col[1]},${col[2]},${k.a.toFixed(3)})`;
|
||||
ctx.beginPath(); ctx.moveTo(k.x, k.y); ctx.lineTo(k.x - k.len * .18, k.y + k.len); ctx.stroke();
|
||||
}
|
||||
ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.drawImage(s.drops, 0, 0); ctx.setTransform(scale, 0, 0, scale, 0, 0);
|
||||
for (const q of s.slides) {
|
||||
q.y += q.spd * dt; if (q.y > y + h) { q.y = y; q.x = x + Math.random() * w; }
|
||||
ctx.fillStyle = 'rgba(225,236,255,.35)'; ctx.beginPath(); ctx.arc(q.x, q.y, q.r, 0, 7); ctx.fill();
|
||||
ctx.fillStyle = 'rgba(225,236,255,.08)'; ctx.fillRect(q.x - .5, q.y - 26, 1, 26);
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
function draw(now, tier) {
|
||||
const want = tier > 0 ? .5 : 1;
|
||||
if (want !== res) { res = want; build('room', res); build('talk', res); dirty = true; }
|
||||
if (mixStart) { const k = Math.min(1, (now - mixStart) / 1000); mix = mixFrom + (mixTo - mixFrom) * (k * k * (3 - 2 * k)); if (k >= 1) mixStart = 0; dirty = true; }
|
||||
if (still()) { if (!dirty) return; dirty = false; paint('room', 0, 0); paint('talk', 0, 0); return; }
|
||||
if (document.hidden) return;
|
||||
if (tier > 1 && now - lastDraw < 32) return; // ~30fps on slow devices
|
||||
const dt = lastDraw ? Math.min(.05, (now - lastDraw) / 1000) : 0; lastDraw = now;
|
||||
if (visible.room) paint('room', dt, now);
|
||||
if (visible.talk) paint('talk', dt, now);
|
||||
}
|
||||
function view(cam, talkOpacity) { visible.room = talkOpacity < .998; visible.talk = talkOpacity > .002; dirty = true; }
|
||||
function setTheme(name, instant) {
|
||||
mixTo = name === 'fog' ? 1 : 0;
|
||||
if (instant) { mix = mixTo; mixStart = 0; dirty = true; return; }
|
||||
mixFrom = mix; mixStart = performance.now();
|
||||
}
|
||||
document.addEventListener('visibilitychange', () => { lastDraw = 0; });
|
||||
return {draw, view, setTheme};
|
||||
})();
|
||||
|
||||
// Your side of the table: drawn per theme at the viewport's own size, so the cup and candle never stretch.
|
||||
const Near = (() => {
|
||||
const host = document.getElementById('near');
|
||||
const PAL = {
|
||||
moon: {top: ['#3b2c30', '#221a24', '#0b0a14'], cool: '150,180,255', warm: '255,190,130', grain: ['#c9b8ff', '#ffd9b0'], rim: ['170,200,255', '240,230,255', '255,205,150'], cup: ['#5a6aa0', '#d9def2', '#9ea6c8', '#3a3f66'], handle: '#aeb6d8', bokeh: ['160,190,255', '255,200,140']},
|
||||
fog: {top: ['#3a2a3e', '#231a30', '#0e0a18'], cool: '200,170,255', warm: '255,180,175', grain: ['#e2c4ff', '#ffd2d8'], rim: ['205,180,255', '246,226,255', '255,192,176'], cup: ['#7a62a8', '#e6dcf2', '#b0a2c8', '#4a3a66'], handle: '#c2b4d8', bokeh: ['205,170,255', '255,186,200']}
|
||||
};
|
||||
function anchors(W, H) {
|
||||
const sx = W / 1600, sy = H / 1000, u = Math.min(1.35, Math.max(.42, Math.min(sx, sy))), phone = W <= 720 || W / H < .9;
|
||||
return {sx, sy, u, phone, cup: phone ? [34, H - 8] : [210 * sx, 985 * sy], candle: phone ? [W - 26, H - 30] : [1400 * sx, 966 * sy]};
|
||||
}
|
||||
function paint(cv, pal, W, H, dpr) {
|
||||
cv.width = Math.round(W * dpr); cv.height = Math.round(H * dpr);
|
||||
const c = cv.getContext('2d'), A = anchors(W, H), {sx, sy, u} = A, px = n => n * dpr;
|
||||
c.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||
const ex = W / 2, ey = 1585 * sy, rx = 1300 * Math.max(sx, .32), ry = 775 * sy;
|
||||
// Table top: one arc of a large round table, the part nearest to you.
|
||||
c.save(); c.filter = `blur(${px(2.5 * u)}px)`;
|
||||
c.beginPath(); c.ellipse(ex, ey, rx, ry, 0, Math.PI, 2 * Math.PI); c.lineTo(W + 100, H + 100); c.lineTo(-100, H + 100); c.closePath();
|
||||
const top = c.createLinearGradient(0, ey - ry - 30 * sy, 0, H);
|
||||
top.addColorStop(0, pal.top[0]); top.addColorStop(.3, pal.top[1]); top.addColorStop(1, pal.top[2]);
|
||||
c.fillStyle = top; c.fill(); c.clip();
|
||||
let g = c.createRadialGradient(300 * sx, 860 * sy, 0, 300 * sx, 860 * sy, 520 * u);
|
||||
g.addColorStop(0, `rgba(${pal.cool},.22)`); g.addColorStop(1, `rgba(${pal.cool},0)`); c.fillStyle = g; c.fillRect(0, 0, W, H);
|
||||
g = c.createRadialGradient(1260 * sx, 840 * sy, 0, 1260 * sx, 840 * sy, 560 * u);
|
||||
g.addColorStop(0, `rgba(${pal.warm},.26)`); g.addColorStop(1, `rgba(${pal.warm},0)`); c.fillStyle = g; c.fillRect(0, 0, W, H);
|
||||
c.globalAlpha = .06;
|
||||
for (let i = 0; i < 26; i++) {
|
||||
c.strokeStyle = pal.grain[i % 2]; c.lineWidth = 1;
|
||||
c.beginPath(); c.ellipse(ex, ey, Math.max(10, rx - i * 9 * sx), Math.max(10, ry - (i * 6 + 14) * sy), 0, Math.PI * 1.08, Math.PI * 1.92); c.stroke();
|
||||
}
|
||||
c.restore();
|
||||
c.save(); c.filter = `blur(${px(1)}px)`;
|
||||
const rim = c.createLinearGradient(0, 0, W, 0);
|
||||
rim.addColorStop(0, `rgba(${pal.rim[0]},.05)`); rim.addColorStop(.25, `rgba(${pal.rim[0]},.45)`);
|
||||
rim.addColorStop(.55, `rgba(${pal.rim[1]},.3)`); rim.addColorStop(.8, `rgba(${pal.rim[2]},.55)`); rim.addColorStop(1, `rgba(${pal.rim[2]},.08)`);
|
||||
c.strokeStyle = rim; c.lineWidth = 2;
|
||||
c.beginPath(); c.ellipse(ex, ey, rx, ry, 0, Math.PI * 1.03, Math.PI * 1.97); c.stroke();
|
||||
c.restore();
|
||||
// Your cup (nearest, most out of focus). Drawn in HEL-798 units around its base.
|
||||
c.save(); c.translate(A.cup[0], A.cup[1]); c.scale(u, u); c.translate(-210, -985); c.filter = `blur(${px(5 * u)}px)`;
|
||||
c.fillStyle = '#0d0c18'; c.beginPath(); c.ellipse(205, 985, 150, 34, 0, 0, 7); c.fill();
|
||||
const cup = c.createLinearGradient(100, 0, 320, 0);
|
||||
cup.addColorStop(0, pal.cup[0]); cup.addColorStop(.35, pal.cup[1]); cup.addColorStop(.7, pal.cup[2]); cup.addColorStop(1, pal.cup[3]);
|
||||
c.fillStyle = cup; c.beginPath(); c.moveTo(108, 830); c.bezierCurveTo(108, 950, 140, 985, 210, 985); c.bezierCurveTo(280, 985, 312, 950, 312, 830); c.closePath(); c.fill();
|
||||
c.strokeStyle = pal.handle; c.lineWidth = 16; c.beginPath(); c.arc(320, 885, 34, -Math.PI / 2.2, Math.PI / 2.2); c.stroke();
|
||||
c.fillStyle = '#3a2416'; c.beginPath(); c.ellipse(210, 830, 102, 18, 0, 0, 7); c.fill();
|
||||
c.fillStyle = 'rgba(255,200,140,.35)'; c.beginPath(); c.ellipse(240, 828, 46, 7, 0, 0, 7); c.fill();
|
||||
c.restore();
|
||||
// Your small candle, answering the one beside her.
|
||||
c.save(); c.translate(A.candle[0], A.candle[1]); c.scale(u, u); c.translate(-1400, -966); c.filter = `blur(${px(3.5 * u)}px)`;
|
||||
const glass = c.createLinearGradient(1350, 0, 1450, 0);
|
||||
glass.addColorStop(0, 'rgba(255,190,130,.25)'); glass.addColorStop(.5, 'rgba(255,225,180,.55)'); glass.addColorStop(1, 'rgba(255,170,110,.22)');
|
||||
c.fillStyle = glass; c.beginPath(); c.moveTo(1356, 850); c.lineTo(1444, 850); c.lineTo(1440, 952); c.quadraticCurveTo(1400, 966, 1360, 952); c.closePath(); c.fill();
|
||||
c.fillStyle = 'rgba(255,240,215,.35)'; c.beginPath(); c.ellipse(1400, 850, 44, 9, 0, 0, 7); c.fill();
|
||||
c.restore();
|
||||
// Near bokeh (depth of field).
|
||||
c.save(); c.globalCompositeOperation = 'screen';
|
||||
const bok = [[60, 120, 70, 0, .1], [1530, 300, 90, 1, .09], [1480, 980, 120, 1, .1], [560, 990, 80, 0, .08], [30, 560, 60, 0, .08]];
|
||||
for (const [x, y, r0, k, a] of bok) {
|
||||
const r = r0 * u, X = x * sx, Y = y * sy, col = pal.bokeh[k];
|
||||
g = c.createRadialGradient(X, Y, r * .6, X, Y, r);
|
||||
g.addColorStop(0, `rgba(${col},${a})`); g.addColorStop(.9, `rgba(${col},${a * .8})`); g.addColorStop(1, `rgba(${col},0)`);
|
||||
c.fillStyle = g; c.beginPath(); c.arc(X, Y, r, 0, 7); c.fill();
|
||||
}
|
||||
c.restore();
|
||||
return A;
|
||||
}
|
||||
function draw() {
|
||||
const W = innerWidth, H = innerHeight, tier = +(document.documentElement.dataset.tier || 0);
|
||||
const dpr = Math.min(tier > 0 ? 1 : 2, window.devicePixelRatio || 1);
|
||||
let A;
|
||||
for (const cv of host.querySelectorAll('canvas')) A = paint(cv, PAL[cv.dataset.themeLayer], W, H, dpr);
|
||||
host.style.setProperty('--u', A.u.toFixed(3));
|
||||
host.style.setProperty('--steam-x', (A.cup[0] + 5 * A.u).toFixed(1) + 'px'); host.style.setProperty('--steam-y', (A.cup[1] - 330 * A.u).toFixed(1) + 'px');
|
||||
host.style.setProperty('--candle-x', A.candle[0].toFixed(1) + 'px'); host.style.setProperty('--candle-y', (A.candle[1] - 116 * A.u).toFixed(1) + 'px');
|
||||
}
|
||||
return {draw};
|
||||
})();
|
||||
@@ -0,0 +1,297 @@
|
||||
/* HEL-799 · 对坐:共同空间动态小样
|
||||
Based on the approved HEL-798 still (talk state, 1600×1000) and the HEL-793/795 tokens.
|
||||
Motion budget: UI feedback 160ms · text 420–680ms · camera spring ≈0.85s · ambient loops 6–30s. */
|
||||
:root{
|
||||
color-scheme:dark;
|
||||
--font-sans:"PingFang SC","HarmonyOS Sans SC","MiSans","Microsoft YaHei UI","Microsoft YaHei","Noto Sans CJK SC",system-ui,sans-serif;
|
||||
--ease-out:cubic-bezier(.22,1,.36,1);--ease-space:cubic-bezier(.65,0,.25,1);--ease-in-out:cubic-bezier(.65,0,.35,1);
|
||||
--dur-fast:160ms;--dur-ui:280ms;--dur-text:620ms;--dur-space:850ms;
|
||||
--view-h:100dvh;--view-top:0px;--safe-bottom:env(safe-area-inset-bottom,0px);
|
||||
--stage-h:128px;--nav-space:52px;
|
||||
}
|
||||
html[data-theme="moon"]{--bg-0:#050918;--text-1:#eef2ff;--text-2:#b9c6e6;--text-3:#94a5c8;--accent:#a9dcff;--accent-soft:#a9dcff1f;--accent-glow:#96d2ff55;--on-accent:#0b1534;--user:#d7e2ff;--glass:#16244e66;--glass-read:#0b1534c4;--glass-line:#b8d4ff26;--surface:#0b1330;--input-a:#16244e70;--input-b:#1c264c70;--input-c:#3a2c3a60;--pool:#050918;--glass-blur:20px}
|
||||
html[data-theme="fog"]{--bg-0:#0e0820;--text-1:#f6efff;--text-2:#dccbee;--text-3:#bba7d6;--accent:#ebbcff;--accent-soft:#ebbcff24;--accent-glow:#e2aaff5c;--on-accent:#2a0f40;--user:#f1e2ff;--glass:#36226666;--glass-read:#211444c8;--glass-line:#ecd8ff2e;--surface:#24154a;--input-a:#3a245e70;--input-b:#3a265470;--input-c:#5a2c5260;--pool:#0e0820;--glass-blur:28px}
|
||||
*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden;background:var(--bg-0);transition:background-color .9s}
|
||||
body{font:15px/1.7 var(--font-sans);color:var(--text-1);-webkit-font-smoothing:antialiased;transition:color .6s}
|
||||
button,input,textarea,select{font:inherit;color:inherit}
|
||||
button{border:0;background:none;cursor:pointer;transition:transform var(--dur-fast) var(--ease-out),opacity var(--dur-fast) var(--ease-out),background-color var(--dur-ui) var(--ease-out),color var(--dur-ui) var(--ease-out),box-shadow var(--dur-ui) var(--ease-out)}
|
||||
button:disabled{opacity:.3;cursor:default}button:active:not(:disabled){transform:scale(.97)}
|
||||
button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
|
||||
button svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;flex:none}
|
||||
h1,h2,h3,p{margin:0}h2{font-size:22px;font-weight:350}h3{font-size:18px;font-weight:400}strong{font-weight:400}[hidden]{display:none!important}
|
||||
.symbols,.sr{position:absolute;width:1px;height:1px;clip-path:inset(50%);overflow:hidden;white-space:nowrap}
|
||||
.glass{transition:background-color .6s,border-color .6s,box-shadow .6s,transform var(--dur-fast) var(--ease-out),opacity var(--dur-fast) var(--ease-out);background:var(--glass);border:1px solid var(--glass-line);box-shadow:inset 0 1px 0 #ffffff0d,0 20px 80px #0206162a;backdrop-filter:blur(var(--glass-blur)) saturate(125%);-webkit-backdrop-filter:blur(var(--glass-blur)) saturate(125%)}
|
||||
.round{width:40px;height:40px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;flex:none}
|
||||
.primary{display:inline-flex;gap:10px;align-items:center;justify-content:center;background:var(--accent);color:var(--on-accent);padding:12px 22px;border-radius:30px;box-shadow:0 0 30px var(--accent-glow),inset 0 1px 0 #ffffff60}
|
||||
.small-link{color:var(--text-2);padding:10px 0;font-size:13px;text-align:left}
|
||||
.eyebrow{font-size:12px;letter-spacing:.18em;color:var(--text-3);margin-bottom:14px}.quiet{color:var(--text-2);font-size:14px}.quiet span{margin:0 10px}.subtle{font-size:13px;color:var(--text-2)}
|
||||
|
||||
/* ── The room: two reference stills on one camera ── */
|
||||
#scene{position:fixed;inset:0;overflow:hidden;background:#04060f}
|
||||
.cam{position:absolute;inset:0;transition:transform 1.4s var(--ease-out)}
|
||||
/* Each plate box covers its whole picture (so a mask never clips it to 1600×1000); .po is the 1600×1000 design origin. */
|
||||
.plate{position:absolute;will-change:transform;contain:layout style}
|
||||
#plate-room{left:-640px;top:-112px;width:2240px;height:1260px;transform-origin:640px 112px}
|
||||
#plate-talk{left:-118px;top:-10px;width:1792px;height:1008px;transform-origin:118px 10px}
|
||||
#plate-room .po{left:640px;top:112px}#plate-talk .po{left:118px;top:10px}
|
||||
.po{position:absolute;width:1600px;height:1000px}
|
||||
.plate .photo{position:absolute;max-width:none;user-select:none;-webkit-user-drag:none}
|
||||
#plate-room .photo{left:-640px;top:-112px;width:2240px;height:1260px;filter:saturate(.9) brightness(.8) contrast(1.05)}
|
||||
#plate-talk .photo{left:-118px;top:-10px;width:1792px;height:1008px;filter:saturate(.92) brightness(.9) contrast(1.04)}
|
||||
#plate-talk{visibility:hidden}
|
||||
.tint{position:absolute;inset:0;transition:opacity .9s var(--ease-in-out)}
|
||||
.tint i,.po>i{position:absolute;pointer-events:none;display:block}
|
||||
html[data-theme="moon"] .tint.fog,html[data-theme="fog"] .tint.moon{opacity:0}
|
||||
/* Her side, close: the HEL-798 still, unchanged (stage px = plate px). */
|
||||
#plate-talk .tint .night{inset:0;mix-blend-mode:multiply}
|
||||
#plate-talk .tint .night::before{content:"";position:absolute;left:-118px;top:-10px;width:118px;bottom:0}
|
||||
#plate-talk .tint .night2{inset:-10px 0 0;mix-blend-mode:color;-webkit-mask:linear-gradient(90deg,#000 0 40%,transparent 56%);mask:linear-gradient(90deg,#000 0 40%,transparent 56%)}
|
||||
#plate-talk .tint .beam{left:120px;top:40px;width:560px;height:1040px;transform:skewX(18deg);filter:blur(30px);mix-blend-mode:screen}
|
||||
#plate-talk .moon .night{background:linear-gradient(100deg,#1c2f7fcc 0%,#1b2c78aa 28%,#1a2a7044 46%,transparent 60%)}
|
||||
#plate-talk .moon .night::before{background:#1c2f7fcc}
|
||||
#plate-talk .moon .night2{background:linear-gradient(180deg,#24357ccc 0%,#24357c66 18%,transparent 34%)}
|
||||
#plate-talk .moon .beam{background:linear-gradient(180deg,#a9c8ff22,#a9c8ff10 55%,transparent)}
|
||||
#plate-talk .fog .night{background:linear-gradient(100deg,#3b2a7ccc 0%,#3a2874aa 28%,#38266a44 46%,transparent 60%)}
|
||||
#plate-talk .fog .night::before{background:#3b2a7ccc}
|
||||
#plate-talk .fog .night2{background:linear-gradient(180deg,#5a3a92cc 0%,#5a3a9266 18%,transparent 34%)}
|
||||
#plate-talk .fog .beam{background:linear-gradient(180deg,#e6c4ff1c,#e6c4ff0c 55%,transparent);transform:skewX(-8deg)}
|
||||
/* Her side, far: the room still turned to the same rainy night. Coordinates are plate px. */
|
||||
#plate-room .tint{inset:auto;left:-640px;top:-112px;width:2240px;height:1260px}
|
||||
#plate-room .tint .night{inset:0;mix-blend-mode:multiply}
|
||||
#plate-room .tint .night2{inset:0;mix-blend-mode:color;-webkit-mask:radial-gradient(ellipse 150px 210px at 1915px 459px,transparent 70%,#000 100%),linear-gradient(180deg,#000 0 27%,transparent 40%);mask:radial-gradient(ellipse 150px 210px at 1915px 459px,transparent 70%,#000 100%),linear-gradient(180deg,#000 0 27%,transparent 40%);-webkit-mask-composite:source-in;mask-composite:intersect}
|
||||
#plate-room .moon .night{background:radial-gradient(ellipse 330px 420px at 1930px 560px,#ffffff 0 30%,#ffffff00 100%),linear-gradient(97deg,#16225cf2 0%,#1a2768e0 30%,#1c2c74b0 50%,#2a3a8a70 62%,#ffffff00 80%),linear-gradient(180deg,#00000000 50%,#1a204c66 100%)}
|
||||
#plate-room .moon .night2{background:linear-gradient(180deg,#24357ce6 0%,#24357ccc 22%,#24357c55 40%)}
|
||||
#plate-room .fog .night{background:radial-gradient(ellipse 330px 420px at 1930px 560px,#ffffff 0 30%,#ffffff00 100%),linear-gradient(97deg,#2c1f5ef2 0%,#32246ae0 30%,#3a2a78b0 50%,#4a3a8a70 62%,#ffffff00 80%),linear-gradient(180deg,#00000000 50%,#2a1c4c66 100%)}
|
||||
#plate-room .fog .night2{background:linear-gradient(180deg,#5a3a92e6 0%,#5a3a92cc 22%,#5a3a9255 40%)}
|
||||
.plate canvas.rain{position:absolute;left:0;top:0;width:1600px;height:1000px;pointer-events:none}
|
||||
/* Weather in the window: a slow cloud veil (moon) or folding violet mist (fog). */
|
||||
.mist{border-radius:50%;filter:blur(38px);mix-blend-mode:screen;opacity:0;transition:opacity 1.2s var(--ease-in-out);animation:mist 34s var(--ease-in-out) infinite alternate}
|
||||
.mist.m2{animation-duration:47s;animation-delay:-20s}
|
||||
#plate-talk .mist{left:-60px;top:120px;width:560px;height:120px}#plate-talk .mist.m2{top:250px;left:120px;width:460px}
|
||||
#plate-room .mist{left:660px;top:20px;width:420px;height:90px}#plate-room .mist.m2{top:120px;left:760px;width:360px}
|
||||
html[data-theme="moon"] .mist{background:#b9c8ff;opacity:.07}
|
||||
html[data-theme="fog"] .mist{background:linear-gradient(90deg,#c69cff,#ff9fd8 60%,#9cc0ff);opacity:.32}
|
||||
@keyframes mist{from{transform:translateX(-60px) scaleY(.8)}to{transform:translateX(90px) scaleY(1.25)}}
|
||||
.spill{inset:0;mix-blend-mode:screen;animation:breathe-light 9s var(--ease-in-out) infinite alternate}
|
||||
#plate-talk .spill{background:radial-gradient(ellipse 520px 380px at 1290px 40px,#ffcf8a30,transparent 70%),radial-gradient(ellipse 760px 260px at 1180px 900px,#ffb97a2a,transparent 70%)}
|
||||
#plate-room .spill{background:radial-gradient(ellipse 360px 300px at 1420px 150px,#ffcf8a38,transparent 70%),radial-gradient(ellipse 600px 240px at 1250px 760px,#ffb97a22,transparent 70%)}
|
||||
html[data-theme="fog"] .spill{filter:hue-rotate(-28deg) saturate(1.1)}
|
||||
@keyframes breathe-light{from{opacity:.75}to{opacity:1}}
|
||||
.flame-glow{width:90px;height:90px;margin:-45px 0 0 -45px;border-radius:50%;background:radial-gradient(circle,#ffd9a0aa,#ffb46a44 35%,transparent 70%);mix-blend-mode:screen;animation:flicker 3.2s steps(1,end) infinite,flame 2.4s var(--ease-in-out) infinite alternate}
|
||||
.flame-glow+.flame-glow{animation-delay:-1.1s,-.7s}
|
||||
@keyframes flicker{0%,100%{opacity:.9}17%{opacity:.72}18%{opacity:.95}46%{opacity:.8}47%{opacity:1}79%{opacity:.78}}
|
||||
@keyframes flame{to{transform:scale(1.12) translateY(-3px)}}
|
||||
.mote{left:var(--x);top:var(--y);width:4px;height:4px;border-radius:50%;background:#ffe2b8;box-shadow:0 0 8px 2px #ffd59a88;opacity:0;animation:mote var(--d) linear var(--dl) infinite}
|
||||
@keyframes mote{0%{transform:translate(0,0);opacity:0}15%{opacity:.7}80%{opacity:.5}100%{transform:translate(-40px,-160px);opacity:0}}
|
||||
.moon-disc{position:absolute;left:0;top:0;width:44px;height:44px;margin:-22px 0 0 -22px;border-radius:50%;background:radial-gradient(circle at 42% 40%,#fbfdff 0%,#e4ecff 55%,#c9d6f5 100%);filter:blur(.6px);box-shadow:0 0 22px 6px #cfe0ff88,0 0 90px 40px #8fb0ff33,0 0 220px 120px #5f7fe022;transform-origin:50% 50%;will-change:transform;transition:opacity 1s var(--ease-in-out)}
|
||||
html[data-theme="fog"] .moon-disc{opacity:0}
|
||||
.vignette{position:absolute;inset:0;pointer-events:none;background:radial-gradient(ellipse 62% 74% at 54% 42%,transparent 52%,#050918aa 100%),linear-gradient(180deg,#050918aa 0%,transparent 13%)}
|
||||
html[data-theme="fog"] .vignette{background:radial-gradient(ellipse 62% 74% at 54% 42%,transparent 52%,#0e0820aa 100%),linear-gradient(180deg,#0e0820aa 0%,transparent 13%)}
|
||||
/* Your side: the table edge, a cup and a small candle. Drawn for the viewport, never stretched. */
|
||||
.near{position:absolute;inset:0;pointer-events:none;--near-y:0px;transform:translate3d(var(--px,0px),calc(var(--py,0px) + var(--near-y)),0);transition:transform var(--dur-space) var(--ease-space),opacity var(--dur-space) var(--ease-out),filter var(--dur-space) var(--ease-out)}
|
||||
.near-c{position:absolute;inset:0;width:100%;height:100%;transition:opacity .9s var(--ease-in-out)}
|
||||
html[data-theme="moon"] .near-c[data-theme-layer="fog"],html[data-theme="fog"] .near-c[data-theme-layer="moon"]{opacity:0}
|
||||
.steam{position:absolute;left:var(--steam-x);top:var(--steam-y);width:calc(var(--u) * 40px);height:calc(var(--u) * 170px);margin-left:calc(var(--u) * -20px);border-radius:50%;background:radial-gradient(ellipse at 50% 80%,#d2e1ff33,transparent 70%);filter:blur(calc(var(--u) * 9px));transform-origin:50% 100%;animation:steam 7s var(--ease-in-out) infinite}
|
||||
.steam.s2{margin-left:calc(var(--u) * 14px);animation-duration:9s;animation-delay:-4s}
|
||||
@keyframes steam{0%{transform:translateY(20%) scaleX(.7) skewX(0);opacity:0}30%{opacity:.9}70%{opacity:.5}100%{transform:translateY(-30%) scaleX(1.3) skewX(-14deg);opacity:0}}
|
||||
.candle{position:absolute;left:var(--candle-x);top:var(--candle-y);width:calc(var(--u) * 380px);height:calc(var(--u) * 380px);margin:calc(var(--u) * -190px) 0 0 calc(var(--u) * -190px);border-radius:50%;background:radial-gradient(circle,#ffdca0cc 0,#ffbe7866 12%,#ffaa6420 40%,transparent 70%);mix-blend-mode:screen;animation:flicker 2.8s steps(1,end) infinite,flame 2s var(--ease-in-out) infinite alternate}
|
||||
.veil{position:absolute;inset:0;background:radial-gradient(ellipse at 50% 40%,#02061433,#020614cc 90%);opacity:0;pointer-events:none;transition:opacity var(--dur-space) var(--ease-out)}
|
||||
body[data-mode="pane"] .veil{opacity:.75}body[data-mode="record"] .veil{opacity:.35}
|
||||
body[data-mode="home"] .near{--near-y:3.5vh}
|
||||
body[data-mode="pane"] .near,body[data-mode="record"] .near{--near-y:7vh;opacity:.7}
|
||||
|
||||
#viewport{position:absolute;top:var(--view-top);left:0;right:0;height:var(--view-h);min-height:260px;overflow:hidden}
|
||||
#world{position:absolute;inset:0}
|
||||
|
||||
/* ── Top ── */
|
||||
.topbar{position:relative;z-index:4;height:84px;display:flex;align-items:center;justify-content:space-between;gap:16px;padding:0 40px}
|
||||
.identity{display:flex;align-items:baseline;gap:12px;min-width:0;text-shadow:0 1px 12px var(--pool)}
|
||||
.identity strong{font-size:22px;font-weight:400;letter-spacing:.04em;max-width:240px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.presence{color:var(--text-2);font-size:13px;letter-spacing:.04em;white-space:nowrap;transition:opacity var(--dur-ui) var(--ease-out)}
|
||||
.glint{flex:none;align-self:center;width:7px;height:7px;background:var(--accent);border-radius:50%;box-shadow:0 0 10px var(--accent);animation:pulse 4.5s var(--ease-in-out) infinite}
|
||||
@keyframes pulse{50%{box-shadow:0 0 4px var(--accent);opacity:.65}}
|
||||
.top-actions{display:flex;align-items:center;gap:12px;flex:none;font-size:12px;color:var(--text-2)}
|
||||
.sample-tag{height:30px;padding:0 13px;border-radius:15px;border:1px dashed var(--glass-line);background:var(--glass);color:var(--text-3);font-size:12px;white-space:nowrap;backdrop-filter:blur(18px)}
|
||||
.weather small{color:var(--text-3)}
|
||||
.theme{display:flex;gap:2px;border:1px solid var(--glass-line);padding:3px;border-radius:16px;background:var(--glass);backdrop-filter:blur(18px)}
|
||||
.theme button{font-size:12px;color:var(--text-3);height:24px;padding:0 11px;border-radius:12px;display:flex;align-items:center;gap:6px;white-space:nowrap}
|
||||
.theme button i{width:5px;height:5px;border-radius:50%;background:#a9dcff}.theme button[data-theme="fog"] i{background:#ebbcff}
|
||||
.theme [aria-pressed="true"]{color:var(--text-1);background:var(--accent-soft);box-shadow:inset 0 0 0 1px var(--accent-glow)}
|
||||
.end-talk{display:none;height:30px;padding:0 13px;border-radius:15px;align-items:center;gap:7px;background:var(--glass);border:1px solid var(--glass-line);color:var(--text-1);font-size:12px;white-space:nowrap;backdrop-filter:blur(18px)}
|
||||
.end-talk svg{width:14px;height:14px}
|
||||
body[data-mode="talk"] .end-talk,body[data-mode="record"] .end-talk{display:inline-flex;animation:chip-in 420ms var(--ease-out) 200ms both}
|
||||
@keyframes chip-in{from{opacity:0;transform:translateY(-4px)}}
|
||||
|
||||
/* ── Being here (home) ── */
|
||||
.home-copy{position:absolute;z-index:2;left:6.5vw;top:50%;width:min(420px,32vw);transform:translateY(-44%);transition:opacity 360ms var(--ease-out),transform 520ms var(--ease-out),filter 360ms var(--ease-out);text-shadow:0 2px 18px var(--pool)}
|
||||
.home-copy h1{font-size:30px;font-weight:300;line-height:1.6;letter-spacing:.02em;margin-bottom:14px}
|
||||
.left-note{display:block;width:100%;text-align:left;padding:16px 18px;border-radius:20px;margin-top:28px;line-height:1.85;font-size:14px;text-shadow:none}
|
||||
.note-meta{display:flex;justify-content:space-between;gap:8px;font-size:12px;color:var(--accent);margin-bottom:8px}.note-meta time{color:var(--text-3)}
|
||||
.home-actions{display:flex;align-items:center;gap:12px;margin-top:14px}.home-actions .round{width:48px;height:48px}
|
||||
body:not([data-mode="home"]) .home-copy{opacity:0;transform:translate(-24px,-44%);filter:blur(6px);pointer-events:none;transition-duration:220ms,420ms,220ms}
|
||||
body[data-mode="home"] .home-copy{transition-delay:240ms,200ms,240ms}
|
||||
.her-hit{position:absolute;z-index:1;left:0;top:0;width:10px;height:10px;border-radius:40% 40% 30% 30%;display:flex;align-items:flex-start;justify-content:center}
|
||||
.her-hit span{margin-top:-34px;padding:5px 12px;border-radius:14px;font-size:12px;background:var(--glass);border:1px solid var(--glass-line);backdrop-filter:blur(14px);opacity:0;transform:translateY(4px);transition:opacity var(--dur-ui) var(--ease-out),transform var(--dur-ui) var(--ease-out);pointer-events:none;white-space:nowrap}
|
||||
.her-hit:focus-visible span{opacity:1;transform:none}
|
||||
body:not([data-mode="home"]) .her-hit{visibility:hidden}
|
||||
|
||||
/* ── Talking: the lines fall on your side of the table, under her gaze ── */
|
||||
.conversation{position:absolute;z-index:3;left:50%;bottom:calc(var(--nav-space) + var(--safe-bottom));width:min(940px,88vw);transform:translate(-50%,14px);opacity:0;pointer-events:none;transition:opacity 220ms var(--ease-out),transform 420ms var(--ease-out);display:flex;flex-direction:column;align-items:center}
|
||||
body[data-mode="talk"] .conversation{opacity:1;transform:translate(-50%,0);pointer-events:auto;transition-duration:520ms,620ms;transition-delay:300ms}
|
||||
.stage{position:relative;width:100%;height:var(--stage-h);display:flex;flex-direction:column;justify-content:flex-end;align-items:center;gap:6px;text-align:center}
|
||||
.stage::before{content:"";position:absolute;left:4%;right:4%;top:0;bottom:-40%;background:radial-gradient(ellipse 50% 55% at 50% 64%,color-mix(in srgb,var(--pool) 62%,transparent),transparent 100%);pointer-events:none;z-index:-1}
|
||||
.line{width:100%;display:flex;flex-direction:column;align-items:center;gap:3px}
|
||||
.line .who{display:inline-flex;align-items:center;gap:7px;font-size:12px;letter-spacing:.08em;color:var(--text-2);max-width:100%}
|
||||
.line .who b{font-weight:400;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:16em}
|
||||
.line .who i{width:7px;height:7px;border-radius:50%;background:var(--accent);box-shadow:0 0 8px var(--accent);flex:none}
|
||||
.line[data-role="user"] .who i{background:transparent;box-shadow:none;border:1px solid var(--user)}
|
||||
.line .state{font-style:normal;color:var(--text-3);font-size:11px;letter-spacing:0}
|
||||
.line p{font-size:23px;font-weight:350;line-height:1.5;letter-spacing:.02em;max-width:900px;overflow-wrap:anywhere;text-shadow:0 2px 18px var(--pool),0 0 2px color-mix(in srgb,var(--pool) 60%,transparent);color:var(--text-1)}
|
||||
.line[data-role="user"] p{color:var(--user);font-size:20px;font-weight:300}
|
||||
/* Previous line: tag and words on one row, quiet (HEL-798). Fixed size; the hand-off is a crossfade of two copies. */
|
||||
.line.is-prev{flex-direction:row;justify-content:center;gap:10px;opacity:.6;margin-bottom:4px}
|
||||
.line.is-prev p{font-size:15px;font-weight:300;color:var(--user);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:min(680px,72vw)}
|
||||
.line.is-prev[data-role="her"] p{color:var(--text-2)}
|
||||
.ink span{display:inline;animation:ink 460ms var(--ease-out) both;animation-delay:calc(var(--i) * 14ms)}
|
||||
@keyframes ink{from{opacity:0;filter:blur(3px)}}
|
||||
.line.waiting .state::after{content:"";display:inline-block;width:18px;height:6px;margin-left:5px;background:radial-gradient(circle,var(--accent) 1.5px,transparent 2px) 0 50%/6px 6px repeat-x;animation:dots 1.4s linear infinite;vertical-align:middle;opacity:.8}
|
||||
@keyframes dots{50%{opacity:.25}}
|
||||
|
||||
.reader-bar{display:flex;align-items:center;justify-content:center;gap:4px;height:30px;margin:4px 0 6px;font-size:12px;color:var(--text-3)}
|
||||
.reader-bar>button{height:28px;padding:0 9px;border-radius:14px;white-space:nowrap;display:inline-flex;align-items:center;gap:5px;color:var(--text-2)}
|
||||
.reader-bar .icon{width:28px;padding:0;justify-content:center}.reader-bar svg{width:14px;height:14px}
|
||||
.reader-bar .count{position:relative;min-width:72px;height:28px;display:inline-flex;align-items:center;justify-content:center;font-variant-numeric:tabular-nums;font-size:11px;color:var(--text-3)}
|
||||
/* The dwell meter lives under the count: one quiet line, as in the approved still. */
|
||||
.reader-bar .count::after{content:"";position:absolute;left:0;right:0;bottom:3px;height:2px;border-radius:1px;background:#ffffff1c}
|
||||
.reader-bar .count i{position:absolute;left:0;right:0;bottom:3px;height:2px;border-radius:1px;background:var(--accent);box-shadow:0 0 6px var(--accent);transform-origin:left;transform:scaleX(0);z-index:1}
|
||||
body.reading-paused .reader-bar .count i{opacity:.3}body.reading-held .reader-bar .count i{opacity:.5}
|
||||
.reader-bar .flow[aria-pressed="false"]{color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent-glow)}
|
||||
#stop{color:var(--accent)}
|
||||
.latest{color:var(--on-accent)!important;background:var(--accent);box-shadow:0 0 16px var(--accent-glow)}
|
||||
body.single-page .reader-bar .icon,body.single-page .reader-bar .count span{visibility:hidden}
|
||||
|
||||
.composer{width:min(640px,100%);height:50px;border-radius:25px;display:flex;align-items:center;gap:6px;padding:0 6px 0 8px;background:linear-gradient(90deg,var(--input-a),var(--input-b) 70%,var(--input-c));border:1px solid var(--glass-line);backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);box-shadow:0 10px 40px #02051466,inset 0 1px 0 #ffffff12;transition:border-color var(--dur-ui),box-shadow var(--dur-ui)}
|
||||
.composer .round{width:38px;height:38px;color:var(--text-2)}
|
||||
.composer textarea{flex:1;min-width:0;resize:none;height:38px;max-height:88px;border:0;background:transparent;line-height:1.6;padding:8px 4px;outline:none;color:var(--text-1);font-size:15px}
|
||||
.composer textarea::placeholder{color:var(--text-3)}
|
||||
.composer:focus-within{border-color:var(--accent-glow);box-shadow:0 0 0 1px var(--accent-soft),0 0 30px var(--accent-soft)}
|
||||
.voice-button{width:38px;height:38px;border-radius:50%;display:grid;place-items:center;background:var(--accent);color:var(--on-accent);box-shadow:0 0 18px var(--accent-glow);flex:none}
|
||||
.voice-row{display:flex;align-items:center;justify-content:center;gap:12px;font-size:12px;color:var(--text-2);margin-bottom:6px}.voice-row button{color:var(--accent)}
|
||||
.voice-wave{display:inline-flex;gap:3px;align-items:center;height:14px}.voice-wave i{width:2px;height:100%;background:var(--accent);border-radius:2px;animation:wave 1.1s var(--ease-in-out) infinite}.voice-wave i:nth-child(2){animation-delay:.15s}.voice-wave i:nth-child(3){animation-delay:.3s}.voice-wave i:nth-child(4){animation-delay:.45s}
|
||||
@keyframes wave{50%{transform:scaleY(.3)}}
|
||||
|
||||
/* ── Navigation: small, translucent, under everything ── */
|
||||
.navigation{position:absolute;z-index:5;left:50%;bottom:calc(6px + var(--safe-bottom));transform:translateX(-50%);display:flex;gap:4px;padding:3px;border-radius:17px;background:color-mix(in srgb,var(--surface) 40%,transparent);border:1px solid var(--glass-line);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);transition:transform 420ms var(--ease-out),opacity 280ms var(--ease-out)}
|
||||
.nav-glow{position:absolute;left:0;top:3px;bottom:3px;width:64px;border-radius:13px;background:var(--accent-soft);box-shadow:0 0 14px var(--accent-glow);transition:transform 460ms var(--ease-out),opacity 280ms;pointer-events:none}
|
||||
.navigation button{position:relative;width:64px;height:26px;display:inline-flex;align-items:center;justify-content:center;gap:6px;border-radius:13px;font-size:12px;letter-spacing:.04em;color:var(--text-3)}
|
||||
.navigation svg{width:14px;height:14px}.navigation [aria-current="page"]{color:var(--text-1)}.navigation [aria-current="page"] svg{color:var(--accent)}
|
||||
.ref-note{position:absolute;right:40px;bottom:calc(14px + var(--safe-bottom));font-size:11px;color:var(--text-3);opacity:.8;letter-spacing:.04em;pointer-events:none}
|
||||
.toast{position:absolute;left:50%;top:84px;transform:translate(-50%,-8px);padding:8px 16px;border-radius:20px;font-size:12px;color:var(--text-1);background:var(--glass-read);border:1px solid var(--glass-line);backdrop-filter:blur(14px);opacity:0;pointer-events:none;transition:opacity 280ms var(--ease-out),transform 280ms var(--ease-out);z-index:6;white-space:nowrap;max-width:calc(100vw - 32px);overflow:hidden;text-overflow:ellipsis}
|
||||
.toast.show{opacity:1;transform:translate(-50%,0)}
|
||||
|
||||
/* ── Panels: reading surfaces inside the room ── */
|
||||
.sheet{position:fixed;inset:auto;margin:0;top:calc(var(--view-top) + 84px);left:5vw;width:min(900px,60vw);height:calc(var(--view-h) - 150px - var(--safe-bottom));max-height:none;max-width:calc(100vw - 24px);padding:0;border-radius:26px;color:var(--text-1);background:var(--glass-read);overflow:hidden;box-shadow:0 25px 100px #02041270,inset 0 1px 0 #ffffff10}
|
||||
.sheet::backdrop{background:transparent}
|
||||
.sheet[data-kind="history"],.sheet[data-kind="full"]{width:min(470px,36vw);left:4vw}
|
||||
.sheet-header{display:flex;justify-content:space-between;align-items:center;gap:20px;padding:22px 26px 16px;border-bottom:1px solid var(--glass-line);height:100px}
|
||||
.sheet-header .eyebrow{font-size:11px;margin-bottom:3px}
|
||||
.sheet-content{height:calc(100% - 100px);overflow:auto;overscroll-behavior:contain;padding:22px 26px 32px;scrollbar-gutter:stable;line-height:1.9}
|
||||
.sheet-content>*{animation:rise 520ms var(--ease-out) both}.sheet-content>:nth-child(2){animation-delay:40ms}.sheet-content>:nth-child(3){animation-delay:80ms}.sheet-content>:nth-child(4){animation-delay:120ms}.sheet-content>:nth-child(n+5){animation-delay:160ms}
|
||||
@keyframes rise{from{opacity:0;transform:translateY(10px);filter:blur(4px)}}
|
||||
.sheet-content :is(p,ul){margin-bottom:16px}
|
||||
.sheet-content .row{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin:15px 0}
|
||||
.sheet-content .pill{border:1px solid var(--glass-line);border-radius:24px;padding:8px 17px;font-size:13px}
|
||||
.sheet-content .pill[aria-pressed="true"]{background:var(--accent-soft);color:var(--accent);box-shadow:0 0 16px var(--accent-soft)}
|
||||
.sheet-content .item{width:100%;text-align:left;border-top:1px solid var(--glass-line);padding:20px 4px;display:block;border-radius:6px}
|
||||
.item small{display:block;color:var(--text-2);margin-top:7px;font-size:13px}.item .date{font-size:11px;letter-spacing:.08em;color:var(--accent);margin-bottom:10px}
|
||||
.quote{font-size:20px;font-weight:350;border-left:1px solid var(--accent);padding-left:20px;margin:24px 0}
|
||||
.sheet-content .message{padding:16px 0;border-bottom:1px solid var(--glass-line)}
|
||||
.message .author{display:flex;align-items:center;gap:7px;color:var(--accent);font-size:12px;margin-bottom:6px;overflow-wrap:anywhere}
|
||||
.message .author i{width:7px;height:7px;border-radius:50%;background:var(--accent);box-shadow:0 0 8px var(--accent);flex:none}
|
||||
.message[data-role="user"] .author{color:var(--text-2)}.message[data-role="user"] .author i{background:none;box-shadow:none;border:1px solid var(--user)}
|
||||
.message p{font-size:15px;white-space:pre-wrap;overflow-wrap:anywhere}.message .incomplete{font-size:12px;color:var(--text-2)}
|
||||
.sheet-content label{display:block;font-size:13px;color:var(--text-2);margin:18px 0 7px}
|
||||
.sheet-content input,.sheet-content textarea,.sheet-content select{border:1px solid var(--glass-line);border-radius:12px;background:var(--surface);padding:11px 14px;width:100%;max-width:100%;font-size:15px}
|
||||
.sheet-content textarea{min-height:90px;resize:vertical}
|
||||
.sheet-content .notice{padding:14px 17px;border:1px solid var(--glass-line);border-radius:16px;color:var(--text-2);font-size:13px}
|
||||
.sheet-content .status{color:var(--accent);min-height:26px;font-size:13px}.sheet-content .guide{font-size:13px;color:var(--text-2)}
|
||||
.sheet-content summary{cursor:pointer;color:var(--accent);padding:10px 0}.sheet-content details{border-top:1px solid var(--glass-line);margin-top:20px}
|
||||
.sheet-content .error{color:#ffb8c8}
|
||||
.sheet-content .primary{color:var(--on-accent)}
|
||||
*{scrollbar-width:thin;scrollbar-color:var(--accent-glow) transparent}
|
||||
::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-thumb{background:var(--accent-glow);border-radius:10px}::-webkit-scrollbar-thumb:hover{background:var(--accent)}::-webkit-scrollbar-track{background:transparent}
|
||||
|
||||
/* Hover only where a real pointer exists; touch never gets stuck hover states. */
|
||||
@media(hover:hover) and (pointer:fine){
|
||||
button:hover:not(:disabled){opacity:.85}.sheet-content .item:hover{color:var(--accent);background:linear-gradient(90deg,var(--accent-soft),transparent 70%)}
|
||||
.reader-bar>button:hover:not(:disabled),.navigation button:hover{background:#ffffff0d;opacity:1}
|
||||
.her-hit{cursor:pointer}.her-hit:hover span{opacity:1;transform:none}
|
||||
}
|
||||
@media(max-width:1100px){
|
||||
.weather,.ref-note{display:none}.identity strong{max-width:180px}
|
||||
.home-copy{width:min(400px,40vw)}
|
||||
.sheet{width:84vw;left:8vw}.sheet[data-kind="history"],.sheet[data-kind="full"]{width:min(440px,52vw)}
|
||||
}
|
||||
|
||||
/* ── Phone ── */
|
||||
@media(max-width:720px){
|
||||
.vignette,html[data-theme="fog"] .vignette{background:radial-gradient(ellipse 95% 70% at 55% 38%,transparent 55%,color-mix(in srgb,var(--bg-0) 66%,transparent) 100%),linear-gradient(180deg,color-mix(in srgb,var(--bg-0) 66%,transparent) 0%,transparent 10%)}
|
||||
:root{--stage-h:132px;--nav-space:60px}
|
||||
.topbar{height:56px;padding:0 14px;gap:8px}.identity{gap:8px}.identity strong{font-size:16px;max-width:96px}.presence{display:none}
|
||||
.top-actions{gap:6px}.sample-tag{height:26px;font-size:10px;padding:0 8px}.theme{padding:2px}.theme button{font-size:11px;height:22px;padding:0 8px;gap:4px}
|
||||
.end-talk{height:28px;width:28px;padding:0;justify-content:center}.end-talk span{position:absolute;width:1px;height:1px;clip-path:inset(50%);overflow:hidden}
|
||||
.ref-note{display:block;top:52px;right:14px;bottom:auto;font-size:10px;opacity:.65}
|
||||
.home-copy{left:20px;right:20px;top:auto;bottom:calc(var(--nav-space) + 6px + var(--safe-bottom));width:auto;transform:none}
|
||||
body:not([data-mode="home"]) .home-copy{transform:translateY(16px)}
|
||||
.home-copy .eyebrow{margin-bottom:8px}.home-copy h1{font-size:22px;line-height:1.55;margin-bottom:8px}.home-copy .quiet{font-size:12px}
|
||||
.left-note{padding:12px 15px;font-size:13px;margin-top:14px;border-radius:18px;line-height:1.7}.note-meta{font-size:11px;margin-bottom:4px}
|
||||
.home-copy .small-link{padding:8px 0;font-size:12px}.home-actions{margin-top:4px}.home-actions .primary{padding:10px 20px;font-size:14px}.home-actions .round{width:44px;height:44px}
|
||||
.conversation{width:calc(100% - 20px)}
|
||||
.line p{font-size:18px;line-height:1.55}.line[data-role="user"] p{font-size:16px}.line.is-prev p{font-size:13px;max-width:70vw}
|
||||
.reader-bar{gap:0;margin:2px 0 6px;font-size:11px}.reader-bar>button{padding:0 7px;height:34px}.reader-bar .icon{width:34px}.reader-bar .count{min-width:56px}
|
||||
.composer{height:48px;padding:0 4px}.composer textarea{font-size:16px}
|
||||
.navigation{bottom:calc(6px + var(--safe-bottom));padding:3px}.navigation button{width:70px;height:40px;font-size:12px}.nav-glow{width:70px;border-radius:14px}
|
||||
.toast{top:60px;font-size:11px}
|
||||
.sheet,.sheet[data-kind="history"],.sheet[data-kind="full"]{left:10px;right:10px;width:calc(100% - 20px);top:calc(var(--view-top) + 60px);height:calc(var(--view-h) - 128px - var(--safe-bottom));border-radius:22px}
|
||||
.sheet-header{padding:14px 18px;height:80px}.sheet-content{padding:16px 18px 26px;height:calc(100% - 80px)}h2{font-size:20px}.quote{font-size:18px}
|
||||
body[data-mode="talk"] .latest span{max-width:9em;overflow:hidden;text-overflow:ellipsis}
|
||||
}
|
||||
@media(max-width:360px){.sample-tag{font-size:0;width:26px;padding:0}.sample-tag::before{content:"演示";font-size:10px}.identity strong{max-width:70px}}
|
||||
@media(max-height:700px) and (max-width:720px){
|
||||
.home-copy h1{font-size:19px}.home-copy .quiet{display:none}.home-copy .left-note{margin-top:8px;padding:9px 13px}.home-copy .left-note br{display:none}
|
||||
}
|
||||
/* Candidate only (?frame=media, HEL-802 v2 §2.3): on phones the room sits in a top media box of height --media-h, its
|
||||
bottom 12% fading into the page; the words and the composer live underneath. No foreground table on phones. */
|
||||
.frame-note{display:none}html.media-on .frame-note{display:inline}
|
||||
html.media-on #scene{bottom:auto;height:var(--media-h)}
|
||||
html.media-on #scene::after{content:"";position:absolute;left:0;right:0;bottom:0;height:12%;background:linear-gradient(180deg,transparent,var(--bg-0));pointer-events:none;transition:background .9s}
|
||||
html.media-on .near{display:none}
|
||||
/* Clean masters for image-to-video: no interface; optionally no foreground. */
|
||||
html.clean #viewport,html.clean #sheet{display:none}html.clean .veil{opacity:0}html.no-fore .near,html.no-fore .vignette{display:none}
|
||||
/* Short visual viewport = keyboard open or a squat window. Her face yields first, the words never do. */
|
||||
body.compact{--stage-h:78px;--nav-space:54px}
|
||||
body.compact .topbar{height:46px}body.compact .weather,body.compact .presence,body.compact .ref-note{display:none}
|
||||
body.compact .line.is-prev{display:none}body.compact .line p{font-size:16px;line-height:1.55}
|
||||
body.compact .reader-bar{margin:0 0 4px}
|
||||
body.compact .navigation button{height:36px}
|
||||
body.compact .sheet{top:calc(var(--view-top) + 48px);height:calc(var(--view-h) - 104px - var(--safe-bottom))}body.compact .sheet-header{height:66px;padding:8px 18px}body.compact .sheet-content{height:calc(100% - 66px)}
|
||||
body.compact.typing[data-mode="talk"] .navigation{transform:translate(-50%,150%);opacity:0;pointer-events:none}
|
||||
body.compact.typing{--nav-space:6px}
|
||||
body.compact[data-mode="home"] .home-copy .eyebrow,body.compact[data-mode="home"] .home-copy .quiet,body.compact[data-mode="home"] .small-link,body.compact[data-mode="home"] .note-text{display:none}
|
||||
body.compact[data-mode="home"] .home-copy h1{font-size:18px;margin:0}
|
||||
body.compact[data-mode="home"] .left-note{margin-top:6px;padding:7px 12px}body.compact[data-mode="home"] .note-meta{margin:0}
|
||||
body.micro .reader-bar .count,body.micro #read-all{display:none}
|
||||
body.micro[data-mode="home"] .left-note{display:none}
|
||||
|
||||
/* ── Motion preferences and fallbacks ── */
|
||||
html.no-motion *,html.no-motion *::before,html.no-motion *::after{animation:none!important;transition-duration:1ms!important}
|
||||
body.suspended *,body.suspended *::before,body.suspended *::after{animation-play-state:paused!important}
|
||||
/* Keyboard shortcuts (snap): land on the target state with no transition; ambient loops keep running. */
|
||||
body.snap *,body.snap *::before,body.snap *::after{transition:none!important}
|
||||
@media(prefers-reduced-motion:reduce){
|
||||
*,*::before,*::after{animation:none!important}
|
||||
.home-copy,.conversation,.near,.veil,.navigation,.nav-glow,.cam,.tint,.near-c,.moon-disc{transition:opacity 200ms linear!important}
|
||||
}
|
||||
/* Tier 2 (slow device): no backdrop blur, the most expensive compositor effect; no per-frame mask. */
|
||||
html[data-tier="2"] .glass,html[data-tier="2"] .sheet,html[data-tier="2"] .composer,html[data-tier="2"] .navigation{backdrop-filter:none;-webkit-backdrop-filter:none;background:var(--glass-read)}
|
||||
html[data-tier="2"] .mote,html[data-tier="2"] .mist{display:none}
|
||||
Vendored
+195
@@ -0,0 +1,195 @@
|
||||
'use strict';
|
||||
// ── Scene: one room, one camera. ──
|
||||
// Two approved reference stills of the same person, room and clothes are aligned on her face, so the camera can
|
||||
// move continuously from "sitting across the room" (room still) to "sitting across the table" (talk still, = the
|
||||
// approved HEL-798 composition). Only transform and opacity move per frame; the face itself is never warped.
|
||||
const Scene = (() => {
|
||||
const html = document.documentElement;
|
||||
const plate = {room: document.getElementById('plate-room'), talk: document.getElementById('plate-talk')};
|
||||
const moon = document.getElementById('moon'), cam = document.getElementById('cam'), near = document.getElementById('near'), hit = document.getElementById('her-hit');
|
||||
// Plate px. FACE: centre of her face in each still. K: her face is K× larger on the talk plate than on the room plate
|
||||
// (measured from eye spacing and hair width on the two stills: 3.8 native × 1.12 / 1.4).
|
||||
const FACE = {room: [1275, 347], talk: [856, 315]}, K = 3.04;
|
||||
const BOUNDS = {room: [-640, -112, 1600, 1148], talk: [-118, -10, 1674, 998]};
|
||||
const MOON = {room: [1082, 98, 30], talk: [404, 92, 44]};
|
||||
const HER = [1195, 235, 1445, 700]; // her figure on the room plate, for the tap target
|
||||
let M = 12; // overscan kept for pointer parallax
|
||||
const reduced = matchMedia('(prefers-reduced-motion: reduce)');
|
||||
const motionOff = () => reduced.matches || html.classList.contains('no-motion');
|
||||
const sstep = (a, b, x) => { const t = Math.min(1, Math.max(0, (x - a) / (b - a))); return t * t * (3 - 2 * t); };
|
||||
const lerp = (a, b, t) => a + (b - a) * t;
|
||||
|
||||
// Candidate (HEL-802 v2 §2.3, not approved): on phones the room lives in a 4:5 media box at the top instead of the
|
||||
// whole screen. H = min(1.25·w, max(w, h − 240), h − 56). Off unless ?frame=media; desktop stays full-viewport.
|
||||
const q = new URLSearchParams(location.search), media = q.get('frame') === 'media';
|
||||
html.dataset.frame = media ? 'media' : 'full';
|
||||
// Clean master export (?clean=1): no interface at all, no parallax overscan; ?fore=0 also drops your table, cup and
|
||||
// candle; ?fit=height keeps the whole 1000px height of the composition (16:9 masters widen instead of cropping).
|
||||
const clean = q.get('clean') === '1', fitHeight = q.get('fit') === 'height';
|
||||
html.classList.toggle('clean', clean); html.classList.toggle('no-fore', clean && q.get('fore') === '0');
|
||||
if (clean) M = 0;
|
||||
let vw = innerWidth, vh = innerHeight, tier = 0, boxed = false;
|
||||
// t: camera (0 = across the room, 1 = across the table). b: how much of the close still shows.
|
||||
let t = 0, v = 0, target = 0, b = 0, bFrom = 0, bStart = 0, settled = true, maskOn = null;
|
||||
|
||||
function layout() { return boxed || vw <= 720 || vw / vh < .9 ? 'phone' : 'desk'; }
|
||||
function shot(kind) {
|
||||
const phone = layout() === 'phone';
|
||||
if (boxed) {
|
||||
// Whole height of the 1600×1000 composition stays visible (cover by height); the talk still keeps its body
|
||||
// midline — source x 0.56 of a 16:9 frame = x 907 of the 16:10 composition — at the centre of the box.
|
||||
const s = Math.max(vw / 1600, vh / 1000);
|
||||
if (kind === 'room') return {plate: 'room', ax: .6, ay: 347 * s / vh, m: 1};
|
||||
return {plate: 'talk', ax: .5 + s * (856 - 907) / vw, ay: 315 * s / vh, m: 1};
|
||||
}
|
||||
if (kind === 'room') return {plate: 'room', ax: phone ? .6 : 1275 / 1600, ay: phone ? .25 : .347, m: 1};
|
||||
return {plate: 'talk', ax: phone ? .5 : 856 / 1600, ay: phone ? .27 : .315, m: 1};
|
||||
}
|
||||
function cover(s, o, p) {
|
||||
// How far a plate must shift so its picture still covers the viewport (plus parallax overscan).
|
||||
const [x0, y0, x1, y1] = BOUNDS[p], c = [0, 0];
|
||||
const fit = (pos, a0, a1, size, i) => {
|
||||
const min = size + M - s * a1, max = -M - s * a0;
|
||||
if (min > max) { c[i] = (min + max) / 2 - pos; return; }
|
||||
if (pos < min) c[i] = min - pos; else if (pos > max) c[i] = max - pos;
|
||||
};
|
||||
fit(o[0], x0, x1, vw, 0); fit(o[1], y0, y1, vh, 1);
|
||||
return c;
|
||||
}
|
||||
function rest(kind) {
|
||||
const sh = shot(kind), base = (fitHeight ? vh / 1000 : Math.max(vw / 1600, vh / 1000)) * sh.m, f = FACE[sh.plate];
|
||||
const o = [sh.ax * vw - base * f[0], sh.ay * vh - base * f[1]];
|
||||
const c = cover(base, o, sh.plate);
|
||||
return {s: base, o: [o[0] + c[0], o[1] + c[1]]};
|
||||
}
|
||||
// Camera at parameter x: zoom in log-space, face travels in a straight line on screen.
|
||||
function at(x) {
|
||||
const A = rest('room'), B = rest('talk');
|
||||
const sRB = B.s * K;
|
||||
const phA = [A.o[0] + A.s * FACE.room[0], A.o[1] + A.s * FACE.room[1]];
|
||||
const phB = [B.o[0] + B.s * FACE.talk[0], B.o[1] + B.s * FACE.talk[1]];
|
||||
const sR = A.s * Math.pow(sRB / A.s, x), sT = sR / K;
|
||||
const ph = [lerp(phA[0], phB[0], x), lerp(phA[1], phB[1], x)];
|
||||
const oR = [ph[0] - sR * FACE.room[0], ph[1] - sR * FACE.room[1]];
|
||||
const oT = [ph[0] - sT * FACE.talk[0], ph[1] - sT * FACE.talk[1]];
|
||||
const cR = cover(sR, oR, 'room'), cT = cover(sT, oT, 'talk'), w = sstep(.35, .8, x);
|
||||
const c = [lerp(cR[0], cT[0], w), lerp(cR[1], cT[1], w)];
|
||||
return {room: {s: sR, o: [oR[0] + c[0], oR[1] + c[1]]}, talk: {s: sT, o: [oT[0] + c[0], oT[1] + c[1]]}};
|
||||
}
|
||||
const put = (el, tr) => { el.style.transform = `translate3d(${tr.o[0].toFixed(2)}px,${tr.o[1].toFixed(2)}px,0) scale(${tr.s.toFixed(5)})`; };
|
||||
const map = (tr, p) => [tr.o[0] + tr.s * p[0], tr.o[1] + tr.s * p[1]];
|
||||
|
||||
function apply() {
|
||||
const off = motionOff();
|
||||
// Reduced motion: both stills stay at rest and simply crossfade.
|
||||
const cam0 = off ? {room: rest('room'), talk: null} : at(t);
|
||||
if (off) cam0.talk = rest('talk');
|
||||
put(plate.room, cam0.room); put(plate.talk, cam0.talk);
|
||||
const blend = off ? b : t;
|
||||
const useMask = !off && tier < 2;
|
||||
const op = useMask ? sstep(.08, .45, blend) : sstep(off ? 0 : .3, off ? 1 : .8, blend);
|
||||
plate.talk.style.opacity = op.toFixed(3);
|
||||
plate.talk.style.visibility = op < .002 ? 'hidden' : 'visible';
|
||||
plate.room.style.visibility = blend > .999 ? 'hidden' : 'visible';
|
||||
// The close still opens out from her face: a soft-edged circle that grows until it reaches the corners.
|
||||
// (Mask coordinates are in the plate box, which starts at the picture's corner: face + (118, 10).)
|
||||
const r = 150 + 1450 * sstep(.1, .97, blend);
|
||||
const wantMask = useMask && blend < .985 && op > .002;
|
||||
if (wantMask) {
|
||||
// ...intersected with soft picture edges, which tighten to nothing as the picture reaches the screen edges.
|
||||
const e = (260 * (1 - sstep(.7, .985, blend))).toFixed(0);
|
||||
const edge = d => `linear-gradient(${d},transparent 0,#000 ${e}px,#000 calc(100% - ${e}px),transparent 100%)`;
|
||||
const m = `radial-gradient(circle at ${FACE.talk[0] + 118}px ${FACE.talk[1] + 10}px,#000 ${r.toFixed(0)}px,transparent ${(r + 520).toFixed(0)}px),${edge('90deg')},${edge('180deg')}`;
|
||||
const s = plate.talk.style;
|
||||
s.webkitMaskImage = m; s.maskImage = m;
|
||||
if (!maskOn) { s.webkitMaskComposite = 'source-in, source-in'; s.maskComposite = 'intersect'; }
|
||||
maskOn = true;
|
||||
} else if (maskOn !== false) { plate.talk.style.webkitMaskImage = 'none'; plate.talk.style.maskImage = 'none'; maskOn = false; }
|
||||
// The moon is far away: it drifts less than the room and hands over between the two windows.
|
||||
const mw = off ? (b > .5 ? 1 : 0) : sstep(.2, .8, t);
|
||||
const mr = map(cam0.room, MOON.room), mt = map(cam0.talk, MOON.talk);
|
||||
const size = lerp(MOON.room[2] * cam0.room.s, MOON.talk[2] * cam0.talk.s, mw);
|
||||
moon.style.transform = `translate3d(${lerp(mr[0], mt[0], mw).toFixed(1)}px,${lerp(mr[1], mt[1], mw).toFixed(1)}px,0) scale(${(size / 44).toFixed(4)})`;
|
||||
// Tap target over her (only used while you are across the room).
|
||||
const a = map(cam0.room, [HER[0], HER[1]]), z = map(cam0.room, [HER[2], HER[3]]);
|
||||
Object.assign(hit.style, {left: a[0] + 'px', top: a[1] + 'px', width: (z[0] - a[0]) + 'px', height: (z[1] - a[1]) + 'px'});
|
||||
Rain.view(cam0, op);
|
||||
}
|
||||
|
||||
// Critically damped spring: interruptible, keeps its velocity when the target changes mid-way.
|
||||
const W = 7.2;
|
||||
function step(dt) {
|
||||
if (motionOff()) {
|
||||
t = target; v = 0;
|
||||
const k = Math.min(1, (performance.now() - bStart) / 200);
|
||||
b = lerp(bFrom, target, k);
|
||||
settled = k >= 1;
|
||||
return;
|
||||
}
|
||||
// Fixed small sub-steps keep the spring in real time even when frames arrive late.
|
||||
for (let left = dt; left > 0; left -= 1 / 240) {
|
||||
const h = Math.min(left, 1 / 240), a = W * W * (target - t) - 2 * W * v;
|
||||
v += a * h; t += v * h;
|
||||
}
|
||||
if (Math.abs(target - t) < 4e-4 && Math.abs(v) < 4e-3) { t = target; v = 0; settled = true; }
|
||||
b = t;
|
||||
}
|
||||
function go(mode, instant = false) {
|
||||
const nt = mode === 'talk' || mode === 'record' ? 1 : 0;
|
||||
html.dataset.camera = nt ? 'close' : 'far';
|
||||
if (instant) { t = target = b = nt; v = 0; settled = true; apply(); return; }
|
||||
if (nt === target && settled) return;
|
||||
bFrom = b; bStart = performance.now();
|
||||
target = nt; settled = false;
|
||||
}
|
||||
|
||||
// Pointer parallax (fine pointers only): far things move a little, your table the other way.
|
||||
const fine = matchMedia('(hover: hover) and (pointer: fine)');
|
||||
addEventListener('pointermove', e => {
|
||||
if (!fine.matches || motionOff() || e.pointerType !== 'mouse') return;
|
||||
const px = e.clientX / vw - .5, py = e.clientY / vh - .5;
|
||||
cam.style.transform = `translate3d(${(-px * 16).toFixed(1)}px,${(-py * 10).toFixed(1)}px,0)`;
|
||||
near.style.setProperty('--px', (px * 22).toFixed(1) + 'px'); near.style.setProperty('--py', (py * 10).toFixed(1) + 'px');
|
||||
}, {passive: true});
|
||||
|
||||
// Frame loop + automatic quality tiers (average frame interval while settled).
|
||||
let last = 0, samples = [], forced = false;
|
||||
function frame(now) {
|
||||
const dt = last ? Math.min(.12, (now - last) / 1000) : 0; last = now;
|
||||
if (!settled) { step(dt); apply(); }
|
||||
Rain.draw(now, tier);
|
||||
if (!forced && settled && dt && !document.hidden) {
|
||||
samples.push(dt); if (samples.length > 120) samples.shift();
|
||||
if (samples.length === 120) {
|
||||
const avg = samples.reduce((x, y) => x + y) / 120;
|
||||
if (avg > .026 && tier < 2) { setTier(tier + 1); samples = []; }
|
||||
}
|
||||
}
|
||||
requestAnimationFrame(frame);
|
||||
}
|
||||
function setTier(n, force = false) { tier = n; forced = forced || force; html.dataset.tier = String(n); Near.draw(); apply(); }
|
||||
function resize() {
|
||||
const vv = window.visualViewport, w = innerWidth, h = vv ? vv.height : innerHeight;
|
||||
boxed = media && w <= 720;
|
||||
html.classList.toggle('media-on', boxed);
|
||||
vw = w; vh = boxed ? Math.round(Math.min(1.25 * w, Math.max(w, h - 240), h - 56) * 10) / 10 : innerHeight;
|
||||
html.style.setProperty('--media-h', boxed ? vh + 'px' : '100%');
|
||||
Near.draw(); apply();
|
||||
}
|
||||
addEventListener('resize', resize);
|
||||
document.addEventListener('visibilitychange', () => { last = 0; samples = []; });
|
||||
requestAnimationFrame(frame);
|
||||
return {
|
||||
go, setTier, resize, apply,
|
||||
// Review hook: freeze the camera at any point of the move (used for the frame strips in evidence/).
|
||||
peek(x) { t = target = b = x; v = 0; settled = true; apply(); },
|
||||
get tier() { return tier; },
|
||||
info: () => {
|
||||
// Her face on screen (forehead to chin, from the close still's transform), for overlap checks.
|
||||
const m = /translate3d\(([-\d.]+)px, ?([-\d.]+)px.*scale\(([-\d.]+)\)/.exec(plate.talk.style.transform) || [0, 0, 0, 0];
|
||||
const s = +m[3], cx = +m[1] + s * FACE.talk[0], cy = +m[2] + s * FACE.talk[1];
|
||||
return {t: +t.toFixed(4), target, b: +b.toFixed(4), settled, tier, layout: layout(), frame: boxed ? {w: vw, h: vh} : null, face: {x: +cx.toFixed(1), y: +cy.toFixed(1)}, talkOpacity: +plate.talk.style.opacity, roomVisible: plate.room.style.visibility !== 'hidden', mask: !!maskOn,
|
||||
head: {left: cx - 200 * s, right: cx + 200 * s, top: cy - 300 * s, bottom: cy + 140 * s}};
|
||||
}
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1,109 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN" data-theme="moon">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover,interactive-widget=resizes-content">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; script-src 'unsafe-inline'; connect-src 'none'; form-action 'none'; base-uri 'none'">
|
||||
<title>CyberGril · 对坐 · HEL-799 共同空间动态小样</title>
|
||||
<style>{{STYLE}}</style>
|
||||
</head>
|
||||
<body data-mode="home">
|
||||
<svg class="symbols" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><defs>
|
||||
<symbol id="i-moon" viewBox="0 0 24 24"><path d="M20 14.5A8 8 0 1 1 9.5 4a6.5 6.5 0 0 0 10.5 10.5z"/></symbol>
|
||||
<symbol id="i-talk" viewBox="0 0 24 24"><path d="M4 12a8 8 0 1 1 3.5 6.6L4 20l1.2-3.6A8 8 0 0 1 4 12z"/></symbol>
|
||||
<symbol id="i-book" viewBox="0 0 24 24"><rect x="5" y="3" width="14" height="18" rx="2"/><path d="M9 8h6M9 12h6M9 16h4"/></symbol>
|
||||
<symbol id="i-sun" viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1"/></symbol>
|
||||
<symbol id="i-mic" viewBox="0 0 24 24"><rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0M12 18v3"/></symbol>
|
||||
<symbol id="i-arrow" viewBox="0 0 24 24"><path d="M12 19V5M6 11l6-6 6 6"/></symbol>
|
||||
<symbol id="i-close" viewBox="0 0 24 24"><path d="M6 6l12 12M18 6L6 18"/></symbol>
|
||||
<symbol id="i-lines" viewBox="0 0 24 24"><path d="M4 7h16M4 12h10M4 17h13"/></symbol>
|
||||
<symbol id="i-pause" viewBox="0 0 24 24"><path d="M9 6v12M15 6v12"/></symbol>
|
||||
<symbol id="i-play" viewBox="0 0 24 24"><path d="M8 5.5v13l10-6.5z"/></symbol>
|
||||
<symbol id="i-prev" viewBox="0 0 24 24"><path d="m14.5 6-6 6 6 6"/></symbol>
|
||||
<symbol id="i-next" viewBox="0 0 24 24"><path d="m9.5 6 6 6-6 6"/></symbol>
|
||||
<symbol id="i-down" viewBox="0 0 24 24"><path d="m6 9.5 6 6 6-6"/></symbol>
|
||||
</defs></svg>
|
||||
|
||||
<!-- One room, one camera. Far: her room and the rainy city. Middle: her. Near: your table, cup and candle. -->
|
||||
<div id="scene" aria-hidden="true">
|
||||
<div class="cam" id="cam">
|
||||
<div class="plate" id="plate-room" data-plate="room"><div class="po">
|
||||
<img class="photo" src="{{ROOM}}" alt="">
|
||||
<div class="tint moon"><i class="night"></i><i class="night2"></i></div>
|
||||
<div class="tint fog"><i class="night"></i><i class="night2"></i></div>
|
||||
<canvas class="rain" width="800" height="500"></canvas>
|
||||
<i class="mist m1"></i><i class="mist m2"></i>
|
||||
<i class="flame-glow" style="left:931px;top:500px"></i>
|
||||
<i class="spill"></i>
|
||||
</div></div>
|
||||
<div class="plate" id="plate-talk" data-plate="talk"><div class="po">
|
||||
<img class="photo" src="{{TALK}}" alt="">
|
||||
<div class="tint moon"><i class="night"></i><i class="night2"></i><i class="beam"></i></div>
|
||||
<div class="tint fog"><i class="night"></i><i class="night2"></i><i class="beam"></i></div>
|
||||
<canvas class="rain" width="800" height="500"></canvas>
|
||||
<i class="mist m1"></i><i class="mist m2"></i>
|
||||
<i class="flame-glow" style="left:89px;top:738px"></i><i class="flame-glow" style="left:-12px;top:704px"></i>
|
||||
<i class="spill"></i>
|
||||
<i class="mote" style="--x:1180px;--y:330px;--d:17s;--dl:-3s"></i><i class="mote" style="--x:1290px;--y:240px;--d:21s;--dl:-9s"></i><i class="mote" style="--x:1400px;--y:420px;--d:19s;--dl:-14s"></i><i class="mote" style="--x:1230px;--y:520px;--d:24s;--dl:-6s"></i>
|
||||
</div></div>
|
||||
<i class="moon-disc" id="moon"></i>
|
||||
</div>
|
||||
<div class="near" id="near">
|
||||
<canvas class="near-c" data-theme-layer="moon"></canvas>
|
||||
<canvas class="near-c" data-theme-layer="fog"></canvas>
|
||||
<i class="steam s1"></i><i class="steam s2"></i>
|
||||
<i class="candle"></i>
|
||||
</div>
|
||||
<div class="vignette"></div>
|
||||
<div class="veil"></div>
|
||||
</div>
|
||||
|
||||
<div id="viewport">
|
||||
<header class="topbar">
|
||||
<div class="identity"><span class="glint"></span><strong data-name>晚晚</strong><span class="presence" id="presence">在窗边</span></div>
|
||||
<div class="top-actions">
|
||||
<button id="rehearse" class="sample-tag">独立小样 · 演示数据</button>
|
||||
<span class="weather">上海 · 小雨 14° <small>示例</small></span>
|
||||
<div class="theme" role="group" aria-label="空间主题"><button data-theme="moon" aria-pressed="true"><i></i>月光</button><button data-theme="fog" aria-pressed="false"><i></i>雾光</button></div>
|
||||
<button class="end-talk" id="close-talk"><svg><use href="#i-close"/></svg><span>结束交谈</span></button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main id="world" aria-label="相处空间">
|
||||
<section class="home-copy" aria-label="此刻">
|
||||
<p class="eyebrow">此 刻</p><h1>她在窗边,<br>雨声不大。</h1><p class="quiet">安静,有点倦 <span>·</span> 你们最近挺熟络</p>
|
||||
<button class="left-note glass" id="shared-note"><span class="note-meta"><span>她留给你的</span><time>今天 15:52</time></span><span class="note-text">楼下花店的洋桔梗开了。<br>我挑了一小束,放在窗边。</span></button>
|
||||
<button class="small-link" id="days-link">你不在时,她分享过的小事 <span>›</span></button>
|
||||
<div class="home-actions"><button class="primary" id="start-talk"><svg><use href="#i-talk"/></svg>和她说话</button><button class="round glass" id="home-voice" aria-label="语音演示"><svg><use href="#i-mic"/></svg></button></div>
|
||||
</section>
|
||||
|
||||
<button class="her-hit" id="her-hit" aria-label="走近她,开始交谈"><span>和她说话</span></button>
|
||||
|
||||
<section class="conversation" id="conversation" aria-label="当前对话" inert>
|
||||
<div class="voice-row" id="voice-row" hidden><span class="voice-wave" aria-hidden="true"><i></i><i></i><i></i><i></i></span><span>语音界面演示 · 没有收音</span><button id="end-voice">结束演示</button></div>
|
||||
<div class="stage" id="stage" aria-hidden="true"></div>
|
||||
<div class="reader-bar">
|
||||
<button id="toggle-flow" class="flow" aria-pressed="true"><svg><use href="#i-pause"/></svg><span>暂停</span></button>
|
||||
<button id="previous" class="icon" aria-label="上一句"><svg><use href="#i-prev"/></svg></button>
|
||||
<span id="page-count" class="count">1 / 1</span>
|
||||
<button id="next" class="icon" aria-label="下一句"><svg><use href="#i-next"/></svg></button>
|
||||
<button id="read-all">全文</button>
|
||||
<button id="stop" hidden>停止回复</button>
|
||||
<button id="latest" class="latest" hidden><svg><use href="#i-down"/></svg><span>回到读到的地方</span></button>
|
||||
</div>
|
||||
<form class="composer" id="composer"><button type="button" class="round" id="history" aria-label="完整聊天记录"><svg><use href="#i-lines"/></svg></button><textarea id="draft" rows="1" maxlength="4000" placeholder="想和她说点什么…" aria-label="想和她说的话"></textarea><button type="submit" class="send round" aria-label="发送演示消息"><svg><use href="#i-arrow"/></svg></button><button type="button" class="voice-button" id="voice" aria-label="语音演示"><svg><use href="#i-mic"/></svg></button></form>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<nav class="navigation" aria-label="主要区域">
|
||||
<span class="nav-glow" aria-hidden="true"></span>
|
||||
<button data-nav="home" aria-current="page"><svg><use href="#i-moon"/></svg><span>此刻</span></button><button data-nav="talk"><svg><use href="#i-talk"/></svg><span>交谈</span></button><button data-nav="days"><svg><use href="#i-book"/></svg><span>日子</span></button><button data-nav="manage"><svg><use href="#i-sun"/></svg><span>设置</span></button>
|
||||
</nav>
|
||||
<p class="ref-note">人物为旧参考静帧 · 不代表新日常<span class="frame-note"> · 4:5 容器候选</span> · 未接入真实动态</p>
|
||||
<p class="toast" id="toast" role="status" aria-live="polite"></p>
|
||||
</div>
|
||||
|
||||
<dialog id="sheet" class="sheet glass" aria-labelledby="sheet-title"><header class="sheet-header"><div><p class="eyebrow" id="sheet-kicker"></p><h2 id="sheet-title"></h2></div><button class="round" id="close-sheet" aria-label="关闭浮层"><svg><use href="#i-close"/></svg></button></header><div id="sheet-content" class="sheet-content"></div></dialog>
|
||||
<p id="announcement" class="sr" aria-live="polite" aria-atomic="true"></p>
|
||||
<script>{{SCRIPT}}</script>
|
||||
</body></html>
|
||||
Vendored
+456
@@ -0,0 +1,456 @@
|
||||
'use strict';
|
||||
// Conversation, panels and modes. Reading logic carried over from the verified HEL-793/795 prototype (PR#8);
|
||||
// what changed is where it lives: in the same room, across the table, instead of inside her window.
|
||||
// Local fixtures only. CSP forbids connections; nothing is persisted.
|
||||
const $ = s => document.querySelector(s);
|
||||
const $$ = s => [...document.querySelectorAll(s)];
|
||||
const html = document.documentElement;
|
||||
const sheet = $('#sheet'), content = $('#sheet-content'), stage = $('#stage');
|
||||
const reducedQuery = matchMedia('(prefers-reduced-motion: reduce)');
|
||||
const motionOff = () => reducedQuery.matches || html.classList.contains('no-motion');
|
||||
const EASE = 'cubic-bezier(.22,1,.36,1)';
|
||||
|
||||
const state = {
|
||||
mode: 'home', name: '晚晚', relation: '朋友', turn: 0, cursor: 0, head: 0,
|
||||
flow: true, held: new Set(), busy: false, voice: false, token: 0, dialog: null, returnMode: 'home',
|
||||
dwell: 0, dwellTotal: 0, createdNew: false
|
||||
};
|
||||
let messages = [
|
||||
{id: -3, turn: -2, role: 'user', text: '淡色的花看起来很安静。', status: 'complete', life: 0},
|
||||
{id: -2, turn: -2, role: 'her', text: '楼下花店的洋桔梗开了。我挑了一小束,放在窗边。', status: 'complete', life: 0},
|
||||
{id: -1, turn: -1, role: 'her', text: '我们就这样一起听一会儿雨吧。', status: 'complete', life: 1},
|
||||
{id: 1, turn: 0, role: 'user', text: '外面下雨了,你那边听得见吗?', status: 'complete'},
|
||||
{id: 2, turn: 0, role: 'her', text: '听得见,打在玻璃上很轻。你也坐一会儿吧,陪我听一会儿雨。', status: 'complete'}
|
||||
];
|
||||
let nextId = 3, streamTimer = 0, closing = null, trigger = null, toastTimer = 0;
|
||||
const SHORT = '刚刚看完一小节,正好想歇一会儿。你呢,今天过得怎么样?';
|
||||
const LONG = '今天望着窗外的雨,想到小时候放学回家的那条路。那时候总觉得路很长,下雨时又不舍得走快,想听雨落在不同屋檐上的声音。后来搬到高一点的地方,雨声变远了,能看见的灯却多了。我还是会在这种时候把手边的事放一放,看看窗外,给自己泡一杯热茶。\n\n有时候,一天里也没有发生什么大事。可能只是花店换了橱窗,或者听到一首特别喜欢的歌。但如果能把这些细小的事情讲给你听,这一天就像多了一盏亮着的灯。\n\n我也想知道你那边的天气。如果你今天有点累,我们可以慢慢聊,不急着把所有的话一次说完。等你想说的时候,我就在这里。最后这一句也完整保留:愿今晚的雨声让你睡得安稳。';
|
||||
const FIXTURES = [
|
||||
{title: '窗边的洋桔梗', time: '今天 · 15:52', text: '楼下花店的洋桔梗开了。我挑了一小束,放在窗边。', memory: '你说,淡色的花看起来很安静。'},
|
||||
{title: '一起听过的雨', time: '昨天 · 21:16', text: '昨晚我们都没有急着说话,只是听了一会儿雨。', memory: '没有话的时候,也可以一起待一会儿。'}
|
||||
];
|
||||
const escapeHTML = v => String(v).replace(/[&<>"']/g, c => ({'&': '&', '<': '<', '>': '>', '"': '"', "'": '''}[c]));
|
||||
const graphemes = text => typeof Intl.Segmenter === 'function' ? [...new Intl.Segmenter('zh', {granularity: 'grapheme'}).segment(text)].map(s => s.segment) : Array.from(text);
|
||||
const who = m => m.role === 'user' ? '你' : state.name;
|
||||
|
||||
function toast(text) {
|
||||
const t = $('#toast'); t.textContent = text; t.classList.add('show');
|
||||
clearTimeout(toastTimer); toastTimer = setTimeout(() => t.classList.remove('show'), 2600);
|
||||
}
|
||||
function announce(text) { $('#announcement').textContent = text; }
|
||||
function setName(name) {
|
||||
state.name = name;
|
||||
$$('[data-name]').forEach(n => { n.textContent = name; n.title = name; });
|
||||
present('jump');
|
||||
}
|
||||
|
||||
// ── Space: the camera moves you closer or back; the UI for each place fades in once you have arrived. ──
|
||||
// Keyboard shortcuts land on the target state at once: CSS transitions are suspended for two frames
|
||||
// and any finite animation already under way jumps to its end.
|
||||
function snap() {
|
||||
document.body.classList.add('snap');
|
||||
for (const a of document.getAnimations()) if (a.effect && a.effect.getTiming().iterations !== Infinity) a.finish();
|
||||
requestAnimationFrame(() => requestAnimationFrame(() => document.body.classList.remove('snap')));
|
||||
}
|
||||
function setMode(mode, {instant = false} = {}) {
|
||||
if (instant) snap();
|
||||
state.mode = mode; document.body.dataset.mode = mode;
|
||||
Scene.go(mode, instant);
|
||||
$('.home-copy').inert = mode !== 'home'; $('#conversation').inert = mode !== 'talk'; $('#her-hit').inert = mode !== 'home';
|
||||
$$('.navigation button').forEach(n => n.dataset.nav === (mode === 'pane' || mode === 'record' ? state.dialogNav : mode) ? n.setAttribute('aria-current', 'page') : n.removeAttribute('aria-current'));
|
||||
moveNavGlow(); updatePresence();
|
||||
if (mode === 'talk') present(instant ? 'instant' : 'jump');
|
||||
}
|
||||
function updatePresence() {
|
||||
const close = state.mode === 'talk' || state.mode === 'record';
|
||||
$('#presence').textContent = state.busy && close ? '在窗边 · 正在回应(演示)' : state.voice && close ? '语音界面演示 · 没有收音' : close ? '在窗边 · 看着你' : '在窗边';
|
||||
}
|
||||
// The glow only slides (transform); every nav item has the same width, set in CSS.
|
||||
function moveNavGlow() {
|
||||
const cur = $('.navigation [aria-current]'), glow = $('.nav-glow');
|
||||
if (!cur) { glow.style.opacity = 0; return; }
|
||||
glow.style.opacity = 1; glow.style.transform = `translateX(${cur.offsetLeft - 3}px)`;
|
||||
}
|
||||
function openTalk(focus = false) { if (state.mode !== 'talk') setMode('talk'); if (focus) $('#draft').focus({preventScroll: true}); }
|
||||
|
||||
// ── Reading: replies flow on by themselves, one or two lines at a time. ──
|
||||
function chunks(text) {
|
||||
const compact = document.body.classList.contains('compact');
|
||||
const width = Math.max(220, Math.min(stage.clientWidth, 900) - 24), font = compact ? 16 : innerWidth <= 720 ? 18 : 23;
|
||||
const perLine = Math.floor(width / font), max = Math.max(14, Math.min(60, Math.floor(perLine * (compact ? 1.6 : 2))));
|
||||
const units = graphemes(text), out = []; let line = '';
|
||||
for (const ch of units) {
|
||||
if (ch === '\n') { if (line.trim()) { out.push(line); line = ''; } continue; }
|
||||
// Keep closing punctuation with its sentence; never produce an empty line.
|
||||
if (!line && out.length && /[。!?!?,、;:,;:」』))”]/.test(ch)) { out[out.length - 1] += ch; continue; }
|
||||
line += ch;
|
||||
const n = graphemes(line).length;
|
||||
// Short sentences travel together (as in the approved still); a line ends at a sentence once it has some weight.
|
||||
if (/[。!?!?]/.test(ch) && n >= Math.min(22, max * .45)) { out.push(line); line = ''; }
|
||||
else if (n >= max) {
|
||||
const cut = Math.max(line.lastIndexOf(','), line.lastIndexOf('、'), line.lastIndexOf(';'));
|
||||
if (cut > max * .55) { out.push(line.slice(0, cut + 1)); line = line.slice(cut + 1); } else { out.push(line); line = ''; }
|
||||
}
|
||||
}
|
||||
if (line.trim()) out.push(line);
|
||||
return out;
|
||||
}
|
||||
function pages() {
|
||||
const list = [];
|
||||
for (const m of messages.filter(m => m.turn === state.turn)) {
|
||||
const parts = chunks(m.text);
|
||||
// The newest chunk of a reply still being written is held back (it may still grow or merge with the next
|
||||
// sentence), so a line never changes or re-animates after it has appeared.
|
||||
if (m.status === 'generating' && parts.length) parts.pop();
|
||||
parts.forEach((text, index) => list.push({message: m, text, index, key: `${m.id}:${index}`}));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
function dwellFor(page) {
|
||||
const n = graphemes(page.text).length;
|
||||
return page.message.role === 'user' ? Math.min(3000, Math.max(1400, 900 + n * 60)) : Math.min(8000, Math.max(2400, 1500 + n * 150));
|
||||
}
|
||||
function lineEl(page, current, animate = true) {
|
||||
const el = document.createElement('div');
|
||||
el.className = 'line' + (current ? ' is-current' : ' is-prev');
|
||||
el.dataset.role = page.message.role; el.dataset.key = page.key;
|
||||
const label = page.message.role === 'user' ? '你' : state.name;
|
||||
const chars = graphemes(page.text);
|
||||
const ink = current && animate && !motionOff() && page.message.role === 'her';
|
||||
const body = ink ? chars.map((c, i) => `<span style="--i:${Math.min(i, 48)}">${escapeHTML(c)}</span>`).join('') : escapeHTML(page.text);
|
||||
el.innerHTML = `<span class="who"><i></i><b>${escapeHTML(label)}</b><em class="state"></em></span><p class="${ink ? 'ink' : ''}">${body}</p>`;
|
||||
return el;
|
||||
}
|
||||
function present(how = 'advance') {
|
||||
const list = pages();
|
||||
state.cursor = Math.max(0, Math.min(state.cursor, list.length - 1));
|
||||
state.head = Math.max(state.head, state.cursor);
|
||||
updateControls(list);
|
||||
const page = list[state.cursor];
|
||||
if (!page) { stage.replaceChildren(); return; }
|
||||
const prev = list[state.cursor - 1];
|
||||
const want = [prev, page].filter(Boolean);
|
||||
const have = [...stage.querySelectorAll('.line:not(.leaving)')];
|
||||
const keys = have.map(n => n.dataset.key);
|
||||
state.dwell = 0; state.dwellTotal = dwellFor(page);
|
||||
announce(`${who(page.message)}:${page.text}`);
|
||||
if (how === 'instant') {
|
||||
// Keyboard review: show the target lines as they are — no slide, no re-played ink.
|
||||
stage.replaceChildren(...want.map(p => lineEl(p, p === page, false)));
|
||||
refreshState(); return;
|
||||
}
|
||||
if (keys.join() === want.map(p => p.key).join()) { refreshState(); return; }
|
||||
const animate = !motionOff() && state.mode === 'talk';
|
||||
// Forward by one: the finished line lifts toward the "previous" slot while a small copy settles there; the oldest drifts away.
|
||||
// Both copies keep a fixed font size (no per-frame re-typesetting); only transform/opacity move.
|
||||
if (how === 'advance' && animate && keys[keys.length - 1] === (prev && prev.key)) {
|
||||
const first = new Map(have.map(n => [n, n.getBoundingClientRect()]));
|
||||
const stageRect = stage.getBoundingClientRect();
|
||||
for (const n of have) if (n.dataset.key !== prev.key) leave(n, first.get(n), stageRect);
|
||||
const keep = have.find(n => n.dataset.key === prev.key), was = first.get(keep);
|
||||
const settled = lineEl(prev, false), fresh = lineEl(page, true);
|
||||
pin(keep, was, stageRect);
|
||||
stage.append(settled, fresh);
|
||||
const to = settled.getBoundingClientRect();
|
||||
if (to.height) {
|
||||
const shrink = parseFloat(getComputedStyle(settled.querySelector('p')).fontSize) / parseFloat(getComputedStyle(keep.querySelector('p')).fontSize);
|
||||
leave(keep, was, stageRect, false, to.top - was.top, shrink);
|
||||
settled.animate([{opacity: 0, transform: `translateY(${Math.round((was.top - to.top) * .35)}px)`}, {opacity: getComputedStyle(settled).opacity, transform: 'none'}], {duration: 620, easing: EASE});
|
||||
} else leave(keep, was, stageRect); // compact screens hide the previous line
|
||||
fresh.animate([{opacity: 0, transform: 'translateY(16px)', filter: 'blur(8px)'}, {opacity: 1, transform: 'none', filter: 'blur(0)'}], {duration: 680, easing: EASE});
|
||||
} else {
|
||||
// Jumps (review, new turn, resize) crossfade instead of sliding, so direction never lies.
|
||||
const stageRect = stage.getBoundingClientRect();
|
||||
for (const n of have) animate ? leave(n, n.getBoundingClientRect(), stageRect, true) : n.remove();
|
||||
want.forEach(p => {
|
||||
const el = lineEl(p, p === page); stage.append(el);
|
||||
if (animate) el.animate([{opacity: 0, filter: 'blur(6px)'}, {opacity: 1, filter: 'blur(0)'}], {duration: 520, delay: 90, easing: EASE, fill: 'backwards'});
|
||||
});
|
||||
}
|
||||
refreshState();
|
||||
}
|
||||
// Take a line out of the flow at its current place, so the remaining lines lay out once at their final size.
|
||||
function pin(node, rect, stageRect) {
|
||||
node.classList.add('leaving');
|
||||
Object.assign(node.style, {position: 'absolute', left: rect.left - stageRect.left + 'px', top: rect.top - stageRect.top + 'px', width: rect.width + 'px', transformOrigin: '50% 0'});
|
||||
}
|
||||
function leave(node, rect, stageRect, quick = false, lift = quick ? -4 : -14, shrink = 1) {
|
||||
pin(node, rect, stageRect);
|
||||
node.animate([{opacity: getComputedStyle(node).opacity, transform: 'none', filter: 'blur(0)'}, {opacity: 0, transform: `translateY(${lift}px) scale(${shrink})`, filter: 'blur(5px)'}],
|
||||
{duration: quick ? 240 : 520, easing: EASE, fill: 'forwards'}).finished.then(() => node.remove()).catch(() => node.remove());
|
||||
}
|
||||
function refreshState() {
|
||||
const cur = stage.querySelector('.line.is-current:not(.leaving)'); if (!cur) return;
|
||||
const list = pages(), atEnd = state.cursor >= list.length - 1;
|
||||
const page = list[state.cursor];
|
||||
const s = cur.querySelector('.state');
|
||||
s.textContent = page && page.message.status === 'cancelled' && page.index === chunks(page.message.text).length - 1 ? '未完成 · 已取消' : atEnd && state.busy ? '还在说' : '';
|
||||
cur.classList.toggle('waiting', atEnd && state.busy);
|
||||
}
|
||||
function updateControls(list = pages()) {
|
||||
const n = list.length;
|
||||
$('#previous').disabled = state.cursor <= 0;
|
||||
$('#next').disabled = state.cursor >= n - 1;
|
||||
$('#page-count').innerHTML = `<span>${n ? `${state.cursor + 1} / ${n}${state.busy ? '…' : ''}` : '0 / 0'}</span><i></i>`;
|
||||
document.body.classList.toggle('single-page', n <= 1 && !state.busy);
|
||||
$('#stop').hidden = !state.busy;
|
||||
const t = $('#toggle-flow');
|
||||
t.setAttribute('aria-pressed', String(state.flow));
|
||||
t.innerHTML = state.flow ? '<svg><use href="#i-pause"/></svg><span>暂停</span>' : '<svg><use href="#i-play"/></svg><span>继续</span>';
|
||||
const unread = n - 1 - state.cursor;
|
||||
const latest = $('#latest');
|
||||
latest.hidden = state.flow || state.cursor >= state.head;
|
||||
latest.querySelector('span').textContent = unread > 0 ? `回到读到的地方 · 后面还有 ${unread} 句` : '回到读到的地方';
|
||||
document.body.classList.toggle('reading-paused', !state.flow);
|
||||
updatePresence();
|
||||
}
|
||||
function go(delta, manual = true, instant = false) {
|
||||
const n = pages().length;
|
||||
const to = Math.max(0, Math.min(state.cursor + delta, n - 1));
|
||||
if (to === state.cursor) return;
|
||||
state.cursor = to;
|
||||
present(instant ? 'instant' : delta === 1 ? 'advance' : 'jump');
|
||||
}
|
||||
function back(instant = false) { if (state.flow) setFlow(false, true); go(-1, true, instant); updateControls(); }
|
||||
function setFlow(on, quiet = false) {
|
||||
state.flow = on; state.dwell = 0;
|
||||
updateControls();
|
||||
if (!quiet) toast(on ? '继续自动呈现' : '已暂停 · 可以慢慢回看');
|
||||
}
|
||||
// Reading clock. Holds (hover, selection, open panels, hidden tab) freeze it without changing the user's choice.
|
||||
let lastTick = 0;
|
||||
function tick(now) {
|
||||
const dt = lastTick ? Math.min(100, now - lastTick) : 0; lastTick = now;
|
||||
if (state.mode === 'talk' && state.flow && !state.held.size && !document.hidden) {
|
||||
const list = pages(), page = list[state.cursor];
|
||||
if (page) {
|
||||
if (state.dwell < state.dwellTotal) state.dwell += dt;
|
||||
if (state.dwell >= state.dwellTotal && state.cursor < list.length - 1) go(1, false);
|
||||
}
|
||||
}
|
||||
const bar = $('#page-count i');
|
||||
if (bar) bar.style.transform = `scaleX(${state.dwellTotal ? Math.min(1, state.dwell / state.dwellTotal) : 0})`;
|
||||
document.body.classList.toggle('reading-held', state.held.size > 0 && state.flow);
|
||||
requestAnimationFrame(tick);
|
||||
}
|
||||
requestAnimationFrame(tick);
|
||||
const hold = (why, on) => { on ? state.held.add(why) : state.held.delete(why); };
|
||||
|
||||
// ── Simulated reply stream (sentence by sentence; not a real SSE connection). ──
|
||||
function cancelReply(silent = false) {
|
||||
const wasBusy = state.busy;
|
||||
state.token++; clearTimeout(streamTimer); state.busy = false;
|
||||
messages.filter(m => m.status === 'generating').forEach(m => { m.status = 'cancelled'; if (!m.text) m.text = '(回复在内容出现前取消)'; });
|
||||
present('refresh');
|
||||
if (wasBusy && !silent) toast('已停止。已出现的部分保留,并标为未完成');
|
||||
}
|
||||
function beginReply(text, reply = SHORT, after = null) {
|
||||
cancelReply(true);
|
||||
const resumed = !state.flow;
|
||||
state.turn++; state.flow = true; state.cursor = 0; state.head = 0;
|
||||
messages.push({id: nextId++, turn: state.turn, role: 'user', text, status: 'complete'});
|
||||
present('jump');
|
||||
if (resumed) toast('新的一轮会自动呈现,随时可以暂停');
|
||||
streamReply(reply, after);
|
||||
}
|
||||
function streamReply(reply, after = null) {
|
||||
const token = ++state.token;
|
||||
const message = {id: nextId++, turn: state.turn, role: 'her', text: '', status: 'generating'};
|
||||
messages.push(message); state.busy = true; updateControls(); refreshState();
|
||||
const parts = reply.match(/[^。!?!?\n]+[。!?!?]*|\n+/gu) || [reply]; let index = 0;
|
||||
function append() {
|
||||
if (token !== state.token) return;
|
||||
message.text += parts[index++];
|
||||
if (index >= parts.length) { state.busy = false; message.status = 'complete'; }
|
||||
updateControls(); refreshState();
|
||||
if (state.dialog === 'history') renderHistory();
|
||||
if (state.busy) streamTimer = setTimeout(append, 520); else if (after) after();
|
||||
}
|
||||
streamTimer = setTimeout(append, 900);
|
||||
}
|
||||
|
||||
// ── Panels. Native dialog restores focus; the room steps back while one is open. ──
|
||||
function showSheet(kind, title, kicker, markup, nav = state.dialogNav) {
|
||||
hold('sheet', true);
|
||||
if (closing) { closing.cancel(); closing = null; }
|
||||
state.dialogNav = nav;
|
||||
const target = (kind === 'history' || kind === 'full') && (state.mode === 'talk' || state.mode === 'record') ? 'record' : 'pane';
|
||||
if (!sheet.open) { trigger = document.activeElement; state.returnMode = state.mode; sheet.showModal(); setMode(target); }
|
||||
else if (state.mode !== target) setMode(target);
|
||||
else { $$('.navigation button').forEach(n => n.dataset.nav === nav ? n.setAttribute('aria-current', 'page') : n.removeAttribute('aria-current')); moveNavGlow(); }
|
||||
state.dialog = kind; sheet.dataset.kind = kind;
|
||||
$('#sheet-title').textContent = title; $('#sheet-kicker').textContent = kicker; content.innerHTML = markup; content.scrollTop = 0;
|
||||
if (!motionOff()) sheet.animate([{opacity: 0, transform: 'translateY(18px) scale(.985)', filter: 'blur(6px)'}, {opacity: 1, transform: 'none', filter: 'blur(0)'}], {duration: 460, easing: EASE});
|
||||
$('#close-sheet').focus({preventScroll: true});
|
||||
}
|
||||
function finishClose(instant = false) {
|
||||
sheet.getAnimations().forEach(a => a.cancel()); if (sheet.open) sheet.close();
|
||||
state.dialog = null; closing = null; hold('sheet', false); state.dialogNav = null;
|
||||
setMode(['pane', 'record'].includes(state.returnMode) ? 'home' : state.returnMode, {instant});
|
||||
if (trigger && trigger.isConnected && !trigger.inert) trigger.focus({preventScroll: true});
|
||||
}
|
||||
function closeSheet(instant = false) {
|
||||
if (!sheet.open) return;
|
||||
if (instant) { if (closing) closing.cancel(); finishClose(true); return; }
|
||||
if (closing) return;
|
||||
if (motionOff()) { finishClose(); return; }
|
||||
closing = sheet.animate([{opacity: 1, transform: 'none', filter: 'blur(0)'}, {opacity: 0, transform: 'translateY(14px) scale(.985)', filter: 'blur(4px)'}], {duration: 240, easing: EASE, fill: 'forwards'});
|
||||
closing.finished.then(() => finishClose()).catch(() => {});
|
||||
}
|
||||
function renderHistory() {
|
||||
const keep = content.scrollTop;
|
||||
content.innerHTML = '<p class="guide">本小样中的文字均为虚构。内容完整保留;关闭后回到刚才那一句,自动呈现会接着走。</p>' + messages.map(m => `<article class="message" data-role="${m.role}" data-life="${m.life ?? ''}"><div class="author"><i></i>${escapeHTML(who(m))}</div><p>${escapeHTML(m.text || '正在回应…')}</p>${m.status === 'cancelled' ? '<span class="incomplete">已停止 · 这是未完成片段</span>' : ''}</article>`).join('');
|
||||
content.scrollTop = keep;
|
||||
}
|
||||
function showHistory() { showSheet('history', '你们说过的话', '完整记录 · 演示', '', 'talk'); renderHistory(); }
|
||||
function showFull() {
|
||||
const cur = pages()[state.cursor]; if (!cur) return;
|
||||
const m = cur.message;
|
||||
showSheet('full', '这一段,慢慢看', `${who(m)} · 演示全文`, `<p class="guide">整段完整可读。关闭后回到刚才那一句。</p><article class="message" data-role="${m.role}"><div class="author"><i></i>${escapeHTML(who(m))}</div><p>${escapeHTML(m.text)}</p>${m.status === 'cancelled' ? '<span class="incomplete">这段回复已停止,内容未完成。</span>' : ''}</article>`, 'talk');
|
||||
}
|
||||
function showDays(memory = false) {
|
||||
if (state.createdNew) { showSheet('days', memory ? '我们的回忆' : '她的日子', '初次见面 · 演示', `<div class="row"><button class="pill" data-action="days" aria-pressed="${!memory}">她的日子</button><button class="pill" data-action="memories" aria-pressed="${memory}">我们的回忆</button></div><p>刚刚见面,还没有分享过的日子与共同回忆。</p><p class="guide">真实生活和记忆尚未接入,小样不会自动编出她未分享的经历。</p>`, 'days'); return; }
|
||||
showSheet('days', '留在日子里的微光', '生活与共同回忆 · 演示', `<div class="row"><button class="pill" data-action="days" aria-pressed="${!memory}">她的日子</button><button class="pill" data-action="memories" aria-pressed="${memory}">我们的回忆</button></div><p class="guide">只放她已经向你分享的事。以下两条都是虚构的演示记录。</p>${FIXTURES.map((f, i) => `<button class="item" data-event="${i}"><div class="date">${f.time} · 已分享</div><h3>${memory ? f.memory : f.title}</h3><small>${memory ? '与这一天相连' : f.text}</small></button>`).join('')}<p class="subtle">更多真实生活、记忆和成长,等待后续功能接入。</p>`, 'days');
|
||||
}
|
||||
function eventDetail(i) {
|
||||
const f = FIXTURES[i]; if (!f) return;
|
||||
showSheet('event', f.title, '已分享的生活 · 演示', `<button class="small-link" data-action="days">‹ 回到她的日子</button><p class="subtle">${f.time}</p><div class="quote">${f.text}</div><h3>与你有关的回忆</h3><p>${f.memory}</p><button class="pill" data-event-history="${i}">看那时说的话</button><p class="guide">演示故事,不是真实的后台生活。</p>`, 'days');
|
||||
}
|
||||
function showManage() {
|
||||
showSheet('manage', '慢慢安排你们的世界', '设置 · 演示', `<p class="guide">这里只体验入口和操作关系。所有更改只在这次小样中保留。</p><button class="item" data-action="profile"><h3>她与最初的底色</h3><small>出生底色只读,成长另行积累</small></button><button class="item" data-action="relationship"><h3>你们的关系</h3><small>称呼与相处边界,可以慢慢调整</small></button><button class="item" data-action="city"><h3>城市与天气</h3><small>跟随你选择的城市 · 本小样天气为示例</small></button><button class="item" data-action="appearance"><h3>外观素材</h3><small>换外观,保留同一个她</small></button><button class="item" data-action="backup"><h3>备份与恢复</h3><small>完整导出与每日备份 · 尚未接入</small></button><button class="item" data-action="services"><h3>语音与视觉观察</h3><small>开关、状态与时效 · 尚未接入</small></button><button class="item" data-action="display"><h3>空间与显示</h3><small>两套主题、动效强度</small></button>`, 'manage');
|
||||
}
|
||||
function showInfo(kind) {
|
||||
const info = {
|
||||
profile: ['她与最初的底色', '出生资料在创建后保留为只读底色,每轮重新提供给模型。个性的诠释、少量初始喜好与后来的成长分别保留。', '本小样不生成排盘、性格或成长,也不读取真实档案。相关真实能力仍须后续补齐。'],
|
||||
appearance: ['外观素材', '替换外观前应先检查素材、预览新旧效果,再明确启用。记忆、生日、关系和成长仍属于同一个她。', '本小样只使用已认可的两张参考静帧,没有导入素材、人物动态或实时口型。'],
|
||||
backup: ['备份与恢复', '产品仍需每日自动备份,并支持包含人物、场景、设定与记忆的完整导出和恢复。', '备份尚未接入。本小样没有执行或伪装任何导出、备份、恢复操作。'],
|
||||
services: ['语音与视觉观察', '语音由你主动开启,结束后停止收音。视觉观察可关闭,过期观察不再当作眼前事实。', '本小样不申请麦克风或摄像头权限,不采集声音与影像,也不连接任何服务。']
|
||||
}[kind];
|
||||
showSheet(kind, info[0], '入口示意 · 尚未接入', `<button class="small-link" data-action="manage">‹ 返回设置</button><p>${info[1]}</p><p class="notice">${info[2]}</p>${kind === 'services' ? '<button class="pill" data-action="voice">体验语音界面演示</button>' : ''}`, 'manage');
|
||||
}
|
||||
function showRelationship() {
|
||||
showSheet('relationship', '你们的关系', '演示表单', `<button class="small-link" data-action="manage">‹ 返回设置</button><form id="relation-form"><label for="relation">现在的关系</label><select id="relation"><option ${state.relation === '朋友' ? 'selected' : ''}>朋友</option><option ${state.relation === '恋人' ? 'selected' : ''}>恋人</option></select><label for="boundaries">相处边界</label><textarea id="boundaries" maxlength="500">${escapeHTML(state.boundaries || '彼此保留自己的时间,有想法可以直接说。')}</textarea><p class="guide">修改关系不会改写出生底色、过去的记忆与信任。</p><div class="row"><button class="primary" type="submit">确认本次演示选择</button><button class="pill" type="button" data-action="manage">取消</button></div><p id="form-status" class="status" role="status"></p></form>`, 'manage');
|
||||
}
|
||||
function showCity() {
|
||||
showSheet('city', '她窗外的城市', '城市选择 · 演示', `<button class="small-link" data-action="manage">‹ 返回设置</button><form id="city-form"><label for="city">选择一个城市</label><select id="city"><option>上海</option><option>杭州</option><option>成都</option></select><p class="guide">正式产品将按城市跟随当地天气与作息。这里仅演示选择反馈,没有查询天气;窗外的雨是界面氛围。</p><button class="primary" type="submit">保存演示选择</button><p id="form-status" class="status" role="status"></p></form>`, 'manage');
|
||||
}
|
||||
function showDisplay() {
|
||||
showSheet('display', '空间与显示', '显示偏好 · 小样', `<button class="small-link" data-action="manage">‹ 返回设置</button><p>同一个房间、同一套布局,切换整片空间的光、雾、窗外天色与材质。</p><div class="row"><button class="pill" data-theme="moon" aria-pressed="${html.dataset.theme === 'moon'}">靛蓝月光</button><button class="pill" data-theme="fog" aria-pressed="${html.dataset.theme === 'fog'}">蓝紫雾光</button></div><button class="pill" data-action="motion">${html.classList.contains('no-motion') ? '恢复空间动效' : '减少动效'}</button><p class="guide">系统“减少动态效果”同样生效:镜头不再推近拉远,只做淡入淡出,雨停在一帧。设备较慢时会自动降低雨的分辨率并去掉毛玻璃。</p>`, 'manage');
|
||||
}
|
||||
function showRehearsal() {
|
||||
showSheet('rehearsal', '试试这些相处片段', '小样试用 · 全部为演示', `<p>点她或「和她说话」走近;「结束交谈」或「此刻」退回原处。回复会自动一句接一句呈现,想停下时点「暂停」,往回看用左右箭头,「全文」看整段。</p><div class="row"><button class="pill" data-scenario="long">一段长回复</button><button class="pill" data-scenario="short">短句回复</button><button class="pill" data-scenario="incoming">连续来两段话</button><button class="pill" data-scenario="waiting">生成中与停止</button></div><p class="guide">每句停留随长度变化(约 2.4–8 秒),鼠标停在文字上会先停住计时,移开继续。新发消息总会自动呈现。</p><details><summary>试试初次见面与长名字</summary><p class="guide">只创建临时演示身份,不连接或重置现有伴侣。</p><button class="pill" data-action="create">重新演示初次创建</button></details><details><summary>验证说明与边界</summary><p class="guide">人物是两张获批参考静帧,走近的过程是镜头在两张照片之间对齐她的脸并推近,不是人物视频;她不会眨眼、呼吸或说话,也没有口型。文字、生活与回忆都是虚构。没有连接模型、语音、摄像头、天气或备份服务。窗外的雨、城市灯光、烛光和热气是界面氛围,不代表真实天气。</p><p class="guide">相处画面里她在沙发上看书,那只是旧参考静帧,用来示意你们在同一间房里的位置;看书已不是新的默认日常,按时段、天气和穿搭准备的新日常素材还没有生成。</p><p class="guide">地址加 <code>?frame=media</code> 可在手机宽度下试 HEL-802 v2 的候选取景:房间放进顶部 4:5 媒体容器,对话与输入在容器下方,手机不画前景桌杯。这只是候选,未获认可。</p></details>`);
|
||||
}
|
||||
function showCreation() {
|
||||
showSheet('create', '先给她一个名字', '初次创建 · 临时演示', `<form id="create-form"><label for="new-name">你想怎么叫她</label><input id="new-name" maxlength="40" autocomplete="off" required placeholder="由你起名,1–20 字"><label for="new-relation">你们从什么关系开始</label><select id="new-relation" required><option value="" selected disabled>由你选择</option><option value="朋友">朋友</option><option value="恋人">恋人</option></select><p class="guide">出生资料、排盘与底色说明沿用既有创建流程,本次不模拟生成。确认仅进入这次虚构小样,不会接触真实档案。</p><div class="row"><button class="primary" type="submit">以这个名字体验小样</button><button class="pill" type="button" data-action="dismiss">取消</button></div><p id="creation-error" class="error" role="status"></p></form>`);
|
||||
}
|
||||
function showVoice() {
|
||||
showSheet('voice', '体验语音界面', '没有收音的演示', `<p>这里仅演示语音开启、结束的界面。不会申请麦克风权限,也不会播放或识别声音。</p><div class="row"><button class="primary" data-action="start-voice">开始界面演示</button><button class="pill" data-action="dismiss">暂不开启</button></div>`, 'talk');
|
||||
}
|
||||
function runScenario(kind) {
|
||||
if (sheet.open) { state.returnMode = 'talk'; finishClose(); }
|
||||
openTalk();
|
||||
if (kind === 'incoming') beginReply('你刚才想和我说什么?', '窗边的花开了一点。', () => streamReply('还有,今天的雨声很轻。我想把这片安静也分一点给你。'));
|
||||
else if (kind === 'long') beginReply('慢慢讲,我想听听你今天的想法。', LONG);
|
||||
else if (kind === 'waiting') beginReply('可以和我多说一会儿吗?', LONG);
|
||||
else beginReply('你在做什么?', SHORT);
|
||||
}
|
||||
function applyTheme(theme, instant = false) {
|
||||
if (!['moon', 'fog'].includes(theme)) return;
|
||||
if (instant) snap();
|
||||
html.dataset.theme = theme; Rain.setTheme(theme, instant || motionOff());
|
||||
$$('button[data-theme]').forEach(n => n.setAttribute('aria-pressed', String(n.dataset.theme === theme)));
|
||||
}
|
||||
|
||||
document.addEventListener('click', e => {
|
||||
const b = e.target.closest('button'); if (!b) return;
|
||||
if (b.dataset.theme) { applyTheme(b.dataset.theme); return; }
|
||||
if (b.dataset.nav) {
|
||||
const mode = b.dataset.nav;
|
||||
if (mode === 'home' || mode === 'talk') { if (sheet.open) { state.returnMode = mode; closeSheet(); } else mode === 'home' ? setMode('home') : openTalk(); }
|
||||
else if (mode === 'days') showDays(); else showManage();
|
||||
return;
|
||||
}
|
||||
if (b.dataset.event !== undefined) { eventDetail(Number(b.dataset.event)); return; }
|
||||
if (b.dataset.eventHistory !== undefined) {
|
||||
const i = Number(b.dataset.eventHistory); showHistory();
|
||||
content.insertAdjacentHTML('afterbegin', `<button class="small-link" data-event="${i}">‹ 返回这一天</button>`);
|
||||
content.querySelector(`[data-life="${i}"]`)?.scrollIntoView({block: 'center'}); return;
|
||||
}
|
||||
if (b.dataset.scenario) { runScenario(b.dataset.scenario); return; }
|
||||
const actions = {
|
||||
days: () => showDays(), memories: () => showDays(true), manage: showManage, relationship: showRelationship, city: showCity, display: showDisplay, create: showCreation, voice: showVoice, dismiss: closeSheet,
|
||||
motion: () => { html.classList.toggle('no-motion'); Scene.resize(); showDisplay(); },
|
||||
'start-voice': () => { state.returnMode = 'talk'; finishClose(); openTalk(); state.voice = true; document.body.classList.add('has-voice'); $('#voice-row').hidden = false; updateControls(); toast('语音界面演示已开启 · 没有收音'); }
|
||||
};
|
||||
const a = b.dataset.action;
|
||||
if (actions[a]) actions[a](); else if (['profile', 'appearance', 'backup', 'services'].includes(a)) showInfo(a);
|
||||
});
|
||||
$('#start-talk').onclick = () => openTalk();
|
||||
$('#her-hit').onclick = () => openTalk();
|
||||
$('#shared-note').onclick = () => { openTalk(); showHistory(); };
|
||||
$('#days-link').onclick = () => showDays();
|
||||
$('#close-talk').onclick = () => { if (sheet.open) { state.returnMode = 'home'; closeSheet(); } else setMode('home'); };
|
||||
$('#history').onclick = showHistory; $('#read-all').onclick = showFull; $('#close-sheet').onclick = () => closeSheet(); $('#rehearse').onclick = showRehearsal;
|
||||
$('#home-voice').onclick = showVoice; $('#voice').onclick = showVoice;
|
||||
$('#end-voice').onclick = () => { state.voice = false; document.body.classList.remove('has-voice'); $('#voice-row').hidden = true; cancelReply(true); updateControls(); toast('语音界面演示已结束'); };
|
||||
$('#previous').onclick = () => back();
|
||||
$('#next').onclick = () => go(1);
|
||||
$('#toggle-flow').onclick = () => setFlow(!state.flow);
|
||||
$('#latest').onclick = () => { state.cursor = state.head; present('jump'); setFlow(true, true); };
|
||||
$('#stop').onclick = () => cancelReply();
|
||||
$('#composer').addEventListener('submit', e => { e.preventDefault(); const text = $('#draft').value.trim(); if (!text) { $('#draft').focus(); return; } $('#draft').value = ''; autoSize(); beginReply(text, /长|故事|慢慢|完整|多说/.test(text) ? LONG : SHORT); });
|
||||
function autoSize() { const d = $('#draft'); d.style.height = 'auto'; d.style.height = Math.min(d.scrollHeight, 88) + 'px'; }
|
||||
$('#draft').addEventListener('input', autoSize);
|
||||
$('#draft').addEventListener('keydown', e => { if (e.key === 'Enter' && !e.shiftKey && !e.isComposing && e.keyCode !== 229) { e.preventDefault(); $('#composer').requestSubmit(); } });
|
||||
$('#draft').addEventListener('focus', () => document.body.classList.add('typing'));
|
||||
$('#draft').addEventListener('blur', () => document.body.classList.remove('typing'));
|
||||
stage.addEventListener('pointerenter', e => { if (e.pointerType === 'mouse') hold('hover', true); });
|
||||
stage.addEventListener('pointerleave', () => hold('hover', false));
|
||||
document.addEventListener('selectionchange', () => { const s = getSelection(); hold('select', !!(String(s).length && stage.contains(s.anchorNode))); });
|
||||
sheet.addEventListener('cancel', e => { e.preventDefault(); closeSheet(true); }); // Escape
|
||||
document.addEventListener('submit', e => {
|
||||
if (e.target.id === 'relation-form') { e.preventDefault(); state.relation = $('#relation').value; state.boundaries = $('#boundaries').value; $('#form-status').textContent = '演示选择已确认。记忆和底色保持原样。'; }
|
||||
else if (e.target.id === 'city-form') { e.preventDefault(); $('.weather').innerHTML = `${escapeHTML($('#city').value)} · 小雨 14° <small>示例</small>`; $('#form-status').textContent = '已保存演示选择;这里没有查询真实天气。'; }
|
||||
else if (e.target.id === 'create-form') {
|
||||
e.preventDefault(); const name = $('#new-name').value.trim(), relation = $('#new-relation').value;
|
||||
if (!name || Array.from(name).length > 20 || /[<>\x00-\x1f\x7f]/.test(name) || !relation) { $('#creation-error').textContent = '名字请用 1–20 字,不含尖括号和控制符,并选择关系。'; return; }
|
||||
cancelReply(true); messages = []; state.createdNew = true; state.turn++; state.cursor = 0; state.head = 0; state.flow = true;
|
||||
messages.push({id: nextId++, turn: state.turn, role: 'her', text: '你好。很高兴在这里见到你。', status: 'complete'});
|
||||
state.relation = relation; state.returnMode = 'talk'; setName(name); finishClose(); openTalk(); toast('临时演示身份已建立 · 未接触真实档案');
|
||||
}
|
||||
});
|
||||
// Keyboard shortcuts are frequent, deliberate jumps: they show the target state at once (snap), unlike clicks and auto-flow.
|
||||
document.addEventListener('keydown', e => {
|
||||
if (e.key === 'Escape' && !sheet.open && state.mode === 'talk') { setMode('home', {instant: true}); $('#start-talk').focus({preventScroll: true}); }
|
||||
if (state.mode === 'talk' && !sheet.open && document.activeElement !== $('#draft')) {
|
||||
if (e.key === 'ArrowLeft') { snap(); back(true); } else if (e.key === 'ArrowRight') { snap(); go(1, true, true); } else if (e.key === ' ' && document.activeElement === document.body) { e.preventDefault(); setFlow(!state.flow); }
|
||||
}
|
||||
});
|
||||
document.addEventListener('visibilitychange', () => document.body.classList.toggle('suspended', document.hidden));
|
||||
|
||||
// Keyboard / short screens: the visual viewport decides how much room the lines get.
|
||||
function fitViewport() {
|
||||
Scene.resize();
|
||||
const vv = window.visualViewport, h = vv ? vv.height : innerHeight, t = vv ? vv.offsetTop : 0;
|
||||
html.style.setProperty('--view-h', `${h}px`); html.style.setProperty('--view-top', `${t}px`);
|
||||
document.body.classList.toggle('compact', h < 610);
|
||||
document.body.classList.toggle('micro', h < 420);
|
||||
// Re-chunk without losing the reading position: keep the same character offset in the same message.
|
||||
const cur = pages()[state.cursor];
|
||||
const anchor = cur ? {id: cur.message.id, offset: chunks(cur.message.text).slice(0, cur.index).join('').length} : null;
|
||||
requestAnimationFrame(() => {
|
||||
if (anchor) { const list = pages(); let used = 0; for (let i = 0; i < list.length; i++) { if (list[i].message.id !== anchor.id) continue; if (used + list[i].text.length > anchor.offset) { state.cursor = i; break; } used += list[i].text.length; } }
|
||||
stage.replaceChildren(); present('jump'); moveNavGlow();
|
||||
});
|
||||
}
|
||||
window.visualViewport?.addEventListener('resize', fitViewport); window.visualViewport?.addEventListener('scroll', fitViewport); addEventListener('resize', fitViewport);
|
||||
|
||||
// Optional start parameters for review links and recordings: ?theme=fog&mode=talk&scene=long&tier=2
|
||||
const params = new URLSearchParams(location.search);
|
||||
applyTheme(params.get('theme') || 'moon', true);
|
||||
if (params.get('tier')) Scene.setTier(+params.get('tier'), true);
|
||||
Scene.resize();
|
||||
fitViewport(); present('jump'); moveNavGlow();
|
||||
if (params.get('mode') === 'talk') setMode('talk', {instant: true});
|
||||
if (params.get('scene')) setTimeout(() => runScenario(params.get('scene')), 600);
|
||||
window.__proto = {state, pages, runScenario, setMode, applyTheme, showDays, showManage, showHistory, showFull, closeSheet, setFlow, go, scene: () => Scene.info()};
|
||||
Reference in New Issue
Block a user