(){document.getElementById('cart-drawer').classList.add('open');document.getElementById('cart-ov').classList.add('open');}
function closeCart(){document.getElementById('cart-drawer').classList.remove('open');document.getElementById('cart-ov').classList.remove('open');}
/* ── WHATSAPP ── */
function sendWhatsApp(){if(!cart.length){toast('Cart is empty');return;}var lines=['*New Order - Your Store*',''];cart.forEach(function(i){lines.push('- '+i.name+' x '+i.qty+' = $'+(i.price*i.qty).toFixed(2));});var total=cart.reduce(function(s,i){return s+i.price*i.qty;},0);lines.push('');lines.push('*Total: $'+total.toFixed(2)+'*');lines.push('');lines.push('_Sent via Ordegate_');window.open('https://wa.me/?text='+encodeURIComponent(lines.join('\n')),'_blank');cart=[];renderCart();closeCart();toast('Order sent!');}
/* ── FILTER ── */
function setCat(cat,el){document.querySelectorAll('.cat-btn').forEach(function(b){b.classList.remove('on');});if(el)el.classList.add('on');document.querySelectorAll('.p-card').forEach(function(c){c.style.display=(cat==='all'||c.dataset.cat===cat)?'':'none';});var vis=document.querySelectorAll('.p-card[style=""], .p-card:not([style])').length;if(!vis){var g=document.getElementById('grid');if(!g.querySelector('.grid-empty'))g.insertAdjacentHTML('beforeend','
');}else{var emp=document.querySelector('.grid-empty');if(emp)emp.remove();}}
function filterProducts(){var q=(document.getElementById('search').value||'').toLowerCase();document.querySelectorAll('.p-card').forEach(function(c){var name=c.querySelector('.p-name').textContent.toLowerCase();c.style.display=name.includes(q)?'':'none';});}
/* ── TOAST ── */
var toastTmr;function toast(msg){var t=document.getElementById('toast');t.textContent=msg;t.classList.add('show');clearTimeout(toastTmr);toastTmr=setTimeout(function(){t.classList.remove('show');},2400);}
function esc(s){return String(s||'').replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"');}
/* ── SCROLL ── */
window.addEventListener('scroll',function(){document.getElementById('btt').classList.toggle('vis',scrollY>400);});
+item.price.toFixed(2)+'