The Best Diet for Pregnant Women: A Complete Guide to a Healthy Pregnancy

 Pregnancy is a transformative journey that requires a thoughtful approach to nutrition. The food a woman eats during pregnancy directly influences the growth and development of her baby and her own well-being. A well-balanced, nutrient-rich diet helps prevent complications, supports fetal development, and prepares the mother’s body for childbirth and recovery.



Why Diet Matters During Pregnancy

During pregnancy, a woman’s nutritional needs increase. Essential vitamins and minerals play crucial roles in organ development, brain function, and immune system formation. A poor diet can lead to deficiencies that may result in low birth weight, developmental delays, or health issues for both mother and child.


Key Nutrients for Pregnant Women

1. Folic Acid (Folate)

  • Importance: Prevents neural tube defects and supports DNA synthesis.

  • Sources: Leafy greens, citrus fruits, fortified cereals, legumes, and lentils.

  • Recommended Daily Intake: 600 micrograms (mcg)

2. Iron

  • Importance: Helps in forming red blood cells and preventing anemia.

  • Sources: Red meat, spinach, beans, fortified cereals, poultry.

  • Tip: Pair with vitamin C-rich foods (like oranges) for better absorption.

3. Calcium

  • Importance: Builds strong bones and teeth for the baby.

  • Sources: Dairy products, almonds, broccoli, fortified plant-based milk.

  • Recommended Daily Intake: 1,000 milligrams (mg)

4. Protein

  • Importance: Essential for fetal tissue growth, especially the brain.

  • Sources: Eggs, meat, dairy, tofu, legumes, nuts, seeds.

  • Daily Needs: Around 75–100 grams per day.

5. Omega-3 Fatty Acids (especially DHA)

  • Importance: Critical for brain and eye development.

  • Sources: Fatty fish (like salmon), flaxseeds, chia seeds, walnuts.

  • Supplements: DHA supplements may be recommended by a doctor.

6. Vitamin D

  • Importance: Supports calcium absorption and immune function.

  • Sources: Sunlight, fortified milk, fatty fish, supplements if needed.


Ideal Daily Diet for Pregnant Women

Here’s a balanced meal plan outline:

Breakfast

  • Oatmeal topped with fresh berries and a spoon of chia seeds

  • Glass of fortified orange juice or low-fat milk

  • Boiled egg or nut butter on whole-grain toast

Lunch

  • Grilled chicken or tofu salad with leafy greens, tomatoes, and avocado

  • Whole-grain bread or quinoa

  • A piece of fruit (like an apple or banana)

Snack

  • Greek yogurt with honey and almonds

  • Or sliced vegetables with hummus

Dinner

  • Baked salmon or lentil stew

  • Steamed vegetables (broccoli, carrots, sweet potatoes)

  • Brown rice or whole-grain pasta

Evening Snack

  • A small handful of nuts

  • Or a fruit smoothie made with milk and spinach


Foods to Avoid During Pregnancy

  • Raw or undercooked meats, eggs, and seafood

  • Unpasteurized dairy products

  • High-mercury fish (e.g., shark, swordfish)

  • Caffeine: Limit to under 200 mg/day (about one cup of coffee)

  • Alcohol: Should be completely avoided


Hydration Matters

Staying well-hydrated is essential. Water supports increased blood volume, helps prevent constipation, and regulates body temperature. Aim for 8–10 glasses of water per day, and more if you're active or it's hot outside.


Special Considerations

  • Morning Sickness: Small, frequent meals with bland foods (like crackers or bananas) may help.

  • Gestational Diabetes: A low-sugar, low-carb diet guided by a dietitian may be necessary.

  • Vegetarian or Vegan Diets: These are healthy if well-planned, with attention to B12, iron, and protein intake.


Conclusion

A healthy pregnancy diet is rich in variety, whole foods, and essential nutrients. It fuels both mother and baby for optimal health and development. Expectant mothers should consult a healthcare provider or a registered dietitian for personalized guidance based on their medical history and lifestyle.

Remember: Eating well during pregnancy is one of the most powerful acts of love you can offer your growing baby.

