import React, { useState } from 'react' const DIFFICULTY = { easy: { label: 'Easy', bg: '#F0FDF4', color: '#166534' }, medium: { label: 'Medium', bg: '#FFFBEB', color: '#92400E' }, hard: { label: 'Hard', bg: '#FFF5F5', color: '#991B1B' }, } function pill(ing) { return (typeof ing === 'string' ? ing : ing?.name || '').replace(/_/g, ' ') } export default function RecipeCard({ recipe, rank }) { const [open, setOpen] = useState(false) const pct = Math.round(recipe.match_percentage || 0) const diff = DIFFICULTY[(recipe.difficulty || 'medium').toLowerCase()] || DIFFICULTY.medium const barColor = pct >= 75 ? '#4ADE80' : pct >= 50 ? '#FCD34D' : '#D1D5DB' return (
{/* ── Main row (always visible) ── */} {/* ── Expanded detail ── */} {open && (
{/* Ingredient pills */}
{recipe.matched_ingredients?.map((ing, i) => ( {pill(ing)} ))} {recipe.missing_ingredients?.map((ing, i) => ( + {pill(ing)} ))}
{/* Description */} {recipe.description && (

{recipe.description}

)} {/* External links */}
e.stopPropagation()} > Watch on YouTube e.stopPropagation()} > Find Recipe
)}
) }