// === GRAMMAR LESSON: 了 ASPECT PARTICLE ===
// Dedicated grammar course focused on the 了 particle in Chinese

window.ContentModules = window.ContentModules || {};

window.ContentModules.GrammarLessonLe = {
    id: "grammar-lesson-le",
    name: "Grammar Lesson: 了 (le) Aspect Particle",
    description: "Complete lesson on the Chinese aspect particle 了 - completion and change of state",
    difficulty: "intermediate",
    language: "zh-CN",
    type: "grammar_course",

    // === MAIN GRAMMAR LESSON ===
    grammar: {
        "le-aspect-particle": {
            title: "The 了 (le) Aspect Particle - 动态助词了",
            explanation: "了 is one of the most important particles in Chinese. It indicates completion of an action or a change of state. Unlike English past tense, 了 focuses on the aspect (how the action is viewed) rather than when it happened.",

            mainRules: [
                "了 shows that an action has been completed",
                "了 indicates a change from one state to another",
                "了 can appear after the verb (了1) or at the end of sentence (了2)",
                "了 does NOT simply mean 'past tense' - it's about completion/change"
            ],

            detailedExplanation: {
                "completion": {
                    title: "1. Completion of Action (动作完成)",
                    explanation: "了 after a verb shows the action has been completed",
                    pattern: "Subject + Verb + 了 + Object",
                    examples: [
                        {
                            chinese: "我吃了饭",
                            english: "I ate (have eaten) the meal",
                            pronunciation: "wǒ chī le fàn",
                            breakdown: "我(I) + 吃(eat) + 了(completed) + 饭(meal)",
                            explanation: "The eating action is completed"
                        },
                        {
                            chinese: "他买了一本书",
                            english: "He bought a book",
                            pronunciation: "tā mǎi le yì běn shū",
                            breakdown: "他(he) + 买(buy) + 了(completed) + 一本书(a book)",
                            explanation: "The buying action is finished"
                        },
                        {
                            chinese: "老师讲了三个故事",
                            english: "The teacher told three stories",
                            pronunciation: "lǎo shī jiǎng le sān gè gù shì",
                            breakdown: "老师(teacher) + 讲(tell) + 了(completed) + 三个故事(three stories)",
                            explanation: "The telling action is complete"
                        }
                    ]
                },

                "change-of-state": {
                    title: "2. Change of State (状态变化)",
                    explanation: "了 at the end of a sentence shows a change in situation or state",
                    pattern: "Subject + Verb + Object + 了",
                    examples: [
                        {
                            chinese: "天黑了",
                            english: "It has gotten dark / It's dark now",
                            pronunciation: "tiān hēi le",
                            breakdown: "天(sky) + 黑(dark) + 了(change of state)",
                            explanation: "Change from light to dark"
                        },
                        {
                            chinese: "我饿了",
                            english: "I'm hungry now / I've become hungry",
                            pronunciation: "wǒ è le",
                            breakdown: "我(I) + 饿(hungry) + 了(change of state)",
                            explanation: "Change from not hungry to hungry"
                        },
                        {
                            chinese: "下雨了",
                            english: "It's raining now / It started to rain",
                            pronunciation: "xià yǔ le",
                            breakdown: "下雨(rain) + 了(change of state)",
                            explanation: "Change from not raining to raining"
                        }
                    ]
                },

                "double-le": {
                    title: "3. Double 了 Construction",
                    explanation: "Sometimes 了 appears both after the verb AND at the end of sentence",
                    pattern: "Subject + Verb + 了 + Object + 了",
                    examples: [
                        {
                            chinese: "我买了三本书了",
                            english: "I have bought three books (and the situation has changed)",
                            pronunciation: "wǒ mǎi le sān běn shū le",
                            breakdown: "我 + 买了(completed buying) + 三本书 + 了(new situation)",
                            explanation: "Action completed AND situation changed"
                        },
                        {
                            chinese: "他吃了两个苹果了",
                            english: "He has eaten two apples (and is now full/satisfied)",
                            pronunciation: "tā chī le liǎng gè píng guǒ le",
                            breakdown: "他 + 吃了(completed eating) + 两个苹果 + 了(new state)",
                            explanation: "Eating completed AND state changed"
                        }
                    ]
                }
            },

            commonMistakes: [
                {
                    mistake: "Using 了 for all past actions",
                    wrong: "我昨天了去学校",
                    correct: "我昨天去了学校 / 我昨天去学校",
                    explanation: "了 shows completion, not just past time. Don't add 了 randomly to past time expressions."
                },
                {
                    mistake: "Forgetting 了 for completed actions",
                    wrong: "我吃饭，现在很饱",
                    correct: "我吃了饭，现在很饱",
                    explanation: "Need 了 to show the eating is completed before being full"
                },
                {
                    mistake: "Using 了 with ongoing actions",
                    wrong: "我正在吃了饭",
                    correct: "我正在吃饭",
                    explanation: "Can't use 了 with 正在 (ongoing) - they're contradictory"
                }
            ],

            practicePoints: [
                "Ask yourself: Is the action completed? Use 了 after verb",
                "Ask yourself: Has the situation changed? Use 了 at end",
                "Remember: 了 ≠ past tense. It's about completion/change",
                "Pay attention to context - sometimes 了 is not needed even for past actions"
            ]
        }
    },

    // === VOCABULARY FOR THE LESSON ===
    vocabulary: {
        "了": {
            translation: "aspect particle (completion/change)",
            type: "particle",
            pronunciation: "le",
            usage: "Shows completed action or change of state"
        },
        "吃": {
            translation: "to eat",
            type: "verb",
            pronunciation: "chī"
        },
        "买": {
            translation: "to buy",
            type: "verb",
            pronunciation: "mǎi"
        },
        "讲": {
            translation: "to tell/speak",
            type: "verb",
            pronunciation: "jiǎng"
        },
        "饭": {
            translation: "meal/food",
            type: "noun",
            pronunciation: "fàn"
        },
        "书": {
            translation: "book",
            type: "noun",
            pronunciation: "shū"
        },
        "故事": {
            translation: "story",
            type: "noun",
            pronunciation: "gù shì"
        },
        "天": {
            translation: "sky/day",
            type: "noun",
            pronunciation: "tiān"
        },
        "黑": {
            translation: "dark/black",
            type: "adjective",
            pronunciation: "hēi"
        },
        "饿": {
            translation: "hungry",
            type: "adjective",
            pronunciation: "è"
        },
        "下雨": {
            translation: "to rain",
            type: "verb",
            pronunciation: "xià yǔ"
        }
    },

    // === FILL IN THE BLANKS EXERCISES ===
    fillInBlanks: [
        {
            sentence: "我吃___饭，现在很饱",
            options: ["了", "的", "在", "着"],
            correctAnswer: "了",
            explanation: "Use 了 to show the eating action is completed before being full",
            grammarFocus: "completion"
        },
        {
            sentence: "天黑___，我们回家吧",
            options: ["了", "的", "在", "着"],
            correctAnswer: "了",
            explanation: "Use 了 to show change of state - it has become dark",
            grammarFocus: "change-of-state"
        },
        {
            sentence: "他买___三本书___",
            options: ["了...了", "的...的", "在...在", "着...着"],
            correctAnswer: "了...了",
            explanation: "Double 了: action completed (买了) AND situation changed (了)",
            grammarFocus: "double-le"
        },
        {
            sentence: "我昨天___学校",
            options: ["去了", "了去", "去的", "的去"],
            correctAnswer: "去了",
            explanation: "了 comes after the verb to show completed action",
            grammarFocus: "word-order"
        },
        {
            sentence: "下雨___，路很湿",
            options: ["了", "的", "在", "着"],
            correctAnswer: "了",
            explanation: "Change of state: it has started raining (wasn't raining before)",
            grammarFocus: "change-of-state"
        }
    ],

    // === CORRECTION EXERCISES ===
    corrections: [
        {
            incorrect: "我昨天了去学校",
            correct: "我昨天去了学校",
            explanation: "了 should come after the verb, not before it",
            grammarFocus: "word-order"
        },
        {
            incorrect: "我正在吃了饭",
            correct: "我正在吃饭",
            explanation: "Cannot use 了 (completion) with 正在 (ongoing action)",
            grammarFocus: "aspect-conflict"
        },
        {
            incorrect: "我吃饭，现在很饱",
            correct: "我吃了饭，现在很饱",
            explanation: "Need 了 to show eating is completed before the result (being full)",
            grammarFocus: "completion"
        },
        {
            incorrect: "他很高了的人",
            correct: "他是很高的人",
            explanation: "Don't use 了 in descriptions with 的. 了 is for actions/changes, not permanent descriptions",
            grammarFocus: "inappropriate-usage"
        }
    ],

    // === TRANSLATION EXERCISES ===
    sentences: [
        {
            english: "I finished my homework",
            chinese: "我做完了作业",
            pronunciation: "wǒ zuò wán le zuò yè",
            grammarFocus: "completion"
        },
        {
            english: "It's gotten cold",
            chinese: "天气冷了",
            pronunciation: "tiān qì lěng le",
            grammarFocus: "change-of-state"
        },
        {
            english: "He bought two books and now has them",
            chinese: "他买了两本书了",
            pronunciation: "tā mǎi le liǎng běn shū le",
            grammarFocus: "double-le"
        },
        {
            english: "The teacher finished the lesson",
            chinese: "老师讲完了课",
            pronunciation: "lǎo shī jiǎng wán le kè",
            grammarFocus: "completion"
        }
    ]
};