// Handle option button clicks
function handleOptionClick(button, question, value) {
debugLog('Button clicked: ' + question + ' = ' + value);
// Remove selected class from all buttons in this question
const questionContainer = button.closest('.question-container');
questionContainer.querySelectorAll('.option-button').forEach(btn => {
btn.classList.remove('selected');
});
// Add selected class to clicked button
button.classList.add('selected');
// Store the answer
userAnswers[question] = value;
// Update progress
const progress = ((currentQuestion + 1) / questions.length) * 100;
document.querySelector('.progress').style.width = progress + '%';
// Wait a moment to show the selection before moving to next question
setTimeout(() => {
// Move to next question or show results
if (currentQuestion < questions.length - 1) {
// Hide current question
questionContainer.style.display = 'none';
// Show next question
currentQuestion++;
document.querySelector(`[data-question="${questions[currentQuestion]}"]`).style.display = 'block';
} else {
showResults();
}
}, 300); // Wait 300ms to show the selection
}