#!/usr/bin/env python3
"""
Week 26: Phase 4 Review
Comprehensive review of Phases 3-4: measurement, time, money, data, geometry
Standards: 2.MD.A.1, 2.MD.C.7, 2.MD.C.8, 2.MD.D.10, 2.G.A.1-3

Review week — mixes questions from Weeks 16-24; no new content.

New Standard:
- Reduced drill (40% fewer problems)
- Estimation before calculating
- Multiple strategies encouraged
- Better word problems (reasoning over keywords)
- Real challenges (open-ended thinking)
- Number talks (explain WITHOUT calculating)
- Friday self-check with reflection
"""

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,
    shape_svg, grid_svg, clock_svg, coin_svg,
)
from activity_builders import (
    build_clock_telling,
    build_coin_identification,
    build_money_adding,
    build_bar_graph,
    build_picture_graph,
    build_shape_attributes,
    build_area_perimeter,
    build_ruler_measurement,
    build_challenge_box,
)

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


# ═══════════════════════════════════════════════════
# MONDAY — Time & Measurement Review (W16-17)
# ═══════════════════════════════════════════════════
def monday():
    # 1: Warm-up
    s1 = '<div class="abox" style="background:#e8f5e9;">'\
         '<p><b>2-min Warm-up</b> — Time facts! Fill in the blanks.</p>'\
         '<div class="mgrid c3">'
    for q in [f'1 hour = {b("3em")} minutes', f'Half an hour = {b("3em")} minutes',
              f'A quarter past 3 is 3:{b("3em")}']:
        s1 += f'<div class="abox"><p>{q}</p></div>'
    s1 += '</div></div>'

    # 2: Telling time review (2.MD.C.7) — reduced from 9 to 6
    s2 = build_clock_telling({
        "times": [
            {"hour": 3, "minute": 30, "blank": True},
            {"hour": 7, "minute": 15, "blank": True},
            {"hour": 11, "minute": 45, "blank": True},
            {"hour": 1, "minute": 5, "blank": True},
            {"hour": 9, "minute": 50, "blank": True},
            {"hour": 6, "minute": 20, "blank": True},
        ],
        "note": "Remember from Week 16: the short hand tells the hour, the long red hand tells the minutes (count by 5s)."
    })

    # 3: Ruler measurement review (2.MD.A.1) — reduced to 3
    s3 = build_ruler_measurement({
        "lines": [
            {"length_px": 96, "label": "A."},
            {"length_px": 240, "label": "B."},
            {"length_px": 144, "label": "C."},
        ],
        "unit": "inches",
        "note": "Measure each line to the nearest inch with your real ruler. Line up the 0!"
    })

    # 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>Ella\'s soccer practice starts at 4:00 and ends at 5:30. Piano lasts from 6:00 to 7:00. Which is longer? How do you know without counting minutes one by one?</p><p style="font-size:11px;">My thinking: ' + bw() + '</p></div>'
    s4 += '<div class="abox"><p>Would you measure your bedroom in inches or in feet? Why?</p><p style="font-size:11px;">My thinking: ' + bw() + '</p></div>'
    s4 += '</div></div>'

    # 5: Word problems — time
    s5 = '<div class="wp">'\
         '<p class="note">Read carefully. Draw a clock if it helps!</p>'\
         '<div class="mgrid c2">'
    problems = [
        "The movie starts at 2:30 and lasts 1 hour. What time does it end?",
        "Sam wakes at 7:00. He needs 30 minutes to get ready and the bus comes at 7:45. Does he have extra time? How much?",
    ]
    for text in problems:
        s5 += f'<div class="abox"><p style="font-size:0.95em;">{text}</p>'\
              '<p style="font-size:11px;">My thinking: ' + bw() + '</p>'\
              '<p>Answer: ' + b("6em") + '</p></div>'
    s5 += '</div></div>'

    return page(26, "Monday", "Review: Time & Measurement",
        f'''{sec(1, "Warm-up: Time Facts", s1)}
{sec(2, "Telling Time (from Week 16)", s2)}
{sec(3, "Measuring with a Ruler (from Week 17)", s3)}
{sec(4, "Number Talk: Time Thinking", s4)}
{sec(5, "Word Problems: Time", s5)}''')


