#!/usr/bin/env python3
"""
Week 32: End-of-Year Celebration & Review โ€” THE LAST WEEK!
Phase: Grand Finale โ€” a FUN celebration of everything learned in 2nd grade math.
Standards reviewed (lightly & joyfully): 2.OA, 2.NBT, 2.MD, 2.G

This is NOT a test โ€” it is a celebration! Puzzles, games, a math scavenger
hunt, and a certificate. Keep the tone light and encouraging.

New Standard (still present, celebration-style):
- Reduced drill (games and puzzles instead of drill)
- Estimation activities (estimation station game)
- Multiple strategies celebrated
- Playful word problems
- Open-ended challenges (design your own!)
- Number talks (favorite tricks)
- Friday self-check + reflection + CERTIFICATE
- Fact fluency warmup daily
"""

import os
import glob
from weasyprint import HTML

from math_helpers import (
    CSS, TEACHER_CSS,
    page, page_multi, hdr, sec, b, bw, bl,
    tg_page_multi, tg_sec, tg_note, tg_section_title,
    star_svg, medal_svg, trophy_svg, check_svg,
    clock_svg, coin_svg, shape_svg, array_svg,
)
from activity_builders import (
    build_scavenger_hunt,
    build_certificate,
    build_challenge_box,
)

BASE = os.path.expanduser("~/Home_School/2nd_Grade/Math")
WEEK = os.path.join(BASE, "Week_32")

BLUE = "#1e88e5"
RED = "#e53935"
GREEN = "#43a047"
GOLD = "#fbc02d"


def stars(n=3):
    return ''.join(star_svg(GOLD, 18) for _ in range(n))


def warmup(title, exprs):
    s = f'<div class="abox" style="background:#e8f5e9;">'\
        f'<p><b>{title}</b> {stars(3)}</p>'\
        '<div class="mgrid c3">'
    for expr in exprs:
        s += f'<div class="abox"><p>{expr} = {b("4em")}</p></div>'
    s += '</div></div>'
    return s


# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# MONDAY โ€” Math Memory Lane
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
def monday():
    s1 = warmup("Victory Lap Warm-up โ€” you know these cold now!",
                ["8 + 8", "15 โˆ’ 7", "9 + 9", "14 โˆ’ 6"])

    # 2: Memory lane โ€” remember when?
    s2 = f'<div class="abox" style="background:#fff8e1;">'\
         f'<p>{trophy_svg(28)} <b>Remember when these were HARD?</b> Now they are easy! Solve each one and give yourself a star.</p>'\
         '<div class="mgrid c2">'
    for label, prob in [("Way back in fall:", "9 + 6 = " + b("3em")),
                        ("Winter challenge:", "52 โˆ’ 27 = " + b("3em")),
                        ("Spring skill:", "2 quarters + 1 dime = " + b("3em") + "ยข"),
                        ("Newest power:", "3 rows of 4 = " + b("3em"))]:
        s2 += f'<div class="abox"><p style="font-size:11px; color:#888;">{label}</p><p>{prob}</p>'\
              f'<p style="font-size:11px;">I did it! {star_svg(GOLD, 14)}</p></div>'
    s2 += '</div></div>'

    # 3: Number Talk โ€” favorite math trick
    s3 = '<div class="abox" style="background:#e3f2fd;">'\
         '<p><b>Number Talk</b> โ€” Explain WITHOUT calculating on paper.</p>'\
         '<p>What is your FAVORITE mental math trick from this year? '\
         '(Making 10s? Doubles? Counting up? Friendly numbers?) '\
         'Use it to solve <b>29 + 36</b> in your head, then explain your trick to your teacher.</p>'\
         '<p style="font-size:11px;">My trick: ' + bw() + '</p>'\
         '<p>29 + 36 = ' + b("4em") + '</p>'\
         '</div>'

    # 4: Math riddles (fun, light)
    s4 = '<div class="abox">'\
         '<p class="note">Math riddles! Solve each one.</p>'\
         '<div class="mgrid c2">'
    riddles = [
        "I am an even number between 31 and 35. Who am I?",
        "I have 4 equal sides and 4 corners. What shape am I?",
        "I am worth 25ยข but I am only one coin. What am I?",
        "Double me and you get 18. Who am I?",
    ]
    for r in riddles:
        s4 += f'<div class="abox"><p style="font-size:0.95em;">{r}</p><p>Answer: {b("5em")}</p></div>'
    s4 += '</div></div>'

    # 5: Create Your Own riddle
    s5 = '<div class="abox" style="background:#f3e5f5;">'\
         '<p><b>Create Your Own Math Riddle!</b> Write a riddle about a number or shape. '\
         'Try it on someone in your family tonight!</p>'\
         '<p style="min-height:40px; border-bottom:1px solid #333;"></p>'\
         '<p style="min-height:26px; border-bottom:1px solid #333;"></p>'\
         '<p>Answer: ' + bl() + '</p>'\
         '</div>'

    return page(32, "Monday", "Math Memory Lane",
        f'''{sec(1, "Warm-up: Victory Lap", s1)}
{sec(2, "Remember When These Were Hard?", s2)}
{sec(3, "Number Talk: Your Favorite Trick", s3)}
{sec(4, "Math Riddles", s4)}
{sec(5, "Create Your Own Riddle", s5)}''')


# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# TUESDAY โ€” Estimation Station & Puzzle Day
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
def tuesday():
    s1 = warmup("Speedy Stars Warm-up",
                ["7 + 6", "13 โˆ’ 8", "6 + 6", "16 โˆ’ 8"])

    # 2: Estimation Station game
    s2 = '<div class="abox" style="background:#fff3e0;">'\
         '<p><b>Estimate First! โ€” Estimation Station Game</b> ' + stars(2) + '</p>'\
         '<p class="note">Grab a jar or bowl and small items (beans, blocks, cereal). '\
         'Estimate FIRST, then count. Score a star if you are within 10!</p>'\
         '<div class="mgrid c1">'
    for i in [1, 2, 3]:
        s2 += f'<div class="abox"><p>Round {i}: Item: {b("6em")} '\
              f'My estimate: {b("3em")} &nbsp; Real count: {b("3em")} &nbsp; Within 10? '\
              f'{star_svg(GOLD, 14)} yes / no</p></div>'
    s2 += '</div></div>'

    # 3: Missing number puzzles
    s3 = '<div class="abox">'\
         '<p class="note">Puzzle time! Find the missing numbers.</p>'\
         '<div class="mgrid c2">'
    for puz in ["25 + " + b("3em") + " = 40",
                b("3em") + " โˆ’ 15 = 25",
                "10 + 10 + " + b("3em") + " = 45",
                b("3em") + " + " + b("3em") + " = 20 (two DIFFERENT numbers!)"]:
        s3 += f'<div class="abox"><p>{puz}</p></div>'
    s3 += '</div></div>'

    # 4: Shape puzzle
    s4 = '<div class="abox">'\
         '<p class="note">Shape detective! Read the clues, circle the answer.</p>'\
         '<div class="mgrid c2">'
    s4 += f'<div class="abox"><p>I have 3 sides. Circle me!</p>'\
          f'<div style="display:flex; gap:10px;">{shape_svg("square", BLUE, 34)}{shape_svg("triangle", GREEN, 34)}{shape_svg("circle", RED, 34)}</div></div>'
    s4 += f'<div class="abox"><p>I have 0 corners. Circle me!</p>'\
          f'<div style="display:flex; gap:10px;">{shape_svg("rectangle", GOLD, 34)}{shape_svg("triangle", BLUE, 34)}{shape_svg("circle", GREEN, 34)}</div></div>'
    s4 += '</div></div>'

    # 5: Playful word problem
    s5 = '<div class="wp">'\
         '<p class="note">A silly story problem โ€” read carefully and underline the important numbers. Draw it if you want!</p>'\
         '<div class="abox"><p style="font-size:0.95em;">A dragon collects 48 shiny coins. A sneaky goblin borrows 19. '\
         'Then a friendly knight gives the dragon 25 more. How many coins does the dragon have now?</p>'\
         '<p style="font-size:11px;">Draw or write your thinking: ' + bw() + '</p>'\
         '<p>' + b("4em") + ' coins</p></div></div>'

    return page(32, "Tuesday", "Estimation Station & Puzzle Day",
        f'''{sec(1, "Warm-up: Speedy Stars", s1)}
{sec(2, "Estimation Station Game", s2)}
{sec(3, "Missing Number Puzzles", s3)}
{sec(4, "Shape Detective", s4)}
{sec(5, "Silly Story Problem", s5)}''')


# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# WEDNESDAY โ€” Math Scavenger Hunt!
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
def wednesday():
    s1 = warmup("Treasure Hunter Warm-up",
                ["20 + 30", "100 โˆ’ 50", "25 + 25", "60 โˆ’ 20"])

    # 2: The big scavenger hunt
    s2 = f'<div class="abox" style="background:#fff8e1;"><p>{trophy_svg(28)} '\
         '<b>The Great Math Scavenger Hunt!</b> Hunt around your home to solve each clue.</p></div>'
    s2 += build_scavenger_hunt({
        "note": "Solve each clue by exploring your home. Bring your answers back for a prize star!",
        "clues": [
            {"question": "Count the chairs in your home. Is that number odd or even?", "hint": "Pair them up!"},
            {"question": "Find a clock. What time is it right now?", "hint": "Hour hand first, then minutes."},
            {"question": "Find something shaped like a rectangle. What is it?", "hint": "Doors? Books? Windows?"},
            {"question": "Count all the shoes by 2s. How many pairs? How many shoes?", "hint": "One pair = 2 shoes."},
            {"question": "Find 3 coins. How much money is that all together?", "hint": "Start with the biggest coin."},
            {"question": "Measure a spoon with your ruler. How many cm long is it?", "hint": "Line up the 0!"},
        ],
    })

    # 3: Number Talk โ€” scavenger reasoning
    s3 = '<div class="abox" style="background:#e3f2fd;">'\
         '<p><b>Number Talk</b> โ€” Explain WITHOUT counting again.</p>'\
         '<p>You counted 7 pairs of shoes. Without counting the shoes one by one, '\
         'how do you KNOW how many shoes there are? What trick did you use?</p>'\
         '<p style="font-size:11px;">My thinking: ' + bw() + '</p>'\
         '</div>'

    # 4: Bonus challenge
    s4 = build_challenge_box({
        "problems": [
            {"text": "Super Hunter Bonus: Find the LONGEST thing in your room and the SHORTEST thing. "
                     "Estimate how many of the short thing would fit along the long thing: " + b("3em")},
            {"text": "Extra star: Count something in your home by 5s (fingers, toes, nickels...). "
                     "What did you count and how many? " + bl()},
        ],
    })

    return page(32, "Wednesday", "The Great Math Scavenger Hunt",
        f'''{sec(1, "Warm-up: Treasure Hunter", s1)}
{sec(2, "Scavenger Hunt Clues", s2)}
{sec(3, "Number Talk: Shoe-Counting Trick", s3)}
{sec(4, "Super Hunter Bonus", s4)}''')


# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# THURSDAY โ€” Design Your Own Math!
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
def thursday():
    s1 = warmup("Champion Warm-up",
                ["9 + 8", "14 โˆ’ 7", "6 + 7", "11 โˆ’ 4"])

    # 2: Be the teacher โ€” write problems for a grown-up
    s2 = '<div class="abox" style="background:#f3e5f5;">'\
         '<p><b>Create Your Own โ€” Be the Teacher!</b> ' + stars(2) + '</p>'\
         '<p class="note">Write 3 math problems for a grown-up to solve. Make one EASY, one MEDIUM, and one TRICKY. '\
         'Then check their work โ€” you are the teacher now!</p>'\
         '<div class="mgrid c1">'
    for lvl in ["EASY", "MEDIUM", "TRICKY"]:
        s2 += f'<div class="abox"><p><b>{lvl}:</b> ' + bl() + '</p>'\
              f'<p style="font-size:11px;">Their answer: {b("4em")} &nbsp; Correct? {check_svg(14)} yes / no</p></div>'
    s2 += '</div></div>'

    # 3: Estimate First! โ€” playful estimation
    s3 = '<div class="abox" style="background:#fff3e0;">'\
         '<p><b>Estimate First!</b> No calculating allowed โ€” just smart estimates!</p>'\
         '<div class="mgrid c2">'
    for q in ["About how many crackers could you eat in one day?",
              "About how many steps from your bed to the kitchen?",
              "About how many books fit on one shelf?",
              "About how many minutes is recess... er, playtime?"]:
        s3 += f'<div class="abox"><p style="font-size:0.95em;">{q}</p><p>My estimate: {b("4em")}</p></div>'
    s3 += '</div><p style="font-size:11px; color:#666;">Pick ONE and actually check it. Was your estimate close? ' + b("6em") + '</p></div>'

    # 4: Show two ways โ€” victory lap
    s4 = '<div class="abox">'\
         '<p><b>Show two different ways</b> to solve <b>35 + 47</b> โ€” you have so many strategies now!</p>'\
         '<div class="mgrid c2">'\
         '<div class="abox"><p style="font-size:11px;">Way 1: ' + bw() + '</p><div style="min-height:50px;"></div></div>'\
         '<div class="abox"><p style="font-size:11px;">Way 2: ' + bw() + '</p><div style="min-height:50px;"></div></div>'\
         '</div><p>Answer: ' + b("4em") + ' &nbsp; Which way was faster for you? ' + b("6em") + '</p></div>'

    # 5: Story problem starring YOU
    s5 = '<div class="wp">'\
         '<p class="note">A story problem starring YOU! Read carefully and underline the important numbers.</p>'\
         '<div class="abox"><p style="font-size:0.95em;">You are the hero of a game. You score 36 points in round one and '\
         '28 points in round two. You need 75 points to win the golden trophy. '\
         'How many more points do you need?</p>'\
         '<p style="font-size:11px;">Draw or write your thinking: ' + bw() + '</p>'\
         '<p>' + b("4em") + f' more points {trophy_svg(20)}</p></div></div>'

    return page(32, "Thursday", "Design Your Own Math",
        f'''{sec(1, "Warm-up: Champion Round", s1)}
{sec(2, "Create Your Own: Be the Teacher", s2)}
{sec(3, "Estimate First: Silly Estimates", s3)}
{sec(4, "Show Two Different Ways", s4)}
{sec(5, "Story Problem Starring YOU", s5)}''')


# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# FRIDAY โ€” Celebration & Certificate Day!
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
def friday():
    # 1: Final victory lap
    s1 = warmup("FINAL Victory Lap โ€” the last warm-up of 2nd grade!",
                ["10 + 10", "20 โˆ’ 10", "50 + 50", "100 โˆ’ 1"])

    # 2: My year in math โ€” reflection
    s2 = f'<div class="abox" style="background:#fff8e1;">'\
         f'<p>{medal_svg("2", GOLD, 30)} <b>My Year in Math</b> โ€” Finish each sentence.</p>'\
         '<p><b>The hardest thing I learned was:</b> ' + bl() + '</p>'\
         '<p><b>The most FUN math day was:</b> ' + bl() + '</p>'\
         '<p><b>Something I can do now that I could not do in the fall:</b> ' + bl() + '</p>'\
         '<p><b>One thing I learned this year:</b> ' + bl() + '</p>'\
         '</div>'

    # 3: Final self-check with emoji reflection
    s3 = '<div class="selfcheck">'\
         '<p><b>Final Self-Check: Look how far you came!</b></p>'\
         '<div style="display:flex; gap:20px; flex-wrap:wrap;">'\
         '<div style="background:#fff3e0; padding:10px; border-radius:5px; flex:1; min-width:150px;">'\
         '<p><b>Adding & Subtracting Big Numbers</b></p>'\
         '<p>๐Ÿ˜Š I got it!  |  ๐Ÿ˜ Getting there  |  ๐Ÿ˜Ÿ Need help</p>'\
         '</div>'\
         '<div style="background:#e3f2fd; padding:10px; border-radius:5px; flex:1; min-width:150px;">'\
         '<p><b>Time, Money & Measuring</b></p>'\
         '<p>๐Ÿ˜Š I got it!  |  ๐Ÿ˜ Getting there  |  ๐Ÿ˜Ÿ Need help</p>'\
         '</div>'\
         '<div style="background:#f3e5f5; padding:10px; border-radius:5px; flex:1; min-width:150px;">'\
         '<p><b>Shapes, Patterns & Equal Groups</b></p>'\
         '<p>๐Ÿ˜Š I got it!  |  ๐Ÿ˜ Getting there  |  ๐Ÿ˜Ÿ Need help</p>'\
         '</div>'\
         '</div>'\
         '<p style="margin-top:10px;"><b>I am most proud of:</b> ' + bl() + '</p>'\
         '</div>'

    # 4: One last fun challenge
    s4 = build_challenge_box({
        "problems": [
            {"text": "The Grand Finale Puzzle: I am thinking of a number. It is even. It is between 40 and 50. "
                     "Its digits add up to 8. What number am I? " + b("4em")},
            {"text": "Celebration math: If your party has 4 tables with 5 balloons each, how many balloons? " + b("3em")},
        ],
    })

    # 5: THE CERTIFICATE
    s5 = f'<div style="text-align:center; margin-bottom:8px;">{trophy_svg(40)} {stars(5)} {trophy_svg(40)}</div>'
    s5 += build_certificate({
        "title": "Certificate of Achievement",
        "subtitle": "This certifies that",
        "achievement": "has successfully completed 2nd Grade Math โ€” mastering addition, subtraction, "
                       "place value, time, money, measurement, shapes, and patterns. "
                       "Congratulations, Mathematician!",
        "include_name": True,
    })

    return page(32, "Friday", "Celebration & Certificate Day",
        f'''{sec(1, "Warm-up: FINAL Victory Lap", s1)}
{sec(2, "My Year in Math", s2)}
{sec(3, "Final Self-Check", s3)}
{sec(4, "Grand Finale Challenge", s4)}
{sec(5, "Your Certificate!", s5)}''')


# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# TEACHER GUIDE
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
def teacher_guide():
    return tg_page_multi(
        "Week 32", "End-of-Year Celebration & Review โ€” Teacher Guide",

        tg_section_title("Overview: This is a CELEBRATION week!") +
        tg_note("Keep it light and joyful. No grades, no pressure. The goal is for your "
                "student to feel proud of a year of growth. Add snacks, stickers, and ceremony "
                "for Friday's certificate!") +

        tg_section_title("Monday: Math Memory Lane") +
        tg_sec(1, "Warm-up", ["16, 8, 18, 8"]) +
        tg_sec(2, "Memory Lane", ["15; 25; 60ยข; 12 โ€” celebrate each with a drawn star"]) +
        tg_sec(3, "Number Talk", ["29+36=65; e.g. friendly number 30+36โˆ’1, or 29+1=30 then +35"]) +
        tg_sec(4, "Riddles", ["32 or 34 (both even, accept either); square; quarter; 9"]) +
        tg_sec(5, "Create Riddle", ["Any riddle with a checkable answer"]) +
        tg_note("Page break"),

        tg_section_title("Tuesday: Estimation Station & Puzzles") +
        tg_sec(1, "Warm-up", ["13, 5, 12, 8"]) +
        tg_sec(2, "Estimation Station", ["Any items; praise estimates within 10"]) +
        tg_sec(3, "Missing Numbers", ["15; 40; 25; any pair summing to 20 (e.g. 8+12)"]) +
        tg_sec(4, "Shape Detective", ["triangle; circle"]) +
        tg_sec(5, "Story Problem", ["48โˆ’19+25 = 54 coins"]) +
        tg_note("Page break"),

        tg_section_title("Wednesday: Scavenger Hunt") +
        tg_sec(1, "Warm-up", ["50, 50, 50, 40"]) +
        tg_sec(2, "Scavenger Hunt", ["Answers vary โ€” check reasoning, not exactness"]) +
        tg_sec(3, "Number Talk", ["7 pairs โ†’ count by 2s or double 7 = 14 shoes"]) +
        tg_sec(4, "Bonus", ["Estimates vary; counting by 5s โ€” any valid count"]) +
        tg_note("Page break"),

        tg_section_title("Thursday: Design Your Own Math") +
        tg_sec(1, "Warm-up", ["17, 7, 13, 7"]) +
        tg_sec(2, "Be the Teacher", ["Solve their problems (occasionally get one 'wrong' so they can catch you!)"]) +
        tg_sec(3, "Estimate First", ["Silly estimates โ€” discuss what makes an estimate reasonable"]) +
        tg_sec(4, "Two Ways", ["35+47=82; column method; friendly: 35+50โˆ’3; break apart: 30+40=70, 5+7=12"]) +
        tg_sec(5, "Story Problem", ["36+28=64; 75โˆ’64 = 11 more points"]) +
        tg_note("Page break"),

        tg_section_title("Friday: Celebration & Certificate") +
        tg_sec(1, "Warm-up", ["20, 10, 100, 99"]) +
        tg_sec(2, "My Year in Math", ["Accept all reflections โ€” read them together"]) +
        tg_sec(3, "Final Self-Check", ["Discuss growth since fall; compare to early worksheets if saved"]) +
        tg_sec(4, "Grand Finale", ["44 (even, 40-50, 4+4=8); 4ร—5 = 20 balloons"]) +
        tg_sec(5, "Certificate", ["Sign it, date it, make it a ceremony! Congratulations to you too, teacher."])
    )


# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# GENERATE
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
if __name__ == "__main__":
    os.makedirs(WEEK, exist_ok=True)
    for f in glob.glob(os.path.join(WEEK, "*.pdf")):
        os.remove(f)
    for f in glob.glob(os.path.join(WEEK, "*.html")):
        os.remove(f)

    days = [
        (monday, "Monday", "Math Memory Lane"),
        (tuesday, "Tuesday", "Estimation Station & Puzzle Day"),
        (wednesday, "Wednesday", "The Great Math Scavenger Hunt"),
        (thursday, "Thursday", "Design Your Own Math"),
        (friday, "Friday", "Celebration & Certificate Day"),
    ]

    for lesson_func, day, title in days:
        html = lesson_func()
        fname = f"Week_32_{day}"
        path = os.path.join(WEEK, f"{fname}.html")
        with open(path, "w") as f:
            f.write(html)
        pdf_path = os.path.join(WEEK, f"{fname}.pdf")
        HTML(filename=path).write_pdf(pdf_path)
        print(f"Generated: {pdf_path}")

    html = teacher_guide()
    path = os.path.join(WEEK, "Week_32_Teacher_Guide.html")
    with open(path, "w") as f:
        f.write(html)
    pdf_path = os.path.join(WEEK, "Week_32_Teacher_Guide.pdf")
    HTML(filename=path).write_pdf(pdf_path)
    print(f"Generated: {pdf_path}")

    print("\nWeek 32 (End-of-Year Celebration) complete! What a year!")