# -*- coding: utf-8 -*-
"""5. Sinif Ingilizce Yillik Mufredat 2026-2027 DOCX uretici."""
from docx import Document
from docx.shared import Pt, Cm, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.section import WD_ORIENT
from docx.oxml.ns import qn
from docx.oxml import OxmlElement

CREAM = "F7F3EC"
ACCENT = "E07856"
INK = RGBColor(0x33, 0x33, 0x33)

doc = Document()

# --- page setup: A4 landscape ---
s = doc.sections[0]
s.orientation = WD_ORIENT.LANDSCAPE
s.page_width, s.page_height = Cm(29.7), Cm(21.0)
for m in ("top_margin", "bottom_margin", "left_margin", "right_margin"):
    setattr(s, m, Cm(1.6))

# --- base style ---
st = doc.styles["Normal"]
st.font.name = "Arial"
st.font.size = Pt(10.5)
st.element.rPr.rFonts.set(qn("w:eastAsia"), "Arial")
st.paragraph_format.space_after = Pt(4)


def shade(cell, hexcolor):
    tcPr = cell._tc.get_or_add_tcPr()
    sh = OxmlElement("w:shd")
    sh.set(qn("w:val"), "clear")
    sh.set(qn("w:fill"), hexcolor)
    tcPr.append(sh)


def h(text, size=15, color=None, align=None, space_before=6, space_after=4):
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(space_before)
    p.paragraph_format.space_after = Pt(space_after)
    r = p.add_run(text)
    r.bold = True
    r.font.size = Pt(size)
    r.font.color.rgb = color or INK
    if align:
        p.alignment = align
    return p


def para(text, bold=False, size=10.5, italic=False):
    p = doc.add_paragraph()
    r = p.add_run(text)
    r.bold = bold
    r.italic = italic
    r.font.size = Pt(size)
    return p


def repeat_header(table):
    tr = table.rows[0]._tr
    trPr = tr.get_or_add_trPr()
    th = OxmlElement("w:tblHeader")
    th.set(qn("w:val"), "true")
    trPr.append(th)


def mktable(headers, rows, widths):
    t = doc.add_table(rows=1, cols=len(headers))
    t.style = "Table Grid"
    t.autofit = False
    for i, w in enumerate(widths):
        for c in t.columns[i].cells:
            c.width = Cm(w)
    for i, htxt in enumerate(headers):
        cell = t.rows[0].cells[i]
        cell.text = ""
        p = cell.paragraphs[0]
        r = p.add_run(htxt)
        r.bold = True
        r.font.size = Pt(9.5)
        p.alignment = WD_ALIGN_PARAGRAPH.CENTER
        shade(cell, CREAM)
    for row in rows:
        cells = t.add_row().cells
        for i, val in enumerate(row):
            cells[i].text = ""
            p = cells[i].paragraphs[0]
            r = p.add_run(str(val))
            r.font.size = Pt(9.5)
            if i == 0:
                p.alignment = WD_ALIGN_PARAGRAPH.CENTER
        for i, w in enumerate(widths):
            cells[i].width = Cm(w)
    repeat_header(t)
    return t


# ============ TITLE ============
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
r = p.add_run("KKTC İlkokul İngilizce — 5. Sınıf Yıllık Müfredat")
r.bold = True
r.font.size = Pt(20)
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
r = p.add_run("2026-2027 · Seviye A1-A2 · 39 öğretim haftası · 9 ünite")
r.font.size = Pt(11)
r.italic = True
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
r = p.add_run("Kaynak: KKTC MEB Temel Eğitim İngilizce Dersi Öğretim Programı")
r.font.size = Pt(9)
r.font.color.rgb = RGBColor(0x77, 0x77, 0x77)

