Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ let currentQuestion = 0;
+ const questions = document.querySelectorAll('.question');
+ const nextBtn = document.getElementById('next-btn');
+ const resultDiv = document.getElementById('result');
+ const resultText = document.getElementById('result-text');
+ const restartBtn = document.getElementById('restart-btn');
+ let answers = [];
+
+ function showQuestion(index) {
+ questions.forEach(q => q.classList.remove('active'));
+ questions[index].classList.add('active');
+ }
+
+ function calculateResult() {
+ const dramaLevel = parseInt(document.getElementById('drama-slider').value);
+ const emotionalDrain = answers[1];
+ const communication = answers[2];
+
+ let recommendation = '';
+
+ if (dramaLevel >= 8 && emotionalDrain === 'yes' && communication === 'no') {
+ recommendation = "Consider ending the relationship. The high drama level combined with emotional drain and poor communication suggests an unhealthy dynamic.";
+ } else if (dramaLevel >= 6 && emotionalDrain === 'sometimes' && communication === 'sometimes') {
+ recommendation = "Your relationship needs work. Consider couples counseling to improve communication and reduce drama.";
+ } else if (dramaLevel <= 5 && communication === 'yes') {
+ recommendation = "Your relationship has potential. While there are challenges, good communication is a strong foundation for improvement.";
+ } else {
+ recommendation = "Take time to reflect on what you want from this relationship. Consider discussing your concerns with your partner or a counselor.";
+ }
+
+ return recommendation;
+ }
+
+ nextBtn.addEventListener('click', () => {
+ if (currentQuestion === 0) {
+ answers[0] = document.getElementById('drama-slider').value;
+ } else {
+ const selectedOption = questions[currentQuestion].querySelector('.option-btn.selected');
+ if (!selectedOption) return;
+ answers[currentQuestion] = selectedOption.dataset.value;
+ }
+
+ if (currentQuestion < questions.length - 1) {
+ currentQuestion++;
+ showQuestion(currentQuestion);
+ } else {
+ const result = calculateResult();
+ resultText.textContent = result;
+ document.querySelector('.question-container').style.display = 'none';
+ resultDiv.classList.remove('hidden');
+ }
+ });
+
+ document.querySelectorAll('.option-btn').forEach(btn => {
+ btn.addEventListener('click', (e) => {
+ const parent = e.target.closest('.question');
+ parent.querySelectorAll('.option-btn').forEach(b => b.classList.remove('selected'));
+ e.target.classList.add('selected');
+ });
+ });
+
+ restartBtn.addEventListener('click', () => {
+ currentQuestion = 0;
+ answers = [];
+ document.getElementById('drama-slider').value = 5;
+ document.querySelectorAll('.option-btn').forEach(btn => btn.classList.remove('selected'));
+ document.querySelector('.question-container').style.display = 'block';
+ resultDiv.classList.add('hidden');
+ showQuestion(0);
+ });
+ });