Topic: Phosphorus i need study material in pdf form in easy language

Asking for Preferences
Reading File
Reading File
Finding Sources
Searching the Web

phosphorus chemistry biology phosphorus cycle easy study notes

Running Command

mkdir -p /tmp/workspace/phosphorus-study && ls /tmp/workspace/

Writing File

~/phosphorus-study/make_pdf.py

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak, KeepTogether
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import ListFlowable, ListItem

OUTPUT = "/tmp/workspace/phosphorus-study/Phosphorus_Study_Material.pdf"

# ── Colour palette ──────────────────────────────────────────────────────────
BLUE_DARK  = colors.HexColor("#1a3a5c")
BLUE_MID   = colors.HexColor("#2e6da4")
BLUE_LIGHT = colors.HexColor("#d6eaf8")
GREEN      = colors.HexColor("#1e8449")
GREEN_LIGHT= colors.HexColor("#d5f5e3")
ORANGE     = colors.HexColor("#e67e22")
ORANGE_LIGHT=colors.HexColor("#fdebd0")
RED        = colors.HexColor("#c0392b")
YELLOW_BOX = colors.HexColor("#fef9e7")
GREY_LIGHT = colors.HexColor("#f2f3f4")
WHITE      = colors.white

doc = SimpleDocTemplate(
    OUTPUT, pagesize=A4,
    leftMargin=2*cm, rightMargin=2*cm,
    topMargin=2.2*cm, bottomMargin=2*cm
)

styles = getSampleStyleSheet()

# ── Custom styles ────────────────────────────────────────────────────────────
def S(name, **kw):
    return ParagraphStyle(name, **kw)

cover_title = S("CoverTitle", fontSize=34, textColor=WHITE,
                fontName="Helvetica-Bold", alignment=TA_CENTER, leading=42)
cover_sub   = S("CoverSub",   fontSize=16, textColor=colors.HexColor("#d6eaf8"),
                fontName="Helvetica", alignment=TA_CENTER, leading=24)

ch_title    = S("ChTitle",    fontSize=18, textColor=WHITE,
                fontName="Helvetica-Bold", alignment=TA_LEFT,
                leftIndent=8, leading=24)
sec_head    = S("SecHead",    fontSize=13, textColor=BLUE_DARK,
                fontName="Helvetica-Bold", spaceBefore=14, spaceAfter=4)
sub_head    = S("SubHead",    fontSize=11, textColor=BLUE_MID,
                fontName="Helvetica-Bold", spaceBefore=8, spaceAfter=3)
body        = S("Body",       fontSize=10, textColor=colors.black,
                fontName="Helvetica", leading=15, spaceAfter=5,
                alignment=TA_JUSTIFY)
bullet_s    = S("Bullet",     fontSize=10, textColor=colors.black,
                fontName="Helvetica", leading=14, leftIndent=16,
                bulletIndent=6, spaceAfter=3)
note_s      = S("Note",       fontSize=9.5, textColor=colors.HexColor("#555555"),
                fontName="Helvetica-Oblique", leading=13,
                leftIndent=10, spaceAfter=3)
key_s       = S("KeyFact",    fontSize=10, textColor=BLUE_DARK,
                fontName="Helvetica-Bold", leading=14, spaceAfter=2)
toc_s       = S("TOC",        fontSize=11, textColor=BLUE_MID,
                fontName="Helvetica", leading=18, leftIndent=10)
white_body  = S("WhiteBody",  fontSize=10, textColor=WHITE,
                fontName="Helvetica", leading=14)

# ── Helper builders ──────────────────────────────────────────────────────────
def chapter_banner(text, color=BLUE_DARK):
    data = [[Paragraph(text, ch_title)]]
    t = Table(data, colWidths=[17*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), color),
        ("ROWBACKGROUNDS", (0,0), (-1,-1), [color]),
        ("TOPPADDING",    (0,0), (-1,-1), 10),
        ("BOTTOMPADDING", (0,0), (-1,-1), 10),
        ("LEFTPADDING",   (0,0), (-1,-1), 14),
        ("RIGHTPADDING",  (0,0), (-1,-1), 14),
        ("BOX", (0,0), (-1,-1), 1.5, color),
    ]))
    return t

def info_box(title, paragraphs, bg=BLUE_LIGHT, title_color=BLUE_DARK):
    rows = [[Paragraph(f"<b>{title}</b>", S("IBT", fontSize=10.5,
              textColor=title_color, fontName="Helvetica-Bold", leading=14))]]
    for p in paragraphs:
        rows.append([Paragraph(p, body)])
    t = Table(rows, colWidths=[16.6*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("TOPPADDING",    (0,0), (-1,-1), 6),
        ("BOTTOMPADDING", (0,0), (-1,-1), 6),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("RIGHTPADDING",  (0,0), (-1,-1), 10),
        ("BOX", (0,0), (-1,-1), 1, BLUE_MID),
    ]))
    return t

def fact_box(text, bg=YELLOW_BOX, border=ORANGE):
    data = [[Paragraph(f"<b>&#9733; Key Fact:</b>  {text}", key_s)]]
    t = Table(data, colWidths=[16.6*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), bg),
        ("TOPPADDING",    (0,0), (-1,-1), 7),
        ("BOTTOMPADDING", (0,0), (-1,-1), 7),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("RIGHTPADDING",  (0,0), (-1,-1), 10),
        ("BOX",           (0,0), (-1,-1), 2, border),
    ]))
    return t

def table_2col(headers, rows, col_w=(7*cm, 9.5*cm)):
    data = [headers] + rows
    t = Table(data, colWidths=list(col_w))
    style = [
        ("BACKGROUND",    (0,0), (-1,0),  BLUE_DARK),
        ("TEXTCOLOR",     (0,0), (-1,0),  WHITE),
        ("FONTNAME",      (0,0), (-1,0),  "Helvetica-Bold"),
        ("FONTSIZE",      (0,0), (-1,-1), 9.5),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, GREY_LIGHT]),
        ("GRID",          (0,0), (-1,-1), 0.5, colors.HexColor("#bbbbbb")),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 7),
        ("RIGHTPADDING",  (0,0), (-1,-1), 7),
        ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
    ]
    t.setStyle(TableStyle(style))
    return t

def bullets(items):
    return [Paragraph(f"&#8226;  {i}", bullet_s) for i in items]

def sp(h=6):
    return Spacer(1, h)

def hr():
    return HRFlowable(width="100%", thickness=1, color=colors.HexColor("#cccccc"),
                      spaceAfter=4, spaceBefore=4)

# ════════════════════════════════════════════════════════════════════════════
#  BUILD DOCUMENT
# ════════════════════════════════════════════════════════════════════════════
story = []

# ── COVER PAGE ───────────────────────────────────────────────────────────────
cover_bg = Table(
    [[Paragraph("PHOSPHORUS", cover_title)],
     [sp(8)],
     [Paragraph("Complete Study Material", cover_sub)],
     [sp(6)],
     [Paragraph("Chemistry  •  Biology  •  Environment  •  Health", cover_sub)],
     [sp(20)],
     [Paragraph("Easy Language | Class 11-12 / Competitive Exams", cover_sub)],
    ],
    colWidths=[17*cm]
)
cover_bg.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,-1), BLUE_DARK),
    ("TOPPADDING",    (0,0), (-1,-1), 14),
    ("BOTTOMPADDING", (0,0), (-1,-1), 14),
    ("LEFTPADDING",   (0,0), (-1,-1), 20),
    ("RIGHTPADDING",  (0,0), (-1,-1), 20),
    ("BOX",           (0,0), (-1,-1), 3, BLUE_MID),
]))
story.append(Spacer(1, 2*cm))
story.append(cover_bg)
story.append(Spacer(1, 1.5*cm))

# small summary strip
info = Table(
    [[Paragraph("<b>Topics Covered:</b>  Basic Properties · Allotropes · Compounds · Role in Body · "
                "Phosphorus Cycle · Deficiency & Toxicity · Fertilisers · Quick Revision", body)]],
    colWidths=[17*cm]
)
info.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,-1), BLUE_LIGHT),
    ("TOPPADDING",    (0,0), (-1,-1), 10),
    ("BOTTOMPADDING", (0,0), (-1,-1), 10),
    ("LEFTPADDING",   (0,0), (-1,-1), 14),
    ("BOX",           (0,0), (-1,-1), 1, BLUE_MID),
]))
story.append(info)
story.append(PageBreak())

# ── TABLE OF CONTENTS ────────────────────────────────────────────────────────
story.append(chapter_banner("Table of Contents"))
story.append(sp(14))
toc_items = [
    ("1", "Introduction to Phosphorus",          "3"),
    ("2", "Basic Properties",                    "3"),
    ("3", "Allotropes of Phosphorus",             "4"),
    ("4", "Important Compounds of Phosphorus",   "5"),
    ("5", "Phosphorus in the Human Body",         "6"),
    ("6", "The Phosphorus Cycle",                 "8"),
    ("7", "Phosphorus in Agriculture",            "9"),
    ("8", "Deficiency & Excess (Health)",         "10"),
    ("9", "Environmental Impact",                 "11"),
    ("10","Quick Revision & MCQs",               "12"),
]
for num, title, pg in toc_items:
    row = Table([[Paragraph(f"<b>Chapter {num}</b>", toc_s),
                  Paragraph(title, toc_s),
                  Paragraph(f"Pg {pg}", toc_s)]],
               colWidths=[3.5*cm, 10.5*cm, 3*cm])
    row.setStyle(TableStyle([
        ("ROWBACKGROUNDS", (0,0), (-1,-1), [WHITE, GREY_LIGHT]),
        ("TOPPADDING",     (0,0), (-1,-1), 5),
        ("BOTTOMPADDING",  (0,0), (-1,-1), 5),
        ("LEFTPADDING",    (0,0), (-1,-1), 8),
        ("BOX",            (0,0), (-1,-1), 0.5, colors.HexColor("#aaaaaa")),
    ]))
    story.append(row)
    story.append(sp(3))

story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CHAPTER 1: INTRODUCTION
# ════════════════════════════════════════════════════════════════════════════
story.append(chapter_banner("Chapter 1: Introduction to Phosphorus"))
story.append(sp(10))
story.append(Paragraph("What is Phosphorus?", sec_head))
story.append(Paragraph(
    "Phosphorus is a <b>non-metallic chemical element</b> with the symbol <b>P</b> and atomic number <b>15</b>. "
    "It belongs to <b>Group 15 (VA)</b> of the periodic table, also called the <b>Nitrogen family</b>. "
    "Phosphorus was first discovered in <b>1669</b> by German chemist <b>Hennig Brand</b> while "
    "experimenting with urine. The name comes from the Greek word <i>phosphoros</i>, meaning "
    "<b>'light-bearer'</b>, because white phosphorus glows in the dark!", body))
story.append(sp(6))
story.append(fact_box("Phosphorus is the 11th most abundant element in the Earth's crust."))
story.append(sp(8))
story.append(Paragraph("Why is Phosphorus Important?", sec_head))
story.append(sp(2))
story.extend(bullets([
    "It is a key building block of <b>DNA and RNA</b> (our genetic material).",
    "It forms <b>ATP (Adenosine Triphosphate)</b> - the energy currency of all living cells.",
    "It makes up <b>bones and teeth</b> as calcium phosphate.",
    "It is used in <b>fertilisers</b> to grow food crops.",
    "It is found in <b>phospholipids</b> that form cell membranes.",
]))
story.append(sp(10))

# ════════════════════════════════════════════════════════════════════════════
# CHAPTER 2: BASIC PROPERTIES
# ════════════════════════════════════════════════════════════════════════════
story.append(chapter_banner("Chapter 2: Basic Properties of Phosphorus", color=GREEN))
story.append(sp(10))
story.append(Paragraph("Physical and Chemical Properties at a Glance", sec_head))
story.append(sp(4))

props = table_2col(
    [Paragraph("<b>Property</b>", key_s), Paragraph("<b>Value / Description</b>", key_s)],
    [
        [Paragraph("Symbol", body),          Paragraph("P", body)],
        [Paragraph("Atomic Number", body),    Paragraph("15", body)],
        [Paragraph("Atomic Mass", body),      Paragraph("30.97 u", body)],
        [Paragraph("Group / Period", body),   Paragraph("Group 15, Period 3", body)],
        [Paragraph("Electronic Config.", body),Paragraph("2, 8, 5  (or [Ne] 3s² 3p³)", body)],
        [Paragraph("Valency", body),          Paragraph("3 or 5 (trivalent or pentavalent)", body)],
        [Paragraph("State at Room Temp.", body),Paragraph("Solid", body)],
        [Paragraph("Melting Point", body),    Paragraph("44.1°C (white P)", body)],
        [Paragraph("Boiling Point", body),    Paragraph("280°C (white P)", body)],
        [Paragraph("Electronegativity", body),Paragraph("2.19 (Pauling scale)", body)],
        [Paragraph("Colour (white P)", body), Paragraph("White / pale yellow, waxy solid", body)],
        [Paragraph("Colour (red P)", body),   Paragraph("Reddish-brown powder", body)],
        [Paragraph("Solubility", body),       Paragraph("Insoluble in water; soluble in CS₂ (white P)", body)],
        [Paragraph("Occurrence", body),       Paragraph("Never found free in nature; found as phosphates", body)],
    ],
    col_w=(6.5*cm, 10.1*cm)
)
story.append(props)
story.append(sp(8))

