// Search results screen — match-degree sorted grid + filter sidebar const SearchResults = ({ tags = [], setTags, onOpenRecipe, onBack, mobile = false }) => { const [sort, setSort] = React.useState('match'); const [active, setActive] = React.useState({ time: null, diff: null, diet: null, cat: null }); const [showFilter, setShowFilter] = React.useState(false); const results = React.useMemo(() => { const list = window.RECIPES.map(r => { const have = tags.filter(t => r.have && r.have.includes(t)).length; const need = (r.have || []).length; const m = need === 0 ? r.match : Math.round(have / Math.max(tags.length, 1) * 100); return { ...r, _m: tags.length === 0 ? r.match : Math.max(m, 60) }; }); list.sort((a, b) => { if (sort === 'match') return b._m - a._m; if (sort === 'time') return a.time - b.time; if (sort === 'cal') return a.cal - b.cal; if (sort === 'rating') return b.rating - a.rating; return 0; }); return list; }, [tags, sort]); const W = mobile ? 'm' : 'd'; return (