# ═══════════════════════════════════════════════════
# TUESDAY — Money Review (W18-19)
# ═══════════════════════════════════════════════════
def tuesday():
    # 1: Warm-up — coin values
    s1 = '<div class="abox" style="background:#e8f5e9;">'\
         '<p><b>2-min Warm-up</b> — Coin values from memory!</p>'\
         '<div class="mgrid c2">'
    for coin in [f'Quarter = {b("3em")}¢', f'Dime = {b("3em")}¢',
                 f'Nickel = {b("3em")}¢', f'Penny = {b("3em")}¢']:
        s1 += f'<div class="abox"><p>{coin}</p></div>'
    s1 += '</div></div>'

    # 2: Count the coins — reduced from 6 to 4
    s2 = build_money_adding({
        "problems": [
            {"coins": [{"type": "quarter", "count": 2}, {"type": "dime", "count": 1}], "blank": True},
            {"coins": [{"type": "dime", "count": 3}, {"type": "nickel", "count": 1}, {"type": "penny", "count": 2}], "blank": True},
            {"coins": [{"type": "quarter", "count": 1}, {"type": "nickel", "count": 2}, {"type": "penny", "count": 3}], "blank": True},
            {"coins": [{"type": "quarter", "count": 3}, {"type": "dime", "count": 2}], "blank": True},
        ],
        "note": "Remember Week 18's strategy: start with the biggest coins, then count on."
    })

    # 3: Estimate First! — money
    s3 = '<div class="abox" style="background:#fff3e0;">'\
         '<p><b>Estimate First!</b> Before counting exactly, estimate: is each pile MORE or LESS than $1.00? '\
         'Circle your estimate, then count exactly.</p>'\
         '<div class="mgrid c2">'
    piles = [
        ("4 quarters and 3 pennies", "more / less", "$"),
        ("3 dimes, 2 nickels, 4 pennies", "more / less", "$"),
    ]
    for desc, opts, _d in piles:
        s3 += f'<div class="abox"><p><b>{desc}</b></p>'\
              f'<p style="font-size:11px;">Estimate: {opts} than $1.00</p>'\
              f'<p>Exact: $ {b("3em")}.{b("5em")}</p></div>'
    s3 += '</div></div>'

    # 4: Word problems — money reasoning
    s4 = '<div class="wp">'\
         '<p class="note">Read carefully. Think about what is happening with the money.</p>'\
         '<div class="mgrid c2">'
    problems = [
        "Ana has 3 quarters. A sticker costs 60¢. Does she have enough? How much will be left over?",
        "Two ways to make 30¢: Theo uses 3 dimes. Show a DIFFERENT way using at least one nickel.",
    ]
    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: Challenge — two different ways
    s5 = '<div class="abox" style="background:#f3e5f5;">'\
         '<p><b>Challenge</b> — Show two different ways to make exactly <b>47¢</b>.</p>'\
         '<p style="font-size:11px; color:#666;">Q = quarter, D = dime, N = nickel, P = penny. Which way uses the FEWEST coins?</p>'\
         '<div class="mgrid c2">'
    for i in [1, 2]:
        s5 += f'<div class="abox"><p><b>Way {i}</b></p>'\
              '<p style="font-size:11px;">' + bw() + '</p>'\
              '<p style="font-size:11px;">Number of coins: ' + b("3em") + '</p></div>'
    s5 += '</div></div>'

    return page(26, "Tuesday", "Review: Money",
        f'''{sec(1, "Warm-up: Coin Values", s1)}
{sec(2, "Count the Coins (from Week 18)", s2)}
{sec(3, "Estimate First! More or Less than $1?", s3)}
{sec(4, "Word Problems: Money", s4)}
{sec(5, "Challenge: Two Ways to Make 47¢", s5)}''')


