Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ // Mobile menu toggle
+ const mobileMenu = document.querySelector('.mobile-menu');
+ const navLinks = document.querySelector('.nav-links');
+
+ mobileMenu.addEventListener('click', () => {
+ navLinks.classList.toggle('active');
+
+ // Animate hamburger to X
+ const spans = mobileMenu.querySelectorAll('span');
+ spans.forEach(span => span.classList.toggle('active'));
+ });
+
+ // Smooth scroll for navigation links
+ document.querySelectorAll('a[href^="#"]').forEach(anchor => {
+ anchor.addEventListener('click', function (e) {
+ e.preventDefault();
+ const target = document.querySelector(this.getAttribute('href'));
+ if (target) {
+ target.scrollIntoView({
+ behavior: 'smooth'
+ });
+ // Close mobile menu if open
+ navLinks.classList.remove('active');
+ }
+ });
+ });
+
+ // Search functionality
+ const searchInput = document.getElementById('drug-search');
+ const searchBtn = document.querySelector('.search-btn');
+ const searchResults = document.getElementById('search-results');
+
+ const performSearch = () => {
+ const searchTerm = searchInput.value.trim().toLowerCase();
+ if (searchTerm.length < 2) return;
+
+ // Simulate search results (replace with actual API call)
+ const mockResults = [
+ { name: 'Acetaminophen', risk: 'High' },
+ { name: 'Ibuprofen', risk: 'Moderate' },
+ { name: 'Amoxicillin', risk: 'Low' }
+ ].filter(drug => drug.name.toLowerCase().includes(searchTerm));
+
+ displayResults(mockResults);
+ };
+
+ const displayResults = (results) => {
+ searchResults.innerHTML = results.map(drug => `
+
+
${drug.name}
+
Risk Level: ${drug.risk}
+
+ `).join('');
+ };
+
+ searchBtn.addEventListener('click', performSearch);
+ searchInput.addEventListener('keypress', (e) => {
+ if (e.key === 'Enter') performSearch();
+ });
+
+ // Intersection Observer for animation
+ const observer = new IntersectionObserver((entries) => {
+ entries.forEach(entry => {
+ if (entry.isIntersecting) {
+ entry.target.classList.add('visible');
+ }
+ });
+ }, { threshold: 0.1 });
+
+ document.querySelectorAll('.case-card').forEach(card => {
+ observer.observe(card);
+ });
+ });