# ============ TAKVIM ============
h("Eğitim Yılı Takvimi", 14, RGBColor(0xE0, 0x78, 0x56), space_before=14)
para("Dönem 1: 15 Eylül – 19 Aralık 2026 (14 hafta)")
para("Tatil: 21 Aralık 2026 – 4 Ocak 2027 (2 hafta)")
para("Dönem 2: 5 Ocak – 26 Haziran 2027 (25 hafta)")
para("Resmî tatiller (o hafta 4 gün eğitim): 29 Ekim 2026 (Per) · 23 Nisan 2027 (Cum) · 19 Mayıs 2027 (Çar)")
para("Sınavlar: Quiz 1 (Unit 1-2) · Quiz 2 (Unit 3-4) · Dönem Sonu (Unit 1-4) · Quiz 3 (Unit 5-7) · Quiz 4 (Unit 7-9) · Yıl Sonu (Unit 1-9)")

# ============ YILLIK PLAN TABLOSU ============
h("Yıllık Plan — Haftalık Dağılım (39 Hafta)", 14, RGBColor(0xE0, 0x78, 0x56), space_before=14)

rows = [
    ("1", "15-19 Eyl", "Unit 1", "My Day", "Present Simple (to be), object pronouns, before/after", "Daily routines, times, body parts"),
    ("2", "22-26 Eyl", "Unit 1", "My Day", "\u201cI wake up at 7 o'clock.\u201d / \u201cShe helps me.\u201d", "Times, body parts (detaylı)"),
    ("3", "29 Eyl-3 Eki", "Unit 1", "My Day", "Pekiştirme: robot projesi, \u201cKeep it Clean\u201d posteri", "Tüm Unit 1 kelimeleri"),
    ("4", "06-10 Eki", "Unit 2", "People and Jobs", "Present Simple (tüm formlar), prepositions of place (at/in/on), have to/has to", "Jobs, places, family members"),
    ("5", "13-17 Eki", "Unit 2", "People and Jobs", "\u201cShe is a doctor. She works at a hospital.\u201d", "Jobs (30+), places (20+)"),
    ("6", "20-24 Eki", "Unit 2", "People and Jobs", "\u201cHe has to wear a uniform.\u201d / family tree", "Workplace, pocket money"),
    ("7", "27-31 Eki", "Quiz 1", "Unit 1-2", "Quiz + geri bildirim  ⚠️ 29 Ekim tatili", "—"),
    ("8", "03-07 Kas", "Unit 3", "Works at Home", "Adverbs of frequency, Wh-questions (What/When/Whose), have to/has to", "Chores, furniture, days of week, money"),
    ("9", "10-14 Kas", "Unit 3", "Works at Home", "\u201cI always make my bed.\u201d / \u201cWhat do you do on Monday?\u201d", "always, usually, often, sometimes, never"),
    ("10", "17-21 Kas", "Unit 3", "Works at Home", "Pekiştirme: \u201cChores Chart\u201d, furniture etiketleme", "Tüm chores + furniture"),
    ("11", "24-28 Kas", "Unit 4", "Amazing Animals", "Can/can't (ability), Wh-questions (Who/What/Which/How/Why/Where), because", "Animals (40+), habitats, numbers 1-1000"),
    ("12", "01-05 Ara", "Unit 4", "Amazing Animals", "\u201cCheetahs can run fast.\u201d / \u201cWhy do snakes shed their skin?\u201d", "desert, forest, jungle, ocean, river, lake"),
    ("13", "08-12 Ara", "Unit 4", "Amazing Animals", "Physical complaints: headache, tummy ache, toothache, cut, cough", "Illness vocabulary, because"),
    ("14", "15-19 Ara", "Quiz 2 + Dönem Sonu", "Unit 1-4", "Quiz 2 + Dönem 1 sınavı (Unit 1-4)", "—"),
    ("15", "05-09 Oca", "Unit 5", "Weather", "Past Simple (was/were), comparatives", "Months, seasons, clothes, compass points"),
    ("16", "12-16 Oca", "Unit 5", "Weather", "\u201cIt was sunny yesterday.\u201d / \u201cToday is colder than yesterday.\u201d", "Weather words, flora/fauna"),
    ("17", "19-23 Oca", "Unit 5", "Weather", "\u201cWhat did you wear in winter?\u201d / pekiştirme", "Tüm weather + clothes + seasons"),
    ("18", "26-30 Oca", "Unit 6", "Our Senses", "How does it taste/smell/look/feel?, like + Noun/Gerund, linkers (and/but/or)", "Senses verbs, food, adjectives, prices"),
    ("19", "02-06 Şub", "Unit 6", "Our Senses", "\u201cIt tastes sweet.\u201d / \u201cI like swimming but I don't like running.\u201d", "delicious, awful, horrible, lovely, sweet"),
    ("20", "09-13 Şub", "Unit 6", "Our Senses", "Tenses for likes/dislikes, telling prices, pekiştirme", "Food (30+), adjectives (15+)"),
    ("21", "16-20 Şub", "Unit 7", "Eating Out", "There is/are, some/any/a lot of, countable/uncountable", "Food quantities, main meals, menus"),
    ("22", "23-27 Şub", "Unit 7", "Eating Out", "\u201cIs there any rice?\u201d / \u201cThere are a lot of tomatoes.\u201d", "bread, cereal, cheese, egg, spaghetti, rice, meat"),
    ("23", "09-13 Mar", "Quiz 3", "Unit 5-7", "Quiz 3 (Unit 5-7) + geri bildirim", "—"),
    ("24", "16-20 Mar", "Unit 7", "Eating Out", "\u201cHow much is it?\u201d / restoran diyalogları, pekiştirme", "Menu, quantities, prices"),
    ("25", "23-27 Mar", "Unit 8", "Healthy Life", "Past Simple (was/were), enough", "Healthy/unhealthy, main meals, games & sports"),
    ("26", "30 Mar-3 Nis", "Unit 8", "Healthy Life", "\u201cI was tired yesterday.\u201d / \u201cI don't get enough sleep.\u201d", "calorie, exercise, breakfast, habits"),
    ("27", "06-10 Nis", "Unit 8", "Healthy Life", "Sports vocabulary, pekiştirme: \u201cHealthy Living Wheel\u201d", "football, cycling, tennis, swimming, jogging"),
    ("28", "13-17 Nis", "Unit 9", "Places to Visit", "Past Simple (regular & irregular: went/saw/ate/had/was/got), linkers (and/but/or)", "Places, art vocabulary, countries"),
    ("29", "20-24 Nis", "Unit 9", "Places to Visit", "\u201cWe went to the museum.\u201d / \u201cI saw a painting.\u201d  ⚠️ 23 Nisan", "theatre, circus, zoo, library, museum, gallery"),
    ("30", "27 Nis-1 May", "Quiz 4", "Unit 7-9", "Quiz 4 (Unit 7-9) + geri bildirim", "—"),
    ("31", "04-08 May", "Review", "Unit 1-4", "Dönem 1 tekrarı (My Day, People & Jobs, Works at Home, Animals)", "—"),
    ("32", "11-15 May", "Review", "Unit 5-9", "Dönem 2 tekrarı (Weather, Senses, Eating Out, Healthy Life, Places)", "—"),
    ("33", "18-22 May", "Review", "Tüm üniteler", "Sınav hazırlığı: tüm grammar + vocabulary  ⚠️ 19 Mayıs", "—"),
    ("34", "25-29 May", "Yıl Sonu Sınavı", "Unit 1-9", "Yıl sonu sınavı (dört beceri)", "—"),
    ("35", "01-05 Haz", "Portfolio", "—", "Portfolio sunumları + \u201cMy English Book\u201d", "—"),
    ("36", "08-12 Haz", "Portfolio", "—", "İngilizce oyunları, şarkılar, drama", "—"),
    ("37", "15-19 Haz", "Wrap-up", "—", "Yıl sonu etkinlikleri, sınıf partisi", "—"),
    ("38", "22-26 Haz", "Wrap-up", "—", "Son hafta: oyun günü, sertifika dağıtımı", "—"),
    ("39", "29 Haz-3 Tem", "Wrap-up", "—", "Buffer / makeup günleri", "—"),
]