story.append(info_box(
    "Easy Trick to Remember Valency",
    ["Phosphorus has 5 electrons in its outermost shell (3s² 3p³). It can either GAIN 3 electrons "
     "(valency = 3, like in PH₃) or SHARE all 5 (valency = 5, like in PCl₅). "
     "So phosphorus is trivalent or pentavalent."],
    bg=GREEN_LIGHT, title_color=GREEN
))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CHAPTER 3: ALLOTROPES
# ════════════════════════════════════════════════════════════════════════════
story.append(chapter_banner("Chapter 3: Allotropes of Phosphorus", color=colors.HexColor("#7d3c98")))
story.append(sp(10))
story.append(Paragraph(
    "<b>Allotropes</b> are different physical forms of the same element. "
    "Phosphorus has three main allotropes:", body))
story.append(sp(6))

allotrope_data = [
    [Paragraph("<b>Feature</b>", key_s),
     Paragraph("<b>White Phosphorus</b>", key_s),
     Paragraph("<b>Red Phosphorus</b>", key_s),
     Paragraph("<b>Black Phosphorus</b>", key_s)],
    [Paragraph("Appearance", body),
     Paragraph("White/yellow waxy solid", body),
     Paragraph("Reddish-brown powder", body),
     Paragraph("Black flaky solid", body)],
    [Paragraph("Formula", body),
     Paragraph("P₄ (tetrahedral)", body),
     Paragraph("Polymeric chain", body),
     Paragraph("Layer structure", body)],
    [Paragraph("Toxicity", body),
     Paragraph("Highly toxic", body),
     Paragraph("Non-toxic", body),
     Paragraph("Non-toxic", body)],
    [Paragraph("Reactivity", body),
     Paragraph("Very reactive; ignites at 35°C", body),
     Paragraph("Less reactive", body),
     Paragraph("Least reactive", body)],
    [Paragraph("Glows in Dark?", body),
     Paragraph("YES (phosphorescence)", body),
     Paragraph("No", body),
     Paragraph("No", body)],
    [Paragraph("Stored in", body),
     Paragraph("Under water", body),
     Paragraph("Normal conditions", body),
     Paragraph("Normal conditions", body)],
    [Paragraph("Uses", body),
     Paragraph("Rat poison, smoke screens, old matches", body),
     Paragraph("Safety matches, fireworks", body),
     Paragraph("Research, semiconductors", body)],
]
at = Table(allotrope_data, colWidths=[3.8*cm, 4.3*cm, 4.5*cm, 4*cm])
at.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), colors.HexColor("#7d3c98")),
    ("TEXTCOLOR",     (0,0), (-1,0), WHITE),
    ("FONTNAME",      (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE",      (0,0), (-1,-1), 9),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, colors.HexColor("#f5eef8")]),
    ("GRID",          (0,0), (-1,-1), 0.5, colors.HexColor("#cccccc")),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
]))
story.append(at)
story.append(sp(10))

story.append(fact_box(
    "White phosphorus is stored UNDER WATER because it ignites spontaneously in air at just 35°C! "
    "This is called pyrophoricity."
))
story.append(sp(8))

story.append(info_box(
    "Conversion Between Allotropes",
    ["White P  ---(heat, no air)-->  Red P  ---(high pressure, 200°C)-->  Black P",
     "Red P cannot be converted back to White P easily. Black P is the most stable allotrope."],
    bg=colors.HexColor("#f5eef8"), title_color=colors.HexColor("#7d3c98")
))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CHAPTER 4: COMPOUNDS
# ════════════════════════════════════════════════════════════════════════════
story.append(chapter_banner("Chapter 4: Important Compounds of Phosphorus", color=ORANGE))
story.append(sp(10))

compounds = [
    ("Phosphine (PH₃)",
     "Colourless, toxic gas with a garlic smell. Formed when calcium phosphide "
     "reacts with water. Used as a fumigant. Formula: Ca₃P₂ + 6H₂O → 3Ca(OH)₂ + 2PH₃"),
    ("Phosphorus Trichloride (PCl₃)",
     "Colourless fuming liquid. Formed by burning P in limited Cl₂. "
     "Hydrolysis gives phosphorous acid: PCl₃ + 3H₂O → H₃PO₃ + 3HCl"),
    ("Phosphorus Pentachloride (PCl₅)",
     "White solid. Formed in excess Cl₂. It is a Lewis acid. "
     "Reaction: PCl₅ + H₂O → POCl₃ + 2HCl (partial hydrolysis)"),
    ("Phosphoric Acid (H₃PO₄)",
     "Tribasic, non-volatile, viscous acid. Used in fertilisers, rust removal, food additive. "
     "Prepared: P₄O₁₀ + 6H₂O → 4H₃PO₄"),
    ("Phosphorous Acid (H₃PO₃)",
     "Dibasic acid (only 2 ionisable H). It is a reducing agent. "
     "Not to be confused with phosphoric acid."),
    ("Hypophosphorous Acid (H₃PO₂)",
     "Monobasic acid (1 ionisable H). Strong reducing agent. "
     "Used in electroless plating."),
    ("Calcium Phosphate (Ca₃(PO₄)₂)",
     "Main mineral of bones and teeth. Also found in rock phosphate ore. "
     "Used to make fertilisers (superphosphate)."),
    ("Sodium Tripolyphosphate (Na₅P₃O₁₀)",
     "Used in detergents as a water softener and builder. "
     "Environmental concern: causes algal blooms in water bodies."),
]
for name, desc in compounds:
    story.append(Paragraph(name, sub_head))
    story.append(Paragraph(desc, body))
    story.append(sp(2))

story.append(sp(6))
story.append(fact_box(
    "Oxyacids of Phosphorus: The number of ionisable OH groups = basicity. "
    "H₃PO₄ (basicity 3), H₃PO₃ (basicity 2), H₃PO₂ (basicity 1). "
    "P-H bonds are NOT ionisable!"
))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CHAPTER 5: PHOSPHORUS IN THE HUMAN BODY
# ════════════════════════════════════════════════════════════════════════════
story.append(chapter_banner("Chapter 5: Phosphorus in the Human Body", color=colors.HexColor("#1a5276")))
story.append(sp(10))
story.append(Paragraph(
    "Phosphorus is the <b>second most abundant mineral</b> in the body after calcium. "
    "An adult body contains about <b>700 grams</b> of phosphorus.", body))
story.append(sp(6))

story.append(Paragraph("Where is Phosphorus Found in the Body?", sec_head))
dist_data = [
    [Paragraph("<b>Location</b>", key_s), Paragraph("<b>Amount</b>", key_s), Paragraph("<b>Form</b>", key_s)],
    [Paragraph("Bones & Teeth", body),   Paragraph("~85%", body), Paragraph("Calcium phosphate [Ca₃(PO₄)₂]", body)],
    [Paragraph("Soft Tissues", body),    Paragraph("~14%", body), Paragraph("Organic phosphate compounds", body)],
    [Paragraph("Blood (serum)", body),   Paragraph("~1%",  body), Paragraph("Inorganic phosphate (Pi)", body)],
]
dt = Table(dist_data, colWidths=[5.5*cm, 3.5*cm, 8*cm])
dt.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), colors.HexColor("#1a5276")),
    ("TEXTCOLOR",     (0,0), (-1,0), WHITE),
    ("FONTNAME",      (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE",      (0,0), (-1,-1), 9.5),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, BLUE_LIGHT]),
    ("GRID",          (0,0), (-1,-1), 0.5, colors.HexColor("#aaaaaa")),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 7),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
]))
story.append(dist_data[0])  # won't work - use table directly
story.append(dt)
story.append(sp(10))

story.append(Paragraph("Key Roles of Phosphorus in the Body", sec_head))
roles = [
    ("<b>Energy Production (ATP)</b>",
     "ATP (Adenosine Tri<b>phosphate</b>) is the main energy molecule. The phosphate bonds store energy. "
     "When ATP loses a phosphate group → ADP + Energy. Every cell in your body uses this!"),
    ("<b>DNA and RNA</b>",
     "Phosphate groups form the 'backbone' of the DNA double helix. No phosphorus = no genetic material = no life!"),
    ("<b>Cell Membranes (Phospholipids)</b>",
     "Every cell is surrounded by a phospholipid bilayer. Phospholipids have a phosphate 'head' (water-loving) "
     "and fatty acid 'tail' (water-hating). This structure controls what enters/exits the cell."),
    ("<b>Bone & Tooth Formation</b>",
     "Calcium phosphate [hydroxyapatite: Ca₁₀(PO₄)₆(OH)₂] gives hardness to bones and teeth. "
     "Vitamin D helps the body absorb both calcium and phosphorus."),
    ("<b>Enzyme Activation</b>",
     "Many enzymes need phosphorylation (adding a phosphate group) to become active. "
     "This is the basis of cellular signalling."),
    ("<b>Acid-Base Balance</b>",
     "Phosphate acts as a buffer in the blood, helping to keep pH stable around 7.4."),
    ("<b>Kidney Function</b>",
     "The kidneys filter and regulate phosphorus levels. PTH (parathyroid hormone) "
     "and FGF-23 (a hormone from bones) control how much phosphorus the kidneys excrete."),
]
for title, desc in roles:
    story.append(Paragraph(title, sub_head))
    story.append(Paragraph(desc, body))
    story.append(sp(2))

story.append(sp(6))
story.append(Paragraph("Normal Blood Phosphorus Levels", sec_head))
story.extend(bullets([
    "Normal serum inorganic phosphate: <b>2.5 - 4.5 mg/dL</b> (adults)",
    "Regulated by: PTH, Vitamin D, FGF-23, and kidney reabsorption",
    "Phosphorus is absorbed in the <b>small intestine</b> (60-70% of dietary intake)",
    "Excess phosphorus is excreted by the <b>kidneys</b>",
]))
story.append(sp(6))

story.append(Paragraph("Daily Requirement (RDA)", sec_head))
req_data = [
    [Paragraph("<b>Age Group</b>", key_s), Paragraph("<b>Daily Need</b>", key_s)],
    [Paragraph("Children (1-8 yrs)", body),   Paragraph("460-500 mg/day", body)],
    [Paragraph("Adolescents (9-18 yrs)", body),Paragraph("1250 mg/day", body)],
    [Paragraph("Adults (19+ yrs)", body),      Paragraph("700 mg/day", body)],
    [Paragraph("Pregnant/Lactating", body),    Paragraph("700-1250 mg/day", body)],
]
rt = Table(req_data, colWidths=[8*cm, 8.6*cm])
rt.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), colors.HexColor("#1a5276")),
    ("TEXTCOLOR",     (0,0), (-1,0), WHITE),
    ("FONTNAME",      (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE",      (0,0), (-1,-1), 9.5),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, BLUE_LIGHT]),
    ("GRID",          (0,0), (-1,-1), 0.5, colors.HexColor("#aaaaaa")),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 7),
]))
story.append(rt)
story.append(sp(8))
story.append(info_box(
    "Food Sources of Phosphorus",
    ["Rich sources: Dairy products (milk, cheese, yogurt), Fish, Meat, Poultry, Eggs, "
     "Nuts, Seeds, Whole grains, Legumes (beans, lentils)",
     "Processed foods also contain phosphorus as preservatives (e.g., phosphoric acid in cola drinks)."],
    bg=BLUE_LIGHT
))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CHAPTER 6: PHOSPHORUS CYCLE
# ════════════════════════════════════════════════════════════════════════════
story.append(chapter_banner("Chapter 6: The Phosphorus Cycle", color=GREEN))
story.append(sp(10))
story.append(Paragraph(
    "The <b>phosphorus cycle</b> is a <b>biogeochemical cycle</b> that describes how phosphorus moves "
    "through the environment. Unlike the nitrogen cycle, <b>phosphorus has no gas phase</b>, so it moves "
    "only through rocks, water, soil, and living organisms.", body))
story.append(sp(6))

story.append(Paragraph("Steps of the Phosphorus Cycle", sec_head))
steps = [
    ("Step 1: Weathering of Rocks",
     "Phosphate rocks (like apatite) are slowly broken down by rain and wind. "
     "This releases phosphate ions (PO₄³⁻) into the soil. "
     "This is the <b>main natural source</b> of phosphorus."),
    ("Step 2: Uptake by Plants",
     "Plant roots absorb dissolved phosphate from the soil. Plants use it to make DNA, ATP, and cell membranes. "
     "Mycorrhizal fungi help plants absorb more phosphorus from soil."),
    ("Step 3: Transfer to Animals",
     "Herbivores (plant-eaters) get phosphorus by eating plants. "
     "Carnivores get it by eating other animals. Phosphorus moves up the food chain."),
    ("Step 4: Decomposition",
     "When plants and animals die, <b>decomposers</b> (bacteria and fungi) break down organic matter. "
     "They release phosphate back into the soil. This is called <b>mineralisation</b>."),
    ("Step 5: Runoff to Water",
     "Rain washes phosphate from soil into rivers, lakes, and oceans. "
     "Aquatic organisms then use it. Over millions of years, it settles as sediment on the ocean floor."),
    ("Step 6: Geological Uplift",
     "Over millions of years, geological forces lift ocean sediments back up as rock, "
     "completing the long-term cycle. This is very slow (millions of years!)."),
]
for title, desc in steps:
    story.append(Paragraph(title, sub_head))
    story.append(Paragraph(desc, body))
    story.append(sp(2))

