/* ═══════════════════════════════════════════════════════════════
POULINKES.COM — Sacred Chicken Interaction Engine v1.0.0
Warning: This file is watched by the Poulinkes.
They know what you are.
═══════════════════════════════════════════════════════════════ */
(function () {
'use strict';
// ─── FEATHER RAIN ────────────────────────────────────────────
const FEATHERS = ['🪶', '🪶', '🪶', '✨', '🥚'];
let featherInterval = null;
function spawnFeather() {
const el = document.createElement('div');
el.classList.add('feather');
el.textContent = FEATHERS[Math.floor(Math.random() * FEATHERS.length)];
el.style.left = Math.random() * 100 + 'vw';
el.style.animationDuration = (6 + Math.random() * 8) + 's';
el.style.fontSize = (0.8 + Math.random() * 1.2) + 'rem';
document.body.appendChild(el);
el.addEventListener('animationend', () => el.remove());
}
function startFeathers() {
spawnFeather();
featherInterval = setInterval(() => {
if (Math.random() < 0.7) spawnFeather();
}, 2200);
}
// ─── CLUCK SOUND (Web Audio API) ─────────────────────────────
function playCluck() {
try {
const ctx = new (window.AudioContext || window.webkitAudioContext)();
const times = [0, 0.07, 0.14];
times.forEach((t) => {
const osc = ctx.createOscillator();
const gain = ctx.createGain();
const dist = ctx.createWaveShaper();
// Distortion curve for that raw chicken rasp
const curve = new Float32Array(256);
for (let i = 0; i < 256; i++) {
const x = (i * 2) / 256 - 1;
curve[i] = ((Math.PI + 200) * x) / (Math.PI + 200 * Math.abs(x));
}
dist.curve = curve;
osc.connect(dist);
dist.connect(gain);
gain.connect(ctx.destination);
osc.type = 'sawtooth';
osc.frequency.setValueAtTime(700 - t * 500, ctx.currentTime + t);
osc.frequency.exponentialRampToValueAtTime(120, ctx.currentTime + t + 0.12);
gain.gain.setValueAtTime(0, ctx.currentTime + t);
gain.gain.linearRampToValueAtTime(0.25, ctx.currentTime + t + 0.01);
gain.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + t + 0.13);
osc.start(ctx.currentTime + t);
osc.stop(ctx.currentTime + t + 0.14);
});
// Close context after last note
setTimeout(() => ctx.close(), 600);
} catch (e) {
// Even in failure, the poulinkes forgive you
}
}
// ─── CLUCK BUTTON ────────────────────────────────────────────
function initCluckButton() {
const btn = document.getElementById('cluck-btn');
if (!btn) return;
btn.addEventListener('click', () => {
playCluck();
btn.classList.add('clucking');
btn.textContent = '🐔 B'CLUCK! 🐔';
setTimeout(() => {
btn.classList.remove('clucking');
btn.textContent = '🐔 TRIGGER THE CLUCK 🐔';
}, 800);
});
}
// ─── TOAST MESSAGE ────────────────────────────────────────────
function showToast(msg, duration = 4000) {
let toast = document.getElementById('cluck-toast');
if (!toast) {
toast = document.createElement('div');
toast.id = 'cluck-toast';
document.body.appendChild(toast);
}
toast.innerHTML = msg;
toast.classList.add('show');
clearTimeout(toast._timer);
toast._timer = setTimeout(() => toast.classList.remove('show'), duration);
}
// ─── CLUCK KEYBOARD DETECTOR ──────────────────────────────────
let cluckBuffer = '';
const CLUCK_MESSAGES = [
'🥚 YOU KNOW THE WORD.
They are already watching.',
'🐔 The poulinkes acknowledge your presence.
They have always known.',
'🪶 Interesting that you knew this word.
Almost as if... you were one of them.',
'🥚 C-L-U-C-K.
The ancient greeting. You remembered.',
'🐔 CLUCK ACCEPTED.
Your DNA has been logged.',
];
let cluckMsgIndex = 0;
function initCluckDetector() {
document.addEventListener('keydown', (e) => {
cluckBuffer += e.key.toLowerCase();
if (cluckBuffer.length > 8) cluckBuffer = cluckBuffer.slice(-8);
if (cluckBuffer.includes('cluck')) {
cluckBuffer = '';
playCluck();
setTimeout(playCluck, 200);
showToast(CLUCK_MESSAGES[cluckMsgIndex % CLUCK_MESSAGES.length], 5000);
cluckMsgIndex++;
}
});
}
// ─── KONAMI CODE → CHICKEN OVERLORD MODE ─────────────────────
const KONAMI = [
'ArrowUp','ArrowUp','ArrowDown','ArrowDown',
'ArrowLeft','ArrowRight','ArrowLeft','ArrowRight',
'b','a'
];
let konamiIndex = 0;
function initKonami() {
document.addEventListener('keydown', (e) => {
if (e.key === KONAMI[konamiIndex]) {
konamiIndex++;
if (konamiIndex === KONAMI.length) {
konamiIndex = 0;
activateOverlordMode();
}
} else {
konamiIndex = e.key === KONAMI[0] ? 1 : 0;
}
});
}
function activateOverlordMode() {
let overlay = document.getElementById('overlord-overlay');
if (!overlay) {
overlay = document.createElement('div');
overlay.id = 'overlord-overlay';
overlay.innerHTML = `