mktable(
    ["Hf", "Tarih", "Ünite", "Konu", "Grammar / Odak", "Kelime"],
    rows,
    widths=[0.9, 2.2, 2.6, 3.0, 11.4, 6.4],
)

# ============ UNITE DETAYLARI ============
h("Ünite Detayları — Grammar ve Kelime (Unit 1-9)", 14, RGBColor(0xE0, 0x78, 0x56), space_before=2)
para("Aşağıdaki içerik, KGS 5. sınıf müfredat dokümanından ünite ünite derlenmiştir.", italic=True, size=9.5)

UNITS = [
    ("Unit 1 — My Day", [
        ("Grammar",
         ["Present Simple — to be (am/is/are): olumlu, olumsuz, soru, kısa cevap",
          "Object pronouns: me, you, him, her, it, us, them (fiilden/edattan sonra)",
          "Prepositions of time: at (saat), on (gün), in (ay/mevsim/yıl)",
          "Before / After: \u201cI brush my teeth before school.\u201d / \u201c... after dinner.\u201d"]),
        ("Lexis",
         ["Daily routines: wake up, get up, brush teeth, wash face, have breakfast, go to school, have lunch, do homework, go to bed",
          "Times: o'clock, half past, quarter past, quarter to, a.m., p.m.",
          "Body parts: head, hair, face, eyes, ears, nose, mouth, teeth, arms, hands, legs, feet, shoulders, knees"]),
    ]),
    ("Unit 2 — People and Jobs", [
        ("Grammar",
         ["Present Simple — full verbs: olumlu (he/she/it + s), olumsuz (don't/doesn't + V1), soru (Do/Does + özne + V1)",
          "Prepositions of place: at (spesifik nokta), in (içinde), on (yüzeyde)",
          "Have to / Has to (zorunluluk): have to + V1 / has to + V1; don't/doesn't have to"]),
        ("Lexis",
         ["Jobs: teacher, doctor, nurse, police officer, firefighter, engineer, chef, pilot, dentist, mechanic, vet, farmer",
          "Places: school, hospital, police station, fire station, restaurant, airport, farm, office, factory, garage",
          "Family members: father, mother, brother, sister, grandfather, grandmother, uncle, aunt, cousin, nephew, niece"]),
    ]),
    ("Unit 3 — Works at Home", [
        ("Grammar",
         ["Adverbs of frequency: always, usually, sometimes, rarely, never",
          "Adjective + noun combinations: a big house, a red car, an interesting book",
          "Wh-questions: What? When? Whose?",
          "Have to / Has to (zorunluluk) — pekiştirme"]),
        ("Lexis",
         ["Chores: wash the dishes, make the bed, tidy the room, vacuum, iron, sweep",
          "Furniture: table, chair, sofa, bed, wardrobe, bookshelf, desk, lamp",
          "Days of week: Monday–Sunday",
          "Money: coin, note, pay, cost, change, price, expensive, cheap"]),
    ]),
    ("Unit 4 — Amazing Animals", [
        ("Grammar",
         ["Can / Can't (yetenek): can + V1 (\u201cHe can dance\u201d — can'den sonra -s/-ing gelmez)",
          "Wh-questions: Who? What? Which? How? Why? Where?",
          "Common & irregular nouns: book→books; man→men, woman→women, child→children, foot→feet, tooth→teeth, mouse→mice",
          "Linker: because (\u201cI am happy because it's my birthday.\u201d)"]),
        ("Lexis",
         ["Animals: lion, tiger, elephant, monkey, snake, bird, fish, bear, rabbit",
          "Habitats: forest, desert, ocean, mountain, jungle, river, polar region",
          "Landmarks: Eiffel Tower, Big Ben, Statue of Liberty, Pyramids, Colosseum",
          "Numbers 1-1000: one ... one hundred, five hundred, one thousand"]),
    ]),
    ("Unit 5 — Weather", [
        ("Grammar",
         ["Past Simple — to be (was/were): olumlu, olumsuz (wasn't/weren't), soru, kısa cevap",
          "Comparatives: tall→taller, big→bigger, hot→hotter; beautiful→more beautiful; good→better, bad→worse; ... than"]),
        ("Lexis",
         ["Months: January–December",
          "Seasons: spring, summer, autumn (fall), winter",
          "Clothes: shirt, trousers, dress, skirt, jacket, coat, hat, shoes, socks, gloves, scarf",
          "Points of the compass: north, south, east, west, northeast, northwest, southeast, southwest",
          "Weather: sunny, rainy, cloudy, snowy, windy, stormy, foggy, hot, cold, warm"]),
    ]),
    ("Unit 6 — Our Senses", [
        ("Grammar",
         ["How does it taste/smell/look/feel? — It tastes sweet. / It looks beautiful.",
          "Adjectives of state: hungry, thirsty, tired, cold, sad, happy",
          "Like + Noun / Gerund: I like pizza. / I like swimming. (like + to + V1 de doğru)",
          "Linkers: and, but, or"]),
        ("Lexis",
         ["Senses (verbs): taste, smell, look, feel, sound, hear, see",
          "Food: bread, cheese, rice, pasta, meat, chicken, fish, egg, soup",
          "Vegetables: tomato, potato, carrot, onion, pepper, lettuce, cucumber",
          "Drinks: water, milk, juice, tea, coffee, lemonade",
          "State (adjectives): hungry, thirsty, tired, cold, sad, happy, angry, bored",
          "Telling prices: cost, pay, add"]),
    ]),
    ("Unit 7 — Eating Out", [
        ("Grammar",
         ["Expressing quantity: How much (uncountable) / How many (countable)",
          "There is / There are: tekil/çoğul; soru (Is there...? / Are there...?); olumsuz (isn't/aren't)",
          "Some / any / a lot of: some (olumlu), any (olumsuz/soru), a lot of (her ikisi)",
          "Countable & uncountable nouns: apple/book vs. water/milk/bread/rice/money/music"]),
        ("Lexis",
         ["Food: bread, cheese, rice, pasta, meat, chicken, fish, soup, salad, sandwich",
          "Main meals: breakfast, lunch, dinner, supper, snack, dessert",
          "Quantities of food: a kilo of rice, a bottle of water, a piece of cake, a glass of milk"]),
    ]),
    ("Unit 8 — Healthy Life", [
        ("Grammar",
         ["Past Simple — to be (was/were): olumlu, olumsuz, soru, kısa cevap (pekiştirme)",
          "Enough: adjective + enough (\u201cwarm enough\u201d) / enough + noun (\u201cenough money\u201d)"]),
        ("Lexis",
         ["Meals: breakfast, lunch, dinner, supper",
          "Habits (verbs): brush teeth, make bed, wash face, comb hair, get dressed, have breakfast",
          "Games: chess, checkers, dominoes, cards, hide and seek, tag",
          "Sports: football, basketball, tennis, swimming, running, volleyball, cycling"]),
    ]),
    ("Unit 9 — Places to Visit", [
        ("Grammar",
         ["Past Simple — regular (+ed): walk→walked, play→played; stop→stopped, study→studied",
          "Past Simple — irregular: go→went, see→saw, eat→ate, have→had, be→was/were, get→got",
          "Olumsuz/soru: didn't + V1 / Did + özne + V1 (\u201cShe didn't go\u201d — fiil yalın)",
          "Linkers: and, but, or (pekiştirme)"]),
        ("Lexis",
         ["Places: park, museum, library, cinema, theatre, zoo, beach, market, hospital, school, restaurant",
          "Art: painting, drawing, sculpture, photograph",
          "Art adjectives: beautiful, boring, colourful, funny, interesting, scary, strange, ugly, amazing"]),
    ]),
]

