feat(ui): add Unstuck / Paralysis Emergency Protocol

This commit is contained in:
djg 2026-09-23 04:26:02 +00:00
parent 275aab69b3
commit d90e505c27
3 changed files with 271 additions and 0 deletions

View file

@ -234,6 +234,52 @@
</div>
</footer>
<!-- Unstuck Floating Button -->
<button id="btn-unstuck" class="unstuck-trigger" title="Feeling paralyzed? Click here for the Unstuck Protocol">🆘 Unstuck</button>
<!-- Unstuck Protocol Modal -->
<div id="unstuck-modal" class="modal-overlay" hidden>
<div class="modal-content unstuck-card">
<button class="close-modal" id="unstuck-close">&times;</button>
<!-- Phase 1: Breathe -->
<div id="unstuck-phase-1" class="unstuck-phase">
<h2>Somatic Grounding</h2>
<p>Task paralysis is a nervous system response. Let's disarm it with a physiological sigh.</p>
<div class="breathing-circle-container">
<div class="breathing-circle"></div>
<div id="breathe-text">Inhale...</div>
</div>
<button id="unstuck-next-1" class="btn primary">My body feels calmer &rarr;</button>
</div>
<!-- Phase 2: Micro-Action -->
<div id="unstuck-phase-2" class="unstuck-phase" hidden>
<h2>Rule of 10 Seconds</h2>
<p>Don't think about the whole task right now. What is a ridiculously small physical action you can do in exactly 10 seconds?</p>
<ul class="micro-suggestions">
<li>Stand up and stretch</li>
<li>Open the word doc tab</li>
<li>Find your favorite pen</li>
<li>Drink a glass of water</li>
</ul>
<input type="text" id="unstuck-micro-input" placeholder="My 10-second micro-action is..." style="width: 100%; padding: 10px; margin-bottom: 20px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text-main);">
<button id="unstuck-next-2" class="btn primary">I've got it &rarr;</button>
</div>
<!-- Phase 3: 3-Minute Commitment -->
<div id="unstuck-phase-3" class="unstuck-phase" hidden>
<h2>Commitment-Free Launch</h2>
<p>You only have to execute your micro-action and focus for 3 minutes. If you still hate the task after 3 minutes, you have full permission to walk away entirely guilt-free.</p>
<div class="timer-display" id="unstuck-timer" style="font-size: 3em; font-weight: bold; margin: 20px 0;">03:00</div>
<button id="unstuck-start-3" class="btn primary">Accept 3-Minute Contract</button>
<button id="unstuck-finish" class="btn success" hidden>I'm in the zone, move to Focus Timer</button>
</div>
</div>
</div>
<script src="/static/app.js" defer></script>
</body>
</html>

View file

@ -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();
});
})();

View file

@ -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) */
}