diff --git a/public/alerts/cassette.css b/public/alerts/cassette.css
new file mode 100644
index 0000000..62f615d
--- /dev/null
+++ b/public/alerts/cassette.css
@@ -0,0 +1,40 @@
+/* Cassette tape alert for redeems (see cassette.js). Same corner as the polaroid; they share one queue. */
+#cassette-alert { --ink:#3a2a20; --red:#b74347; position:fixed; left:85px; top:110px; width:440px; visibility:hidden; z-index:50; }
+#cassette-alert * { box-sizing:border-box; }
+
+#cassette-alert.r-common { --shell:#f3ead9; --shell2:#e6dac3; --edge:#8a7558; --band:#f4a0a8; --bandtxt:#7a2f3a; }
+#cassette-alert.r-uncommon { --shell:#cdeedd; --shell2:#b5e2cb; --edge:#4f8a6b; --band:#7fcfa6; --bandtxt:#1f5a3c; }
+#cassette-alert.r-rare { --shell:#ddd0f4; --shell2:#cbb9ee; --edge:#6b54a8; --band:#a88be0; --bandtxt:#ffffff; }
+#cassette-alert.r-ultra { --shell:#f6d77a; --shell2:#eec456; --edge:#9a6a10; --band:#3c2006; --bandtxt:#f6d77a; }
+
+#cassette-alert .tape-wrap { position:relative; width:440px; height:282px; filter:drop-shadow(0 14px 22px rgba(0,0,0,.45)); }
+#cassette-alert.r-ultra .tape-wrap { filter:drop-shadow(0 0 16px #ffd76a) drop-shadow(0 0 4px #fff2c0) drop-shadow(0 14px 22px rgba(0,0,0,.45)); }
+#cassette-alert svg { position:absolute; inset:0; width:100%; height:100%; overflow:visible; }
+#cassette-alert .reel-hub, #cassette-alert .wound { transform-box:fill-box; transform-origin:center; }
+
+#cassette-alert .band { position:absolute; left:34px; right:34px; top:24px; height:32px; display:flex; align-items:center;
+ justify-content:space-between; padding:0 14px; font:900 15px 'Nunito', sans-serif; letter-spacing:2px; color:var(--bandtxt); }
+#cassette-alert .title { position:absolute; left:40px; right:40px; top:58px; text-align:center; font:700 40px/1 'Caveat', cursive;
+ color:var(--ink); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
+#cassette-alert .sub { position:absolute; left:40px; right:40px; top:156px; text-align:center; font:700 22px/1 'Caveat', cursive;
+ color:#7a6656; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
+
+/* per-redeem sticker, bottom-right corner; any shape fits inside 150x125 */
+#cassette-alert .stk { position:absolute; right:-50px; top:150px; width:175px; height:150px; display:flex; align-items:center; justify-content:center; }
+#cassette-alert .stk img { max-width:175px; max-height:150px; transform:rotate(10deg);
+ filter:drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff) drop-shadow(0 5px 8px rgba(0,0,0,.35)); }
+
+#cassette-alert .foil { position:absolute; inset:0; border-radius:20px; pointer-events:none; opacity:0;
+ background:linear-gradient(115deg,#0000 35%,#fff9 48%,#fff3 52%,#0000 62%); mix-blend-mode:screen; }
+#cassette-alert .spark { position:absolute; width:44px; height:44px; opacity:0; pointer-events:none; background:#fffbe6;
+ clip-path:polygon(50% 0,60% 40%,100% 50%,60% 60%,50% 100%,40% 60%,0 50%,40% 40%); filter:drop-shadow(0 0 6px #fff4b0); }
+
+#cassette-alert .strip { position:relative; margin:-6px 0 0 30px; display:inline-block; max-width:400px; padding:8px 22px 10px;
+ background:#fffdf7; transform:rotate(-2deg); box-shadow:0 6px 14px rgba(0,0,0,.35); font:700 30px/1.05 'Caveat', cursive; color:var(--ink); }
+#cassette-alert .strip .u { color:var(--red); }
+#cassette-alert .strip .msg { display:block; font-size:22px; color:#7a6656; margin-top:4px;
+ overflow:hidden; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
+#cassette-alert .strip:before, #cassette-alert .strip:after { content:''; position:absolute; top:-10px; width:70px; height:24px;
+ background:rgba(201,182,228,.85); background-image:repeating-linear-gradient(45deg,#fff6 0 7px,#0000 7px 14px); }
+#cassette-alert .strip:before { left:-22px; transform:rotate(-28deg); }
+#cassette-alert .strip:after { right:-22px; transform:rotate(24deg); }
diff --git a/public/alerts/cassette.js b/public/alerts/cassette.js
new file mode 100644
index 0000000..e5b1ad4
--- /dev/null
+++ b/public/alerts/cassette.js
@@ -0,0 +1,123 @@
+/*
+ Cassette tape renderer for redeem alerts. Called by polaroid.js (shared queue):
+ window.CassetteAlert.show(d, cur, { url, len, volume }) -> Promise (resolves when ejected)
+ d: { title (variation), sub (reward), rarity, sticker (URL), name (user), line (strip text), msg (viewer input) }
+ cur: { anims, timer, audio } from polaroid.js, so reset/skip can stop it.
+ Timeline: slides in (0.7 s), sticker + strip pop on, reels spin and tape winds over the sound's length,
+ stays animation + 3 s or until the sound ends, then ejects upward.
+*/
+(function () {
+ const AFTER_ANIM = 3000, SOUND_LEAD = 600, ANIM_END = 1200;
+ const DEFAULT_STICKER = (window.ALERTS_BASE || '/alerts/') + 'stickers/default-sticker.png';
+ const RAR = { common:['r-common','COMMON'], uncommon:['r-uncommon','UNCOMMON'], rare:['r-rare','★ RARE'], ultra_rare:['r-ultra','★ ULTRA RARE ★'] };
+ const esc = s => String(s ?? '').replace(/[&<>"]/g, c => ({ '&':'&', '<':'<', '>':'>', '"':'"' }[c]));
+ const between = (a, b) => a + Math.random() * (b - a);
+
+ let el = null;
+ function root() {
+ if (!el) { el = document.createElement('div'); el.id = 'cassette-alert'; document.body.appendChild(el); }
+ return el;
+ }
+
+ function reel(cx, id) {
+ const teeth = Array.from({ length: 6 }, (_, i) =>
+ `
${extraHearts}
@@ -178,7 +285,7 @@
const main = q('.photo.main');
const tilt = between(RANGES.photoTilt) * (rnd() < .5 ? -1 : 1);
const rot = dd => `rotate(${tilt + dd}deg)`;
- const anims = [];
+ const anims = cur.anims;
const A = (node, frames, opts) => { const a = node.animate(frames, { fill:'both', ...opts }); anims.push(a); return a; };
// fanned stack behind the main photo (multi-month subs, community gifts, raids)
@@ -234,16 +341,16 @@
A(q('.cap'), [{ clipPath:'inset(0 100% 0 0)' }, { clipPath:'inset(0 0 0 0)' }],
{ delay:t0 + 1700, duration:700, easing:'ease-in-out' });
- // sound as the photo lands; hold covers the whole sound
- const hold = Math.max(MIN_HOLD, (SOUND_MS[d.sound] || 0) + SOUND_PAD);
- const cur = current = { anims, timer:null, audio:null };
- if (d.sound) {
- const a = new Audio(SND(d.sound)); a.volume = VOLUME;
- cur.timer = setTimeout(() => { cur.audio = a; a.play().catch(err => console.warn('[alerts] sound blocked:', err.message)); }, t0 + 400);
+ // stays up: entrance animation + 3 s, or until the sound has finished if that is later
+ const animEnd = t0 + 2400; // caption done writing
+ const soundEnd = url ? t0 + SOUND_LEAD + len : 0;
+ if (url) {
+ const a = new Audio(url); a.volume = d.volume ?? VOLUME;
+ cur.timer = setTimeout(() => { cur.audio = a; a.play().catch(err => console.warn('[alerts] sound blocked:', err.message)); }, t0 + SOUND_LEAD);
}
// 5. exit: lift and drop away
- const exitAt = t0 + 2400 + hold;
+ const exitAt = Math.max(animEnd + AFTER_ANIM, soundEnd);
const exit = A(el, [
{ transform:'translateY(0) rotate(0) scale(1)', opacity:1 },
{ transform:'translateY(-20px) rotate(0deg) scale(1.04)', opacity:1, offset:.25 },
@@ -255,6 +362,6 @@
.catch(() => {}); // cancelled by reset()
}
- window.PolaroidAlerts = { play, reset, describe };
+ window.PolaroidAlerts = { play, playTest, reset, describe };
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', preload); else preload();
})();
diff --git a/public/alerts/poll.css b/public/alerts/poll.css
new file mode 100644
index 0000000..d894da9
--- /dev/null
+++ b/public/alerts/poll.css
@@ -0,0 +1,23 @@
+/* Live poll card (see poll.js): taped paper, left side below the alert corner. */
+#poll-card { --ink:#3a2a20; --red:#b74347; position:fixed; left:85px; top:650px; width:460px; z-index:45; visibility:hidden;
+ padding:24px 26px 22px; background:#fffdf7; box-shadow:0 14px 30px rgba(0,0,0,.45); }
+#poll-card * { box-sizing:border-box; }
+#poll-card:before, #poll-card:after { content:''; position:absolute; top:-14px; width:110px; height:32px;
+ background:rgba(140,215,215,.88); background-image:repeating-linear-gradient(45deg,#fff6 0 8px,#0000 8px 16px); box-shadow:0 1px 2px rgba(0,0,0,.15); }
+#poll-card:before { left:-30px; transform:rotate(-30deg); }
+#poll-card:after { right:-30px; transform:rotate(26deg); }
+#poll-card .head { display:flex; justify-content:space-between; align-items:baseline; font:900 15px 'Nunito', sans-serif; letter-spacing:2px; color:#7a6656; }
+#poll-card .timer { font:700 26px 'Caveat', cursive; letter-spacing:0; color:var(--red); }
+#poll-card .q { font:700 38px/1.05 'Caveat', cursive; color:var(--ink); margin:4px 0 12px; }
+#poll-card .c { position:relative; margin:8px 0; }
+#poll-card .row { display:flex; justify-content:space-between; font:700 28px/1 'Caveat', cursive; color:var(--ink); margin-bottom:3px; }
+#poll-card .row .n { font-size:24px; color:#7a6656; }
+#poll-card .track { height:18px; border:3px solid var(--ink); border-radius:10px; background:#fff; overflow:hidden; }
+#poll-card .fill { height:100%; width:0; border-radius:6px; transition:width .6s cubic-bezier(.3,.7,.4,1);
+ background-image:repeating-linear-gradient(45deg,#fff5 0 6px,#0000 6px 12px); }
+#poll-card .c.win .row .t { color:var(--red); }
+#poll-card .c.lose { opacity:.55; }
+#poll-card .heart { position:absolute; right:-78px; top:-22px; width:64px; opacity:0;
+ filter:drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff) drop-shadow(0 4px 6px rgba(0,0,0,.35)); }
+#poll-card .stamp { position:absolute; right:22px; top:14px; padding:4px 14px; border:4px solid var(--red); border-radius:8px; color:var(--red);
+ font:900 26px 'Nunito', sans-serif; letter-spacing:3px; transform:rotate(-12deg); opacity:0; }
diff --git a/public/alerts/poll.js b/public/alerts/poll.js
new file mode 100644
index 0000000..0fc9c06
--- /dev/null
+++ b/public/alerts/poll.js
@@ -0,0 +1,91 @@
+/*
+ Live poll card for the overlay. Not part of the alert queue: it stays up while the poll runs.
+ PollCard.update(phase, poll) phase: begin | progress | end
+ poll: { id, title, choices:[{ id, title, votes }], ends_at, status } (status on end: completed | archived | terminated)
+ Votes animate live; on 'completed' the winner(s) get a heart and a WINNER stamp, then the card drops away.
+*/
+(function () {
+ const COLORS = ['#f4a0a8', '#a88be0', '#7fcfa6', '#f6c75b', '#8cc8f0'];
+ const HEART = (window.ALERTS_BASE || '/alerts/') + 'art/Heart.png';
+ const SHOW_RESULT_MS = 9000;
+ const esc = s => String(s ?? '').replace(/[&<>"]/g, c => ({ '&':'&', '<':'<', '>':'>', '"':'"' }[c]));
+ let el = null, pollId = null, timer = null, hideTimer = null, endsAt = 0;
+
+ function root() {
+ if (!el) { el = document.createElement('div'); el.id = 'poll-card'; document.body.appendChild(el); }
+ return el;
+ }
+
+ function build(poll) {
+ const el = root();
+ clearTimeout(hideTimer); el.getAnimations().forEach(a => a.cancel());
+ pollId = poll.id;
+ el.innerHTML = `