#!/usr/bin/env python3
"""
Week 10 - Suffixes: -ED, -ING, -S, -ES

Add endings to change verb tense and make plurals.
Grammar: Subject-verb agreement (he runs, they run)
"""
import os, sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from monday_wp import generate_monday
from tuesday_wp import generate_tuesday
from wednesday_wp import generate_wednesday
from thursday_wp import generate_thursday
from friday_wp import generate_friday
from teacher_guide import generate_teacher_guide

week_dir = os.path.join(os.path.dirname(__file__))
week_num = 10
topic_label = "Suffixes: -ED, -ING, -S, -ES"

# ─── Word List (12 words) ─────────────────────────────────────────────────────
words = [
    ("played",    "play + ed",   "past tense β€” did the action before"),
    ("running",   "run + ning",  "happening now β€” moving fast on foot"),
    ("jumps",     "jump + s",    "he/she/it jumps β€” does it every time"),
    ("watches",   "watch + es",  "he/she/it watches β€” looks carefully"),
    ("walked",    "walk + ed",   "past tense β€” moved on foot before"),
    ("swimming",  "swim + mming", "happening now β€” moving in water"),
    ("kicks",     "kick + s",    "he/she/it kicks β€” hits with foot"),
    ("dances",    "dance + es",  "he/she/it dances β€” moves to music"),
    ("jumped",    "jump + ed",   "past tense β€” leaped before"),
    ("singing",   "sing + ing",  "happening now β€” making music with voice"),
    ("brushes",   "brush + es",  "he/she/it brushes β€” cleans with a brush"),
    ("painted",   "paint + ed",  "past tense β€” used color before"),
]

WORD_NAMES = [w[0] for w in words]

# ─── Suffix Examples ──────────────────────────────────────────────────────────
suffix_examples = [
    "-ed = past tense (played = did it before)",
    "-ing = happening now (running = doing it right now)",
    "-s = he/she/it (jumps = he jumps)",
    "-es = he/she/it with sh/ch (watches = he watches)",
    "Watch spelling rules: run β†’ running (double n), swim β†’ swimming (double m)",
    "Suffixes go at the END of words β€” not the beginning!",
]

# ─── Learning Text ────────────────────────────────────────────────────────────
learning_text = (
    "A <strong>suffix</strong> is a group of letters added to the <strong>end</strong> of a word "
    "to change its meaning. This week we are learning four suffixes: "
    "<strong>-ed</strong> (means 'past β€” did it before'), <strong>-ing</strong> (means 'happening now'), "
    "<strong>-s</strong> (for he/she/it), and <strong>-es</strong> (for he/she/it with words ending in sh or ch)."
)

# ─── MONDAY DATA ──────────────────────────────────────────────────────────────
MONDAY_STORY = (
    'On Saturday morning, Leo <strong>played</strong> outside with his friends. '\
    'They were <strong>running</strong> around the park when Leo saw a frog. '\
    'The frog <strong>jumps</strong> into a puddle every time it sees someone. '\
    'Leo <strong>watches</strong> the frog carefully. '\
    'Yesterday, they <strong>walked</strong> to the same park together. '\
    'Now their friend Mia is <strong>swimming</strong> in the pool at home. '\
    'Her dog <strong>kicks</strong> sand whenever it digs a hole. '\
    'At the party, everyone <strong>dances</strong> to music. '\
    'Last week, Leo <strong>jumped</strong> over a big puddle. '\
    'His sister loves <strong>singing</strong> songs at school. '\
    'She <strong>brushes</strong> her hair before every show. '\
    'Last summer, they <strong>painted</strong> a mural on the wall.'
)

monday_sort_labels = ["-ed", "-ing", "-s/-es"]

monday_fill_data = [
    ("They __________ soccer yesterday.", "played"),
    ("She is __________ to the store right now.", "running"),
    ("My cat __________ on the bed every morning.", "jumps"),
    ("He __________ TV after dinner.", "watches"),
    ("We __________ to school yesterday.", "walked"),
    ("The kids are __________ in the pool.", "swimming"),
    ("The dog __________ the ball away.", "kicks"),
    ("She __________ at every party.", "dances"),
]

monday_opposite_words = [
    "played", "running", "jumps", "watches", "swimming", "kicks"
]

monday_sentence_words = WORD_NAMES[:8]

monday_add_suffix_data = [
    ("play",    "-ed",  "played"),
    ("run",     "-ing", "running"),
    ("jump",    "-s",   "jumps"),
    ("watch",   "-es",  "watches"),
    ("walk",    "-ed",  "walked"),
    ("swim",    "-ing", "swimming"),
    ("kick",    "-s",   "kicks"),
    ("dance",   "-es",  "dances"),
]