story.append(sp(6))
story.append(info_box(
    "Key Differences: Phosphorus Cycle vs Nitrogen Cycle",
    ["1. Phosphorus has NO gaseous phase (nitrogen does). Phosphorus cycle is a SEDIMENTARY cycle.",
     "2. The phosphorus cycle is much SLOWER - the long-term geological cycle takes millions of years.",
     "3. Phosphorus often LIMITS plant growth because it is less available in soil.",
     "4. Phosphorus does NOT require special bacteria to fix it (unlike nitrogen fixation)."],
    bg=GREEN_LIGHT, title_color=GREEN
))
story.append(sp(8))
story.append(fact_box(
    "Phosphorus is often the LIMITING NUTRIENT in freshwater ecosystems. "
    "That is why adding phosphorus fertiliser to a lake causes rapid algae growth (eutrophication)."
))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CHAPTER 7: AGRICULTURE
# ════════════════════════════════════════════════════════════════════════════
story.append(chapter_banner("Chapter 7: Phosphorus in Agriculture", color=colors.HexColor("#6e2f0a")))
story.append(sp(10))
story.append(Paragraph(
    "Phosphorus is one of the three main <b>macronutrients</b> for plants, along with "
    "Nitrogen (N) and Potassium (K). Together they are called <b>NPK</b>.", body))
story.append(sp(6))

story.append(Paragraph("Role of Phosphorus in Plants", sec_head))
story.extend(bullets([
    "Promotes <b>root growth</b> (especially important in seedlings)",
    "Helps in <b>flower and seed formation</b>",
    "Involved in <b>photosynthesis</b> (phosphate is in ATP and NADPH)",
    "Strengthens <b>cell walls</b> and overall plant structure",
    "Improves <b>disease resistance</b>",
]))
story.append(sp(8))

story.append(Paragraph("Phosphate Fertilisers", sec_head))
fert_data = [
    [Paragraph("<b>Fertiliser</b>", key_s),     Paragraph("<b>% P₂O₅</b>", key_s), Paragraph("<b>How Made</b>", key_s)],
    [Paragraph("Superphosphate", body),           Paragraph("16-20%", body),  Paragraph("Rock phosphate + H₂SO₄", body)],
    [Paragraph("Triple Superphosphate", body),    Paragraph("44-48%", body),  Paragraph("Rock phosphate + H₃PO₄", body)],
    [Paragraph("Diammonium Phosphate (DAP)", body),Paragraph("46%", body),    Paragraph("H₃PO₄ + NH₃", body)],
    [Paragraph("Monoammonium Phosphate (MAP)", body),Paragraph("48-61%", body),Paragraph("H₃PO₄ + NH₃ (less)", body)],
    [Paragraph("Bone Meal", body),                Paragraph("20-25%", body),  Paragraph("Ground animal bones", body)],
    [Paragraph("Rock Phosphate", body),           Paragraph("20-32%", body),  Paragraph("Direct mining, slow release", body)],
]
ft = Table(fert_data, colWidths=[5.5*cm, 3*cm, 8.1*cm])
ft.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,0), colors.HexColor("#6e2f0a")),
    ("TEXTCOLOR",     (0,0), (-1,0), WHITE),
    ("FONTNAME",      (0,0), (-1,0), "Helvetica-Bold"),
    ("FONTSIZE",      (0,0), (-1,-1), 9),
    ("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, ORANGE_LIGHT]),
    ("GRID",          (0,0), (-1,-1), 0.5, colors.HexColor("#cccccc")),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
]))
story.append(ft)
story.append(sp(8))
story.append(info_box(
    "DAP (Diammonium Phosphate) - Most Used Fertiliser",
    ["DAP is the most popular phosphorus fertiliser worldwide. It contains both phosphorus (P) and nitrogen (N).",
     "Formula: (NH₄)₂HPO₄. It releases ammonium ions and hydrogen phosphate when dissolved in soil water.",
     "India is the largest importer of DAP fertiliser."],
    bg=ORANGE_LIGHT, title_color=ORANGE
))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CHAPTER 8: DEFICIENCY & EXCESS
# ════════════════════════════════════════════════════════════════════════════
story.append(chapter_banner("Chapter 8: Phosphorus Deficiency & Excess (Health)", color=RED))
story.append(sp(10))

story.append(Paragraph("Hypophosphatemia (Low Phosphorus)", sec_head))
story.append(Paragraph(
    "When blood phosphorus falls below <b>2.5 mg/dL</b>, it is called <b>hypophosphatemia</b>.", body))
story.append(sp(4))
story.append(Paragraph("Causes:", sub_head))
story.extend(bullets([
    "Poor dietary intake (malnutrition, starvation)",
    "Excessive use of antacids containing aluminium or magnesium (bind phosphate in gut)",
    "Hyperparathyroidism (excess PTH increases kidney excretion of phosphorus)",
    "Vitamin D deficiency (reduces intestinal absorption)",
    "Refeeding syndrome (rapid feeding after starvation)",
    "Diabetic ketoacidosis treatment (insulin moves P into cells)",
]))
story.append(sp(4))
story.append(Paragraph("Symptoms:", sub_head))
story.extend(bullets([
    "Bone pain and softening (osteomalacia in adults, rickets in children)",
    "Muscle weakness and fatigue",
    "Confusion and irritability (brain needs phosphorus for ATP)",
    "Haemolytic anaemia (red blood cells break down)",
    "Respiratory failure in severe cases (breathing muscles weaken)",
]))
story.append(sp(8))

story.append(Paragraph("Hyperphosphatemia (High Phosphorus)", sec_head))
story.append(Paragraph(
    "When blood phosphorus rises above <b>4.5 mg/dL</b>, it is called <b>hyperphosphatemia</b>. "
    "This is most common in patients with <b>chronic kidney disease (CKD)</b>.", body))
story.append(sp(4))
story.append(Paragraph("Causes:", sub_head))
story.extend(bullets([
    "Chronic kidney disease (kidneys cannot excrete phosphorus)",
    "Hypoparathyroidism (low PTH = less kidney excretion)",
    "Excessive phosphorus intake (too many dairy products, cola drinks)",
    "Vitamin D toxicity",
]))
story.append(sp(4))
story.append(Paragraph("Symptoms & Complications:", sub_head))
story.extend(bullets([
    "Low calcium levels (Ca and P have inverse relationship in blood)",
    "Calcification of blood vessels and soft tissues (dangerous!)",
    "Bone disease (renal osteodystrophy in CKD patients)",
    "Itching, joint pain",
    "Increased risk of heart disease",
]))
story.append(sp(6))
story.append(info_box(
    "Calcium-Phosphorus Balance",
    ["Ca × P product in blood should be < 55 mg²/dL². If it rises too high, calcium phosphate crystals "
     "deposit in soft tissues - a process called calcification or calciphylaxis.",
     "In CKD, doctors use phosphate binders (like calcium carbonate or sevelamer) to lower blood phosphorus."],
    bg=colors.HexColor("#fadbd8"), title_color=RED
))
story.append(sp(6))

story.append(Paragraph("Phosphorus Toxicity (Forensic / Chemistry)", sec_head))
story.append(Paragraph(
    "White phosphorus is highly toxic. It was historically used in rat poison and incendiary weapons.", body))
story.extend(bullets([
    "Lethal dose (white P): ~1 mg/kg body weight",
    "Symptoms: Nausea, vomiting, garlic-like breath, luminous vomit/stool",
    "Multi-organ failure (liver, kidney, heart) - called 'Phossy Jaw' in matchstick workers (necrosis of jaw)",
    "Treatment: Supportive; copper sulphate was historically used to make P insoluble",
]))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CHAPTER 9: ENVIRONMENTAL IMPACT
# ════════════════════════════════════════════════════════════════════════════
story.append(chapter_banner("Chapter 9: Environmental Impact of Phosphorus", color=GREEN))
story.append(sp(10))

story.append(Paragraph("Eutrophication - The Main Problem", sec_head))
story.append(Paragraph(
    "<b>Eutrophication</b> is the process where excess phosphorus (and nitrogen) causes <b>explosive algae "
    "growth</b> in water bodies. This is one of the major water pollution problems worldwide.", body))
story.append(sp(4))
story.append(Paragraph("How it happens - step by step:", sub_head))
steps_e = [
    "Phosphate fertilisers are applied to farmland.",
    "Rain washes phosphate into nearby rivers and lakes (runoff).",
    "Phosphate causes rapid growth of algae (algal bloom).",
    "When algae die, bacteria decompose them using up all the oxygen.",
    "Low oxygen levels kill fish and aquatic life. This is called a 'dead zone'.",
    "The water becomes murky, foul-smelling, and undrinkable.",
]
for i, s in enumerate(steps_e, 1):
    story.append(Paragraph(f"<b>{i}.</b>  {s}", bullet_s))
story.append(sp(6))

story.append(Paragraph("Sources of Phosphorus Pollution", sec_head))
story.extend(bullets([
    "<b>Agricultural runoff</b> - fertilisers, animal manure",
    "<b>Sewage and wastewater</b> - human waste, detergents (phosphates)",
    "<b>Industrial discharge</b> - food processing, chemical industries",
    "<b>Urban runoff</b> - lawns, gardens, car washing",
]))
story.append(sp(6))

story.append(Paragraph("Solutions to Phosphorus Pollution", sec_head))
story.extend(bullets([
    "Use of <b>phosphate-free detergents</b> (already banned in many countries)",
    "<b>Constructed wetlands</b> to filter runoff before it reaches lakes",
    "<b>Precision agriculture</b> - applying fertiliser only where and when needed",
    "<b>Wastewater treatment</b> - remove phosphorus from sewage before discharge",
    "<b>Buffer strips</b> of vegetation along water bodies to absorb runoff",
    "<b>Phosphorus recovery</b> from wastewater to reuse as fertiliser",
]))
story.append(sp(6))

story.append(Paragraph("Peak Phosphorus", sec_head))
story.append(Paragraph(
    "Phosphate rock is a <b>non-renewable resource</b>. Scientists predict that easily mined phosphate "
    "reserves could run out in 50-100 years. This is called <b>'Peak Phosphorus'</b>. "
    "The main phosphate rock reserves are in <b>Morocco (largest), China, Algeria, and Syria</b>. "
    "India imports most of its phosphorus needs.", body))
story.append(sp(6))
story.append(fact_box(
    "Morocco holds about 70% of the world's known phosphate rock reserves. "
    "Phosphorus cannot be manufactured - we can only mine it or recycle it!"
))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CHAPTER 10: QUICK REVISION + MCQs
# ════════════════════════════════════════════════════════════════════════════
story.append(chapter_banner("Chapter 10: Quick Revision & Practice MCQs", color=BLUE_MID))
story.append(sp(10))