# ═══════════════════════════════════════════════════
# WEDNESDAY — Data & Graphs Review (W20-21)
# ═══════════════════════════════════════════════════
def wednesday():
    # 1: Warm-up
    s1 = '<div class="abox" style="background:#e8f5e9;">'\
         '<p><b>2-min Warm-up</b> — Mental math! Solve in your head.</p>'\
         '<div class="mgrid c3">'
    for q in [f'14 − 8 = {b("5em")}', f'9 + 7 = {b("5em")}', f'15 − 6 = {b("5em")}',
              f'12 + 10 = {b("5em")}', f'20 − 10 = {b("5em")}', f'6 + 6 = {b("5em")}']:
        s1 += f'<div class="abox"><p>{q}</p></div>'
    s1 += '</div></div>'

    # 2: Bar graph review (2.MD.D.10)
    s2 = build_bar_graph({
        "entries": [
            {"label": "Dogs", "value": 8},
            {"label": "Cats", "value": 6},
            {"label": "Fish", "value": 3},
            {"label": "Birds", "value": 5},
        ],
        "max_value": 10,
        "note": "Our class voted for favorite pets. Read the bar graph, then answer below."
    })
    s2 += '<div class="mgrid c2">'
    for q in [f'How many MORE voted for dogs than fish? {b("3em")}',
              f'How many kids voted in all? {b("3em")}',
              f'Which two pets together equal the dog votes? {b("8em")}',
              f'If 2 fish-voters change to birds, how many bird votes? {b("3em")}']:
        s2 += f'<div class="abox"><p style="font-size:0.95em;">{q}</p></div>'
    s2 += '</div>'

    # 3: Picture graph review
    s3 = build_picture_graph({
        "categories": [
            {"name": "Monday", "count": 6, "blank": False},
            {"name": "Tuesday", "count": 4, "blank": False},
            {"name": "Wednesday", "count": 8, "blank": False},
        ],
        "key_value": 2,
        "symbol": "📚",
        "note": "Books read by the class this week. Careful: each symbol = 2 books!"
    })
    s3 += '<div class="mgrid c2">'
    s3 += f'<div class="abox"><p>How many books on Wednesday? {b("3em")}</p></div>'
    s3 += f'<div class="abox"><p>How many MORE on Monday than Tuesday? {b("3em")}</p></div>'
    s3 += '</div>'

    # 4: Number Talk — graphs
    s4 = '<div class="abox" style="background:#e3f2fd;">'\
         '<p><b>Number Talk</b> — Explain WITHOUT counting exactly.</p>'\
         '<div class="mgrid c2">'
    s4 += '<div class="abox"><p>Just by LOOKING at the pet bar graph, how can you tell which pet won — without reading any numbers?</p><p style="font-size:11px;">My thinking: ' + bw() + '</p></div>'
    s4 += '<div class="abox"><p>In the book graph, one symbol = 2 books. If the key changed to 1 symbol = 5 books, would the graph need MORE or FEWER symbols for the same books?</p><p style="font-size:11px;">My thinking: ' + bw() + '</p></div>'
    s4 += '</div></div>'

    # 5: Create Your Own graph
    s5 = '<div class="abox" style="background:#f3e5f5;">'\
         '<p><b>Create Your Own</b> — Take a survey! Ask 3 family members their favorite season. '\
         'Include your own vote. Then draw a bar for each season (1 box = 1 vote).</p>'\
         f'<div style="text-align:center;">{grid_svg(4, 8, cell=20, gap=1, color="#ddd")}</div>'\
         '<p style="font-size:11px;">Labels: ' + bw() + '</p>'\
         '<p style="font-size:11px;">Write one question about your graph for someone else to answer: ' + bw() + '</p></div>'

    return page(26, "Wednesday", "Review: Data & Graphs",
        f'''{sec(1, "Warm-up: Mental Math", s1)}
{sec(2, "Bar Graphs (from Week 20)", s2)}
{sec(3, "Picture Graphs (from Week 21)", s3)}
{sec(4, "Number Talk: Graph Sense", s4)}
{sec(5, "Create Your Own Survey Graph", s5)}''')