grammar_note = "Grammar Focus: <strong>Subject-Verb Agreement</strong> β€” he/she/it gets -s or -es, but I/you/we/they do not."

grammar_deep = (
    "When the subject is <strong>he, she, or it</strong>, we add -s or -es to the verb. "
    "Example: 'He <strong>jumps</strong>.' 'She <strong>watches</strong>.' "
    "But with <strong>I, you, we, they</strong>, we don't add -s: 'They jump.' 'We watch.'"
)

grammar_practice = [
    "She (run/__________) to school every day.",
    "They (jump/__________) over the puddle.",
    "He (watch/__________) TV after lunch.",
    "We (play/__________) outside every afternoon.",
    "The dog (kick/__________) the ball.",
    "I (swim/__________) in the pool on weekends.",
]

# ─── TUESDAY DATA ─────────────────────────────────────────────────────────────
TUESDAY_READING = (
    'At the school talent show, everyone was <strong>singing</strong> and <strong>dancing</strong> on stage. '\
    'Last year, the school <strong>played</strong> a different show. '\
    'This year, Mia <strong>jumped</strong> over chairs while her friend <strong>watched</strong>. '\
    'The teacher said, "You <strong>brushes</strong> β€” wait, you all <strong>brush</strong> up on your lines!" '\
    'The actors had <strong>walked</strong> through the whole show already. '\
    'One boy was <strong>running</strong> late and <strong>kicked</strong> his shoes off in a hurry. '\
    'Someone was <strong>swimming</strong> in the big water balloon on stage. '\
    'The art class had <strong>painted</strong> the backdrop all by themselves. '\
    '"This show is the best!" said everyone.'
)

tuesday_comp_questions = [
    "What was everyone doing on stage?",
    "What did the school play last year?",
    "Why did the boy kick his shoes off?",
    "Who painted the backdrop?",
]

tuesday_word_part_examples = [
    "-ed at the end = PAST (played = did it before)",
    "-ing at the end = NOW (running = doing it right now)",
    "-s at the end = HE/SHE/IT (jumps = he jumps)",
    "-es at the end = HE/SHE/IT + sh/ch (watches = he watches)",
]

tuesday_word_part_hunt = {
    "match": ["played", "running", "jumps", "watches", "swimming", "singing"],
    "decoy": ["play", "run", "jump", "watch", "swim", "sing"],
}

tuesday_swap_data = [
    ("She play the piano.", ("play", "plays"), ("plays", "played")),
]

tuesday_builder_prompts = [
    ("Write about something you did yesterday.", "walked"),
    ("Write about something happening right now.", "singing"),
    ("Write about what your pet does every day.", "kicks"),
]

tuesday_remember_boxes = [
    ("Remember!", "A suffix goes at the END of a word. play-ed, run-ning, jump-s."),
    ("Spelling Tip!", "Short vowel + 1 consonant? Double it! run β†’ running, swim β†’ swimming."),
]

tuesday_identify_data = [
    ("played", "What is the suffix? What does it tell you?"),
    ("running",  "What is the suffix? What does it tell you?"),
    ("watches",  "What is the suffix? What does it tell you?"),
    ("singing",  "What is the suffix? What does it tell you?"),
]

# ─── WEDNESDAY DATA ───────────────────────────────────────────────────────────
WEDNESDAY_READING = (
    'Emma loves <strong>singing</strong> songs in the shower. '\
    'Her brother <strong>jumps</strong> on the bed every morning before school. '\
    'Yesterday, Emma <strong>played</strong> the piano for her whole family. '\
    'Her mom <strong>watches</strong> TV while she cooks dinner. '\
    'Last weekend, they <strong>walked</strong> to the park together. '\
    'Emma saw a boy <strong>swimming</strong> in the lake. '\
    'A dog <strong>kicked</strong> a stick into the water. '\
    'At the dance party, everyone <strong>dances</strong> to loud music. '\
    'Emma <strong>brushes</strong> her teeth twice a day. '\
    'Last summer, she <strong>painted</strong> her room pink. '\
    'Now she is <strong>running</strong> to catch the bus!'
)

wednesday_vocab_question = (
    'In the story, what does "played" mean?<br>'
    'A) Playing right now<br>'
    'B) Did the action in the past<br>'
    'C) Will play tomorrow<br>'
    'D) Never plays'
)

