Mystic Hearth Baking Studio

Your baking shelf

Cart

Keep your chosen lessons together and review the learning rhythm before you begin.

`; const footerHTML = ``; document.getElementById('site-header').innerHTML = headerHTML; document.getElementById('site-footer').innerHTML = footerHTML; const catalogData = [ {id:1,title:"Sourdough Fundamentals",price:89,description:"Master the basics of wild yeast and long fermentation."}, {id:2,title:"Rye & Ancient Grains",price:104,description:"Explore heritage flours and hearty loaves."}, {id:3,title:"Naturally Leavened Pastries",price:129,description:"Croissants, danish, and laminated doughs."}, {id:4,title:"Seasonal Fruit Breads",price:76,description:"Incorporate peak produce into beautiful loaves."}, {id:5,title:"Wood-Fired Oven Mastery",price:149,description:"Build and bake in traditional stone ovens."}, {id:6,title:"Whole Grain Sandwich Loaves",price:68,description:"Reliable daily bread for the family table."} ]; function getCart(){try{return JSON.parse(localStorage.getItem('mh-cart'))||{};}catch(e){return{};}} function saveCart(cart){localStorage.setItem('mh-cart',JSON.stringify(cart));} function renderCart(){ const container=document.getElementById('cart-items'); const totalEl=document.getElementById('cart-total'); const emptyEl=document.getElementById('cart-empty'); const contentEl=document.getElementById('cart-content'); container.innerHTML=''; const cart=getCart(); const ids=Object.keys(cart); if(ids.length===0){ contentEl.style.display='none'; emptyEl.classList.remove('hidden'); totalEl.textContent='$0.00'; return; } contentEl.style.display='grid'; emptyEl.classList.add('hidden'); let total=0; ids.forEach(id=>{ const item=catalogData.find(p=>p.id===parseInt(id)); if(!item)return; const qty=cart[id]; const subtotal=item.price*qty; total+=subtotal; const row=document.createElement('div'); row.className='rounded-3xl border border-[#DCCDBD] bg-white p-6 dark:bg-[#26352D]'; row.innerHTML=`

${item.title}

${item.description}

$${item.price} × ${qty}

${qty}
$${subtotal}
`; container.appendChild(row); }); totalEl.textContent='$'+total; container.querySelectorAll('.qty-btn').forEach(btn=>{ btn.addEventListener('click',()=>{ const id=btn.dataset.id; const action=btn.dataset.action; let c=getCart(); if(action==='plus')c[id]=(c[id]||0)+1; else if(action==='minus'){c[id]=(c[id]||1)-1;if(c[id]<1)c[id]=1;} saveCart(c); renderCart(); }); }); container.querySelectorAll('.remove-btn').forEach(btn=>{ btn.addEventListener('click',()=>{ let c=getCart(); delete c[btn.dataset.id]; saveCart(c); renderCart(); }); }); } function setupCheckout(){ const link=document.getElementById('checkout-link'); const modal=document.getElementById('checkout-modal'); if(link&&modal){ link.addEventListener('click',function(e){ e.preventDefault(); modal.classList.remove('hidden'); modal.classList.add('grid'); }); modal.addEventListener('click',function(e){ if(e.target===modal){ modal.classList.remove('grid'); modal.classList.add('hidden'); } }); const closeLinks=modal.querySelectorAll('a'); closeLinks.forEach(a=>{ a.addEventListener('click',function(){ modal.classList.remove('grid'); modal.classList.add('hidden'); }); }); } } function init(){ renderCart(); setupCheckout(); const cartKey='mh-cart'; if(!localStorage.getItem(cartKey)){ localStorage.setItem(cartKey,JSON.stringify({1:1,3:2})); renderCart(); } } init(); })();