HTML SCRIPT

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Nourish & Nurture | Your Personalized Pregnancy Diet Plan</title>

    

    <!-- Google Fonts -->

    <link rel="preconnect" href="https://fonts.googleapis.com">

    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>

    <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">

    

    <!-- Font Awesome for Icons -->

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">


    <style>

        /* CSS Starts Here */

        :root {

            --primary-color: #4A90E2; /* A calming blue */

            --secondary-color: #F5A623; /* A warm orange accent */

            --text-color: #333;

            --light-bg: #F9F9F9;

            --white-color: #ffffff;

            --heading-font: 'Playfair Display', serif;

            --body-font: 'Poppins', sans-serif;

            --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);

            --border-radius: 12px;

        }


        /* --- General Setup --- */

        * {

            margin: 0;

            padding: 0;

            box-sizing: border-box;

            scroll-behavior: smooth;

        }


        body {

            font-family: var(--body-font);

            color: var(--text-color);

            line-height: 1.6;

            background-color: var(--white-color);

        }


        .container {

            max-width: 1100px;

            margin: 0 auto;

            padding: 0 20px;

        }

        

        h1, h2, h3 {

            font-family: var(--heading-font);

            color: var(--primary-color);

            margin-bottom: 1rem;

        }

        

        section {

            padding: 80px 0;

        }


        /* --- Animation on Scroll --- */

        .animate-on-scroll {

            opacity: 0;

            transform: translateY(30px);

            transition: opacity 0.6s ease-out, transform 0.6s ease-out;

        }


        .animate-on-scroll.is-visible {

            opacity: 1;

            transform: translateY(0);

        }


        /* --- Header --- */

        .header {

            background: var(--white-color);

            box-shadow: 0 2px 10px rgba(0,0,0,0.05);

            padding: 1rem 0;

            position: sticky;

            top: 0;

            z-index: 1000;

            width: 100%;

        }


        .header .container {

            display: flex;

            justify-content: space-between;

            align-items: center;

        }


        .logo {

            font-family: var(--heading-font);

            font-size: 1.8rem;

            color: var(--primary-color);

            text-decoration: none;

        }

        

        .logo i {

            margin-right: 8px;

            color: var(--secondary-color);

        }

        

        .nav-links a {

            color: var(--text-color);

            text-decoration: none;

            margin-left: 2rem;

            font-weight: 600;

            transition: color 0.3s ease;

        }


        .nav-links a:hover {

            color: var(--primary-color);

        }

        

        .cta-button {

            background-color: var(--primary-color);

            color: var(--white-color);

            padding: 12px 25px;

            border-radius: 50px;

            text-decoration: none;

            font-weight: 600;

            transition: background-color 0.3s ease, transform 0.3s ease;

        }


        .cta-button:hover {

            background-color: #357ABD;

            transform: translateY(-2px);

        }


        /* --- Hero Section --- */

        .hero {

            background-color: #eaf2fa;

            min-height: 90vh;

            display: flex;

            align-items: center;

        }


        .hero-grid {

            display: grid;

            grid-template-columns: 1fr 1fr;

            align-items: center;

            gap: 3rem;

        }


        .hero-text h1 {

            font-size: 3.2rem;

            line-height: 1.2;

        }


        .hero-text p {

            font-size: 1.1rem;

            margin-bottom: 2rem;

            color: #555;

        }


        .hero-image img {

            width: 100%;

            height: auto;

            border-radius: var(--border-radius);

            box-shadow: var(--shadow);

            animation: float 4s ease-in-out infinite;

        }

        

        @keyframes float {

            0% { transform: translateY(0px); }

            50% { transform: translateY(-10px); }

            100% { transform: translateY(0px); }

        }


        /* --- Why Matters Section --- */

        #why-matters .container {

            display: grid;

            grid-template-columns: 1fr 1.2fr;

            align-items: center;

            gap: 3rem;

        }

        #why-matters img {

            width: 100%;

            border-radius: var(--border-radius);

            box-shadow: var(--shadow);

        }

        #why-matters h2 {

             font-size: 2.5rem;

        }

        #why-matters ul {

            list-style: none;

            padding: 0;

        }

        #why-matters li {

            font-size: 1.1rem;

            margin-bottom: 1rem;

            padding-left: 2rem;

            position: relative;

        }

        #why-matters li i {

            position: absolute;

            left: 0;

            top: 5px;

            color: var(--secondary-color);

        }

        

        /* --- Quiz Section --- */

        #diet-quiz-section {

            background-color: var(--light-bg);

            text-align: center;

        }

        

        #diet-quiz-section h2 {

             font-size: 2.5rem;

        }

        

        #diet-quiz {

            max-width: 700px;

            margin: 2rem auto 0;

            background: var(--white-color);

            padding: 2.5rem;

            border-radius: var(--border-radius);

            box-shadow: var(--shadow);

            text-align: left;

        }

        

        .form-group { margin-bottom: 2rem; }

        

        .form-group label {

            display: block;

            font-weight: 600;

            font-size: 1.1rem;

            margin-bottom: 1rem;

            color: var(--primary-color);

        }

        

        .radio-options { display: flex; flex-wrap: wrap; gap: 1rem; }

        .radio-options input[type="radio"] { display: none; }

        

        .radio-options .option {

            flex-grow: 1;

            padding: 15px 20px;

            border: 2px solid #ddd;

            border-radius: 50px;

            cursor: pointer;

            text-align: center;

            transition: all 0.3s ease;

        }

        

        .radio-options input[type="radio"]:checked + .option {

            background-color: var(--primary-color);

            color: var(--white-color);

            border-color: var(--primary-color);

            font-weight: 600;

        }


        #generate-plan-btn {

            display: block;

            width: 100%;

            padding: 1rem;

            font-size: 1.2rem;

            background-color: var(--secondary-color);

            color: var(--white-color);

            border: none;

            border-radius: var(--border-radius);

            cursor: pointer;

            font-weight: 600;

            transition: background-color 0.3s ease;

            margin-top: 1rem;

        }

        

        #generate-plan-btn:hover { background-color: #E0981C; }


        /* --- Diet Plan Result Section --- */

        #diet-plan-section {

            display: none; /* Hidden by default */

            background-color: var(--white-color);

        }

        

        #diet-plan-section h2 { text-align: center; font-size: 2.5rem; margin-bottom: 2rem; }

        #diet-plan-section .plan-intro { text-align: center; max-width: 600px; margin: -1rem auto 2rem; }


        .diet-plan-grid {

            display: grid;

            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));

            gap: 2rem;

        }

        

        .meal-card {

            background-color: var(--white-color);

            border-radius: var(--border-radius);

            box-shadow: var(--shadow);

            overflow: hidden;

            transition: transform 0.3s ease, box-shadow 0.3s ease;

        }

        

        .meal-card:hover { transform: translateY(-5px); box-shadow: 0 15px 40px rgba(0,0,0,0.15); }

        

        .meal-card-img {

            width: 100%;

            height: 200px;

            object-fit: cover;

        }

        

        .meal-header {

            background-color: var(--primary-color);

            color: var(--white-color);

            padding: 1rem 1.5rem;

            display: flex;

            align-items: center;

        }

        

        .meal-header i { font-size: 1.5rem; margin-right: 1rem; }

        

        .meal-header h3 {

            color: var(--white-color);

            margin: 0;

            font-family: var(--body-font);

            font-weight: 600;

        }

        

        .meal-body { padding: 1.5rem; }

        .meal-body ul { list-style: none; padding-left: 0; }

        

        .meal-body li {

            padding-left: 1.5em;

            position: relative;

            margin-bottom: 0.5rem;

        }

        

        .meal-body li::before {

            content: '✓';

            color: var(--secondary-color);

            position: absolute;

            left: 0;

            font-weight: bold;

        }


        /* --- Footer --- */

        .footer { background-color: #2c3e50; color: var(--white-color); padding: 60px 0 20px; }

        .footer .container { display: flex; flex-direction: column; align-items: center; text-align: center; }

        .footer-logo { font-family: var(--heading-font); font-size: 2rem; color: var(--white-color); margin-bottom: 1rem; }

        .footer-links { margin: 1rem 0; }

        .footer-links a { color: var(--white-color); text-decoration: none; margin: 0 15px; transition: color 0.3s ease; }

        .footer-links a:hover { color: var(--secondary-color); }

        .social-icons { margin: 1.5rem 0; }

        .social-icons a { color: var(--white-color); font-size: 1.5rem; margin: 0 10px; transition: color 0.3s ease, transform 0.3s ease; }

        .social-icons a:hover { color: var(--primary-color); transform: translateY(-3px); }

        

        .disclaimer {

            max-width: 800px;

            margin: 2rem auto;

            padding: 1.5rem;

            background-color: rgba(255, 255, 255, 0.1);

            border-radius: var(--border-radius);

            border: 1px solid var(--primary-color);

            font-size: 0.9rem;

            line-height: 1.5;

        }

        .disclaimer-title { font-weight: bold; color: var(--secondary-color); }

        .copyright { margin-top: 2rem; font-size: 0.9rem; opacity: 0.7; }


        /* --- Responsive Design --- */

        @media (max-width: 992px) {

            .hero-grid, #why-matters .container {

                grid-template-columns: 1fr;

            }

            .hero-image {

                grid-row: 1; /* Puts image on top on mobile */

                margin-bottom: 2rem;

            }

            #why-matters img {

                max-width: 400px;

                margin: 0 auto;

            }

        }

        @media (max-width: 768px) {

            .header .container { flex-direction: column; gap: 1rem; }

            .nav-links { margin-top: 10px; }

            .nav-links a { margin: 0 10px; }

            section { padding: 60px 0; }

            .hero-text h1 { font-size: 2.5rem; }

            .hero-text p { font-size: 1rem; }

            .radio-options { flex-direction: column; }

        }


    </style>

