diff --git a/site/index.html b/site/index.html index c49963d..b813761 100644 --- a/site/index.html +++ b/site/index.html @@ -234,6 +234,52 @@ + + + + + + + diff --git a/site/static/app.js b/site/static/app.js index a6b44ce..d5ab5fe 100644 --- a/site/static/app.js +++ b/site/static/app.js @@ -792,3 +792,137 @@ }); })(); + + +// ========================================== +// UNSTUCK PROTOCOL (Task Paralysis Emergency) +// ========================================== +(function initUnstuck() { + const btnUnstuck = $('#btn-unstuck'); + const modal = $('#unstuck-modal'); + const closeBtn = $('#unstuck-close'); + const p1 = $('#unstuck-phase-1'); + const p2 = $('#unstuck-phase-2'); + const p3 = $('#unstuck-phase-3'); + const timerDisplay = $('#unstuck-timer'); + const startTimerBtn = $('#unstuck-start-3'); + const finishBtn = $('#unstuck-finish'); + + let breathInterval; + let unstuckInterval; + + if (!btnUnstuck || !modal) return; + + function resetUnstuckModal() { + p1.hidden = false; + p2.hidden = true; + p3.hidden = true; + startTimerBtn.hidden = false; + finishBtn.hidden = true; + timerDisplay.textContent = "03:00"; + $('#unstuck-micro-input').value = ""; + clearInterval(unstuckInterval); + clearInterval(breathInterval); + } + + function syncBreathText() { + const text = $('#breathe-text'); + if(!text) return; + clearInterval(breathInterval); + let cycle = 0; + + // Physiological Sigh timing matcher (approximate for the 8s CSS animation) + // 0-2s: Inhale + // 2-3.5s: 2nd Inhale + // 3.5-4s: Hold + // 4-8s: Long slow exhale + + const updateText = () => { + cycle = (cycle + 1) % 8; + if (cycle < 2) text.textContent = "Inhale..."; + else if (cycle < 3) text.textContent = "Sip more air..."; + else if (cycle < 4) text.textContent = "Hold..."; + else text.textContent = "Slooow Exhale..."; + }; + + updateText(); // immediate run + breathInterval = setInterval(() => { + if (modal.hidden || p1.hidden) { + clearInterval(breathInterval); + return; + } + updateText(); + }, 1000); + } + + btnUnstuck.addEventListener('click', () => { + resetUnstuckModal(); + modal.hidden = false; + syncBreathText(); + }); + + closeBtn.addEventListener('click', () => { + modal.hidden = true; + clearInterval(unstuckInterval); + clearInterval(breathInterval); + }); + + // Proceed from phase 1 to 2 + $('#unstuck-next-1').addEventListener('click', () => { + p1.hidden = true; + p2.hidden = false; + }); + + // Proceed from phase 2 to 3 + $('#unstuck-next-2').addEventListener('click', () => { + p2.hidden = true; + p3.hidden = false; + }); + + // Phase 3 Timer + startTimerBtn.addEventListener('click', () => { + startTimerBtn.hidden = true; + let timeLeft = 180; // 3 minutes + + unstuckInterval = setInterval(() => { + timeLeft--; + const m = Math.floor(timeLeft / 60).toString().padStart(2, '0'); + const s = (timeLeft % 60).toString().padStart(2, '0'); + timerDisplay.textContent = `${m}:${s}`; + + if (timeLeft <= 0) { + clearInterval(unstuckInterval); + timerDisplay.textContent = "Contract Complete!"; + finishBtn.hidden = false; + + // Play success tone if soundscapes/audio is available globally + try { + if (window.AudioContext && !window.audioCtx) { + window.audioCtx = new window.AudioContext(); + } + if (window.audioCtx) { + const osc = audioCtx.createOscillator(); + const gain = audioCtx.createGain(); + osc.connect(gain); + gain.connect(audioCtx.destination); + osc.frequency.setValueAtTime(440, audioCtx.currentTime); // A4 + osc.frequency.exponentialRampToValueAtTime(880, audioCtx.currentTime + 0.1); // Jump to A5 + gain.gain.setValueAtTime(0, audioCtx.currentTime); + gain.gain.linearRampToValueAtTime(0.5, audioCtx.currentTime + 0.05); + gain.gain.exponentialRampToValueAtTime(0.01, audioCtx.currentTime + 1); + osc.start(audioCtx.currentTime); + osc.stop(audioCtx.currentTime + 1); + } + } catch(e) { console.log(e); } + } + }, 1000); + }); + + finishBtn.addEventListener('click', () => { + modal.hidden = true; + // Switch to Focus Timer using the main app's tab switching logic + const timerTabBtn = document.getElementById('tab-timer'); + if(timerTabBtn) timerTabBtn.click(); + }); + +})(); diff --git a/site/static/style.css b/site/static/style.css index b521099..8b2370b 100644 --- a/site/static/style.css +++ b/site/static/style.css @@ -270,3 +270,94 @@ input[type="text"]:focus-visible { outline: 2px solid var(--accent); outline-off .timer-wrap, .ring { width: 200px; height: 200px; } .welcome-btn { font-size: .9rem; padding: 12px 16px; } } + + +/* Unstuck Protocol */ +.unstuck-trigger { + position: fixed; + bottom: 25px; + right: 25px; + padding: 12px 24px; + border-radius: 50px; + background: linear-gradient(135deg, #ff7e5f, #feb47b); + color: #121212; + font-size: 1.1em; + font-weight: 800; + border: none; + box-shadow: 0 6px 16px rgba(255, 126, 95, 0.4); + cursor: pointer; + z-index: 100; + transition: transform 0.2s ease, box-shadow 0.2s ease; +} +.unstuck-trigger:hover { + transform: translateY(-3px) scale(1.05); + box-shadow: 0 8px 20px rgba(255, 126, 95, 0.6); +} + +.modal-overlay { + position: fixed; + top: 0; left: 0; width: 100%; height: 100%; + background: rgba(0,0,0,0.6); + backdrop-filter: blur(8px); + display: flex; + justify-content: center; + align-items: center; + z-index: 200; +} +.modal-overlay[hidden] { + display: none !important; +} + +.unstuck-card { + background: var(--bg-card, #1e1e2e); + padding: 40px; + border-radius: 20px; + max-width: 500px; + width: 90%; + border: 1px solid var(--border, #313244); + position: relative; + text-align: center; + box-shadow: 0 20px 40px rgba(0,0,0,0.5); +} +.close-modal { + position: absolute; + top: 15px; right: 20px; + background: none; border: none; font-size: 28px; + color: var(--text-muted, #a6adc8); cursor: pointer; +} +.unstuck-phase h2 { margin-top: 0; color: var(--text-main, #cdd6f4); margin-bottom: 15px; } +.unstuck-phase p { color: var(--text-main, #bac2de); margin-bottom: 25px; font-size: 1.1em; line-height: 1.4;} +.micro-suggestions { text-align: left; color: var(--text-muted, #a6adc8); margin: 0 auto 25px auto; display: inline-block;} +.micro-suggestions li { padding: 6px 0; font-size: 1.05em;} + +/* Breathing Animation - Physiological Sigh */ +.breathing-circle-container { + height: 180px; + display: flex; + justify-content: center; + align-items: center; + position: relative; + margin: 30px 0; +} +.breathing-circle { + width: 80px; height: 80px; border-radius: 50%; + background: rgba(137, 180, 250, 0.4); + border: 2px solid rgba(137, 180, 250, 0.8); + animation: breathe 8s infinite cubic-bezier(0.4, 0, 0.2, 1); +} +#breathe-text { + position: absolute; + font-weight: bold; + color: var(--text-main, #cdd6f4); + font-size: 1.2em; + text-shadow: 0 2px 4px rgba(0,0,0,0.5); +} + +@keyframes breathe { + 0% { transform: scale(1); } /* Start Inhale */ + 25% { transform: scale(1.6); } /* First Inhale done (2s) */ + 35% { transform: scale(1.55); } /* Slight pause */ + 45% { transform: scale(2.0); } /* Second sharp inhale (peak) */ + 50% { transform: scale(2.0); } /* Brief hold */ + 100% { transform: scale(1); } /* Slow extended exhale (4s) */ +}