story.append(Paragraph("Quick Revision Flash Points", sec_head))
flash = [
    "Symbol: P | Atomic Number: 15 | Group: 15, Period: 3",
    "Allotropes: White (toxic, reactive) > Red (safe) > Black (most stable)",
    "White P is stored UNDER WATER; ignites in air at 35°C",
    "Valency: 3 (PH₃) or 5 (PCl₅)",
    "Oxyacids: H₃PO₄ (tribasic), H₃PO₃ (dibasic), H₃PO₂ (monobasic) - P-H bonds not ionisable",
    "Body: 85% in bones as Ca₃(PO₄)₂; also in ATP, DNA, cell membranes",
    "Normal serum P: 2.5-4.5 mg/dL | Regulated by PTH, Vit D, FGF-23",
    "Phosphorus cycle: NO gas phase | Weathering → Plants → Animals → Decomposers → Soil",
    "Eutrophication: Excess P → algal bloom → oxygen depletion → fish kill",
    "Main fertiliser: DAP (Diammonium Phosphate)",
    "Hypophosphatemia: low P → bone pain, muscle weakness, confusion",
    "Hyperphosphatemia: high P → common in CKD → soft tissue calcification",
    "Peak Phosphorus: Morocco has 70% of world reserves; P is non-renewable",
]
flash_table_data = [[Paragraph(f"{'✓'} {item}", body)] for item in flash]
ft2 = Table(flash_table_data, colWidths=[16.6*cm])
ft2.setStyle(TableStyle([
    ("ROWBACKGROUNDS", (0,0), (-1,-1), [WHITE, BLUE_LIGHT]),
    ("TOPPADDING",    (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING",   (0,0), (-1,-1), 10),
    ("BOX",           (0,0), (-1,-1), 1, BLUE_MID),
    ("GRID",          (0,0), (-1,-1), 0.3, colors.HexColor("#dddddd")),
]))
story.append(ft2)
story.append(sp(14))

story.append(Paragraph("Practice MCQs", sec_head))
mcqs = [
    ("Q1. The atomic number of phosphorus is:",
     ["A) 14", "B) 15", "C) 16", "D) 13"],
     "Answer: B) 15"),
    ("Q2. White phosphorus is stored under water because:",
     ["A) It dissolves in water", "B) It reacts with water to form acid",
      "C) It ignites spontaneously in air", "D) Water makes it more stable"],
     "Answer: C) It ignites spontaneously in air"),
    ("Q3. Which allotrope of phosphorus is most stable?",
     ["A) White phosphorus", "B) Red phosphorus",
      "C) Black phosphorus", "D) Yellow phosphorus"],
     "Answer: C) Black phosphorus"),
    ("Q4. ATP stands for:",
     ["A) Adenosine Triphosphate", "B) Adenine Triphosphate",
      "C) Adenosine Triprotein", "D) Amino Triphosphate"],
     "Answer: A) Adenosine Triphosphate"),
    ("Q5. The basicity of H₃PO₃ (phosphorous acid) is:",
     ["A) 1", "B) 2", "C) 3", "D) 0"],
     "Answer: B) 2  (only 2 OH groups are ionisable; one H is directly bonded to P)"),
    ("Q6. Eutrophication in water bodies is caused by:",
     ["A) Excess nitrogen only", "B) Excess phosphorus only",
      "C) Excess phosphorus and nitrogen", "D) Excess carbon dioxide"],
     "Answer: C) Excess phosphorus and nitrogen"),
    ("Q7. Hyperphosphatemia is most commonly seen in patients with:",
     ["A) Liver cirrhosis", "B) Chronic kidney disease",
      "C) Hyperthyroidism", "D) Iron deficiency anaemia"],
     "Answer: B) Chronic kidney disease"),
    ("Q8. Which hormone INCREASES phosphorus excretion by the kidneys?",
     ["A) Insulin", "B) Cortisol",
      "C) Parathyroid hormone (PTH)", "D) Growth hormone"],
     "Answer: C) Parathyroid hormone (PTH)"),
    ("Q9. The main phosphate mineral in bones is:",
     ["A) Calcium carbonate", "B) Hydroxyapatite [Ca₁₀(PO₄)₆(OH)₂]",
      "C) Calcium phosphite", "D) Calcium sulphate"],
     "Answer: B) Hydroxyapatite"),
    ("Q10. Which country holds the largest phosphate rock reserves?",
     ["A) China", "B) USA", "C) India", "D) Morocco"],
     "Answer: D) Morocco (~70% of world reserves)"),
]
for q, opts, ans in mcqs:
    story.append(Paragraph(q, sub_head))
    for opt in opts:
        story.append(Paragraph(f"  {opt}", bullet_s))
    story.append(Paragraph(f"<i>{ans}</i>", S("Ans", fontSize=9.5,
                  textColor=GREEN, fontName="Helvetica-BoldOblique",
                  leading=13, leftIndent=16, spaceAfter=8)))
    story.append(sp(2))

story.append(PageBreak())

# ── BACK PAGE ─────────────────────────────────────────────────────────────────
back = Table(
    [[Paragraph("<b>Phosphorus - Summary Mind Map</b>", S("BT", fontSize=15,
                textColor=WHITE, fontName="Helvetica-Bold",
                alignment=TA_CENTER, leading=20))],
     [sp(8)],
     [Paragraph(
        "PHOSPHORUS (P, Z=15)\n"
        "     |\n"
        "     +--- Chemistry: Group 15, Valency 3/5, Allotropes (White/Red/Black)\n"
        "     |\n"
        "     +--- Compounds: PH₃, PCl₃, PCl₅, H₃PO₄, H₃PO₃, H₃PO₂\n"
        "     |\n"
        "     +--- Body: Bones (85%), ATP, DNA, Cell membranes, Blood pH buffer\n"
        "     |\n"
        "     +--- Cycle: Rocks → Soil → Plants → Animals → Decomposers → Soil\n"
        "     |\n"
        "     +--- Agriculture: Fertilisers (DAP, Superphosphate), NPK\n"
        "     |\n"
        "     +--- Health: Hypophosphatemia (<2.5) | Hyperphosphatemia (>4.5 mg/dL)\n"
        "     |\n"
        "     +--- Environment: Eutrophication, Peak Phosphorus, Non-renewable",
        S("MM", fontSize=10, textColor=WHITE, fontName="Courier",
          leading=16, leftIndent=10)
     )],
    ],
    colWidths=[17*cm]
)
back.setStyle(TableStyle([
    ("BACKGROUND",    (0,0), (-1,-1), BLUE_DARK),
    ("TOPPADDING",    (0,0), (-1,-1), 14),
    ("BOTTOMPADDING", (0,0), (-1,-1), 14),
    ("LEFTPADDING",   (0,0), (-1,-1), 16),
    ("BOX",           (0,0), (-1,-1), 2, BLUE_MID),
]))
story.append(back)
story.append(sp(14))

story.append(Paragraph(
    "Good luck with your studies! Remember: Phosphorus is not just a chemistry element - "
    "it is essential for every cell, every gene, and every living creature on Earth.",
    S("Final", fontSize=11, textColor=BLUE_DARK, fontName="Helvetica-BoldOblique",
      alignment=TA_CENTER, leading=16)
))

# ── BUILD ────────────────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF saved: {OUTPUT}")
Running Command

cd /tmp/workspace/phosphorus-study && python make_pdf.py 2>&1

Editing File

~/phosphorus-study/make_pdf.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/phosphorus-study/make_pdf.py'
Running Command

cd /tmp/workspace/phosphorus-study && python make_pdf.py 2>&1

Your PDF is ready! Download it here:

Phosphorus Study Material

PDF Document · PDF


Here's what's inside the study material (12+ pages, easy language):
ChapterWhat You'll Learn
1. IntroductionWhat is P, who discovered it, why it matters
2. Basic PropertiesSymbol, atomic number, electronic config, valency - full table
3. AllotropesWhite vs Red vs Black phosphorus - comparison table
4. CompoundsPH₃, PCl₃, PCl₅, H₃PO₄, H₃PO₃, H₃PO₂ with reactions
5. In the Human BodyATP, DNA, bones, cell membranes, blood levels, food sources
6. Phosphorus CycleStep-by-step explanation (sedimentary cycle, no gas phase)
7. AgricultureDAP, superphosphate, NPK fertilisers table
8. Deficiency & ExcessHypophosphatemia vs Hyperphosphatemia - causes & symptoms
9. EnvironmentEutrophication, Peak Phosphorus, Morocco reserves
10. Quick Revision & MCQs13 flash points + 10 practice MCQs with answers
Highlights:
  • Coloured chapter banners and tables for easy scanning
  • Key Fact boxes for important exam points
  • Mind Map summary on the last page
  • Written in simple, clear language suitable for Class 11-12 / NEET / JEE / UPSC preparation

I’m in medical college gmch I need the answer according to exam point of view . Topic: Phosphorus, in which you will add RDA, introduction, deficiency, absorption, factor that effect absorption, regulation, mainifest action, precaution, clinical sign and significance, i need study material in pdf form in easy language

Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Finding Sources
Writing File

~/phosphorus-study/make_medical_pdf.py

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY

OUTPUT = "/tmp/workspace/phosphorus-study/Phosphorus_Medical_College_Notes.pdf"

# ── Palette ────────────────────────────────────────────────────────────────
NAVY      = colors.HexColor("#0d2b45")
TEAL      = colors.HexColor("#1a6b72")
TEAL_LIGHT= colors.HexColor("#d0edf0")
GREEN     = colors.HexColor("#1b6b3a")
GREEN_L   = colors.HexColor("#d5f0e0")
RED       = colors.HexColor("#922b21")
RED_L     = colors.HexColor("#fadbd8")
ORANGE    = colors.HexColor("#a04000")
ORANGE_L  = colors.HexColor("#fdebd0")
YELLOW    = colors.HexColor("#fef9e7")
GOLD      = colors.HexColor("#d4ac0d")
PURPLE    = colors.HexColor("#6c3483")
PURPLE_L  = colors.HexColor("#e8daef")
GREY      = colors.HexColor("#f4f6f7")
GREY_D    = colors.HexColor("#a0a0a0")
WHITE     = colors.white
BLACK     = colors.black

doc = SimpleDocTemplate(
    OUTPUT, pagesize=A4,
    leftMargin=2*cm, rightMargin=2*cm,
    topMargin=2*cm, bottomMargin=2*cm
)

# ── Styles ─────────────────────────────────────────────────────────────────
def S(name, **kw):
    return ParagraphStyle(name, **kw)

cover_h  = S("CH", fontSize=36, textColor=WHITE, fontName="Helvetica-Bold",
              alignment=TA_CENTER, leading=44, spaceAfter=8)
cover_s  = S("CS", fontSize=14, textColor=colors.HexColor("#b3d4dc"),
              fontName="Helvetica", alignment=TA_CENTER, leading=20)
cover_c  = S("CC", fontSize=11, textColor=colors.HexColor("#90c4cc"),
              fontName="Helvetica-Oblique", alignment=TA_CENTER, leading=16)

ch_h     = S("CHH", fontSize=17, textColor=WHITE, fontName="Helvetica-Bold",
              alignment=TA_LEFT, leading=22, leftIndent=10)
sec      = S("SEC", fontSize=13, textColor=NAVY, fontName="Helvetica-Bold",
              spaceBefore=12, spaceAfter=4, leading=17)
sub      = S("SUB", fontSize=11, textColor=TEAL, fontName="Helvetica-Bold",
              spaceBefore=8, spaceAfter=3, leading=15)
body     = S("BOD", fontSize=10, textColor=BLACK, fontName="Helvetica",
              leading=15, spaceAfter=4, alignment=TA_JUSTIFY)
bul      = S("BUL", fontSize=10, textColor=BLACK, fontName="Helvetica",
              leading=14, leftIndent=14, spaceAfter=3)
note     = S("NOT", fontSize=9.5, textColor=colors.HexColor("#555"),
              fontName="Helvetica-Oblique", leading=13, leftIndent=10)
kf       = S("KF",  fontSize=10, textColor=NAVY, fontName="Helvetica-Bold",
              leading=14)
toc_s    = S("TOC", fontSize=11, textColor=NAVY, fontName="Helvetica", leading=18)
exam_s   = S("EXM", fontSize=10, textColor=RED, fontName="Helvetica-Bold",
              leading=14, spaceAfter=2)
white10  = S("W10", fontSize=10, textColor=WHITE, fontName="Helvetica", leading=14)

def sp(h=6):   return Spacer(1, h)
def hr():      return HRFlowable(width="100%", thickness=0.8,
                                  color=GREY_D, spaceAfter=3, spaceBefore=3)

# ── Builders ───────────────────────────────────────────────────────────────
def ch_banner(text, color=NAVY):
    t = Table([[Paragraph(text, ch_h)]], colWidths=[17*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND",   (0,0),(-1,-1), color),
        ("TOPPADDING",   (0,0),(-1,-1), 10),
        ("BOTTOMPADDING",(0,0),(-1,-1), 10),
        ("LEFTPADDING",  (0,0),(-1,-1), 14),
        ("BOX",          (0,0),(-1,-1), 1.5, color),
    ]))
    return t

def info_box(title, items, bg=TEAL_LIGHT, title_color=TEAL):
    rows = [[Paragraph(f"<b>{title}</b>",
                       S("IH", fontSize=10.5, textColor=title_color,
                         fontName="Helvetica-Bold", leading=14))]]
    for i in items:
        rows.append([Paragraph(i, body)])
    t = Table(rows, colWidths=[16.6*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND",   (0,0),(-1,-1), bg),
        ("TOPPADDING",   (0,0),(-1,-1), 6),
        ("BOTTOMPADDING",(0,0),(-1,-1), 6),
        ("LEFTPADDING",  (0,0),(-1,-1), 10),
        ("BOX",          (0,0),(-1,-1), 1, title_color),
    ]))
    return t

def exam_box(text):
    t = Table([[Paragraph(f"<b>EXAM TIP:</b>  {text}", exam_s)]],
              colWidths=[16.6*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND",   (0,0),(-1,-1), RED_L),
        ("TOPPADDING",   (0,0),(-1,-1), 7),
        ("BOTTOMPADDING",(0,0),(-1,-1), 7),
        ("LEFTPADDING",  (0,0),(-1,-1), 10),
        ("BOX",          (0,0),(-1,-1), 2, RED),
    ]))
    return t

def key_box(text, bg=YELLOW, border=GOLD):
    t = Table([[Paragraph(f"<b>KEY POINT:</b>  {text}", kf)]],
              colWidths=[16.6*cm])
    t.setStyle(TableStyle([
        ("BACKGROUND",   (0,0),(-1,-1), bg),
        ("TOPPADDING",   (0,0),(-1,-1), 7),
        ("BOTTOMPADDING",(0,0),(-1,-1), 7),
        ("LEFTPADDING",  (0,0),(-1,-1), 10),
        ("BOX",          (0,0),(-1,-1), 2, border),
    ]))
    return t

def two_col(headers, rows, w=(6*cm, 10.6*cm)):
    data = [headers] + rows
    t = Table(data, colWidths=list(w))
    t.setStyle(TableStyle([
        ("BACKGROUND",    (0,0),(-1,0), NAVY),
        ("TEXTCOLOR",     (0,0),(-1,0), WHITE),
        ("FONTNAME",      (0,0),(-1,0), "Helvetica-Bold"),
        ("FONTSIZE",      (0,0),(-1,-1), 9.5),
        ("ROWBACKGROUNDS",(0,1),(-1,-1), [WHITE, GREY]),
        ("GRID",          (0,0),(-1,-1), 0.5, GREY_D),
        ("TOPPADDING",    (0,0),(-1,-1), 5),
        ("BOTTOMPADDING", (0,0),(-1,-1), 5),
        ("LEFTPADDING",   (0,0),(-1,-1), 7),
        ("VALIGN",        (0,0),(-1,-1), "MIDDLE"),
    ]))
    return t

def bullets(items):
    return [Paragraph(f"&#8226;  {i}", bul) for i in items]

# ════════════════════════════════════════════════════════════════════════════
story = []

