/* WeatherMate — dynamic animated background */ function WeatherBackground({ condition, isDay, animate, theme, intensity = 1 }) { const [g1, g2, g3] = theme.bg; // stable random particles const rain = React.useMemo(() => Array.from({ length: 70 }).map(() => ({ left: Math.random() * 100, delay: Math.random() * 1.2, dur: 0.5 + Math.random() * 0.5, len: 14 + Math.random() * 22, op: 0.25 + Math.random() * 0.45, })), []); const snow = React.useMemo(() => Array.from({ length: 60 }).map(() => ({ left: Math.random() * 100, delay: Math.random() * 6, dur: 5 + Math.random() * 6, size: 3 + Math.random() * 5, drift: (Math.random() * 2 - 1) * 40, op: 0.4 + Math.random() * 0.5, })), []); const stars = React.useMemo(() => Array.from({ length: 50 }).map(() => ({ left: Math.random() * 100, top: Math.random() * 55, size: Math.random() < 0.8 ? 1.5 : 2.5, delay: Math.random() * 3, op: 0.4 + Math.random() * 0.6, })), []); const isWet = condition === "rain" || condition === "drizzle" || condition === "thunder"; const showClouds = ["partly", "cloudy", "rain", "drizzle", "thunder", "snow"].includes(condition); const showStars = !isDay && (condition === "clear" || condition === "partly"); return (
{/* celestial glow */}
{/* stars */} {showStars && stars.map((s, i) => ( ))} {/* sun rays (clear day) */} {isDay && condition === "clear" && (
)} {/* drifting clouds */} {showClouds && (
{[ { top: "8%", scale: 1.3, dur: 60, delay: 0, op: isDay ? 0.5 : 0.32 }, { top: "20%", scale: 0.9, dur: 78, delay: -20, op: isDay ? 0.4 : 0.24 }, { top: "4%", scale: 1.7, dur: 95, delay: -50, op: isDay ? 0.32 : 0.2 }, ].map((c, i) => (
))}
)} {/* rain */} {isWet && animate && (
{rain.slice(0, Math.round(70 * intensity)).map((r, i) => ( ))}
)} {/* snow */} {condition === "snow" && animate && (
{snow.map((s, i) => ( ))}
)} {/* fog banks */} {condition === "fog" && (
{[0, 1, 2].map(i => (
))}
)} {/* lightning */} {condition === "thunder" && animate &&
} {/* vignette for depth */}
); } window.WeatherBackground = WeatherBackground;