#!/usr/bin/env python3
"""Part 5: Tüm Cevap Anahtarları + Açıklamalar"""
from docx import Document
from docx.shared import Pt, Cm, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH

PATH = "/root/Akademik/İngilizce/5. Sınıf/Unit1_My_Day.docx"
doc = Document(PATH)

FONT = "Niramit"
BLUE = RGBColor(0x1a, 0x55, 0x9e)
DARK = RGBColor(0x22, 0x22, 0x22)
GRAY = RGBColor(0x55, 0x55, 0x55)

def r(p, text, size=11, bold=False, color=DARK, italic=False):
    rr = p.add_run(text)
    rr.font.name = FONT; rr.font.size = Pt(size)
    rr.bold = bold; rr.font.color.rgb = color; rr.italic = italic
    return rr

def heading(text, sz=14):
    doc.add_page_break()
    p = doc.add_paragraph()
    p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    r(p, text, sz, True, BLUE)

def answer_block(title, answers):
    heading(title)
    doc.add_paragraph()
    
    # Quick answers in a grid
    p = doc.add_paragraph()
    p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    for i, (n, a, _) in enumerate(answers):
        r(p, f" {n}.{a} ", 10, True, DARK)
        if (i+1) % 5 == 0 and i < len(answers)-1:
            p = doc.add_paragraph()
            p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    
    doc.add_paragraph()
    r(doc.add_paragraph(), "Açıklamalar:", 11, True, BLUE)
    doc.add_paragraph()
    for n, a, e in answers:
        p = doc.add_paragraph()
        p.paragraph_format.space_after = Pt(3)
        r(p, f"Soru {n}: {a}  —  ", 10, True)
        r(p, e, 10, False, GRAY)

def reading_answers():
    heading("OKUMA PARÇALARI — CEVAP ANAHTARI")
    doc.add_paragraph()
    
    data = [
        ("Okuma 1 — Kolay (Ayşe's Day)", ["1.B", "2.C", "3.C", "4.B", "5.C"]),
        ("Okuma 2 — Orta (Mehmet and His Family)", ["1.B", "2.B", "3.C", "4.B", "5.C"]),
        ("Okuma 3 — Zor (A Special Morning)", ["1.B", "2.C", "3.C", "4.C", "5.B", "6.B"]),
    ]
    for title, qs in data:
        p = doc.add_paragraph()
        p.paragraph_format.space_before = Pt(6)
        r(p, title, 11, True, BLUE)
        p2 = doc.add_paragraph()
        p2.paragraph_format.left_indent = Cm(0.5)
        r(p2, "  ".join(qs), 10, True, DARK)

# Deneme 1 answers
answer_block("DENEME 1 — CEVAP ANAHTARI", [
    (1,"A","I + am. 'I am 10 years old.'"),
    (2,"C","She + is. 'She is a student.'"),
    (3,"C","We + are. 'We are friends.'"),
    (4,"B","8:15 = quarter past eight (8'i çeyrek geçe)"),
    (5,"C","Saatlerde 'at' kullanılır: at 7 o'clock"),
    (6,"B","Are you...? → Yes, I am. (you sorusuna I ile cevap)"),
    (7,"B","Fiilden sonra object pronoun: love her (she değil)"),
    (8,"C","'wash my face' — yüz yıkamak (günlük rutin)"),
    (9,"B","Is your father...? → No, he isn't. (erkek, tekil)"),
    (10,"B","'brush my teeth' — diş fırçalamak (günlük rutin)"),
    (11,"C","your friends (çoğul) → Are they...?"),
    (12,"A","7:30 = half past seven (yarım/yedi buçuk)"),
    (13,"C","Boynun üstündeki vücut bölümleri: head and shoulders"),
    (14,"D","Ödev okuldan SONRA yapılır: after school"),
    (15,"B","Ali erkek → object pronoun him (he değil)"),
])

# Deneme 2 answers
answer_block("DENEME 2 — CEVAP ANAHTARI", [
    (1,"B","Is your sister...? → No, she isn't. (olumsuz)"),
    (2,"B","My brother and I = we → are (çoğul, 1. şahıs)"),
    (3,"B","Edattan (look at) sonra object pronoun: Look at him."),
    (4,"C","Are you ready? → soru yapısı"),
    (5,"D","Are your pencils (çoğul)? → Yes, they are."),
    (6,"C","Gün bölümlerinde 'in': in the morning"),
    (7,"A","Her name (iyelik sıfatı) + She is (özne zamiri)"),
    (8,"B","Kitap okumak: read a book"),
    (9,"A","Yatmadan ÖNCE diş fırçalamak → before I go to bed"),
    (10,"C","5:30 = half past five"),
    (11,"C","11:45 = quarter to twelve (12'ye çeyrek var)"),
    (12,"B","Amy+Tom = they → Fiilden sonra object pronoun: them"),
    (13,"C","7:45 = quarter to eight (8'e çeyrek var)"),
    (14,"C","Duştan sonra SAÇ taranır: comb my hair"),
    (15,"D","Saat sormak için: What time"),
])

# Deneme 3 answers
answer_block("DENEME 3 — CEVAP ANAHTARI", [
    (1,"A","Soru 'Is' → cevap 'is'. Yer bildiriyor, olumsuz değil."),
    (2,"B","Are you...? → No, we aren't. (çoğul olumsuz)"),
    (3,"C","sister+I = we → are. İyelik: Our birthdays. (Us özne olamaz)"),
    (4,"A","Is he...? → Yes, he is. (he's kısaltması cevapta doğru, 'he does' veya 'he has' anlam kayması yapar. 'hes' ❌)"),
    (5,"B","Look at + object pronoun. She → her. (Çeldirici: 'him' erkek)"),
    (6,"C","What time (saat sorusu) + in the morning (gün bölümü)"),
    (7,"A","help + object pronoun (him) + possessive (his teeth)"),
    (8,"A","Are your parents (çoğul)? → No, they aren't."),
    (9,"B","half past seven = 7:30. at half past seven (saatte at)"),
    (10,"A","İkisi de saat: at 6:30 / at 7 o'clock"),
    (11,"B","8:45 = quarter to nine (9'a çeyrek var)"),
    (12,"B","grandmother = she → object pronoun her"),
    (13,"B","gives + object pronoun (us) + like + object pronoun (her). Çeldirici: we/she özne zamiri."),
    (14,"B","Diş fırçalama kahvaltıdan ÖNCE: before breakfast"),
    (15,"C","8:00 → 8:30. Okul 8'den SONRA başlıyor: after 8 o'clock"),
])

# Reading answers
reading_answers()

# Final page
doc.add_page_break()
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
r(p, "— KİTAP SONU —", 14, True, BLUE)
p2 = doc.add_paragraph()
p2.alignment = WD_ALIGN_PARAGRAPH.CENTER
r(p2, "Unit 1: My Day | KKTC KGS İngilizce Hazırlık | Niramit Edition", 9, False, GRAY, italic=True)

doc.save(PATH)
print("✅ Part 5 eklendi: Tüm cevap anahtarları + açıklamalar")