# ── COVER ─────────────────────────────────────────────────────────────────
cover = Table([
    [Paragraph("PHOSPHORUS", cover_h)],
    [sp(10)],
    [Paragraph("Medical College Study Notes", cover_s)],
    [sp(4)],
    [Paragraph("GMCH | Exam-Oriented | Easy Language", cover_s)],
    [sp(16)],
    [Paragraph("Topics: Introduction  •  RDA  •  Absorption  •  Factors Affecting Absorption", cover_c)],
    [Paragraph("Regulation  •  Manifest Actions  •  Deficiency  •  Clinical Signs  •  Significance", cover_c)],
    [sp(16)],
    [Paragraph("Sources: Ganong's Physiology | Washington Manual | Kidney Foundation Primer | Brenner & Rector", cover_c)],
], colWidths=[17*cm])
cover.setStyle(TableStyle([
    ("BACKGROUND",   (0,0),(-1,-1), NAVY),
    ("TOPPADDING",   (0,0),(-1,-1), 14),
    ("BOTTOMPADDING",(0,0),(-1,-1), 14),
    ("LEFTPADDING",  (0,0),(-1,-1), 18),
    ("BOX",          (0,0),(-1,-1), 3, TEAL),
]))
story.append(sp(1.5*cm))
story.append(cover)
story.append(sp(1*cm))
strip = Table([[Paragraph(
    "<b>Exam Pattern Covered:</b>  Short notes | Long answers | MCQs | Viva questions", body
)]], colWidths=[17*cm])
strip.setStyle(TableStyle([
    ("BACKGROUND",   (0,0),(-1,-1), TEAL_LIGHT),
    ("TOPPADDING",   (0,0),(-1,-1), 9),
    ("BOTTOMPADDING",(0,0),(-1,-1), 9),
    ("LEFTPADDING",  (0,0),(-1,-1), 14),
    ("BOX",          (0,0),(-1,-1), 1, TEAL),
]))
story.append(strip)
story.append(PageBreak())

# ── TABLE OF CONTENTS ──────────────────────────────────────────────────────
story.append(ch_banner("Table of Contents"))
story.append(sp(12))
toc = [
    ("1","Introduction to Phosphorus",               "3"),
    ("2","Recommended Daily Allowance (RDA)",         "4"),
    ("3","Absorption of Phosphorus",                  "5"),
    ("4","Factors Affecting Absorption",              "6"),
    ("5","Regulation of Phosphorus Homeostasis",      "7"),
    ("6","Manifest Actions (Functions) of Phosphorus","9"),
    ("7","Deficiency: Hypophosphatemia",              "11"),
    ("8","Excess: Hyperphosphatemia",                 "13"),
    ("9","Clinical Signs and Significance",           "14"),
    ("10","Precautions in Clinical Practice",         "15"),
    ("11","Quick Revision Table + Viva MCQs",         "16"),
]
for num, title, pg in toc:
    row = Table([
        [Paragraph(f"<b>Ch {num}</b>", toc_s),
         Paragraph(title, toc_s),
         Paragraph(f"Pg {pg}", toc_s)]
    ], colWidths=[2.5*cm, 11.5*cm, 3*cm])
    row.setStyle(TableStyle([
        ("ROWBACKGROUNDS",(0,0),(-1,-1),[WHITE, GREY]),
        ("TOPPADDING",   (0,0),(-1,-1), 5),
        ("BOTTOMPADDING",(0,0),(-1,-1), 5),
        ("LEFTPADDING",  (0,0),(-1,-1), 8),
        ("BOX",          (0,0),(-1,-1), 0.5, GREY_D),
    ]))
    story.append(row)
    story.append(sp(3))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CH 1 - INTRODUCTION
# ════════════════════════════════════════════════════════════════════════════
story.append(ch_banner("Chapter 1: Introduction to Phosphorus", NAVY))
story.append(sp(10))

story.append(Paragraph("What is Phosphorus?", sec))
story.append(Paragraph(
    "Phosphorus (symbol: <b>P</b>, Atomic No: 15) is an essential <b>non-metallic, non-volatile mineral</b> "
    "and the <b>second most abundant mineral</b> in the human body after calcium. "
    "It is a member of Group 15 (Nitrogen family) of the periodic table.", body))
story.append(sp(4))

story.append(Paragraph("Body Distribution (Exam Favourite)", sec))
dist = two_col(
    [Paragraph("<b>Compartment</b>", kf), Paragraph("<b>Amount / Form</b>", kf)],
    [
        [Paragraph("Skeleton (Bone & Teeth)", body), Paragraph("<b>85%</b> as Hydroxyapatite Ca₁₀(PO₄)₆(OH)₂", body)],
        [Paragraph("Intracellular (soft tissue)", body), Paragraph("<b>14%</b> as organic phosphate compounds", body)],
        [Paragraph("Extracellular fluid", body), Paragraph("<b>1%</b>; 70% organic (phospholipids), 30% inorganic (Pi)", body)],
        [Paragraph("Serum (freely circulating)", body), Paragraph("<b>Only 0.15% of total body P</b> — serum levels do NOT reflect body stores!", body)],
        [Paragraph("Total body stores", body), Paragraph("~<b>700 g</b> in adult (Kidney Foundation Primer, 8e)", body)],
    ],
    w=(5.5*cm, 11.1*cm)
)
story.append(dist)
story.append(sp(8))

story.append(Paragraph("Forms of Phosphorus in Blood", sec))
story.extend(bullets([
    "Total plasma phosphorus: ~12 mg/dL",
    "2/3 is in <b>organic</b> compounds (phospholipids, esters)",
    "1/3 is <b>inorganic phosphorus (Pi)</b> — mostly as PO₄³⁻, HPO₄²⁻, H₂PO₄⁻",
    "Of inorganic Pi: 85% freely filterable, 15% protein-bound",
    "<b>Normal serum Pi: 2.5 - 4.5 mg/dL</b> (adults); higher in infants/children",
    "Lab reports it as <b>'phosphorus'</b>, though strictly it is <b>'phosphate'</b>",
]))
story.append(sp(6))
story.append(key_box(
    "Serum phosphorus is the ONLY 0.15% of total body phosphorus. "
    "Normal serum levels do NOT exclude total body depletion — especially in CKD patients."
))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CH 2 - RDA
# ════════════════════════════════════════════════════════════════════════════
story.append(ch_banner("Chapter 2: Recommended Daily Allowance (RDA)", TEAL))
story.append(sp(10))

story.append(Paragraph("Dietary Intake and RDA", sec))
story.append(Paragraph(
    "The average diet provides <b>1000-1400 mg of phosphorus per day</b>. "
    "Of this, approximately <b>60-70% is absorbed</b> by the gut. "
    "Two-thirds of absorbed phosphorus is excreted in <b>urine</b> and "
    "the remaining one-third in <b>stool</b>.", body))
story.append(sp(8))

rda_data = two_col(
    [Paragraph("<b>Age / Group</b>", kf), Paragraph("<b>RDA (mg/day)</b>", kf)],
    [
        [Paragraph("Infants (0-6 months)", body),         Paragraph("100 mg/day (AI)", body)],
        [Paragraph("Infants (7-12 months)", body),        Paragraph("275 mg/day (AI)", body)],
        [Paragraph("Children (1-3 years)", body),         Paragraph("460 mg/day", body)],
        [Paragraph("Children (4-8 years)", body),         Paragraph("500 mg/day", body)],
        [Paragraph("Adolescents (9-18 years)", body),     Paragraph("<b>1250 mg/day</b> (highest need — bone growth)", body)],
        [Paragraph("Adults (19-70 years)", body),         Paragraph("<b>700 mg/day</b>", body)],
        [Paragraph("Adults (>70 years)", body),           Paragraph("700 mg/day", body)],
        [Paragraph("Pregnant (14-18 yrs)", body),         Paragraph("1250 mg/day", body)],
        [Paragraph("Pregnant (19-50 yrs)", body),         Paragraph("700 mg/day", body)],
        [Paragraph("Lactating (14-18 yrs)", body),        Paragraph("1250 mg/day", body)],
        [Paragraph("Lactating (19-50 yrs)", body),        Paragraph("700 mg/day", body)],
        [Paragraph("RDA (general adult, NKF)", body),     Paragraph("<b>800 mg/day</b>", body)],
    ],
    w=(6.5*cm, 10.1*cm)
)
story.append(rda_data)
story.append(sp(8))

story.append(Paragraph("Food Sources of Phosphorus", sec))
story.extend(bullets([
    "<b>Rich sources:</b> Dairy (milk, cheese, yogurt), meat, poultry, fish, eggs",
    "<b>Plant sources:</b> Nuts, seeds, legumes, whole grains (but as <b>phytate</b> - less bioavailable)",
    "<b>Hidden sources:</b> Processed foods, fast foods, cola drinks (phosphoric acid),",
    "<b>Medications:</b> Antihypertensives, multivitamins, antidepressants can add 20-40 mg/pill",
    "Grain-based (soy) protein contains phosphorus bound with phytate — <b>lower bioavailability</b>",
]))
story.append(sp(6))
story.append(exam_box(
    "MCQ Trap: Grain/plant phosphorus is bound as PHYTATE → less bioavailable. "
    "Animal/dairy phosphorus is more readily absorbed. "
    "Processed foods contain ADDITIVE phosphorus — higher absorption than plant-based phytate."
))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CH 3 - ABSORPTION
# ════════════════════════════════════════════════════════════════════════════
story.append(ch_banner("Chapter 3: Absorption of Phosphorus", TEAL))
story.append(sp(10))

story.append(Paragraph("Where is Phosphorus Absorbed?", sec))
story.append(Paragraph(
    "Phosphorus is absorbed throughout the <b>entire small intestine</b> (duodenum, jejunum, ileum) "
    "and also in the large intestine. Absorption occurs by <b>two mechanisms</b>:", body))
story.append(sp(6))

story.append(Paragraph("1. Active (Transcellular) Transport - Major Route", sub))
story.extend(bullets([
    "Transporter: <b>NaPi-IIb (NPT2b)</b> — sodium-phosphate cotransporter located at the apical (brush border) membrane of intestinal epithelial cells",
    "Driven by <b>Na⁺ gradient</b> created by basolateral Na⁺/K⁺-ATPase",
    "NaPi-IIb sits in 'ready-to-use' vesicles just below the brush border — traffics to membrane in response to phosphorus concentration changes",
    "<b>Calcitriol (1,25-(OH)₂D₃)</b> upregulates NaPi-IIb expression → increases phosphorus absorption",
    "Active transport predominates when dietary phosphorus is <b>LOW</b>",
]))
story.append(sp(6))

story.append(Paragraph("2. Passive (Paracellular) Transport - Secondary Route", sub))
story.extend(bullets([
    "Occurs through tight junctions between intestinal cells",
    "Driven by <b>luminal phosphorus concentration gradient</b>",
    "Dominant when dietary phosphorus is <b>HIGH</b> (concentration-dependent)",
    "Not regulated by hormones",
]))
story.append(sp(6))

story.append(Paragraph("Absorption Efficiency", sub))
story.extend(bullets([
    "Overall: <b>60-70%</b> of dietary phosphorus is absorbed",
    "Animal sources: ~70% absorbed",
    "Plant sources (phytate-bound): <b>lower</b> absorption",
    "Processed food additives: <b>nearly 100%</b> absorbed (very bioavailable - clinical concern in CKD)",
]))
story.append(sp(6))
story.append(info_box(
    "Intestinal Transport Summary (Ganong's Physiology 26e)",
    ["Pi is absorbed in the duodenum and small intestine via NaPi-IIb transporter that uses the "
     "low intracellular Na⁺ concentration (established by Na,K-ATPase on basolateral membrane) "
     "to load Pi against its concentration gradient. Many stimuli that increase Ca²⁺ absorption, "
     "including 1,25-dihydroxycholecalciferol, also increase Pi absorption via increased NaPi-IIb "
     "expression and/or its insertion into the enterocyte apical membrane."],
    bg=TEAL_LIGHT, title_color=TEAL
))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CH 4 - FACTORS AFFECTING ABSORPTION
# ════════════════════════════════════════════════════════════════════════════
story.append(ch_banner("Chapter 4: Factors Affecting Phosphorus Absorption", PURPLE))
story.append(sp(10))

story.append(Paragraph("A. Factors that INCREASE Absorption", sec))
factors_inc = two_col(
    [Paragraph("<b>Factor</b>", kf), Paragraph("<b>Mechanism</b>", kf)],
    [
        [Paragraph("Calcitriol (1,25-(OH)₂D₃)\nActive Vitamin D", body),
         Paragraph("Upregulates NaPi-IIb transporter on brush border → increases active transport. "
                   "Most important stimulator.", body)],
        [Paragraph("Low dietary phosphorus intake", body),
         Paragraph("Upregulates NaPi-IIb expression (compensatory increase in absorption)", body)],
        [Paragraph("Growth hormone (GH)", body),
         Paragraph("Stimulates Vitamin D activation → indirect increase in absorption", body)],
        [Paragraph("Insulin-like growth factor-1 (IGF-1)", body),
         Paragraph("Increases renal 1α-hydroxylase → more calcitriol → more absorption", body)],
        [Paragraph("Acidic pH in duodenum", body),
         Paragraph("Favours solubility of phosphate salts → better absorption", body)],
        [Paragraph("Animal protein diet", body),
         Paragraph("Phosphorus in bioavailable form; not bound as phytate", body)],
    ],
    w=(5.5*cm, 11.1*cm)
)
story.append(factors_inc)
story.append(sp(10))

