/* Custom styles for Rebecca's In Home Childcare */

/* Smooth scrolling for anchor links */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #0d9488;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #0f766e;
}

/* Selection color */
::selection {
    background: #0d9488;
    color: white;
}

/* Focus styles for accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid #14b8a6;
    outline-offset: 2px;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* Print styles */
@media print {
    nav,
    .btn-primary,
    .btn-secondary,
    #mobile-menu-btn {
        display: none !important;
    }
    
    body {
        color: #000;
        background: white;
    }
    
    a {
        color: #000;
        text-decoration: underline;
    }
}

/* High contrast mode support */
@media (forced-colors: active) {
    .btn-primary,
    .btn-secondary {
        border: 2px solid ButtonText;
    }
}

/* Ensure images don't overflow */
img {
    max-width: 100%;
    height: auto;
}

/* Prevent text from becoming selectable on double-click */
h1, h2, h3, h4, h5, h6 {
    user-select: none;
}

/* Better touch targets on mobile */
@media (max-width: 768px) {
    a, button {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Ensure proper rendering of SVG icons */
svg {
    display: inline-block;
    vertical-align: middle;
}

/* Form focus states */
input:focus,
textarea:focus,
select:focus {
    border-color: #14b8a6 !important;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2) !important;
}

/* Card hover effects */
.card-hover {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

/* Button ripple effect */
.btn-primary {
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn-primary:active::after {
    width: 300px;
    height: 300px;
}

/* Ensure text contrast on all backgrounds */
.slate-900 { color: #0f172a; }
.slate-850 { color: #1e293b; }
.slate-800 { color: #1e293b; }
.slate-700 { color: #334155; }
.slate-600 { color: #475569; }
.slate-500 { color: #64748b; }
.slate-400 { color: #94a3b8; }
.slate-300 { color: #cbd5e1; }
.slate-200 { color: #e2e8f0; }
.slate-100 { color: #f1f5f9; }
.slate-50 { color: #f8fafc; }

.bg-slate-900 { background-color: #0f172a; }
.bg-slate-850 { background-color: #1e293b; }
.bg-slate-800 { background-color: #1e293b; }
.bg-slate-700 { background-color: #334155; }
.bg-slate-600 { background-color: #475569; }
.bg-slate-500 { background-color: #64748b; }
.bg-slate-400 { background-color: #94a3b8; }
.bg-slate-300 { background-color: #e2e8f0; }
.bg-slate-200 { background-color: #e2e8f0; }
.bg-slate-100 { background-color: #f1f5f9; }
.bg-slate-50 { background-color: #f8fafc; }

/* Teal color contrast fixes */
.text-teal-600 { color: #0d9488; }
.text-teal-700 { color: #0f766e; }
.text-teal-500 { color: #14b8a6; }
.text-teal-400 { color: #2dd4bf; }
.text-teal-300 { color: #5eead4; }
.text-teal-200 { color: #99f6e4; }
.text-teal-100 { color: #ccfbf1; }
.text-teal-50 { color: #f0fdfa; }

.bg-teal-600 { background-color: #0d9488; }
.bg-teal-700 { background-color: #0f766e; }
.bg-teal-500 { background-color: #14b8a6; }
.bg-teal-400 { background-color: #2dd4bf; }
.bg-teal-300 { background-color: #5eead4; }
.bg-teal-200 { background-color: #99f6e4; }
.bg-teal-100 { background-color: #ccfbf1; }
.bg-teal-50 { background-color: #f0fdfa; }

/* Amber color contrast fixes */
.text-amber-600 { color: #d97706; }
.text-amber-700 { color: #b45309; }
.text-amber-500 { color: #f59e0b; }
.text-amber-400 { color: #fbbf24; }
.text-amber-300 { color: #fcd34d; }
.text-amber-200 { color: #fde68a; }
.text-amber-100 { color: #fef3c7; }
.text-amber-50 { color: #fffbeb; }

.bg-amber-600 { background-color: #d97706; }
.bg-amber-700 { background-color: #b45309; }
.bg-amber-500 { background-color: #f59e0b; }
.bg-amber-400 { background-color: #fbbf24; }
.bg-amber-300 { background-color: #fcd34d; }
.bg-amber-200 { background-color: #fde68a; }
.bg-amber-100 { background-color: #fef3c7; }
.bg-amber-50 { background-color: #fffbeb; }

/* White text on dark backgrounds */
.text-white { color: #ffffff; }
.bg-white { background-color: #ffffff; }

/* Border colors */
.border-teal-200 { border-color: #99f6e4; }
.border-teal-500 { border-color: #14b8a6; }
.border-slate-100 { border-color: #f1f5f9; }
.border-slate-200 { border-color: #e2e8f0; }
.border-slate-700 { border-color: #334155; }
.border-slate-800 { border-color: #1e293b; }

/* Focus ring colors */
.focus\:ring-teal-200:focus { box-shadow: 0 0 0 3px rgba(153, 246, 228, 0.5); }
.focus\:ring-teal-500:focus { box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.3); }
</style>
<sm-file path="script.js">
// Rebecca's In Home Childcare - Interactive Script

document.addEventListener('DOMContentLoaded', function() {
    
    // Mobile menu toggle
    const mobileMenuBtn = document.getElementById('mobile-menu-btn');
    const mobileMenu = document.getElementById('mobile-menu');
    const mobileLinks = mobileMenu.querySelectorAll('a');
    
    mobileMenuBtn.addEventListener('click', function() {
        mobileMenu.classList.toggle('open');
        const isOpen = mobileMenu.classList.contains('open');
        mobileMenuBtn.setAttribute('aria-expanded', isOpen);
    });
    
    // Close mobile menu when clicking a link
    mobileLinks.forEach(function(link) {
        link.addEventListener('click', function() {
            mobileMenu.classList.remove('open');
            mobileMenuBtn.setAttribute('aria-expanded', 'false');
        });
    });
    
    // Close mobile menu when clicking outside
    document.addEventListener('click', function(e) {
        if (!mobileMenu.contains(e.target) && !mobileMenuBtn.contains(e.target)) {
            mobileMenu.classList.remove('open');
            mobileMenuBtn.setAttribute('aria-expanded', 'false');
        }
    });
    
    // Scroll reveal animation
    const revealElements = document.querySelectorAll('.reveal');
    
    function checkReveal() {
        const windowHeight = window.innerHeight;
        const elementVisible = 100;
        
        revealElements.forEach(function(element) {
            const elementTop = element.getBoundingClientRect().top;
            if (elementTop < windowHeight - elementVisible) {
                element.classList.add('visible');
            }
        });
    }
    
    // Check on load and scroll
    checkReveal();
    window.addEventListener('scroll', checkReveal);
    
    // Contact form handling
    const contactForm = document.getElementById('contact-form');
    const formSuccess = document.getElementById('form-success');
    
    if (contactForm) {
        contactForm.addEventListener('submit', function(e) {
            e.preventDefault();
            
            // Basic validation
            const firstName = document.getElementById('first-name').value.trim();
            const lastName = document.getElementById('last-name').value.trim();
            const email = document.getElementById('email').value.trim();
            const message = document.getElementById('message').value.trim();
            
            if (!firstName || !lastName || !email || !message) {
                alert('Please fill in all required fields.');
                return;
            }
            
            // Email validation
            const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
            if (!emailRegex.test(email)) {
                alert('Please enter a valid email address.');
                return;
            }
            
            // Simulate form submission
            const submitBtn = contactForm.querySelector('button[type="submit"]');
            const originalText = submitBtn.innerHTML;
            submitBtn.innerHTML = '<svg class="w-5 h-5 animate-spin" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> Sending...';
            submitBtn.disabled = true;
            
            setTimeout(function() {
                contactForm.reset();
                formSuccess.classList.remove('hidden');
                submitBtn.innerHTML = originalText;
                submitBtn.disabled = false;
                
                // Hide success message after 5 seconds
                setTimeout(function() {
                    formSuccess.classList.add('hidden');
                }, 5000);
            }, 1500);
        });
    }
    
    // Navbar background on scroll
    const navbar = document.querySelector('nav');
    
    function updateNavbar() {
        if (window.scrollY > 50) {
            navbar.classList.add('shadow-md');
        } else {
            navbar.classList.remove('shadow-md');
        }
    }
    
    window.addEventListener('scroll', updateNavbar);
    
    // Smooth scroll for anchor links
    document.querySelectorAll('a[href^="#"]').forEach(function(anchor) {
        anchor.addEventListener('click', function(e) {
            e.preventDefault();
            const target = document.querySelector(this.getAttribute('href'));
            if (target) {
                const navbarHeight = navbar.offsetHeight;
                const targetPosition = target.getBoundingClientRect().top + window.pageYOffset - navbarHeight;
                
                window.scrollTo({
                    top: targetPosition,
                    behavior: 'smooth'
                });
            }
        });
    });
    
    // Add tabindex to SVG icons for better accessibility
    document.querySelectorAll('svg').forEach(function(svg) {
        if (!svg.closest('a') && !svg.closest('button')) {
            svg.setAttribute('aria-hidden', 'true');
            svg.setAttribute('focusable', 'false');
        }
    });
    
    // Intersection Observer for performance (fallback for older browsers)
    if ('IntersectionObserver' in window) {
        const revealObserver = new IntersectionObserver(function(entries) {
            entries.forEach(function(entry) {
                if (entry.isIntersecting) {
                    entry.target.classList.add('visible');
                    revealObserver.unobserve(entry.target);
                }
            });
        }, {
            threshold: 0.1,
            rootMargin: '0px 0px -50px 0px'
        });
        
        revealElements.forEach(function(element) {
            revealObserver.observe(element);
        });
    }
});