for title, blocks in UNITS:
    h(title, 13, RGBColor(0x33, 0x33, 0x33), space_before=12, space_after=2)
    for label, items in blocks:
        p = doc.add_paragraph()
        r = p.add_run(label)
        r.bold = True
        r.font.size = Pt(10.5)
        r.font.color.rgb = RGBColor(0xE0, 0x78, 0x56)
        p.paragraph_format.space_before = Pt(4)
        p.paragraph_format.space_after = Pt(2)
        for it in items:
            bp = doc.add_paragraph(style="List Bullet")
            rr = bp.add_run(it)
            rr.font.size = Pt(10)
            bp.paragraph_format.space_after = Pt(1)

# ============ OZET ============
doc.add_page_break()
h("Özet — Ünite / Hafta Dağılımı", 14, RGBColor(0xE0, 0x78, 0x56), space_before=2)
mktable(
    ["Bölüm", "Haftalar", "Sınav"],
    [
        ("Unit 1 — My Day", "1-3", "Quiz 1 (H7, Unit 1-2)"),
        ("Unit 2 — People and Jobs", "4-6", "—"),
        ("Unit 3 — Works at Home", "8-10", "Quiz 2 + Dönem Sonu (H14, Unit 3-4)"),
        ("Unit 4 — Amazing Animals", "11-13", "—"),
        ("Unit 5 — Weather", "15-17", "Quiz 3 (H23, Unit 5-7)"),
        ("Unit 6 — Our Senses", "18-20", "—"),
        ("Unit 7 — Eating Out", "21-22, 24", "—"),
        ("Unit 8 — Healthy Life", "25-27", "Quiz 4 (H30, Unit 7-9)"),
        ("Unit 9 — Places to Visit", "28-29", "—"),
        ("Review", "31-33", "—"),
        ("Yıl Sonu Sınavı", "34", "Unit 1-9"),
        ("Portfolio + Wrap-up", "35-39", "—"),
    ],
    widths=[7.0, 4.0, 12.0],
)