# ═══════════════════════════════════════════════════
# THURSDAY — Geometry Review (W22-24)
# ═══════════════════════════════════════════════════
def thursday():
    # 1: Warm-up — geometry vocabulary
    s1 = '<div class="abox" style="background:#e8f5e9;">'\
         '<p><b>2-min Warm-up</b> — Fill in the geometry words.</p>'\
         '<p>A shape\'s corners are called ' + b("6em") + '.</p>'\
         '<p>A perfect square corner is a ' + b("6em") + ' angle.</p>'\
         '<p>The distance around a shape is its ' + b("6em") + '.</p></div>'

    # 2: Shape attributes review (2.G.A.1) — reduced to 4
    s2 = build_shape_attributes({
        "shapes": [
            {"name": "Triangle", "sides": 3, "vertices": 3, "blanks": ["sides", "vertices"]},
            {"name": "Square", "sides": 4, "vertices": 4, "blanks": ["sides", "vertices"]},
            {"name": "Rectangle", "sides": 4, "vertices": 4, "blanks": ["sides", "vertices"]},
            {"name": "Circle", "sides": 0, "vertices": 0, "blanks": ["sides", "vertices"]},
        ],
        "note": "From Week 22: count the sides and vertices (corners) of each shape."
    })

    # 3: Area & perimeter review — reduced to 3
    s3 = build_area_perimeter({
        "shapes": [
            {"rows": 2, "cols": 4},
            {"rows": 3, "cols": 3},
            {"rows": 2, "cols": 6},
        ],
        "note": "From Week 24: squares inside = area, units around = perimeter."
    })

    # 4: Word problems — geometry reasoning
    s4 = '<div class="wp">'\
         '<p class="note">Read carefully. Draw if it helps!</p>'\
         '<div class="mgrid c2">'
    problems = [
        "I have 4 equal sides, 4 right angles, and 4 lines of symmetry. What shape am I?",
        "Mr. Lee splits a pizza into 4 equal shares. Priya splits the SAME size pizza into 2 equal shares. Whose shares are bigger? Why?",
        "A rectangle rug is 5 units long and 2 units wide. What is its area? What is its perimeter?",
    ]
    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: Number Talk — Explain WITHOUT calculating
    s5 = '<div class="abox" style="background:#e3f2fd;">'\
         '<p><b>Number Talk</b> — Explain WITHOUT calculating.</p>'\
         '<div class="mgrid c2">'
    s5 += '<div class="abox"><p>Can two rectangles have the SAME area but look completely different? Convince me.</p><p style="font-size:11px;">My thinking: ' + bw() + '</p></div>'
    s5 += '<div class="abox"><p>A square and a rectangle both have 4 sides and 4 right angles. What makes the square special?</p><p style="font-size:11px;">My thinking: ' + bw() + '</p></div>'
    s5 += '</div></div>'

    return page(26, "Thursday", "Review: Shapes, Area & Perimeter",
        f'''{sec(1, "Warm-up: Geometry Words", s1)}
{sec(2, "Shape Attributes (from Week 22)", s2)}
{sec(3, "Area & Perimeter (from Week 24)", s3)}
{sec(4, "Word Problems: Geometry", s4)}
{sec(5, "Number Talk: Shape Sense", s5)}''')


