document.addEventListener('DOMContentLoaded', function () { // --- Snowflakes Effect --- function createSnowflakes() { const snowContainer = document.getElementById('snow-container'); if (!snowContainer) return; snowContainer.innerHTML = ''; const numberOfSnowflakes = 50; for (let i = 0; i < numberOfSnowflakes; i++) { const snowflake = document.createElement('div'); snowflake.className = 'snowflake'; const size = Math.random() * 4 + 2; // size from 2px to 6px snowflake.style.width = `${size}px`; snowflake.style.height = `${size}px`; snowflake.style.left = Math.random() * 100 + 'vw'; const animationDuration = Math.random() * 5 + 5; // 5 to 10 seconds snowflake.style.animationDuration = `${animationDuration}s`; const animationDelay = Math.random() * 5; // 0 to 5 seconds snowflake.style.animationDelay = `${animationDelay}s`; snowflake.style.opacity = Math.random() * 0.7 + 0.3; // 0.3 to 1.0 snowContainer.appendChild(snowflake); } } createSnowflakes(); // --- DOM Elements --- const recipeNameInput = document.getElementById('recipeName'); const guestCountInput = document.getElementById('guestCount'); const ingredientsContainer = document.getElementById('ingredients-container'); const addIngredientBtn = document.getElementById('add-ingredient'); const calculateBtn = document.getElementById('calculate-btn'); const newRecipeBtn = document.getElementById('new-recipe-btn'); const shoppingListContainer = document.getElementById('shopping-list-container'); const recipeCardsContainer = document.getElementById('recipe-cards-container'); // --- Core Functions --- async function loadRecipes() { try { const response = await fetch('api/get_recipes.php'); const data = await response.json(); if (data.success) { renderRecipeCards(data.recipes); } else { console.error('Failed to load recipes:', data.error); recipeCardsContainer.innerHTML = '
Error loading recipes.
Could not connect to the server.
Your calculated list will appear here.
Здесь будут появляться ваши сохраненные рецепты.
Нет ингредиентов для расчета.
'; } else { html += '