+ if (savedMoney > 0) allBadges.push(`
+ 💰
+ ${bm.currency}${savedMoney}/m${t('antiwaste.badge_saved_money')}
+ `);
+ if (savedMeals > 0) allBadges.push(`
+ 🥗
+ ${savedMeals}${t('antiwaste.badge_meals')}
+ `);
+ if (savedCO2 > 0) allBadges.push(`
+ 🌍
+ −${savedCO2} kgCO₂
+ `);
+ if (diffPct > 0) allBadges.push(`
✅
−${diffPct}%${t('antiwaste.badge_better')}
`);
- // Random starting fact
- const facts = AW_FACTS[_currentLang] || AW_FACTS['it'];
+ // Initial 3-badge slice
+ const MAX_VISIBLE = 3;
+ const initBadges = allBadges.slice(0, MAX_VISIBLE).join('');
+
+ // Facts
+ const facts = _awGetFacts();
const factIdx = Math.floor(Math.random() * facts.length);
const liveCls = isOnline ? 'aw-live-on' : 'aw-live-off';
@@ -2293,7 +2382,7 @@ function _renderAntiWasteSection(used30, wasted30, usedP30, wastedP30, usedP60,
${statusMsg}
- ${badges.length > 0 ? `${badges.join('')}
` : ''}
+ ${allBadges.length > 0 ? `${initBadges}
` : ''}
${hasTrend ? `
${_awTrendCard(rates[0], labels[0], maxTrend)}
@@ -2308,10 +2397,13 @@ function _renderAntiWasteSection(used30, wasted30, usedP30, wastedP30, usedP60,
${facts[factIdx]}
- ${t('antiwaste.source')}
+ ${(_awLiveFacts && _awLiveFacts.source) || t('antiwaste.source')}
`;
- // Rotate facts every 6 s with CSS fade
+ // Badge rotation (3 at a time)
+ _startBadgeRotation(allBadges, MAX_VISIBLE);
+
+ // Fact rotation (every 6 s)
if (_awFactTimer) clearInterval(_awFactTimer);
if (facts.length > 1) {
let idx = factIdx;
@@ -2426,7 +2518,8 @@ async function loadDashboard() {
// Banner alerts (suspicious quantities + consumption predictions)
loadBannerAlerts();
- // Anti-waste section
+ // Anti-waste section (load facts first so rotation has full dataset)
+ await _awLoadFacts();
_renderAntiWasteSection(
statsData.used_30d || 0, statsData.wasted_30d || 0,
statsData.used_prev_30d || 0, statsData.wasted_prev_30d || 0,