story.append(Paragraph("B. Factors that DECREASE Absorption", sec))
factors_dec = two_col(
    [Paragraph("<b>Factor</b>", kf), Paragraph("<b>Mechanism</b>", kf)],
    [
        [Paragraph("Phosphate Binders", body),
         Paragraph("Calcium carbonate, calcium acetate, sevelamer, lanthanum carbonate — "
                   "bind dietary phosphate in the gut lumen → form insoluble complexes → not absorbed. "
                   "Used therapeutically in CKD.", body)],
        [Paragraph("Antacids (Al³⁺ and Mg²⁺ based)", body),
         Paragraph("Aluminium hydroxide, magnesium hydroxide bind phosphate → reduce absorption. "
                   "Excess antacid use = iatrogenic hypophosphatemia.", body)],
        [Paragraph("Calcium supplements (high dose)", body),
         Paragraph("Bind dietary phosphorus → reduce absorption", body)],
        [Paragraph("Phytate (plant-bound P)", body),
         Paragraph("Grain-based diets (soy) contain phytate-bound phosphorus. Humans lack "
                   "phytase enzyme → poor bioavailability (~30-50%)", body)],
        [Paragraph("PTH (Parathyroid Hormone)", body),
         Paragraph("Inhibits NaPi-IIb indirectly via FGF23; primarily acts on kidney not gut", body)],
        [Paragraph("FGF-23 (Fibroblast Growth Factor 23)", body),
         Paragraph("Inhibits 1α-hydroxylase → reduces calcitriol → reduces intestinal absorption", body)],
        [Paragraph("Vitamin D deficiency", body),
         Paragraph("Reduced calcitriol → NaPi-IIb not upregulated → reduced absorption", body)],
        [Paragraph("Malabsorption syndromes", body),
         Paragraph("Celiac disease, Crohn's, short bowel syndrome → overall reduced nutrient absorption", body)],
        [Paragraph("Alcoholism", body),
         Paragraph("Poor intake + reduced absorption + poor Vitamin D status", body)],
        [Paragraph("Alkaline pH", body),
         Paragraph("Forms insoluble calcium phosphate salts in gut lumen → less absorbable", body)],
    ],
    w=(5.5*cm, 11.1*cm)
)
story.append(factors_dec)
story.append(sp(8))
story.append(exam_box(
    "High-yield MCQ: Most important factor INCREASING absorption = Calcitriol (1,25-OH₂D₃). "
    "Most common cause of DECREASED absorption clinically = Phosphate binders (in CKD) or Antacid abuse. "
    "Phytate makes plant phosphorus less bioavailable than animal phosphorus."
))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CH 5 - REGULATION
# ════════════════════════════════════════════════════════════════════════════
story.append(ch_banner("Chapter 5: Regulation of Phosphorus Homeostasis", colors.HexColor("#1a6b72")))
story.append(sp(10))

story.append(Paragraph(
    "Phosphorus homeostasis is maintained by four major organs (intestine, kidney, bone, parathyroid) "
    "via four key hormones. Think of it as the <b>'4 organs - 4 hormones'</b> system.", body))
story.append(sp(6))

story.append(Paragraph("A. PTH (Parathyroid Hormone) — Most Important Regulator", sec))
story.extend(bullets([
    "Stimulus for release: <b>High phosphorus</b> or <b>Low calcium</b>",
    "<b>Kidney:</b> Inhibits NaPi-IIa and NaPi-IIc transporters in proximal tubule → causes <b>phosphaturia</b> (increased urine phosphorus) → LOWERS serum P",
    "<b>Bone:</b> Stimulates resorption → releases both Ca and P into blood → RAISES serum P",
    "<b>Kidney:</b> Stimulates 1α-hydroxylase → more calcitriol → more intestinal absorption → RAISES serum P",
    "Net effect of PTH on serum phosphorus: <b>DECREASES</b> (renal excretion effect dominates)",
]))
story.append(sp(6))

story.append(Paragraph("B. Calcitriol (1,25-(OH)₂D₃) — Active Vitamin D", sec))
story.extend(bullets([
    "Stimulated by: low Ca, low P, PTH, GH, IGF-1",
    "Inhibited by: FGF-23, high calcitriol itself (negative feedback)",
    "<b>Intestine:</b> Upregulates NaPi-IIb → increases absorption of P → RAISES serum P",
    "<b>Kidney:</b> Decreases phosphorus excretion → RAISES serum P",
    "<b>Bone:</b> Stimulates osteoblasts → increases synthetic activity",
    "Net effect: <b>INCREASES</b> serum phosphorus",
]))
story.append(sp(6))

story.append(Paragraph("C. FGF-23 (Fibroblast Growth Factor 23)", sec))
story.extend(bullets([
    "Source: <b>Osteoblasts and osteocytes</b> in bone",
    "Stimulus: <b>HIGH serum phosphorus</b> (and calcitriol)",
    "Requires <b>co-receptor Klotho</b> (alpha-Klotho) at the kidney to act",
    "<b>Kidney:</b> Inhibits NaPi-IIa and NaPi-IIc in proximal tubule → INCREASES phosphaturia → LOWERS serum P",
    "<b>Kidney:</b> Inhibits 1α-hydroxylase + stimulates CYP24 (degradation enzyme) → reduces calcitriol → less intestinal absorption",
    "<b>Parathyroid:</b> Inhibits PTH secretion (FGF23 has direct PTH-lowering effect)",
    "Net effect: <b>LOWERS serum phosphorus</b>",
    "Clinical importance: FGF-23 is elevated early in CKD (phosphorus sensor)",
]))
story.append(sp(6))

story.append(Paragraph("D. Renal Regulation (Proximal Tubule)", sec))
story.extend(bullets([
    "~85-90% of filtered Pi is reabsorbed in the proximal tubule",
    "Transporters: <b>NaPi-IIa</b> (major) and <b>NaPi-IIc</b> — sodium-dependent cotransporters",
    "PTH → internalises and degrades NaPi-IIa → phosphaturia",
    "FGF-23 → downregulates NaPi-IIa/IIc → phosphaturia",
    "Insulin → shifts phosphate INTO cells → lowers serum P",
    "High serum P itself → directly reduces proximal tubular reabsorption",
]))
story.append(sp(6))

story.append(Paragraph("E. Bone", sec))
story.extend(bullets([
    "~3 mg/kg/day of phosphorus enters bone normally with equal amount leaving via resorption",
    "PTH and calcitriol stimulate osteoclast-mediated resorption → P released into ECF",
    "Insulin, alkalosis: shift P into cells/bone",
    "Post-parathyroidectomy: 'Hungry bone syndrome' — bone rapidly absorbs P → severe hypophosphatemia",
]))
story.append(sp(8))

story.append(info_box(
    "Regulation Summary Table — Effect on Serum Phosphorus",
    [
        "PTH         →  Net DECREASE in serum P (phosphaturia dominates)",
        "Calcitriol  →  Net INCREASE in serum P (increased intestinal absorption)",
        "FGF-23      →  Net DECREASE in serum P (phosphaturia + less calcitriol)",
        "Insulin     →  DECREASE in serum P (shifts P into cells)",
        "High serum P →  Stimulates PTH + FGF-23 → phosphaturia (negative feedback)",
        "Low serum P →  Inhibits FGF-23 → less phosphaturia → P conserved",
    ],
    bg=TEAL_LIGHT, title_color=TEAL
))
story.append(sp(6))
story.append(exam_box(
    "Remember: FGF-23 is produced by BONE, acts on KIDNEY. "
    "Both PTH and FGF-23 cause phosphaturia. "
    "PTH INCREASES calcitriol; FGF-23 DECREASES calcitriol — they are ANTAGONISTS on Vitamin D synthesis. "
    "Klotho is essential co-receptor for FGF-23 signaling."
))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CH 6 - MANIFEST ACTIONS / FUNCTIONS
# ════════════════════════════════════════════════════════════════════════════
story.append(ch_banner("Chapter 6: Manifest Actions (Functions) of Phosphorus", GREEN))
story.append(sp(10))

story.append(Paragraph(
    "Phosphorus participates in virtually every metabolic process. "
    "Here are its key physiological functions:", body))
story.append(sp(6))

functions = [
    ("1. Energy Metabolism (ATP)",
     "Phosphate groups form the high-energy bonds in <b>ATP (Adenosine Triphosphate)</b>, "
     "ADP, AMP, creatine phosphate, and other energy-storing molecules. "
     "Breaking the phosphate bond (ATP → ADP + Pi) releases ~7.3 kcal/mol of free energy. "
     "Without phosphorus, no cellular energy = no life."),
    ("2. Genetic Material (DNA & RNA)",
     "Phosphodiester bonds form the <b>backbone of DNA and RNA</b>. "
     "Each nucleotide has a phosphate group. Phosphorus is thus essential for "
     "cell division, replication, transcription, and translation."),
    ("3. Cell Membrane Structure (Phospholipids)",
     "<b>Phospholipid bilayer</b> forms all cell membranes. The phosphate 'head' is hydrophilic, "
     "fatty acid 'tails' are hydrophobic. This determines membrane permeability and "
     "controls what enters/exits the cell."),
    ("4. Bone and Teeth Mineralisation",
     "As <b>hydroxyapatite [Ca₁₀(PO₄)₆(OH)₂]</b>, phosphorus provides hardness and structural "
     "integrity to bones and teeth. About 85% of total body phosphorus resides here."),
    ("5. Cell Signalling — Phosphorylation",
     "<b>Protein phosphorylation/dephosphorylation</b> is the central switch of intracellular signalling. "
     "Kinases add phosphate → activate/deactivate enzymes, receptors, and transcription factors. "
     "cAMP (cyclic AMP) is a key secondary messenger that contains phosphate."),
    ("6. Oxygen Delivery — 2,3-DPG",
     "<b>2,3-Diphosphoglycerate (2,3-DPG)</b> in red blood cells regulates haemoglobin's affinity for oxygen. "
     "In hypophosphatemia → ↓2,3-DPG → Hb holds oxygen too tightly → tissue hypoxia even when "
     "SpO₂ is normal. This is clinically important in ICU patients."),
    ("7. Acid-Base Buffer",
     "Phosphate acts as an important <b>urinary buffer</b> (titratable acid). "
     "HPO₄²⁻/H₂PO₄⁻ system (pKa 6.8) buffers urine pH. "
     "Also acts as intracellular buffer. This helps maintain systemic pH 7.35-7.45."),
    ("8. Platelet Aggregation",
     "Phosphorus is critical for normal <b>platelet function</b> and aggregation. "
     "Severe hypophosphatemia can cause platelet dysfunction and bleeding."),
    ("9. Enzyme Cofactor",
     "Many enzymes in glycolysis, Krebs cycle, and oxidative phosphorylation require phosphate. "
     "Examples: phosphoglycerate kinase, pyruvate kinase, ATP synthase."),
    ("10. Myocardial and Skeletal Muscle Contractility",
     "Muscle contraction requires ATP (from phosphate). "
     "Severe phosphorus depletion → muscle weakness, heart failure, respiratory failure."),
]
for title, desc in functions:
    story.append(Paragraph(title, sub))
    story.append(Paragraph(desc, body))
    story.append(sp(3))

story.append(sp(6))
story.append(key_box(
    "Mnemonic for Phosphorus Functions: 'ABCDE-POP' = "
    "ATP / Bone mineralisation / Cell membrane (phospholipids) / DNA backbone / Enzyme activation / "
    "Phosphorylation (signalling) / Oxygen (2,3-DPG) / Platelet function"
))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CH 7 - DEFICIENCY / HYPOPHOSPHATEMIA
# ════════════════════════════════════════════════════════════════════════════
story.append(ch_banner("Chapter 7: Deficiency — Hypophosphatemia", RED))
story.append(sp(10))

story.append(Paragraph(
    "<b>Hypophosphatemia</b> = serum phosphate <b>&lt; 2.5 mg/dL</b> (some sources: &lt; 2.8 mg/dL). "
    "Severe = <b>&lt; 1.0 mg/dL</b>.", body))
story.append(sp(6))

story.append(Paragraph("Classification", sec))
cls_data = two_col(
    [Paragraph("<b>Severity</b>", kf), Paragraph("<b>Serum Phosphorus Level</b>", kf)],
    [
        [Paragraph("Mild", body),    Paragraph("2.0 - 2.5 mg/dL", body)],
        [Paragraph("Moderate", body), Paragraph("1.0 - 2.0 mg/dL", body)],
        [Paragraph("Severe", body),  Paragraph("< 1.0 mg/dL — requires IV treatment", body)],
    ],
    w=(6*cm, 10.6*cm)
)
story.append(cls_data)
story.append(sp(8))