# ═══════════════════════════════════════════════════
# FRIDAY — Grand Mixed Review & Self-Check
# ═══════════════════════════════════════════════════
def friday():
    # 1: Warm-up — a little of everything
    s1 = '<div class="abox" style="background:#e8f5e9;">'\
         '<p><b>2-min Warm-up</b> — Lightning round! One from each topic.</p>'\
         '<div class="mgrid c2">'
    for q in [f'Half past 9 is {b("3em")}:{b("3em")}', f'2 quarters = {b("3em")}¢',
              f'A triangle has {b("3em")} vertices', f'Area of a 2×3 rectangle = {b("3em")} squares']:
        s1 += f'<div class="abox"><p>{q}</p></div>'
    s1 += '</div></div>'

    # 2: Mixed stations — reduced set, one per topic
    s2 = '<p class="note">One question from each week. You\'ve got this!</p>'
    s2 += '<div class="mgrid c2">'
    s2 += f'<div class="abox" style="text-align:center;"><p><b>Time</b></p>{clock_svg(4, 45, size=50)}'\
          f'<p>{b("3em")}:{b("3em")}</p></div>'
    s2 += f'<div class="abox" style="text-align:center;"><p><b>Money</b></p>'\
          f'{coin_svg("quarter", size=22)}{coin_svg("dime", size=22)}{coin_svg("dime", size=22)}{coin_svg("penny", size=22)}'\
          f'<p>{b("4em")}¢</p></div>'
    s2 += f'<div class="abox" style="text-align:center;"><p><b>Shapes</b></p>{shape_svg("triangle", size=40)}'\
          f'<p>Sides: {b("3em")} Vertices: {b("3em")}</p></div>'
    s2 += f'<div class="abox" style="text-align:center;"><p><b>Area & Perimeter</b></p>{grid_svg(3, 4, cell=14, gap=1)}'\
          f'<p style="font-size:11px;">Area: {b("3em")} Perimeter: {b("3em")}</p></div>'
    s2 += '</div>'

    # 3: Estimate First! — mixed estimation
    s3 = '<div class="abox" style="background:#fff3e0;">'\
         '<p><b>Estimate First!</b> Circle your estimate FIRST, then check.</p>'\
         '<div class="mgrid c2">'
    s3 += '<div class="abox"><p>Is 3 dimes + 3 nickels more or less than 50¢?</p>'\
          '<p style="font-size:11px;">Estimate: more / less &nbsp; Exact: ' + b("3em") + '¢</p></div>'
    s3 += '<div class="abox"><p>Is the perimeter of a 5×5 square more or less than 15 units?</p>'\
          '<p style="font-size:11px;">Estimate: more / less &nbsp; Exact: ' + b("3em") + ' units</p></div>'
    s3 += '</div></div>'

    # 4: Big word problem — multi-topic, show your strategy
    s4 = '<div class="wp">'\
         '<div class="abox" style="background:#f3e5f5;">'\
         '<p><b>The Lemonade Stand</b> — Maya opens her stand at 1:00 and closes at 3:00. '\
         'She sells 4 cups on the first hour and 6 cups in the second hour. Each cup costs a quarter.</p>'\
         '<p style="font-size:0.95em;">a) How long was the stand open? ' + b("5em") + '</p>'\
         '<p style="font-size:0.95em;">b) How many cups did she sell in all? ' + b("3em") + '</p>'\
         '<p style="font-size:0.95em;">c) How much money did she make? ' + b("5em") + '</p>'\
         '<p style="font-size:11px;">Show your strategy for (c) — count coins, skip count, or add another way: ' + bw() + '</p>'\
         '</div></div>'

    # 5: Self-check with emoji reflection
    s5 = '<div class="selfcheck">'\
         '<p><b>Self-Check: Phase 4 — How do you feel about each topic?</b></p>'\
         '<div style="display:flex; gap:12px; flex-wrap:wrap;">'
    topics = [("Telling Time", "#fff3e0"), ("Money", "#e3f2fd"),
              ("Graphs & Data", "#e8f5e9"), ("Shapes & Symmetry", "#f3e5f5"),
              ("Area & Perimeter", "#ffebee")]
    for name, color in topics:
        s5 += f'<div style="background:{color}; padding:8px; border-radius:5px; flex:1; min-width:120px;">'\
              f'<p style="font-size:11px;"><b>{name}</b></p>'\
              '<p style="font-size:11px;">😊  |  😐  |  😟</p></div>'
    s5 += '</div>'\
          '<p style="margin-top:10px;"><b>One thing I learned in Phase 4:</b> ' + bl() + '</p>'\
          '<p><b>One topic I want to practice more:</b> ' + bl() + '</p>'\
          '<p><b>The math I use most outside of school is:</b> ' + bl() + '</p>'\
          '</div>'

    return page(26, "Friday", "Week 26 Grand Review & Self-Check",
        f'''{sec(1, "Warm-up: Lightning Round", s1)}
{sec(2, "Mixed Stations: One From Each Week", s2)}
{sec(3, "Estimate First!", s3)}
{sec(4, "Big Problem: The Lemonade Stand", s4)}
{sec(5, "Self-Check & Phase 4 Reflection", s5)}''')


