Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const sliders = document.querySelectorAll('.slider');
+ const analyzeBtn = document.getElementById('analyzeBtn');
+ const resultArea = document.getElementById('resultArea');
+ const redFlags = document.querySelectorAll('.checkbox-group input');
+
+ // Update slider values
+ sliders.forEach(slider => {
+ slider.addEventListener('input', (e) => {
+ e.target.nextElementSibling.textContent = e.target.value;
+ });
+ });
+
+ analyzeBtn.addEventListener('click', () => {
+ const scores = Array.from(sliders).map(slider => parseInt(slider.value));
+ const flagsChecked = Array.from(redFlags).filter(flag => flag.checked).length;
+
+ // Calculate compatibility score
+ const avgScore = scores.reduce((a, b) => a + b, 0) / scores.length;
+ const redFlagPenalty = flagsChecked * 15;
+ let finalScore = Math.max(0, (avgScore * 10) - redFlagPenalty);
+
+ // Generate recommendation
+ let recommendation = '';
+ if (flagsChecked >= 3) {
+ recommendation = '🚫 Major red flags detected. Consider ending this relationship.';
+ } else if (finalScore >= 75) {
+ recommendation = '💚 This relationship shows promise! Continue with optimism.';
+ } else if (finalScore >= 50) {
+ recommendation = '💛 Proceed with caution. More time needed to evaluate.';
+ } else {
+ recommendation = '❤️ Consider if this relationship aligns with your needs.';
+ }
+
+ // Display results
+ resultArea.style.display = 'block';
+ resultArea.querySelector('.result-content').innerHTML = `
+
Compatibility Score: ${finalScore.toFixed(1)}%
+
Recommendation: ${recommendation}
+ ${flagsChecked > 0 ? `
Warning: ${flagsChecked} red flag${flagsChecked > 1 ? 's' : ''} detected
` : ''}
+ `;
+
+ // Animate compatibility meter
+ const meterFill = resultArea.querySelector('.meter-fill');
+ meterFill.style.width = `${finalScore}%`;
+
+ // Smooth scroll to results
+ resultArea.scrollIntoView({ behavior: 'smooth' });
+ });
+
+ // Add hover effects for interactive elements
+ document.querySelectorAll('.checkbox-group label').forEach(label => {
+ label.addEventListener('mouseover', () => label.style.color = '#ff4b6e');
+ label.addEventListener('mouseout', () => label.style.color = '');
+ });
+ });