story.append(Paragraph("Causes (Mechanisms)", sec))
story.append(Paragraph("<b>1. Decreased Intestinal Absorption:</b>", sub))
story.extend(bullets([
    "Malabsorption syndromes (celiac, Crohn's, short bowel)",
    "Vitamin D deficiency (reduced calcitriol → less NaPi-IIb expression)",
    "Use of phosphate binders (iatrogenic) or antacid abuse (Al/Mg antacids)",
    "Alcoholism — poor intake + poor Vitamin D status",
    "Starvation, prolonged fasting",
]))
story.append(sp(4))
story.append(Paragraph("<b>2. Increased Renal Excretion (Renal Phosphate Wasting):</b>", sub))
story.extend(bullets([
    "<b>Primary hyperparathyroidism</b> — excess PTH → phosphaturia",
    "<b>Secondary hyperparathyroidism</b> (in Vitamin D deficiency, CKD)",
    "<b>Osmotic diuresis</b> (DM, mannitol) → phosphaturia",
    "<b>X-linked hypophosphatemic rickets (XLH)</b> — defect in PHEX gene → excess FGF-23 → renal Pi wasting",
    "<b>Fanconi Syndrome</b> — proximal tubular dysfunction → generalised reabsorption failure",
    "<b>Oncogenic osteomalacia</b> — tumour produces excess FGF-23",
    "Continuous renal replacement therapy (CRRT) — slow dialysis removes phosphorus",
]))
story.append(sp(4))
story.append(Paragraph("<b>3. Transcellular Shift (P moves from ECF into cells):</b>", sub))
story.extend(bullets([
    "<b>Refeeding syndrome</b> — most important clinical scenario: "
    "Malnourished patient given nutrition → insulin surge → glucose uptake → "
    "phosphorus rapidly enters cells for glycolysis → sudden, severe hypophosphatemia",
    "<b>Respiratory alkalosis</b> — ↑pH → intracellular phosphorylation increases → P enters cells",
    "<b>Insulin administration</b> (treatment of DKA) — insulin drives P into cells",
    "<b>Hungry bone syndrome</b> — after parathyroidectomy → bone rapidly mineralises → takes up P",
    "Rapidly proliferating leukaemia cells — consume phosphorus",
]))
story.append(sp(8))
story.append(exam_box(
    "REFEEDING SYNDROME = Most exam-favourite cause of acute severe hypophosphatemia. "
    "Mechanism: malnourished + sudden feeding → insulin → P shifts intracellularly. "
    "Also watch for: antacid abuse (aluminium/magnesium antacids) as a common iatrogenic cause."
))
story.append(PageBreak())

story.append(Paragraph("Clinical Manifestations of Hypophosphatemia", sec))
story.append(Paragraph(
    "Symptoms usually appear only when <b>total body phosphate depletion is severe</b> "
    "(&lt;1 mg/dL). They reflect the loss of phosphorus from ATP, 2,3-DPG, and cell membranes.", body))
story.append(sp(6))

manif = two_col(
    [Paragraph("<b>System</b>", kf), Paragraph("<b>Manifestations and Mechanism</b>", kf)],
    [
        [Paragraph("Musculoskeletal", body),
         Paragraph("Proximal muscle weakness, myalgia, bone pain, fractures. "
                   "Severe: rhabdomyolysis (muscle breakdown → ↑CK, myoglobinuria)", body)],
        [Paragraph("Respiratory", body),
         Paragraph("Impaired diaphragmatic function → <b>respiratory failure</b> (weaning failure "
                   "from ventilator is classic). ↓ATP in respiratory muscles.", body)],
        [Paragraph("Cardiac", body),
         Paragraph("Cardiomyopathy, heart failure, arrhythmias (rare, severe depletion)", body)],
        [Paragraph("Neurological", body),
         Paragraph("Paraesthesias, dysarthria, confusion, stupor, <b>seizures, coma</b> "
                   "(severe cases). Peripheral neuropathy.", body)],
        [Paragraph("Haematological", body),
         Paragraph("Haemolytic anaemia (RBC membrane fragility ↑), platelet dysfunction (bleeding). "
                   "↓2,3-DPG → tissue hypoxia (O₂ not released from Hb).", body)],
        [Paragraph("Bone (chronic)", body),
         Paragraph("Osteomalacia in adults (soft, demineralised bones). "
                   "Rickets in children (bowed legs, frontal bossing).", body)],
        [Paragraph("Metabolic", body),
         Paragraph("Impaired gluconeogenesis, metabolic acidosis", body)],
    ],
    w=(4*cm, 12.6*cm)
)
story.append(manif)
story.append(sp(8))

story.append(Paragraph("Treatment of Hypophosphatemia", sec))
story.extend(bullets([
    "<b>Mild-Moderate (1.0-2.5 mg/dL, asymptomatic):</b> Oral phosphorus supplementation "
    "(Neutra-Phos 250 mg caps, dissolved in water). Treat underlying cause.",
    "<b>Severe (&lt;1.0 mg/dL) with symptoms:</b> IV phosphate "
    "(K-phosphate: 1.5 mEq K/mmol P OR Na-phosphate: 1.3 mEq Na/mmol P)",
    "Monitor serum Ca and P every 8 hours during IV therapy — risk of hypocalcemia",
    "Treat Vitamin D deficiency first in chronic cases",
    "Stop offending agents (antacids, phosphate binders)",
    "In refeeding syndrome: give phosphorus BEFORE re-feeding; slow the rate of feeding",
]))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CH 8 - HYPERPHOSPHATEMIA
# ════════════════════════════════════════════════════════════════════════════
story.append(ch_banner("Chapter 8: Excess — Hyperphosphatemia", colors.HexColor("#6e2f0a")))
story.append(sp(10))

story.append(Paragraph(
    "<b>Hyperphosphatemia</b> = serum phosphate <b>&gt; 4.5 mg/dL</b>.", body))
story.append(sp(6))

story.append(Paragraph("Causes", sec))
story.append(Paragraph("<b>1. Decreased Renal Excretion (Most Common):</b>", sub))
story.extend(bullets([
    "<b>Chronic Kidney Disease (CKD)</b> — most common cause. As GFR falls, P retention occurs.",
    "Hypoparathyroidism and pseudohypoparathyroidism — ↓PTH → less phosphaturia",
    "Acromegaly — GH excess increases tubular reabsorption of phosphorus",
]))
story.append(Paragraph("<b>2. Transcellular Shift (P moves OUT of cells):</b>", sub))
story.extend(bullets([
    "<b>Rhabdomyolysis</b> — massive muscle breakdown releases intracellular P",
    "<b>Tumour lysis syndrome</b> — cancer treatment kills cells → P floods ECF",
    "Massive haemolysis",
    "DKA (diabetic ketoacidosis) — metabolic acidosis + hypoinsulinaemia → P shifts out",
]))
story.append(Paragraph("<b>3. Increased Intake:</b>", sub))
story.extend(bullets([
    "Fleet Phospho-Soda enemas (especially dangerous in renal insufficiency)",
    "Excessive Vitamin D supplementation → excess intestinal absorption",
    "High dietary phosphorus in CKD patients",
]))
story.append(sp(6))

story.append(Paragraph("Clinical Manifestations", sec))
story.extend(bullets([
    "<b>Hypocalcaemia</b> (most important) — Ca × P product → Ca phosphate deposits form → "
    "free Ca drops → tetany, perioral tingling, Chvostek's sign, Trousseau's sign",
    "<b>Metastatic/Ectopic calcification</b> — calcium phosphate deposits in soft tissues: "
    "blood vessels (vascular calcification), joints, cornea, skin",
    "<b>Calciphylaxis</b> — ischemia from calcification of small blood vessels + thrombosis → "
    "skin necrosis (painful, life-threatening)",
    "<b>Pruritus</b> — calcium phosphate deposits in skin → severe itching",
    "<b>Secondary hyperparathyroidism</b> — chronic high P → stimulates PTH → bone disease",
    "<b>Renal osteodystrophy</b> — CKD-mineral bone disorder (CKD-MBD)",
]))
story.append(sp(6))

story.append(Paragraph("Treatment", sec))
story.extend(bullets([
    "<b>Acute:</b> Saline + acetazolamide to increase phosphaturia. Haemodialysis if severe/renal failure.",
    "<b>Chronic (CKD):</b> Dietary phosphorus restriction + <b>phosphate binders</b>:",
    "   - Calcium-based: Calcium carbonate, calcium acetate (cheapest)",
    "   - Non-calcium: Sevelamer (preferred; also lowers LDL), lanthanum carbonate",
    "   - Aluminium-based: Aluminium hydroxide (effective but risk of aluminium toxicity)",
    "Treat underlying CKD; consider dialysis",
]))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CH 9 - CLINICAL SIGNS AND SIGNIFICANCE
# ════════════════════════════════════════════════════════════════════════════
story.append(ch_banner("Chapter 9: Clinical Signs and Significance", NAVY))
story.append(sp(10))

story.append(Paragraph("Clinical Signs: Quick Reference Card", sec))
signs = two_col(
    [Paragraph("<b>Sign</b>", kf), Paragraph("<b>Seen In / Significance</b>", kf)],
    [
        [Paragraph("Chvostek's Sign", body),
         Paragraph("Tapping facial nerve → ipsilateral facial muscle twitch. "
                   "Sign of hypocalcaemia (secondary to hyperphosphatemia)", body)],
        [Paragraph("Trousseau's Sign", body),
         Paragraph("BP cuff inflation above systolic → carpal spasm (main d'accoucheur). "
                   "More specific than Chvostek's for hypocalcaemia", body)],
        [Paragraph("Bowing of legs", body),
         Paragraph("Rickets in children (chronic phosphorus + Vitamin D deficiency)", body)],
        [Paragraph("Frontal bossing, rachitic rosary, Harrison's sulcus", body),
         Paragraph("Childhood rickets (XLH, nutritional rickets due to chronic hypophosphatemia)", body)],
        [Paragraph("Ventilator weaning failure", body),
         Paragraph("Severe hypophosphatemia → diaphragm weakness → cannot wean from ventilator (ICU)", body)],
        [Paragraph("Rhabdomyolysis", body),
         Paragraph("Severe hypophosphatemia → muscle cell membrane failure → ↑CK, myoglobinuria, dark urine, AKI", body)],
        [Paragraph("Skin necrosis (Calciphylaxis)", body),
         Paragraph("Hyperphosphatemia in CKD → calcification of dermal vessels → tissue ischemia, painful necrosis", body)],
        [Paragraph("Periarticular calcification", body),
         Paragraph("High Ca×P product → deposits in joints, periarticular tissue", body)],
        [Paragraph("Corneal calcification (Band keratopathy)", body),
         Paragraph("Calcium phosphate deposits in Bowman's layer of cornea in chronic hypercalcaemia/hyperphosphatemia", body)],
        [Paragraph("Itching (Pruritus)", body),
         Paragraph("Calcium phosphate microcrystalline deposits in skin; CKD patients", body)],
    ],
    w=(5*cm, 11.6*cm)
)
story.append(signs)
story.append(sp(8))

story.append(Paragraph("Clinical Significance (Why Examiners Ask This)", sec))
sig_points = [
    ("CKD and Phosphorus",
     "In CKD, failing kidneys cannot excrete phosphorus → hyperphosphatemia → stimulates FGF-23 and PTH "
     "→ secondary hyperparathyroidism → bone resorption → CKD-MBD (mineral bone disorder). "
     "Vascular calcification from high Ca×P product → ↑cardiovascular mortality. "
     "Phosphorus management is central to CKD care."),
    ("Refeeding Syndrome",
     "A life-threatening complication when severely malnourished patients "
     "(starvation, anorexia nervosa, cancer, postoperative) are fed rapidly. "
     "Insulin surge drives P, K, Mg into cells → sudden drops. "
     "Can cause cardiac arrhythmias, respiratory failure, seizures, death. "
     "Prevention: monitor and replace P/K/Mg before and during refeeding; start feeding slowly."),
    ("ICU Hypophosphatemia",
     "Common in critically ill patients (mechanical ventilation, DKA treatment, CRRT, sepsis). "
     "Impairs respiratory muscle function → difficulty weaning. "
     "Replace when <2.0 mg/dL in ventilated patients (IV route preferred)."),
    ("X-linked Hypophosphataemic Rickets (XLH)",
     "Most common form of hereditary rickets. "
     "X-linked dominant. Mutation in PHEX gene → excess FGF-23 → renal Pi wasting + reduced calcitriol "
     "→ hypophosphatemia → defective bone mineralisation. "
     "Treatment: oral phosphate + calcitriol supplements; newer: Burosumab (anti-FGF-23 antibody)."),
    ("Tumour-induced Osteomalacia (TIO)",
     "Rare paraneoplastic syndrome. Mesenchymal tumours secrete excess FGF-23 → renal phosphate wasting "
     "→ osteomalacia, bone pain, fractures. Diagnosis: elevated FGF-23, low calcitriol. Cure = remove tumour."),
]
for title, desc in sig_points:
    story.append(Paragraph(title, sub))
    story.append(Paragraph(desc, body))
    story.append(sp(4))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CH 10 - PRECAUTIONS
# ════════════════════════════════════════════════════════════════════════════
story.append(ch_banner("Chapter 10: Precautions in Clinical Practice", ORANGE))
story.append(sp(10))