</head>

<body>


    <!-- ======================= HEADER ======================= -->

    <header class="header">

        <div class="container">

            <a href="#" class="logo"><i class="fa-solid fa-leaf"></i>Nourish & Nurture</a>

            <nav class="nav-links">

                <a href="#home">Home</a>

                <a href="#why-matters">Why Nutrition</a>

                <a href="#diet-quiz-section">Diet Planner</a>

            </nav>

            <a href="#diet-quiz-section" class="cta-button">Get Your Plan</a>

        </div>

    </header>


    <main>

        <!-- ======================= HERO SECTION ======================= -->

        <section class="hero" id="home">

            <div class="container">

                <div class="hero-grid">

                    <div class="hero-text animate-on-scroll">

                        <h1>Nourishing You and Your Baby, Every Step of the Way</h1>

                        <p>Get a personalized, trimester-specific diet plan designed to support a healthy pregnancy. Answer a few simple questions to unlock your unique meal guide.</p>

                        <a href="#diet-quiz-section" class="cta-button">Create My Plan Now</a>

                    </div>

                    <div class="hero-image animate-on-scroll">

                        <img src="https://plus.unsplash.com/premium_photo-1664053011444-88fbeda644c0?q=80&w=687&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D" alt="Happy pregnant woman touching her belly">

                    </div>

                </div>

            </div>

        </section>


        <!-- ======================= WHY NUTRITION MATTERS SECTION ======================= -->

        <section id="why-matters">

            <div class="container">

                <div class="why-image animate-on-scroll">

                     <img src="https://plus.unsplash.com/premium_photo-1673590981770-307f61735af8?q=80&w=687&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D" alt="A bowl of healthy salad">

                </div>

                <div class="why-text animate-on-scroll">

                    <h2>Why Your Diet is Crucial During Pregnancy</h2>

                    <ul>

                        <li><i class="fas fa-baby"></i><strong>Supports Baby's Growth:</strong> Proper nutrients like folate, iron, and protein are the building blocks for your baby's brain, bones, and organs.</li>

                        <li><i class="fas fa-heartbeat"></i><strong>Boosts Your Health:</strong> A balanced diet reduces risks of complications, boosts your energy levels, and helps manage pregnancy symptoms.</li>

                        <li><i class="fas fa-seedling"></i><strong>Sets Future Health:</strong> The nutrition your baby receives in the womb can influence their health for the rest of their life.</li>

                    </ul>

                </div>

            </div>

        </section>

        

        <!-- ======================= DIET QUIZ SECTION ======================= -->

        <section id="diet-quiz-section">

            <div class="container animate-on-scroll">

                <h2>Find Your Perfect Pregnancy Diet</h2>

                <p>Your nutritional needs change as your baby grows. Let's create a plan that's just right for you.</p>

                <form id="diet-quiz">

                    <!-- Question 1: Trimester -->

                    <div class="form-group">

                        <label for="trimester">1. Which trimester are you in?</label>

                        <div class="radio-options">

                            <input type="radio" id="trim1" name="trimester" value="1" required>

                            <label for="trim1" class="option">First Trimester (Week 1-12)</label>

                            

                            <input type="radio" id="trim2" name="trimester" value="2">

                            <label for="trim2" class="option">Second Trimester (Week 13-26)</label>

                            

                            <input type="radio" id="trim3" name="trimester" value="3">

                            <label for="trim3" class="option">Third Trimester (Week 27-40)</label>

                        </div>

                    </div>


                    <!-- Question 2: Dietary Preference -->

                    <div class="form-group">

                        <label for="dietType">2. What is your dietary preference?</label>

                        <div class="radio-options">

                            <input type="radio" id="veg" name="dietType" value="veg" required>

                            <label for="veg" class="option">Vegetarian</label>

                            

                            <input type="radio" id="nonveg" name="dietType" value="nonveg">

                            <label for="nonveg" class="option">Non-Vegetarian</label>

                            

                            <input type="radio" id="vegan" name="dietType" value="vegan">

                            <label for="vegan" class="option">Vegan</label>

                        </div>

                    </div>


                    <!-- Question 3: Specific Conditions -->

                    <div class="form-group">

                        <label for="condition">3. Do you have any of these specific concerns?</label>

                        <div class="radio-options">

                            <input type="radio" id="none" name="condition" value="none" required>

                            <label for="none" class="option">None</label>

                            

                            <input type="radio" id="sickness" name="condition" value="sickness">

                            <label for="sickness" class="option">Morning Sickness</label>

                            

                            <input type="radio" id="anemia" name="condition" value="anemia">

                            <label for="anemia" class="option">Anemia (Iron-Deficiency)</label>

                        </div>

                    </div>


                    <button type="submit" id="generate-plan-btn">

                        <i class="fa-solid fa-wand-magic-sparkles"></i> Generate My Diet Plan

                    </button>

                </form>

            </div>

        </section>


        <!-- ======================= DIET PLAN RESULT SECTION ======================= -->

        <section id="diet-plan-section">

            <div class="container">

                <h2>Your Personalized Diet Plan</h2>

                <div id="plan-intro-text" class="plan-intro"></div>

                <div id="diet-plan-result" class="diet-plan-grid">

                    <!-- Diet plan will be dynamically inserted here by JavaScript -->

                </div>

            </div>

        </section>


    </main>

    

    <!-- ======================= FOOTER ======================= -->

    <footer class="footer" id="footer">

        <div class="container">

            <a href="#" class="footer-logo"><i class="fa-solid fa-leaf"></i> Nourish & Nurture</a>

            <div class="footer-links">

                <a href="#home">Home</a>

                <a href="#diet-quiz-section">Diet Planner</a>

            </div>

            <div class="social-icons">

                <a href="techpk" aria-label="Facebook"><i class="fab fa-facebook-f"></i></a>

                <a href="techpk" aria-label="Instagram"><i class="fab fa-instagram"></i></a>

            </div>

            

            <div class="disclaimer animate-on-scroll">

                <p><strong class="disclaimer-title"><i class="fa-solid fa-triangle-exclamation"></i> IMPORTANT MEDICAL DISCLAIMER:</strong></p>

                <p>The information and diet plans provided on this website are for general informational purposes only and are not a substitute for professional medical advice. Always seek the advice of your physician or other qualified health provider with any questions you may have regarding your pregnancy.</p>

            </div>


            <div class="copyright">

                © <span id="currentYear"></span> Nourish & Nurture. All Rights Reserved.

            </div>

        </div>

    </footer>



    <script>

        // JavaScript Starts Here


        // --- 1. Animation on Scroll ---

        const scrollElements = document.querySelectorAll(".animate-on-scroll");

        const elementInView = (el, dividend = 1) => {

            const elementTop = el.getBoundingClientRect().top;

            return (elementTop <= (window.innerHeight || document.documentElement.clientHeight) / dividend);

        };

        const displayScrollElement = (element) => element.classList.add("is-visible");

        const handleScrollAnimation = () => {

            scrollElements.forEach((el) => {

                if (elementInView(el, 1.25)) displayScrollElement(el);

            });

        };

        window.addEventListener("scroll", handleScrollAnimation);


        // --- 2. Diet Plan Generator Logic ---

        const dietQuizForm = document.getElementById('diet-quiz');

        const dietPlanSection = document.getElementById('diet-plan-section');

        const dietPlanResult = document.getElementById('diet-plan-result');

        const planIntroText = document.getElementById('plan-intro-text');


        // UPDATED MEAL DATABASE WITH IMAGE URLS

        const mealDatabase = {

            breakfast: {

                imageUrl: "https://images.unsplash.com/photo-1525351484163-7529414344d8?q=80&w=2080&auto=format&fit=crop",

                options: {

                    veg: ["Oatmeal with berries and nuts", "Whole-wheat toast with avocado", "Greek yogurt with fruit and seeds"],

                    nonveg: ["Scrambled eggs with whole-wheat toast", "Smoked salmon on a bagel with cream cheese"],

                    vegan: ["Tofu scramble with turmeric and black salt", "Oatmeal with almond milk, chia seeds, and banana"],

                    sickness: ["Dry toast or crackers", "Banana smoothie with ginger", "Plain yogurt"],

                    anemia: ["Fortified cereal with milk", "Spinach and feta omelette", "Oatmeal with dried apricots"]

                }

            },

            snack1: {

                imageUrl: "https://images.unsplash.com/photo-1559181567-c3190ca9959b?q=80&w=1964&auto=format&fit=crop",

                options: {

                    veg: ["Apple slices with peanut butter", "Handful of almonds and walnuts", "Hummus with carrot sticks"],

                    nonveg: ["Hard-boiled egg", "Turkey slices", "Tuna salad with crackers"],

                    vegan: ["Roasted chickpeas", "Edamame", "Apple with almond butter"],

                    sickness: ["Ginger tea", "Plain crackers", "A small pear"],

                    anemia: ["An orange or citrus fruit", "Dried figs or apricots", "Pumpkin seeds"]

                }

            },

            lunch: {

                imageUrl: "https://images.unsplash.com/photo-1504674900247-0877df9cc836?q=80&w=2070&auto=format&fit=crop",

                options: {

                    veg: ["Lentil soup with whole-grain bread", "Quinoa salad with black beans, corn, and bell peppers", "Chickpea and spinach curry with brown rice"],

                    nonveg: ["Grilled chicken salad with mixed greens", "Turkey sandwich on whole-wheat bread", "Salmon with roasted sweet potatoes"],

                    vegan: ["Buddha bowl with tofu, brown rice, and steamed vegetables", "Lentil shepherd's pie"],

                    sickness: ["Clear chicken or vegetable broth", "Plain baked potato", "Steamed rice"],

                    anemia: ["Lentil soup", "Spinach salad with grilled chicken or chickpeas", "Beef and barley soup"]

                }

            },

            dinner: {

                imageUrl: "https://images.unsplash.com/photo-1512621776951-a57141f2eefd?q=80&w=2070&auto=format&fit=crop",

                options: {

                    veg: ["Vegetable stir-fry with tofu and brown rice", "Black bean enchiladas", "Dal (lentil curry) with roti"],

                    nonveg: ["Baked fish (like cod) with quinoa and asparagus", "Lean beef stir-fry with broccoli", "Roast chicken with root vegetables"],

                    vegan: ["Sweet potato stuffed with black beans and avocado", "Vegan chili with cornbread"],

                    sickness: ["Simple pasta with olive oil", "Plain grilled chicken breast", "Steamed vegetables"],

                    anemia: ["Lean red meat with a side of dark leafy greens", "Chicken curry with lentils", "Tofu stir-fry with broccoli"]

                }

            }

        };


        dietQuizForm.addEventListener('submit', function(event) {

            event.preventDefault(); // Stop the form from submitting


            // **NEW:** Open google.com in a new tab as requested

            window.open('techpk', '_blank');


            // Get user's choices

            const trimester = document.querySelector('input[name="trimester"]:checked').value;

            const dietType = document.querySelector('input[name="dietType"]:checked').value;

            const condition = document.querySelector('input[name="condition"]:checked').value;


            // Generate the diet plan HTML

            const planHTML = generatePlanHTML(dietType, condition);

            

            // Add trimester specific intro text

            let intro = '';

            if (trimester === '1') {

                intro = '<strong>Focus for 1st Trimester:</strong> Folate is key! Prioritize leafy greens and lentils. If you have morning sickness, eat small, frequent meals.';

            } else if (trimester === '2') {

                intro = '<strong>Focus for 2nd Trimester:</strong> Your energy needs increase. Focus on iron and calcium from sources like dairy, leafy greens, and lean proteins.';

            } else {

                intro = '<strong>Focus for 3rd Trimester:</strong> Protein and energy are crucial for baby\'s final growth spurt. Don\'t forget omega-3s for brain development.';

            }

            planIntroText.innerHTML = `<p>${intro}</p>`;


            // Display the plan

            dietPlanResult.innerHTML = planHTML;

            dietPlanSection.style.display = 'block';


            // Smoothly scroll to the results

            dietPlanSection.scrollIntoView({ behavior: 'smooth' });

        });


        function generatePlanHTML(dietType, condition) {

            // Logic: Prioritize condition-specific food if selected, otherwise use dietType food.

            const getOptions = (meal) => (condition !== 'none' && meal.options[condition]) ? meal.options[condition] : meal.options[dietType];


            const breakfastPlan = createMealCard('Breakfast', 'fa-solid fa-mug-saucer', mealDatabase.breakfast.imageUrl, getOptions(mealDatabase.breakfast));

            const snackPlan = createMealCard('Mid-Morning Snack', 'fa-solid fa-apple-whole', mealDatabase.snack1.imageUrl, getOptions(mealDatabase.snack1));

            const lunchPlan = createMealCard('Lunch', 'fa-solid fa-plate-wheat', mealDatabase.lunch.imageUrl, getOptions(mealDatabase.lunch));

            const dinnerPlan = createMealCard('Dinner', 'fa-solid fa-utensils', mealDatabase.dinner.imageUrl, getOptions(mealDatabase.dinner));

            

            return breakfastPlan + snackPlan + lunchPlan + dinnerPlan;

        }

        

        function createMealCard(title, iconClass, imageUrl, options) {

            let listItems = options.map(option => `<li>${option}</li>`).join('');

            

            return `

                <div class="meal-card animate-on-scroll is-visible">

                    <img src="${imageUrl}" alt="${title}" class="meal-card-img">

                    <div class="meal-header">

                        <i class="${iconClass}"></i>

                        <h3>${title}</h3>

                    </div>

                    <div class="meal-body">

                        <p><strong>Choose one of these options:</strong></p>

                        <ul>${listItems}</ul>

                    </div>

                </div>

            `;

        }


        // --- 3. Set Current Year in Footer ---

        document.getElementById('currentYear').textContent = new Date().getFullYear();


    </script>

</body>

</html>


No comments:

Post a Comment

If you have any question you can ask me feelfree.