h("Notlar", 13, RGBColor(0x33, 0x33, 0x33), space_before=12)
for n in [
    "Her ünite ~3 hafta: ilk haftalar yeni içerik, son hafta pekiştirme.",
    "Quiz 1 (Unit 1-2), Quiz 2 (Unit 3-4), Quiz 3 (Unit 5-7), Quiz 4 (Unit 7-9).",
    "Dönem Sonu Sınavı: Hafta 14 (Unit 1-4) — dört beceri.",
    "Yıl Sonu Sınavı: Hafta 34 (Unit 1-9) — dört beceri.",
    "Portfolio Dossier: MEB programında her ünite için önerilir.",
    "29 Ekim, 23 Nisan, 19 Mayıs haftaları 4 gün eğitim; quiz/pekiştirme haftasına denk getirildi.",
]:
    bp = doc.add_paragraph(style="List Bullet")
    rr = bp.add_run(n)
    rr.font.size = Pt(10)
    bp.paragraph_format.space_after = Pt(1)

p = doc.add_paragraph()
p.paragraph_format.space_before = Pt(10)
r = p.add_run("* Kaynak: KKTC MEB Temel Eğitim İngilizce Dersi Öğretim Programı · Hazırlık: Serdarlı İlkokulu")
r.italic = True
r.font.size = Pt(9)
r.font.color.rgb = RGBColor(0x77, 0x77, 0x77)

out = "/root/Akademik/İngilizce/5. Sınıf/5_Sinif_Ingilizce_Yillik_Mufredat_2026-2027.docx"
doc.save(out)
print("saved:", out)
print("paras:", len(doc.paragraphs), "tables:", len(doc.tables))
