// Milestone countdown: shows next upcoming event label and countdown
(function(){
const el = document.getElementById('milestone');
const now = new Date();
const milestones = [
{label:'Black Week start', at: new Date('2025-11-24T00:00:00+01:00')},
{label:'Black Friday', at: new Date('2025-11-28T00:00:00+01:00')},
{label:'Cyber Monday', at: new Date('2025-12-01T00:00:00+01:00')}
];
let next = milestones.find(m => m.at > now) || null;
function fmt(ms){
const s = Math.max(0, Math.floor(ms/1000));
const d = Math.floor(s/86400);
const h = Math.floor((s%86400)/3600);
const m = Math.floor((s%3600)/60);
const sec = s%60;
return `${d}d ${h}h ${m}m ${sec}s`;
}
function tick(){
const t = new Date();
if(!next){ el.textContent = 'Kampanjen är live!'; return; }
el.textContent = `${next.label} om ${fmt(next.at - t)}`;
}
tick();
setInterval(tick, 1000);
})();















