#!/usr/bin/env python3
"""
Week 19: Money โ€” Adding & Making Change
Phase 3: Measurement, Time & Money
Standards: 2.MD.C.8 (solve word problems involving money, $ and ยข symbols)

New Standard:
- Reduced drill (40% fewer problems)
- Estimation before calculating (about how much together? enough money?)
- Multiple strategies encouraged (count up to make change vs. subtract)
- Better word problems (real store transactions, reasoning over keywords)
- Real challenges (open-ended thinking โ€” plan a purchase)
- Number talks (compare totals & change without calculating)
- Friday self-check with reflection
- Fact fluency warmup daily (coin values, make-a-dollar facts)
- Word problems every day
"""

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,
    coin_svg, col_add, col_sub,
)
from activity_builders import (
    build_money_adding,
)

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


# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# MONDAY โ€” Adding Two Money Amounts
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
def monday():
    # 1: Fluency warmup โ€” coin value facts (review from Week 18)
    s1 = '<div class="abox" style="background:#e8f5e9;">'\
         '<p><b>2-min Fluency Warm-up</b> โ€” Quick coin facts.</p>'\
         '<div class="mgrid c3">'
    for q in ["2 quarters = ___ยข", "3 dimes = ___ยข", "4 nickels = ___ยข", "quarter + dime = ___ยข"]:
        s1 += f'<div class="abox"><p>{q}</p></div>'
    s1 += '</div></div>'

    # 2: Adding two prices โ€” guided intro
    s2 = '<p class="note">Adding money works just like adding numbers! 25ยข + 30ยข: add the cents like 25 + 30 = 55, so 55ยข. '\
         'If your total reaches 100ยข, that\'s $1.00!</p>'
    s2 += '<div class="mgrid c2">'
    s2 += '<div class="abox"><p><b>Example:</b> A pencil costs 25ยข and an eraser costs 30ยข.</p><p>25ยข + 30ยข = <b>55ยข</b> together.</p></div>'
    s2 += '<div class="abox"><p><b>Example:</b> A sticker costs 60ยข and a card costs 40ยข.</p><p>60ยข + 40ยข = 100ยข = <b>$1.00</b>!</p></div>'
    s2 += '</div>'

    # 3: Add the prices (reduced from 8 to 4)
    s3 = '<p class="note">Add each pair of prices.</p>'\
         '<div class="mgrid c2">'
    for a, c in [(25, 30), (15, 40), (35, 25), (45, 20)]:
        s3 += f'<div class="abox"><p>{a}ยข + {c}ยข = {b("4em")}ยข</p></div>'
    s3 += '</div>'

    # 4: Number Talk โ€” Explain WITHOUT calculating
    s4 = '<div class="abox" style="background:#e3f2fd;">'\
         '<p><b>Number Talk</b> โ€” Explain WITHOUT calculating.</p>'\
         '<div class="mgrid c2">'
    s4 += '<div class="abox"><p>A: 25ยข + 25ยข &nbsp; B: 25ยข + 35ยข</p><p>Which total is bigger? How do you know without adding?</p><p style="font-size:11px;">My thinking: ' + bw() + '</p></div>'
    s4 += '<div class="abox"><p>Toy A costs 49ยข. Toy B costs 51ยข. About how much do they cost together โ€” is it about $1? Why?</p><p style="font-size:11px;">My thinking: ' + bw() + '</p></div>'
    s4 += '</div></div>'

    # 5: Word problem
    s5 = '<div class="wp">'\
         '<p class="note">Read carefully. Think about what is happening.</p>'\
         '<div class="abox"><p style="font-size:0.95em;">At the school store, Nora buys a bookmark for 35ยข and a pencil grip for 25ยข. '\
         'How much does she spend in all? Show your thinking.</p>'\
         '<p style="font-size:11px;">Draw or write your thinking: ' + bw() + '</p>'\
         '<p>Total: ' + b("4em") + 'ยข</p></div></div>'

    return page(19, "Monday", "Adding Money Amounts",
        f'''{sec(1, "Warm-up: Coin Facts", s1)}
{sec(2, "Adding Prices Together", s2)}
{sec(3, "Add the Prices", s3)}
{sec(4, "Number Talk: Compare Totals", s4)}
{sec(5, "Word Problem", s5)}''')


# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# TUESDAY โ€” Estimation + Column Adding with Money
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
def tuesday():
    # 1: Fluency warmup โ€” make a dollar
    s1 = '<div class="abox" style="background:#e8f5e9;">'\
         '<p><b>2-min Fluency Warm-up</b> โ€” How much more to make $1.00?</p>'\
         '<div class="mgrid c3">'
    for n in [75, 50, 90, 25]:
        s1 += f'<div class="abox"><p>{n}ยข + {b("3em")}ยข = $1</p></div>'
    s1 += '</div></div>'

    # 2: Estimate First! โ€” enough money?
    s2 = '<div class="abox" style="background:#fff3e0;">'\
         '<p><b>Estimate First!</b> Round each price to the nearest ten. Estimate the total, then add exactly.</p>'\
         '<div class="mgrid c2">'
    for a, c in [(38, 21), (47, 32), (19, 43), (52, 28)]:
        at = (a + 5) // 10 * 10
        ct = (c + 5) // 10 * 10
        s2 += f'<div class="abox"><p><b>{a}ยข + {c}ยข</b></p>'\
              f'<p>Round: {at}ยข + {ct}ยข</p>'\
              f'<p>Estimate: {b("4em")}ยข</p>'\
              f'<p>Actual: {b("4em")}ยข</p></div>'
    s2 += '</div></div>'

    # 3: Column addition with money (reduced from 6 to 4)
    s3 = '<p class="note">Line up the cents and add โ€” just like column addition!</p>'
    s3 += '<div class="mgrid c2">'
    for a, c in [(38, 21), (47, 32), (19, 43), (52, 28)]:
        s3 += f'<div class="abox">{col_add(a, c)}<p style="text-align:center; font-size:11px;">answer in ยข</p></div>'
    s3 += '</div>'

    # 4: Two items from the store (reduced from 4 to 2)
    s4 = '<div class="abox">'\
         '<p class="note">Store prices: apple 30ยข &nbsp;|&nbsp; juice 45ยข &nbsp;|&nbsp; cookie 25ยข &nbsp;|&nbsp; muffin 55ยข</p>'\
         '<div class="mgrid c2">'
    combos = [("an apple and a juice", "30ยข + 45ยข"), ("a cookie and a muffin", "25ยข + 55ยข")]
    for what, expr in combos:
        s4 += f'<div class="abox"><p>How much for {what}?</p><p>{expr} = {b("4em")}ยข</p></div>'
    s4 += '</div></div>'

    # 5: Word problem
    s5 = '<div class="wp">'\
         '<p class="note">Read carefully. Think about what is happening.</p>'\
         '<div class="abox"><p style="font-size:0.95em;">Eli has 80ยข. He wants to buy a juice (45ยข) and a cookie (25ยข). '\
         'Estimate first: does he have enough? Then add exactly to check.</p>'\
         '<p style="font-size:11px;">Estimate: ' + bw() + '</p>'\
         '<p>Exact total: ' + b("4em") + 'ยข &nbsp; Enough? ' + b("3em") + '</p></div></div>'

    return page(19, "Tuesday", "Estimating and Adding Money",
        f'''{sec(1, "Warm-up: Make a Dollar", s1)}
{sec(2, "Estimate First!", s2)}
{sec(3, "Column Adding with Cents", s3)}
{sec(4, "Shopping for Two Items", s4)}
{sec(5, "Word Problem", s5)}''')


# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# WEDNESDAY โ€” Making Change (Count Up!)
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
def wednesday():
    # 1: Fluency warmup
    s1 = '<div class="abox" style="background:#e8f5e9;">'\
         '<p><b>2-min Fluency Warm-up</b> โ€” Jump to the next ten.</p>'\
         '<div class="mgrid c3">'
    for n in [37, 62, 85, 41]:
        s1 += f'<div class="abox"><p>{n} + {b("3em")} = {((n // 10) + 1) * 10}</p></div>'
    s1 += '</div></div>'

    # 2: What is change? โ€” guided, with count-up strategy
    s2 = '<p class="note"><b>Change</b> is the money you get back when you pay more than the price. '\
         '<b>Strategy: count UP</b> from the price to what you paid.</p>'\
         '<div class="abox"><p><b>Example:</b> A toy costs 35ยข. You pay with 2 quarters (50ยข).</p>'\
         '<p>Count up: 35ยข โ†’ 40ยข (that\'s 5ยข) โ†’ 50ยข (that\'s 10ยข more). Change = 5 + 10 = <b>15ยข</b>.</p></div>'

    # 3: Make change (reduced from 8 to 4)
    s3 = '<p class="note">Count up from the price to the amount paid. Write the change.</p>'\
         '<div class="mgrid c2">'
    for price, paid in [(40, 50), (65, 75), (30, 50), (55, 100)]:
        paid_label = "$1.00" if paid == 100 else f"{paid}ยข"
        s3 += f'<div class="abox"><p>Price: {price}ยข &nbsp; Paid: {paid_label}</p>'\
              f'<p>Change: {b("4em")}ยข</p></div>'
    s3 += '</div>'

    # 4: Two Ways โ€” change by counting up AND subtracting
    s4 = '<div class="abox">'\
         '<p class="note"><b>Two Ways</b> โ€” Find the change two different ways. Do they match?</p>'\
         '<div class="mgrid c2">'
    for price, paid in [(45, 60), (25, 50)]:
        s4 += f'<div class="abox"><p><b>Price {price}ยข, paid {paid}ยข</b></p>'\
              f'<p style="font-size:11px;">Strategy 1 โ€” count up: ' + bw() + '</p>'\
              f'<p style="font-size:11px;">Strategy 2 โ€” subtract {paid} โˆ’ {price}: ' + b("4em") + '</p>'\
              f'<p>Change: {b("4em")}ยข</p></div>'
    s4 += '</div></div>'

    # 5: Challenge โ€” Create Your Own
    s5 = '<div class="abox" style="background:#f3e5f5;">'\
         '<p><b>Create Your Own</b></p>'\
         '<p>Invent an item for your own store. Give it a price under 50ยข. A customer pays with 2 quarters. '\
         'Draw your item, write the price, and figure out the change.</p>'\
         '<p style="min-height:60px; border:1px dashed #999; border-radius:4px; padding:6px; font-size:11px; color:#999;">Draw your item here</p>'\
         '<p>Price: ' + b("3em") + 'ยข &nbsp; Paid: 50ยข &nbsp; Change: ' + b("3em") + 'ยข</p>'\
         '<p style="font-size:11px; color:#666;">Strategy I used: ' + bw() + '</p>'\
         '</div>'

    return page(19, "Wednesday", "Making Change",
        f'''{sec(1, "Warm-up: Next Ten", s1)}
{sec(2, "What Is Change? Count Up!", s2)}
{sec(3, "Make the Change", s3)}
{sec(4, "Two Ways to Find Change", s4)}
{sec(5, "Challenge: Create Your Own", s5)}''')


# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# THURSDAY โ€” Store Transactions (Word Problems)
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
def thursday():
    # 1: Fluency warmup
    s1 = '<div class="abox" style="background:#e8f5e9;">'\
         '<p><b>2-min Fluency Warm-up</b> โ€” Change from a quarter (25ยข).</p>'\
         '<div class="mgrid c3">'
    for price in [20, 15, 10, 5]:
        s1 += f'<div class="abox"><p>Price {price}ยข โ†’ change {b("3em")}ยข</p></div>'
    s1 += '</div></div>'

    # 2: Better word problems โ€” real transactions (reduced from 5 to 3)
    s2 = '<div class="wp">'\
         '<p class="note">Read carefully. Think about what is happening in the situation. Draw coins if it helps!</p>'\
         '<div class="mgrid c2">'
    problems = [
        "Maya buys a hair clip for 40ยข and a ring for 35ยข at the craft fair. She pays with a $1 bill. How much does she spend, and how much change does she get?",
        "Owen has 3 quarters. He buys a bouncy ball for 55ยข. Does he have enough? If yes, how much change should he get?",
        "Two friends each buy a 30ยข snack. They pay together with 3 quarters. Is that enough money? Explain.",
    ]
    for text in problems:
        s2 += f'<div class="abox"><p style="font-size:0.95em;">{text}</p>'\
              '<p style="font-size:11px;">Draw or write your thinking: ' + bw() + '</p>'\
              '<p>Answer: ' + bw() + '</p></div>'
    s2 += '</div></div>'

    # 3: Two-step transaction
    s3 = '<div class="abox">'\
         '<p class="note">Solve step by step. Write each answer as you go.</p>'\
         '<div class="abox"><p style="font-size:0.95em;">Ivy starts with 90ยข. She buys a sticker for 25ยข. '\
         'Then she buys a lollipop for 30ยข. How much money does Ivy have left?</p>'\
         '<p>Step 1: 90ยข โˆ’ 25ยข = ' + b("4em") + 'ยข</p>'\
         '<p>Step 2: ' + b("4em") + 'ยข โˆ’ 30ยข = ' + b("4em") + 'ยข</p>'\
         '<p><b>Ivy has ' + b("4em") + 'ยข left.</b></p></div></div>'

    # 4: Number Talk โ€” Explain WITHOUT calculating
    s4 = '<div class="abox" style="background:#e3f2fd;">'\
         '<p><b>Number Talk</b> โ€” Explain WITHOUT calculating.</p>'\
         '<div class="mgrid c2">'
    s4 += '<div class="abox"><p>A toy costs 48ยข. Jen pays 50ยข, Kim pays $1. Who gets MORE change? How do you know without figuring out either amount?</p><p style="font-size:11px;">My thinking: ' + bw() + '</p></div>'
    s4 += '<div class="abox"><p>Two items cost 45ยข and 45ยข. Will a $1 bill be enough? Reason without adding exactly.</p><p style="font-size:11px;">My thinking: ' + bw() + '</p></div>'
    s4 += '</div></div>'

    # 5: Create your own word problem
    s5 = '<div class="abox" style="background:#f3e5f5;">'\
         '<p><b>Create Your Own Word Problem</b></p>'\
         '<p>Write a store word problem where someone buys something and gets change. Then solve it.</p>'\
         '<p style="min-height:60px; border-bottom:1px solid #333;"></p>'\
         '<p style="min-height:30px; border-bottom:1px solid #333;"></p>'\
         '<p>Answer: ' + bl() + '</p>'\
         '</div>'

    return page(19, "Thursday", "Store Transactions",
        f'''{sec(1, "Warm-up: Change from a Quarter", s1)}
{sec(2, "Word Problems: Think About What Is Happening", s2)}
{sec(3, "Two-Step Transaction", s3)}
{sec(4, "Number Talk: Reasoning About Change", s4)}
{sec(5, "Challenge: Create Your Own", s5)}''')


# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# FRIDAY โ€” Review & Self-Check
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
def friday():
    # 1: Fluency warmup
    s1 = '<div class="abox" style="background:#e8f5e9;">'\
         '<p><b>2-min Fluency Warm-up</b> โ€” Money facts. Go fast!</p>'\
         '<div class="mgrid c3">'
    for q in ["50ยข + 50ยข = $___", "75ยข + 25ยข = $___", "60ยข + 20ยข = ___ยข", "30ยข + 30ยข = ___ยข"]:
        s1 += f'<div class="abox"><p>{q}</p></div>'
    s1 += '</div></div>'

    # 2: Estimate First! โ€” review
    s2 = '<div class="abox" style="background:#fff3e0;">'\
         '<p><b>Estimate First!</b> Round to tens, estimate the total, then add exactly.</p>'\
         '<div class="mgrid c2">'
    for a, c in [(29, 42), (53, 18), (36, 37), (41, 24)]:
        at = (a + 5) // 10 * 10
        ct = (c + 5) // 10 * 10
        s2 += f'<div class="abox"><p><b>{a}ยข + {c}ยข</b></p>'\
              f'<p>Estimate ({at} + {ct}): {b("4em")}ยข</p>'\
              f'<p>Actual: {b("4em")}ยข</p></div>'
    s2 += '</div></div>'

    # 3: Mixed money review โ€” add and make change (reduced from 8 to 4)
    s3 = '<p class="note">Use any strategy you prefer โ€” count up or subtract.</p>'\
         '<div class="mgrid c2">'
    s3 += f'<div class="abox"><p>35ยข + 45ยข = {b("4em")}ยข</p></div>'
    s3 += f'<div class="abox"><p>Price 60ยข, paid 75ยข. Change: {b("4em")}ยข</p></div>'
    s3 += f'<div class="abox"><p>20ยข + 55ยข = {b("4em")}ยข</p></div>'
    s3 += f'<div class="abox"><p>Price 45ยข, paid $1.00. Change: {b("4em")}ยข</p></div>'
    s3 += '</div>'

    # 4: Word problem review
    s4 = '<div class="wp">'\
         '<p class="note">Read carefully. Show your thinking.</p>'\
         '<div class="mgrid c2">'
    problems = [
        "Ben buys a granola bar for 55ยข and pays with 3 quarters. How much change does he get?",
        "Ella has 50ยข. Pencils cost 20ยข each. Can she buy two pencils? How much will she have left?",
    ]
    for text in problems:
        s4 += f'<div class="abox"><p style="font-size:0.95em;">{text}</p>'\
              '<p style="font-size:11px;">My thinking: ' + bw() + '</p>'\
              '<p>Answer: ' + bw() + '</p></div>'
    s4 += '</div></div>'

    # 5: Self-check with emoji reflection
    s5 = '<div class="selfcheck">'\
         '<p><b>Self-Check: How do you feel about adding money and making change?</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 Money Amounts</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>Making Change (Count Up)</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>Store Word Problems</b></p>'\
         '<p>๐Ÿ˜Š I got it!  |  ๐Ÿ˜ Getting there  |  ๐Ÿ˜Ÿ Need help</p>'\
         '</div>'\
         '</div>'\
         '<p style="margin-top:10px;"><b>One thing I learned this week:</b> ' + bl() + '</p>'\
         '<p><b>One thing I want to practice more:</b> ' + bl() + '</p>'\
         '<p><b>My favorite strategy for making change:</b> ' + bl() + '</p>'\
         '</div>'

    return page(19, "Friday", "Week 19 Review & Self-Check",
        f'''{sec(1, "Warm-up: Money Facts", s1)}
{sec(2, "Estimate First!", s2)}
{sec(3, "Add & Make Change Review", s3)}
{sec(4, "Word Problems", s4)}
{sec(5, "Self-Check & Reflection", s5)}''')


# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# TEACHER GUIDE
# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
def teacher_guide():
    return tg_page_multi(
        "Week 19", "Money: Adding & Change โ€” Teacher Guide",

        tg_section_title("Monday: Adding Money Amounts") +
        tg_sec(1, "Warm-up coin facts", ["50ยข, 30ยข, 20ยข, 35ยข"]) +
        tg_sec(2, "Adding Prices (guided)", ["Read together"]) +
        tg_sec(3, "Add the Prices", ["55ยข, 55ยข, 60ยข, 65ยข"]) +
        tg_sec(4, "Number Talk", ["B is bigger โ€” same first addend, 35 > 25", "Yes, about $1 โ€” 49 is almost 50 and 51 is just over 50"]) +
        tg_sec(5, "Word Problem", ["35 + 25 = 60ยข"]) +
        tg_note("Page break"),

        tg_section_title("Tuesday: Estimating and Adding Money") +
        tg_sec(1, "Warm-up make $1", ["25ยข, 50ยข, 10ยข, 75ยข"]) +
        tg_sec(2, "Estimate First", ["Est 60, actual 59 / Est 80, actual 79 / Est 60, actual 62 / Est 80, actual 80"]) +
        tg_sec(3, "Column Adding", ["59, 79, 62, 80"]) +
        tg_sec(4, "Shopping", ["75ยข, 80ยข"]) +
        tg_sec(5, "Word Problem", ["45+25=70ยข โ€” yes, 80ยข is enough (10ยข left)"]) +
        tg_note("Page break"),

        tg_section_title("Wednesday: Making Change") +
        tg_sec(1, "Warm-up next ten", ["3, 8, 5, 9"]) +
        tg_sec(2, "Count Up (guided)", ["Model counting up on a number line"]) +
        tg_sec(3, "Make Change", ["10ยข, 10ยข, 20ยข, 45ยข"]) +
        tg_sec(4, "Two Ways", ["45โ†’60: change 15ยข both ways", "25โ†’50: change 25ยข both ways"]) +
        tg_sec(5, "Create Own", ["Accept any price <50ยข with correct change from 50ยข"]) +
        tg_note("Page break"),

        tg_section_title("Thursday: Store Transactions") +
        tg_sec(1, "Warm-up change from 25ยข", ["5ยข, 10ยข, 15ยข, 20ยข"]) +
        tg_sec(2, "Word Problems", ["Spends 75ยข, change 25ยข from $1", "75ยข โ‰ฅ 55ยข yes; change 20ยข", "Snacks 60ยข, paid 75ยข โ€” yes, enough (15ยข left)"]) +
        tg_sec(3, "Two-Step", ["Step 1: 90โˆ’25=65ยข; Step 2: 65โˆ’30=35ยข left"]) +
        tg_sec(4, "Number Talk", ["Kim โ€” she paid more for the same price", "Yes โ€” 45 is less than 50, and 50+50=100, so 45+45 < $1"]) +
        tg_sec(5, "Create Own", ["Accept student-created transaction problems"]) +
        tg_note("Page break"),

        tg_section_title("Friday: Review & Self-Check") +
        tg_sec(1, "Warm-up", ["$1.00, $1.00, 80ยข, 60ยข"]) +
        tg_sec(2, "Estimate First", ["Est 70, actual 71 / Est 70, actual 71 / Est 80, actual 73 / Est 60, actual 65"]) +
        tg_sec(3, "Add & Change Review", ["80ยข; 15ยข; 75ยข; 55ยข"]) +
        tg_sec(4, "Word Problems", ["75โˆ’55=20ยข change", "Yes โ€” 2 pencils = 40ยข, 10ยข left"]) +
        tg_sec(5, "Self-Check", ["Accept student self-assessment and reflection"])
    )


# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
# 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", "Adding Money Amounts"),
        (tuesday, "Tuesday", "Estimating and Adding Money"),
        (wednesday, "Wednesday", "Making Change"),
        (thursday, "Thursday", "Store Transactions"),
        (friday, "Friday", "Week 19 Review & Self-Check"),
    ]

    for lesson_func, day, title in days:
        html = lesson_func()
        fname = f"Week_19_{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_19_Teacher_Guide.html")
    with open(path, "w") as f:
        f.write(html)
    pdf_path = os.path.join(WEEK, "Week_19_Teacher_Guide.pdf")
    HTML(filename=path).write_pdf(pdf_path)
    print(f"Generated: {pdf_path}")

    print("\nWeek 19 (Money: Adding & Change, new standard) complete!")