wednesday_syn_ant_words = [
    "played", "running", "jumps", "watches", "swimming", "singing"
]

wednesday_word_web_center = "suffix"
wednesday_word_web_instruction = "Write 4 words that end with -ed, -ing, -s, or -es."

wednesday_sentence_sort_data = [
    "The boy jumps on the trampoline",
    "They walked to the store",
    "She is swimming in the pool",
]

wednesday_correct_sentences = [
    "she sings in the choir every week",
    "they played basketball yesterday",
    "he watches cartoons on Saturday",
]

wednesday_fill_data = [
    ("Yesterday, we __________ a great game.", "played"),
    ("Look! The dog is __________ after the ball.", "running"),
    ("My little sister __________ rope every morning.", "jumps"),
    ("He __________ his favorite show on weekends.", "watches"),
    ("They are __________ in the river.", "swimming"),
]

wednesday_context_clue = (
    'Read this sentence: "The runner was <strong>running</strong> so fast that everyone cheered. '\
    'Sweat was on her face and her legs moved quickly." What does "running" tell you '\
    'about when this is happening?'
)

wednesday_learning_skills = [
    "Using context clues to find word meanings",
    "Identifying suffixes in reading",
    "Understanding how -ed, -ing, -s, and -es change word meaning"
]

wednesday_word_families = [
    ("play",   ["played", "playing"]),
    ("run",    ["running", "runs"]),
    ("jump",   ["jumps", "jumped"]),
    ("watch",  ["watches", "watched"]),
    ("swim",   ["swimming", "swam"]),
    ("sing",   ["singing", "sings"]),
]

# ─── THURSDAY DATA ────────────────────────────────────────────────────────────
THURSDAY_STORY = (
    'Detective Mia had to solve the case of the missing cake. '\
    'Someone <strong>played</strong> a trick on the baker. '\
    'The suspect was <strong>running</strong> away from the kitchen. '\
    '"He <strong>jumps</strong> over fences every day," said the witness. '\
    'Mia <strong>watches</strong> all the security cameras. '\
    'Last night, the thief <strong>walked</strong> past the front door. '\
    'Mia was <strong>swimming</strong> through clues like a detective fish. '\
    'The cat <strong>kicks</strong> everything it doesn\'t like. '\
    'The baker <strong>dances</strong> when the cakes come out of the oven. '\
    'Yesterday, someone <strong>jumped</strong> over the fence to steal it. '\
    'Mia\'s partner was <strong>singing</strong> a detective song while searching. '\
    'She <strong>brushes</strong> up on her clues every morning. '\
    'Last week, they <strong>painted</strong> a wanted poster for the cake thief.'
)

thursday_remember_text = (
    "Suffix -ed = PAST (played = did it before)\n"
    "Suffix -ing = NOW (running = doing it right now)\n"
    "Suffix -s = HE/SHE/IT (jumps = he jumps)\n"
    "Suffix -es = HE/SHE/IT with sh/ch (watches = he watches)\n"
    "Always look at the END of the word for the suffix!"
)

thursday_comp_questions = [
    "What case is Detective Mia solving?",
    "Who was running away from the kitchen?",
    "What does the baker do when cakes come out?",
    "What did they paint last week?",
]

thursday_sentence_sort_data = [
    "The dog kicks the ball every day",
    "They walked to the park yesterday",
    "She is swimming in the pool now",
]

thursday_detective_words = [
    "playd", "runnig", "jumpes", "watchs", "swimmin"
]

thursday_swap_data = [
    ("He run to the store.", ("run", "runs"), ("runs", "ran")),
]

thursday_map_word = "played"

thursday_para_prompts = [
    "Write about something you did yesterday. Use 2 spelling words with -ed.",
    "Write about what your family does every day. Use 2 spelling words with -s/-es.",
]

thursday_build_words = [
    ("walk",   "-ed",  "past tense"),
    ("sing",   "-ing", "happening now"),
    ("kick",   "-s",   "he/she/it"),
    ("brush",  "-es",  "he/she/it"),
    ("paint",  "-ed",  "past tense"),
]

thursday_story_prompt = "Write a story about a busy day. Use at least 5 spelling words with suffixes."

