#!/usr/bin/env python3
"""Part 4: Okuma 2 (Orta) + Okuma 3 (Zor)"""
from docx import Document
from docx.shared import Pt, Cm, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.oxml.ns import qn

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(0x66, 0x66, 0x66)

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

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

def sub(text):
    p = doc.add_paragraph()
    p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    run(p, text, 10, False, GRAY, italic=True)

def add_q(num, stem, opts):
    doc.add_paragraph()
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(6)
    run(p, f"{num}. {stem}", 11, True)
    for o in opts:
        p2 = doc.add_paragraph()
        p2.paragraph_format.left_indent = Cm(1)
        p2.paragraph_format.space_before = Pt(1)
        p2.paragraph_format.space_after = Pt(1)
        run(p2, o, 10.5)

def passage_box(text, title=None):
    if title:
        p = doc.add_paragraph()
        run(p, title, 11, True, DARK, italic=True)
    table = doc.add_table(rows=1, cols=1)
    cell = table.cell(0, 0)
    p = cell.paragraphs[0]
    r = p.add_run(text)
    r.font.name = FONT; r.font.size = Pt(11); r.italic = True
    shading = cell._element.get_or_add_tcPr()
    shd = shading.makeelement(qn('w:shd'), {qn('w:val'): 'clear', qn('w:color'): 'auto', qn('w:fill'): 'F5F8FC'})
    shading.append(shd)
    doc.add_paragraph()

# ================================================================
# OKUMA 2 - ORTA
# ================================================================
heading("OKUMA 2 — ORTA")
sub("Aşağıdaki metni okuyunuz. Soruları metne göre cevaplayınız.")

passage_box(
    "Hi! I am Mehmet. I am 11 years old. I am in the 5th grade. "
    "I have a big family. There are five people in my family: my mother, my father, "
    "my two sisters and me. My sisters are younger than me. Their names are Elif and Zeynep. "
    "Elif is 7 and Zeynep is 4 years old. They are very cute but they are noisy in the morning! "
    "My mother is a teacher. She works at a school in Kyrenia. "
    "She wakes up very early at 5:30 every day. After she wakes up, she prepares breakfast for us. "
    "My father is a doctor. He works at a hospital. He wakes up at 6 o'clock. "
    "Before he goes to work, he drinks coffee and reads the newspaper. "
    "I wake up at 7 o'clock. I have breakfast with my sisters at 7:30. "
    "After breakfast, I brush my teeth and get dressed. My mother takes us to school at 8 o'clock. "
    "School starts at 8:30. My favourite lesson is English. Our English teacher is Mrs. Smith. She is very kind. "
    "After school, I come home at 3 o'clock. I do my homework before dinner. "
    "After dinner, I play with my sisters or watch TV. "
    "I go to bed at 9:30. My sisters go to bed at 8:30 because they are younger.",
    title="Mehmet and His Family"
)

add_q(1, "How many sisters does Mehmet have?",
    ["A) One", "B) Two", "C) Three", "D) Four"])

add_q(2, "What does Mehmet's mother do?",
    ["A) She is a doctor.", "B) She is a teacher.",
     "C) She is a nurse.", "D) She is a student."])

add_q(3, "What does Mehmet's father do before he goes to work?",
    ["A) He prepares breakfast.", "B) He reads a book.",
     "C) He drinks coffee and reads the newspaper.", "D) He takes a shower."])

add_q(4, "Why do Mehmet's sisters go to bed at 8:30?",
    ["A) Because they are tired.", "B) Because they are younger.",
     "C) Because they don't like TV.", "D) Because they are hungry."])

add_q(5, "What is true about Mrs. Smith?",
    ["A) She is Mehmet's mother.", "B) She is a strict teacher.",
     "C) She is very kind.", "D) She teaches Maths."])

# ================================================================
# OKUMA 3 - ZOR
# ================================================================
heading("OKUMA 3 — ZOR")
sub("Aşağıdaki metni okuyunuz. Soruları metne göre cevaplayınız.")

passage_box(
    "It is a busy morning in the Brown family. Mr. Brown is a carpenter. He works in a workshop near their house. "
    "He usually wakes up at 6 o'clock. But today is different. Today, he is not at the workshop. "
    "He is at home because it is his birthday! Mrs. Brown is in the kitchen. She is preparing a special breakfast for him. "
    "She is a wonderful cook. Their children, Tom and Emily, are in their rooms. "
    "Tom is 12 years old. He is getting dressed. He has a big exam at school today. "
    "He is a little nervous. Emily is 9 years old. She is brushing her long, brown hair in front of the mirror. "
    "She is very happy because today is also her best friend's birthday party after school. "
    "Grandpa Brown is in the garden. He is 75 years old but he is very strong. He is watering the flowers. "
    "He lives with the family. He is a very kind man. He always helps Mrs. Brown in the garden. "
    "At 7 o'clock, the family is at the breakfast table. There are pancakes, eggs, fruit, and orange juice. "
    "Mr. Brown is very happy. 'Thank you, everyone! This is a perfect morning!' he says. "
    "Before they eat, Tom says, 'Happy birthday, Dad!' and gives him a small box. "
    "Inside the box, there is a beautiful pen. Mr. Brown loves it. "
    "After breakfast, Tom goes to school. Emily goes to school too, but after school, she is going to the party. "
    "Mr. Brown stays at home with Mrs. Brown. It is a special day for all of them.",
    title="A Special Morning — The Brown Family"
)

add_q(1, "Why is Mr. Brown at home today instead of at the workshop?",
    ["A) He is sick.", "B) It is his birthday.",
     "C) The workshop is closed.", "D) He is on holiday."])

add_q(2, "What is Emily doing before breakfast?",
    ["A) She is studying for an exam.",
     "B) She is getting dressed.",
     "C) She is brushing her hair.",
     "D) She is watering the flowers."])

add_q(3, "Who lives with the Brown family?",
    ["A) Emily's best friend.", "B) Mrs. Brown's mother.",
     "C) Grandpa Brown.", "D) Tom's teacher."])

add_q(4, "What does Tom give his father for his birthday?",
    ["A) A book.", "B) A watch.", "C) A pen.", "D) A box of chocolates."])

add_q(5, "Why is Tom nervous?",
    ["A) He has a birthday party.", "B) He has an exam at school.",
     "C) He is late for school.", "D) He doesn't like breakfast."])

add_q(6, "What can we understand about Grandpa Brown from the text?",
    ["A) He is 75 and very weak.",
     "B) He helps Mrs. Brown in the garden.",
     "C) He doesn't live with the family.",
     "D) He is a carpenter."])

doc.save(PATH)
print("✅ Part 4 eklendi: Okuma 2 (Orta) + Okuma 3 (Zor)")