# ═══════════════════════════════════════════════════
# TEACHER GUIDE
# ═══════════════════════════════════════════════════
def teacher_guide():
    return tg_page_multi(
        "Week 26", "Phase 4 Review — Teacher Guide",

        tg_section_title("Monday: Time & Measurement") +
        tg_sec(1, "Warm-up", ["60 minutes, 30 minutes, 3:15"]) +
        tg_sec(2, "Clocks", ["3:30, 7:15, 11:45, 1:05, 9:50, 6:20"]) +
        tg_sec(3, "Ruler", ["A: 1 in, B: 2.5 in (accept 2 or 3), C: 1.5 in (accept 1 or 2) — nearest inch"]) +
        tg_sec(4, "Number Talk", ["Soccer (1½ hr) is longer than piano (1 hr) — compare lengths, no counting",
                                  "Feet — inches would take too many; big spaces need big units"]) +
        tg_sec(5, "Word Problems", ["3:30", "Yes — ready at 7:30, bus at 7:45, so 15 extra minutes"]) +
        tg_note("Page break"),

        tg_section_title("Tuesday: Money") +
        tg_sec(1, "Warm-up", ["25¢, 10¢, 5¢, 1¢"]) +
        tg_sec(2, "Count Coins", ["$0.60, $0.37, $0.38, $0.95"]) +
        tg_sec(3, "Estimate First", ["More: $1.03", "Less: $0.44"]) +
        tg_sec(4, "Word Problems", ["Yes — 75¢ ≥ 60¢, 15¢ left over",
                                    "Examples: 1 quarter + 1 nickel; 2 dimes + 2 nickels; 6 nickels"]) +
        tg_sec(5, "Challenge", ["Fewest: Q+2D+2P = 5 coins; many other ways (4D+N+2P, etc.)"]) +
        tg_note("Page break"),

        tg_section_title("Wednesday: Data & Graphs") +
        tg_sec(1, "Warm-up", ["6, 16, 9, 22, 10, 12"]) +
        tg_sec(2, "Bar Graph", ["5 more", "22 in all", "Cats not possible alone — Fish + Birds = 8 ✓", "7 bird votes"]) +
        tg_sec(3, "Picture Graph", ["8 books Wednesday", "2 more on Monday (6 − 4)"]) +
        tg_sec(4, "Number Talk", ["The tallest bar wins — height shows amount",
                                  "Fewer symbols — each symbol stands for more"]) +
        tg_sec(5, "Create Own", ["Any accurate 4-vote graph with labels and a sensible question"]) +
        tg_note("Page break"),

        tg_section_title("Thursday: Geometry") +
        tg_sec(1, "Warm-up", ["vertices, right, perimeter"]) +
        tg_sec(2, "Attributes", ["Triangle 3/3, Square 4/4, Rectangle 4/4, Circle 0/0"]) +
        tg_sec(3, "Area & Perimeter", ["2×4: A=8 P=12 | 3×3: A=9 P=12 | 2×6: A=12 P=16"]) +
        tg_sec(4, "Word Problems", ["A square", "Priya's — same pizza in fewer shares means bigger pieces",
                                    "Area 10 square units, Perimeter 14 units"]) +
        tg_sec(5, "Number Talk", ["Yes — 2×6 and 3×4 both cover 12 squares but look different",
                                  "All four sides of a square are EQUAL"]) +
        tg_note("Page break"),

        tg_section_title("Friday: Grand Review & Self-Check") +
        tg_sec(1, "Warm-up", ["9:30, 50¢, 3 vertices, 6 squares"]) +
        tg_sec(2, "Mixed Stations", ["Time: 4:45 | Money: 46¢ | Triangle: 3 sides 3 vertices | Grid: A=12 P=14"]) +
        tg_sec(3, "Estimate First", ["Less — 45¢", "More — 20 units"]) +
        tg_sec(4, "Lemonade Stand", ["a) 2 hours  b) 10 cups  c) 10 quarters = $2.50; accept skip counting by 25s"]) +
        tg_sec(5, "Self-Check", ["Use 😟 topics to plan next week's warm-ups"])
    )


# ═══════════════════════════════════════════════════
# 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"),
        (tuesday, "Tuesday"),
        (wednesday, "Wednesday"),
        (thursday, "Thursday"),
        (friday, "Friday"),
    ]

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

    print("\nWeek 26 (Phase 4 Review — new standard) complete!")