# ─── FRIDAY DATA ──────────────────────────────────────────────────────────────
FRIDAY_REVIEW_STORY = (
    'On the last day of Suffix Week, our class had a talent show. '\
    'Jake was <strong>singing</strong> a song about spelling. '\
    'Sarah <strong>danced</strong> to the music β€” she <strong>dances</strong> every day. '\
    'I had to <strong>walked</strong> β€” wait, I <strong>walked</strong> to the front of the room. '\
    'Our teacher <strong>watches</strong> everyone carefully. '\
    'Last week, we <strong>played</strong> a spelling game all morning. '\
    'The principal was <strong>running</strong> late but still came to watch. '\
    'No one <strong>jumps</strong> on tables β€” that is against the rules! '\
    'Yesterday, Leo <strong>jumped</strong> over three chairs at recess. '\
    'The art class had <strong>painted</strong> a big banner. '\
    'Everyone <strong>kicks</strong> their feet when they are excited. '\
    'Our teacher said we <strong>brushes</strong> β€” no, we <strong>brushed</strong> up on our suffixes! '\
    'The pool team was <strong>swimming</strong> laps during recess.'
)

friday_story_questions = [
    "What was Jake singing about?",
    "Who was running late?",
    "What did the art class paint?",
    "What did we brush up on?",
]

friday_opposite_words = [
    "played", "running", "jumps", "swimming", "singing", "painted"
]

friday_builder_words = [
    "jumped", "watches", "swimming", "singing", "dances"
]

friday_journal_words = [
    "played", "running", "jumps", "watches", "swimming", "singing"
]

# ─── Sort Answers for Monday ──────────────────────────────────────────────────
monday_sort_answers = {
    "-ed":    ["played", "walked", "jumped", "painted"],
    "-ing":   ["running", "swimming", "singing"],
    "-s/-es": ["jumps", "watches", "kicks", "dances", "brushes"],
}

# ══════════════════════════════════════════════════════════════════════════════
# GENERATE ALL DAYS
# ══════════════════════════════════════════════════════════════════════════════

print("=" * 60)
print("Week 10 - Suffixes: -ED, -ING, -S, -ES")
print("=" * 60)

# Remove old files
for day in ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Teacher_Guide"]:
    day_dir = os.path.join(week_dir, day)
    if os.path.exists(day_dir):
        for f in os.listdir(day_dir):
            if f.endswith('.pdf'):
                os.remove(os.path.join(day_dir, f))
                print(f"  Removed old: {day}/{f}")

# ── MONDAY ──
print("\n[Monday]...")
generate_monday(
    week_dir=week_dir,
    week_num=week_num,
    day_name="Monday",
    topic_label=topic_label,
    words=words,
    learning_text=learning_text,
    prefix_examples=suffix_examples,
    grammar_note=grammar_note,
    grammar_deep=grammar_deep,
    grammar_practice=grammar_practice,
    story_text=MONDAY_STORY,
    sort_labels=monday_sort_labels,
    sort_title="Suffix Sort",
    sort_instruction="Sort each word under the correct suffix: -ed, -ing, or -s/-es.",
    fill_data=monday_fill_data,
    opposite_words=monday_opposite_words,
    sentence_words=monday_sentence_words,
    add_prefix_data=monday_add_suffix_data,
    # Suffix-specific labels
    word_part_type="suffix",
    examples_title="Suffix Examples",
    add_word_part_title="Add the Suffix",
    add_word_part_note="Add the suffix to the base word to make a new word.",
    word_cards_note="Read each word. Notice the suffix and how it changes the meaning.",
    grammar_activity_title="Grammar: Subject-Verb Agreement",
    grammar_practice_title="Practice: Subject-Verb Agreement",
    grammar_practice_note="Choose the correct verb form for each sentence.",
)

# ── TUESDAY ──
print("\n[Tuesday]...")
generate_tuesday(
    week_dir=week_dir,
    week_num=week_num,
    day_name="Tuesday",
    topic_label=topic_label,
    words=words,
    learning_text=learning_text,
    word_part_examples=tuesday_word_part_examples,
    remember_boxes=tuesday_remember_boxes,
    reading_text=TUESDAY_READING,
    comp_questions=tuesday_comp_questions,
    word_part_hunt=tuesday_word_part_hunt,
    word_part_hunt_instruction="Check each word that contains a suffix: -ed, -ing, -s, or -es.",
    word_part_hunt_title="Suffix Hunt",
    swap_data=tuesday_swap_data,
    builder_prompts=tuesday_builder_prompts,
    identify_data=tuesday_identify_data,
)