story.append(Paragraph("Precautions While Treating Phosphorus Disorders", sec))
prec = [
    ("1. Treating hypophosphatemia with IV phosphate",
     ["Monitor serum calcium every 8 hours — IV phosphate can precipitate HYPOCALCAEMIA",
      "Stop infusion if patient develops hypotension (suspect acute hypocalcaemia)",
      "Do NOT mix phosphate with calcium-containing IV solutions → calcium phosphate precipitate",
      "Maximum rate: 0.08 mmol/kg/hr for asymptomatic; up to 0.16 mmol/kg/hr for symptomatic"]),
    ("2. Refeeding syndrome prevention",
     ["Identify high-risk patients: BMI <16, negligible food intake >10 days, weight loss >15%",
      "Check and replete P, K, Mg BEFORE starting nutrition",
      "Start feeding SLOWLY (max 10-20 kcal/kg/day initially)",
      "Monitor electrolytes daily for the first week of refeeding",
      "Give thiamine (Vitamin B1) before any glucose — prevent Wernicke's"]),
    ("3. Phosphate binders in CKD",
     ["Calcium-based binders: limit if Ca×P product is high (>55) — risk of vascular calcification",
      "Aluminium hydroxide: effective but avoid long-term use → aluminium toxicity (bone disease, encephalopathy)",
      "Sevelamer: preferred as it does not add calcium load and reduces LDL",
      "All binders must be taken WITH MEALS to bind dietary phosphorus in gut"]),
    ("4. Phosphate supplementation caution",
     ["Oral phosphate: common side effect = diarrhoea (osmotic)",
      "In renal failure: avoid oral/IV phosphate supplementation — risk of fatal hyperphosphatemia",
      "Phophate enemas (Fleet) are CONTRAINDICATED in renal insufficiency — severe hyperphosphatemia + hypocalcaemia"]),
    ("5. Monitoring in ICU",
     ["Check phosphorus in ALL critically ill patients daily",
      "Especially: TPN patients, ventilated patients, DKA management, CRRT patients",
      "Severe hypophosphatemia (<1 mg/dL) = emergency → IV phosphate"]),
]
for title, pts in prec:
    story.append(Paragraph(title, sub))
    story.extend(bullets(pts))
    story.append(sp(4))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════════════════
# CH 11 - QUICK REVISION + MCQs
# ════════════════════════════════════════════════════════════════════════════
story.append(ch_banner("Chapter 11: Quick Revision + MCQ Practice", NAVY))
story.append(sp(10))

story.append(Paragraph("Master Revision Table", sec))
rev_data = [
    [Paragraph("<b>Topic</b>", kf), Paragraph("<b>Key Fact</b>", kf)],
    [Paragraph("Normal serum P", body), Paragraph("2.5 - 4.5 mg/dL (adults)", body)],
    [Paragraph("Total body P", body),   Paragraph("~700 g; 85% in bone", body)],
    [Paragraph("RDA (adults)", body),   Paragraph("700-800 mg/day; teens: 1250 mg/day", body)],
    [Paragraph("% absorbed from gut", body), Paragraph("60-70% overall", body)],
    [Paragraph("Main absorptive transporter", body), Paragraph("NaPi-IIb (NPT2b) — small intestine", body)],
    [Paragraph("Main renal reabsorption transporter", body), Paragraph("NaPi-IIa (major) + NaPi-IIc — proximal tubule", body)],
    [Paragraph("% filtered P reabsorbed", body), Paragraph("85-90% in proximal tubule", body)],
    [Paragraph("Increases absorption", body), Paragraph("Calcitriol (1,25-OH₂D₃) — MOST IMPORTANT", body)],
    [Paragraph("Decreases absorption", body), Paragraph("Phosphate binders, Al/Mg antacids, FGF-23, phytate", body)],
    [Paragraph("PTH effect on P", body), Paragraph("NET DECREASE — phosphaturia via NaPi-IIa inhibition", body)],
    [Paragraph("FGF-23 source", body), Paragraph("Osteoblasts/osteocytes; requires Klotho co-receptor", body)],
    [Paragraph("FGF-23 effect", body), Paragraph("Phosphaturia + reduces calcitriol — NET DECREASE in P", body)],
    [Paragraph("Insulin effect on P", body), Paragraph("Shifts P into cells — DECREASES serum P", body)],
    [Paragraph("Hypophosphatemia def.", body), Paragraph("< 2.5 mg/dL; severe < 1.0 mg/dL", body)],
    [Paragraph("Hyperphosphatemia def.", body), Paragraph("> 4.5 mg/dL", body)],
    [Paragraph("Commonest cause hypo-P", body), Paragraph("Refeeding syndrome, antacid abuse, alcoholism", body)],
    [Paragraph("Commonest cause hyper-P", body), Paragraph("Chronic Kidney Disease (CKD)", body)],
    [Paragraph("Life-threatening hypo-P", body), Paragraph("Respiratory failure (diaphragm weakness), rhabdomyolysis", body)],
    [Paragraph("Hyper-P most dangerous", body), Paragraph("Calciphylaxis, vascular calcification, hypocalcaemia", body)],
    [Paragraph("2,3-DPG significance", body), Paragraph("Low P → ↓2,3-DPG → Hb holds O₂ → tissue hypoxia", body)],
    [Paragraph("XLH", body), Paragraph("X-linked hypophosphatemic rickets; PHEX mutation; excess FGF-23", body)],
    [Paragraph("TIO (Tumour-induced)", body), Paragraph("Mesenchymal tumour → FGF-23 → phosphate wasting → osteomalacia", body)],
]
rt = Table(rev_data, colWidths=[6*cm, 10.6*cm])
rt.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),(-1,0), NAVY),
    ("TEXTCOLOR",     (0,0),(-1,0), WHITE),
    ("FONTNAME",      (0,0),(-1,0), "Helvetica-Bold"),
    ("FONTSIZE",      (0,0),(-1,-1), 9),
    ("ROWBACKGROUNDS",(0,1),(-1,-1), [WHITE, TEAL_LIGHT]),
    ("GRID",          (0,0),(-1,-1), 0.5, GREY_D),
    ("TOPPADDING",    (0,0),(-1,-1), 4),
    ("BOTTOMPADDING", (0,0),(-1,-1), 4),
    ("LEFTPADDING",   (0,0),(-1,-1), 7),
    ("VALIGN",        (0,0),(-1,-1), "MIDDLE"),
]))
story.append(rt)
story.append(PageBreak())

story.append(Paragraph("Practice MCQs (Exam Style)", sec))
mcqs = [
    ("Q1. Normal serum phosphorus in adults is:",
     ["A) 1.5 - 2.5 mg/dL", "B) 2.5 - 4.5 mg/dL", "C) 4.5 - 6.5 mg/dL", "D) 8.5 - 10.5 mg/dL"],
     "B) 2.5 - 4.5 mg/dL"),
    ("Q2. The RDA of phosphorus for an adult is approximately:",
     ["A) 400 mg/day", "B) 1000 mg/day", "C) 700-800 mg/day", "D) 2000 mg/day"],
     "C) 700-800 mg/day (teens need 1250 mg/day)"),
    ("Q3. The transporter responsible for active phosphorus absorption in the small intestine is:",
     ["A) NaPi-IIa", "B) NaPi-IIb (NPT2b)", "C) NaPi-IIc", "D) SGLT-1"],
     "B) NaPi-IIb (NPT2b) — on brush border of enterocytes"),
    ("Q4. Which hormone MOST IMPORTANTLY increases intestinal phosphorus absorption?",
     ["A) PTH", "B) FGF-23", "C) Calcitriol (1,25-OH₂D₃)", "D) Cortisol"],
     "C) Calcitriol — upregulates NaPi-IIb transporter"),
    ("Q5. A malnourished patient is started on TPN. Two days later, he develops confusion, "
     "respiratory failure and arrhythmia. Serum phosphorus is 0.6 mg/dL. Diagnosis?",
     ["A) Hyperphosphatemia", "B) Refeeding syndrome", "C) Hypercalcaemia", "D) Hyponatraemia"],
     "B) Refeeding Syndrome — insulin-driven intracellular shift of P"),
    ("Q6. FGF-23 is secreted by:",
     ["A) Parathyroid glands", "B) Kidneys", "C) Osteoblasts and osteocytes (bone)", "D) Intestine"],
     "C) Osteoblasts and osteocytes"),
    ("Q7. Net effect of PTH on serum phosphorus is:",
     ["A) Increase", "B) Decrease", "C) No effect", "D) Increases in kidney, decreases in gut"],
     "B) Decrease — phosphaturia via inhibition of NaPi-IIa in proximal tubule"),
    ("Q8. Most common cause of hyperphosphatemia is:",
     ["A) Hypoparathyroidism", "B) Excess Vitamin D intake", "C) Chronic Kidney Disease", "D) Rhabdomyolysis"],
     "C) Chronic Kidney Disease (CKD)"),
    ("Q9. In severe hypophosphatemia, tissue hypoxia occurs because:",
     ["A) Haemoglobin production stops", "B) ↓2,3-DPG → Hb increased O₂ affinity → O₂ not released",
      "C) Lung function decreases", "D) RBC membrane ruptures"],
     "B) ↓2,3-DPG → Hb holds O₂ tightly → tissue hypoxia despite normal SpO₂"),
    ("Q10. Phosphate binders should be taken:",
     ["A) At bedtime", "B) 1 hour before meals", "C) WITH meals", "D) On empty stomach"],
     "C) WITH MEALS — to bind dietary phosphate in gut lumen"),
    ("Q11. Calciphylaxis is seen in:",
     ["A) Hypophosphatemia", "B) Hyperphosphatemia (usually CKD)", "C) Rickets", "D) Osteomalacia"],
     "B) Hyperphosphatemia — calcification of small dermal blood vessels → necrosis"),
    ("Q12. X-linked Hypophosphatemic Rickets (XLH) is due to mutation in:",
     ["A) Vitamin D receptor", "B) PHEX gene → excess FGF-23", "C) NaPi-IIb transporter gene", "D) PTH receptor"],
     "B) PHEX gene mutation → excess FGF-23 → renal phosphate wasting"),
]
for q, opts, ans in mcqs:
    story.append(Paragraph(q, sub))
    for o in opts:
        story.append(Paragraph(f"   {o}", bul))
    story.append(Paragraph(f"<b>Answer:</b> {ans}",
                            S("ANS", fontSize=9.5, textColor=GREEN,
                              fontName="Helvetica-Bold", leading=13,
                              leftIndent=14, spaceAfter=8)))
    story.append(sp(3))

story.append(PageBreak())

# ── FINAL SUMMARY BOX ─────────────────────────────────────────────────────
story.append(ch_banner("Final Exam Summary — Phosphorus at a Glance", NAVY))
story.append(sp(10))
summary_box = Table([
    [Paragraph(
        "<b>INTRODUCTION:</b>  P = 15; 2nd most abundant mineral; 85% in bone; serum normal = 2.5-4.5 mg/dL<br/><br/>"
        "<b>RDA:</b>  700-800 mg/day (adults) | 1250 mg/day (teens) | 60-70% absorbed<br/><br/>"
        "<b>ABSORPTION:</b>  NaPi-IIb in small intestine (active, Na-dependent); passive paracellular route<br/><br/>"
        "<b>FACTORS ↑ ABSORPTION:</b>  Calcitriol (most important), low P intake, GH, IGF-1<br/><br/>"
        "<b>FACTORS ↓ ABSORPTION:</b>  Phosphate binders, Al/Mg antacids, FGF-23, phytate (plants), Vit D deficiency<br/><br/>"
        "<b>REGULATION:</b>  PTH → ↓P (phosphaturia); Calcitriol → ↑P; FGF-23 → ↓P + ↓calcitriol; Insulin → ↓P (cell shift)<br/><br/>"
        "<b>FUNCTIONS:</b>  ATP, DNA/RNA, phospholipids, bone (hydroxyapatite), signalling, 2,3-DPG, acid-base buffer<br/><br/>"
        "<b>HYPOPHOSPHATEMIA (&lt;2.5):</b>  Causes: refeeding, antacids, malabsorption, XLH, Fanconi, CRRT<br/>"
        "   Features: muscle weakness, resp failure, rhabdomyolysis, haemolysis, seizures, ↓2,3-DPG<br/><br/>"
        "<b>HYPERPHOSPHATEMIA (&gt;4.5):</b>  Causes: CKD (most common), hypoparathyroidism, rhabdomyolysis, TLS<br/>"
        "   Features: hypocalcaemia, calciphylaxis, vascular calcification, pruritus, CKD-MBD<br/><br/>"
        "<b>PRECAUTIONS:</b>  Monitor Ca during IV P therapy | Phosphate binders WITH MEALS | "
        "Avoid Fleet enemas in CKD | Prevent refeeding syndrome",
        S("SB", fontSize=9.5, textColor=WHITE, fontName="Helvetica", leading=17)
    )]
], colWidths=[16.6*cm])
summary_box.setStyle(TableStyle([
    ("BACKGROUND",   (0,0),(-1,-1), NAVY),
    ("TOPPADDING",   (0,0),(-1,-1), 14),
    ("BOTTOMPADDING",(0,0),(-1,-1), 14),
    ("LEFTPADDING",  (0,0),(-1,-1), 14),
    ("BOX",          (0,0),(-1,-1), 2, TEAL),
]))
story.append(summary_box)
story.append(sp(12))
story.append(Paragraph(
    "Best of luck for your exams! — Sources: Ganong's Physiology 26e | "
    "Washington Manual of Medical Therapeutics | National Kidney Foundation Primer 8e | "
    "Brenner & Rector's The Kidney | Morgan & Mikhail's Clinical Anaesthesiology",
    S("FT", fontSize=9, textColor=GREY_D, fontName="Helvetica-Oblique",
      alignment=TA_CENTER, leading=14)
))

# ── BUILD ──────────────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF saved: {OUTPUT}")
Your credits are exhausted. You can purchase a top-up or subscribe to a plan to continue using Orris. If you're already subscribed, your daily credits will reset tomorrow.
This is a shared conversation. Sign in to Orris to start your own chat.