document.getElementById('assessmentForm').addEventListener('submit', function(event) { event.preventDefault(); // Prevent the form from reloading the page // Get values from the form and convert to numbers const passiveAngle = parseFloat(document.getElementById('passiveAngle').value); const activeAngle = parseFloat(document.getElementById('activeAngle').value); const latStanding = parseFloat(document.getElementById('latStanding').value); const latSeated = parseFloat(document.getElementById('latSeated').value); const pecMajorAngle = parseFloat(document.getElementById('pecMajorAngle').value); const externalRotationAngle = parseFloat(document.getElementById('externalRotationAngle').value); let reportHTML = '

Your Personalized Diagnosis

'; let limitingFactors = []; // --- Analysis Logic --- // 1. Active vs. Passive (Strength vs. Flexibility) const flexionDifference = passiveAngle - activeAngle; let flexionReport = `

Strength vs. Flexibility

`; if (flexionDifference > 15) { flexionReport += `

Your passive range (${passiveAngle}°) is significantly greater than your active range (${activeAngle}°). This points to a Motor Control or Strength Deficit. You have the flexibility but lack the strength to use it.

`; limitingFactors.push('Motor Control/Strength'); } else { flexionReport += `

Your active and passive ranges are similar. Any limitation is likely due to tissue tightness. This is a good result.

`; } flexionReport += `
`; reportHTML += flexionReport; // 2. Lat Length Test const latDifference = latStanding - latSeated; let latReport = `

Latissimus Dorsi (Lats)

`; if (latDifference > 15) { latReport += `

Your range of motion dropped significantly from ${latStanding}° (standing) to ${latSeated}° (seated/rounded). This strongly indicates that Tight Lats are a primary limiting factor.

`; limitingFactors.push('Tight Lats'); } else { latReport += `

Your range of motion was stable between the two positions. Your lats are likely not a significant restriction. This is a good result.

`; } latReport += `
`; reportHTML += latReport; // 3. Pec Major Length Test let pecReport = `

Pectoralis Major (Pecs)

`; if (pecMajorAngle < 45) { pecReport += `

Your arms only reached ${pecMajorAngle}° past your shoulders (goal is 45°). This indicates Tight Pec Major muscles, which can pull the shoulders forward.

`; limitingFactors.push('Tight Pec Major'); } else { pecReport += `

You achieved ${pecMajorAngle}° of extension, meeting the goal of 45°. Your pec major length is excellent. This is a great result.

`; } pecReport += `
`; reportHTML += pecReport; // 4. External Rotation Test let externalRotationReport = `

Internal Rotators (Subscapularis & Teres Major)

`; if (externalRotationAngle < 45) { externalRotationReport += `

Your external rotation was ${externalRotationAngle}° past vertical (goal is 45°). This indicates Tight Internal Rotators, a very common issue that restricts overhead mobility.

`; limitingFactors.push('Tight Internal Rotators'); } else { externalRotationReport += `

You achieved ${externalRotationAngle}° of external rotation, meeting the goal of 45°. Your internal rotator length is excellent. This is a great result.

`; } externalRotationReport += `
`; reportHTML += externalRotationReport; // --- Final Summary --- let summaryReport = `

Summary & Recommendations

`; if (limitingFactors.length === 0) { summaryReport += `

Excellent work! Based on your results, you have well-balanced shoulder mobility with no significant limitations detected. Focus on maintaining this balance with a well-rounded program.

`; } else { summaryReport += `

Your primary areas for improvement appear to be: ${limitingFactors.join(', ')}.

`; summaryReport += `

To improve your shoulder health, prioritize stretches and mobility drills that target these specific muscles.

`; } summaryReport += `
`; reportHTML += summaryReport; // Display the final report on the page const reportOutput = document.getElementById('reportOutput'); reportOutput.innerHTML = reportHTML; reportOutput.scrollIntoView({ behavior: 'smooth' }); // Automatically scroll to the results });