# ── WEDNESDAY ──
print("\n[Wednesday]...")
generate_wednesday(
    week_dir=week_dir,
    week_num=week_num,
    day_name="Wednesday",
    topic_label=topic_label,
    words=words,
    learning_text=learning_text,
    learning_skills=wednesday_learning_skills,
    reading_passage=WEDNESDAY_READING,
    vocab_question=wednesday_vocab_question,
    syn_ant_words=wednesday_syn_ant_words,
    word_web_center=wednesday_word_web_center,
    word_web_instruction=wednesday_word_web_instruction,
    sentence_sort_data=wednesday_sentence_sort_data,
    correct_sentences=wednesday_correct_sentences,
    fill_data=wednesday_fill_data,
    context_clue=wednesday_context_clue,
    word_families=wednesday_word_families,
)

# ── THURSDAY ──
print("\n[Thursday]...")
generate_thursday(
    week_dir=week_dir,
    week_num=week_num,
    day_name="Thursday",
    topic_label=topic_label,
    words=words,
    learning_text=learning_text,
    remember_text=thursday_remember_text,
    story_text=THURSDAY_STORY,
    comp_questions=thursday_comp_questions,
    sentence_sort_data=thursday_sentence_sort_data,
    detective_words=thursday_detective_words,
    swap_data=thursday_swap_data,
    map_word=thursday_map_word,
    para_prompts=thursday_para_prompts,
    build_words=thursday_build_words,
    story_prompt=thursday_story_prompt,
    # Suffix-specific labels
    word_part_type="suffix",
)

# ── FRIDAY ──
print("\n[Friday]...")
generate_friday(
    week_dir=week_dir,
    week_num=week_num,
    day_name="Friday",
    topic_label=topic_label,
    words=words,
    review_story=FRIDAY_REVIEW_STORY,
    story_questions=friday_story_questions,
    opposite_words=friday_opposite_words,
    builder_words=friday_builder_words,
    journal_words=friday_journal_words,
)

# ── TEACHER GUIDE ──
print("\n[Teacher Guide]...")
generate_teacher_guide(
    week_dir=week_dir,
    week_num=week_num,
    phonics_label=topic_label,
    words=words,

    monday_phonics_explanation=(
        "Today we are learning that suffixes are letter groups added to the "
        "END of words to change their meaning. -ed = past tense, -ing = happening now, "
        "-s = he/she/it present, -es = he/she/it with sh/ch endings. "
        "Teach spelling rules: double consonant before -ing (run→running, swim→swimming), "
        "drop -e before -es (dance→dances)."
    ),
    monday_grammar_focus="Subject-Verb Agreement",
    monday_grammar_explanation=(
        "He/she/it takes -s or -es on the verb (he jumps, she watches). "
        "I/you/we/they do NOT take -s (they jump, we watch). "
        "Have students identify the subject first, then choose the correct verb ending."
    ),
    monday_story_text=MONDAY_STORY,
    monday_sort_labels=["-ed", "-ing", "-s/-es"],
    monday_sort_answers=[
        ["played", "walked", "jumped", "painted"],
        ["running", "swimming", "singing"],
        ["jumps", "watches", "kicks", "dances", "brushes"],
    ],
    monday_fill_answers=["played", "running", "jumps", "watches", "walked", "swimming", "kicks", "dances"],
    monday_opposite_answers=[
        ("played", "play"), ("running", "stop"), ("jumps", "lands"),
        ("watches", "looks away"), ("swimming", "drowning"), ("kicks", "catches"),
    ],
    monday_sentence_words=monday_sentence_words,

    tuesday_phonics_explanation=(
        "Suffixes change word meaning: -ed = past, -ing = now, -s = he/she/it, -es = he/she/it + sh/ch. "
        "Practice identifying suffixes in reading and applying spelling rules (double consonant, drop -e)."
    ),
    tuesday_comp_questions=tuesday_comp_questions,

    wednesday_phonics_explanation=(
        "Words with suffixes show relationships and context. "
        "Practice using context clues to determine suffix meaning."
    ),
    wednesday_vocab_q_answer="B) Did the action in the past",

    thursday_phonics_explanation=(
        "Apply suffixes in writing. Fix common spelling errors with suffixes. "
        "Build words from base + suffix."
    ),
    thursday_detective_answers=[
        ("playd", "played"),
        ("runnig", "running"),
        ("jumpes", "jumps"),
        ("watchs", "watches"),
        ("swimmin", "swimming"),
    ],

    friday_phonics_explanation=(
        "Assessment week β€” review all suffixes: -ed (past), -ing (now), -s (he/she/it), -es (he/she/it + sh/ch). "
        "Spelling test covers all 12 words."
    ),
    friday_story_answers=[
        "A song about spelling",
        "The principal",
        "A big banner",
        "Their suffixes",
    ],
)

print("\nβœ… Week 10 generation complete!")
print(f"   Output: {week_dir}/")