const episodes=[
{title:'This is the World... According to Me',cat:'Growth',desc:'The origin story, the mission, and why Craig speaks from real life.'},
{title:'Barbershop Therapy',cat:'Mental Health',desc:'How everyday conversations can become a place for honesty and healing.'},
{title:'Ghosting, Growth, and Giving a Damn',cat:'Growth',desc:'Boundaries, accountability, and learning to move with intention.'},
{title:'When Grief Grows with You',cat:'Family',desc:'A personal reflection on loss, memory, and becoming stronger without becoming cold.'},
{title:'The Village Ain’t What it Used to Be',cat:'Culture',desc:'Community, parenting, support systems, and what we owe each other.'},
{title:'Delayed... Not Denied',cat:'Growth',desc:'School, work, barriers, and staying committed when the timeline changes.'},
{title:'Raising Men, Breaking Cycles',cat:'Family',desc:'Fatherhood, legacy, and the responsibility to change the pattern.'},
{title:'The Loneliest Generation Isn’t the Oldest—It’s Ours',cat:'Mental Health',desc:'A controversial look at connection, isolation, and modern life.'}
];
const grid=document.querySelector('#episodeGrid');let filter='all';
function renderEpisodes(){const q=(document.querySelector('#episodeSearch')?.value||'').toLowerCase();grid.innerHTML=episodes.filter(e=>(filter==='all'||e.cat===filter)&&(e.title.toLowerCase().includes(q)||e.desc.toLowerCase().includes(q))).map(e=>`<article class="episode"><span class="badge">${e.cat}</span><h3>${e.title}</h3><p>${e.desc}</p><button class="ghost">View Episode</button></article>`).join('')||'<p>No episodes found.</p>'}
renderEpisodes();
document.querySelectorAll('.filters button').forEach(b=>b.addEventListener('click',()=>{document.querySelector('.filters .active').classList.remove('active');b.classList.add('active');filter=b.dataset.filter;renderEpisodes()}));
document.querySelector('#episodeSearch').addEventListener('input',renderEpisodes);
document.querySelector('.menu-toggle').addEventListener('click',()=>document.querySelector('.nav').classList.toggle('open'));
document.querySelector('#themeToggle').addEventListener('click',()=>{document.body.classList.toggle('light');localStorage.setItem('craigTheme',document.body.classList.contains('light')?'light':'dark')});
if(localStorage.getItem('craigTheme')==='light')document.body.classList.add('light');
const reveals=document.querySelectorAll('.reveal');const io=new IntersectionObserver(es=>es.forEach(e=>{if(e.isIntersecting)e.target.classList.add('show')}),{threshold:.12});reveals.forEach(r=>io.observe(r));
const topBtn=document.querySelector('.to-top');window.addEventListener('scroll',()=>topBtn.style.display=scrollY>700?'block':'none');topBtn.onclick=()=>scrollTo({top:0,behavior:'smooth'});
let playing=false,progress=0,timer;document.querySelector('#playBtn').onclick=()=>{playing=!playing;playBtn.textContent=playing?'❚❚':'▶';clearInterval(timer);if(playing)timer=setInterval(()=>{progress=(progress+4)%104;document.querySelector('.progress span').style.width=progress+'%'},500)};
document.querySelector('#newsletterForm').addEventListener('submit',e=>{e.preventDefault();formMsg.textContent='You are in Craig’s World now. Check your inbox soon.';e.target.reset()});
document.querySelector('#contactForm').addEventListener('submit',e=>{e.preventDefault();alert('Message ready! Connect this form to Formspree, Netlify Forms, or your email service when publishing.');e.target.reset()});
document.querySelector('#year').textContent=new Date().getFullYear();
