Ovulation, fertilisation and implementation reproductive health comprehensive notes

Reading File
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Finding Sources
Reading File
Reading File
Finding Sources
Reading File
Reading File
Loading Image
Loading Image
Loading Image
I now have all the material needed for comprehensive notes. Let me compile them.

Ovulation, Fertilisation & Implantation — Comprehensive Reproductive Health Notes


PART 1: OVULATION

1.1 Hormonal Control of the Ovarian Cycle

The menstrual cycle is coordinated by the hypothalamic–pituitary–ovarian (HPO) axis. FSH and LH, secreted by the anterior pituitary, drive follicular development and trigger ovulation.
Hormonal fluctuations and ovarian/endometrial changes during the menstrual cycle
Blood levels of LH, FSH, estrogen, and progesterone during a 28-day cycle. The LH surge precedes ovulation by 24–36 hours. If fertilization does not occur, estrogen and progesterone fall, triggering menstruation. — The Developing Human, Clinically Oriented Embryology
Key hormonal events:
  • Follicular phase (Days 1–13): FSH stimulates cohort of primordial follicles; one becomes the dominant (Graafian) follicle, grows to ~25 mm. Rising estrogen from granulosa cells initially exerts negative feedback on FSH/LH.
  • Pre-ovulatory estrogen peak: When estrogen exceeds a threshold (~200 pg/mL for ≥50 hours), it switches to positive feedback, triggering the LH surge.
  • LH surge: LH rises 6–10 fold; peaks ~16 hours before ovulation. FSH also rises 2–3 fold synergistically.
  • Ovulation timing: Occurs 24–36 hours after the LH peak, 10–12 hours after the LH peak in some sources.

1.2 Follicular Maturation Leading to Ovulation

StageKey Events
Primordial follicleOocyte arrested in prophase I; flat granulosa cells
Primary follicleCuboidal granulosa cells; zona pellucida forms
Secondary (antral) follicleFluid-filled antrum; thecal layers develop
Mature Graafian follicleRapid growth to 25 mm; LH surge triggers meiosis I completion; oocyte arrested in metaphase II ~3 hours before ovulation
The LH surge triggers:
  1. Completion of meiosis I → secondary oocyte + first polar body
  2. Arrest at metaphase II (meiosis II only completed at fertilization)
  3. Increased collagenase activity → digestion of collagen in follicular wall
  4. Rise in prostaglandins → smooth muscle contraction of the ovarian wall

1.3 Mechanism of Follicle Rupture

The LH surge causes rapid secretion of follicular steroid hormones (primarily progesterone), triggering two parallel events:
Mechanism of ovulation — LH cascade
Postulated mechanism of ovulation. LH drives progesterone synthesis → proteolytic enzymes weaken the follicle wall AND prostaglandins cause follicular hyperemia with plasma transudation → follicle swelling + stigma degeneration → rupture and evagination of the ovum. — Guyton & Hall Textbook of Medical Physiology
Step-by-step:
  1. A small avascular spot — the stigma — appears at the apex of the bulging follicle
  2. Lysosomal proteolytic enzymes (collagenase, plasmin, matrix metalloproteinases) digest the follicular capsule wall
  3. Prostaglandins cause vasodilation and hyperemia → plasma transudation into the follicle
  4. Follicle swells; the stigma balloons outward, then ruptures (~2 minutes after ooze begins)
  5. The viscous antral fluid expels the secondary oocyte surrounded by the corona radiata (radially arranged cumulus oophorus cells) and zona pellucida — together forming the oocyte–cumulus complex
  6. MAPK3/1 (ERK1/2) signaling pathways in follicular cells also help regulate this process

1.4 The Oocyte Post-Ovulation

  • The released cell is a secondary oocyte (not a mature ovum) — still arrested in metaphase II
  • Surrounded by: zona pellucida (glycoprotein coat: ZPA, ZPB, ZPC) → corona radiata → cumulus oophorus remnant
  • Swept into the fallopian tube (uterine tube) by ciliary action; must be fertilized within 12–24 hours
  • If not fertilized, degenerates

1.5 Corpus Luteum Formation

After ovulation, the ruptured follicle undergoes luteinization under continued LH stimulation:
  • Remaining granulosa and theca interna cells luteinize → enlarge 2× diameter, fill with lipid → yellow appearance
  • Form the corpus luteum, which secretes progesterone (primarily) and estrogen
  • Progesterone causes the secretory transformation of the endometrium, preparing it for blastocyst implantation
Two outcomes:
ScenarioWhat Happens
No fertilizationCorpus luteum involutes 10–12 days after ovulation → corpus luteum of menstruation → corpus albicans (white scar); progesterone/estrogen fall → menstruation
Fertilization occursSyncytiotrophoblast of blastocyst secretes hCG → rescues corpus luteum → corpus luteum of pregnancy; maintains hormone production for first 20 weeks until placenta takes over

1.6 Clinical Correlates of Ovulation

ConditionNotes
MittelschmerzMid-cycle pelvic pain from follicular rupture with slight peritoneal bleeding
Basal body temperature (BBT)Rises ~0.3–0.5°C after ovulation due to progesterone thermogenic effect
AnovulationInsufficient gonadotropins → failure to ovulate; treatable with clomiphene citrate or exogenous gonadotropins (risk: multiple pregnancy, 10× above baseline)
Oral contraceptivesEstrogen + progesterone suppress GnRH, FSH, and LH → prevent dominant follicle development and LH surge

PART 2: FERTILISATION

2.1 Site and Timing

  • Fertilisation normally occurs in the ampulla of the uterine tube (widest part, closest to the ovary)
  • Window: oocyte viable 12–24 hours post-ovulation; sperm viable in female tract up to 5–7 days
  • Of ~200–300 million spermatozoa deposited in the vagina, only 300–500 reach the site of fertilisation; only one fertilises the oocyte

2.2 Sperm Transport

  1. Only ~1% of deposited sperm enter the cervix
  2. Transport from cervix to uterine tube via uterine smooth muscle contractions (not primarily sperm motility); can take 30 minutes to 6 days
  3. Sperm reach the isthmus → become less motile and pause
  4. At ovulation, cumulus cell chemoattractants stimulate sperm to resume active motility toward the ampulla

2.3 Capacitation

Before fertilisation, sperm must undergo capacitation — a period of conditioning in the female reproductive tract lasting ~7 hours in humans.
What happens during capacitation:
  • Removal of a glycoprotein coat and seminal plasma proteins from the membrane overlying the acrosomal region
  • Membrane becomes destabilized → primes sperm for acrosome reaction
  • Only capacitated sperm can penetrate the corona radiata and undergo the acrosome reaction

2.4 Acrosome Reaction

Triggered when capacitated sperm bind to the zona pellucida (ZP3 glycoprotein in particular):
  • Outer acrosomal membrane fuses with the overlying plasma membrane → releases acrosomal enzymes
  • Key enzymes released: hyaluronidase, acrosin (proteolytic), esterase, neuraminidase
  • These digest a path through the zona pellucida

2.5 Three Phases of Fertilisation

Stages of fertilisation — secondary oocyte to zygote
A: Secondary oocyte surrounded by sperm. B: Sperm enters oocyte; second meiotic division completes → female pronucleus forms; second polar body extruded. C: Male and female pronuclei. D: Pronuclear membranes break down; chromosomes align. E: Zygote with cleavage spindle. — The Developing Human, Clinically Oriented Embryology

Phase 1 — Penetration of the Corona Radiata

  • Capacitated sperm pass freely through the corona cells
  • Hyaluronidase (from acrosome) + tubal enzymes disperse follicular cells
  • Sperm tail movements aid mechanical penetration

Phase 2 — Penetration of the Zona Pellucida

  • Acrosin (serine protease) and other enzymes lyse the zona, forming a pathway
  • Once one sperm penetrates, the zona reaction occurs immediately:
    • Cortical granules beneath the oocyte membrane release lysosomal enzymes into the perivitelline space
    • These enzymes modify the zona pellucida, making it impermeable to further sperm
    • This is the primary block to polyspermy

Phase 3 — Fusion of Plasma Membranes

  • Sperm plasma membrane (posterior head region — acrosomal head cap membrane is shed) fuses with oocyte membrane
  • The sperm head and tail enter oocyte cytoplasm; sperm plasma membrane remains on oocyte surface
  • Oocyte responds with:
    1. Cortical/zona reaction (as above)
    2. Resumption of meiosis II → second polar body extruded → female pronucleus formed (22+X)
    3. Metabolic activation of the egg → initiates early embryogenesis

2.6 Pronuclei and Syngamy

  • Sperm nucleus decondenses → swells → male pronucleus (22+X or 22+Y); tail detaches and degenerates
  • Male and female pronuclei migrate toward each other; both haploid, each must replicate their DNA
  • Nuclear envelopes break down; chromosomes align on the first mitotic spindle
  • Chromosomes split at centromere; sister chromatids move to opposite poles
  • Deep cleavage furrow divides cytoplasm → 2-cell zygote (diploid, 46 chromosomes)
  • The entire fertilisation process takes approximately 24 hours

2.7 Results of Fertilisation (Summary)

ResultSignificance
Restores diploid number (46 chromosomes)New genetic combination from both parents
Determines chromosomal sexX sperm → 46,XX (female); Y sperm → 46,XY (male)
Completes meiosis II of oocyteProduces mature ovum + second polar body
Initiates cleavage of zygoteBegins embryonic development
Establishes genetic variabilityMingling of maternal + paternal chromosomes

2.8 Sex Preselection

  • X-bearing sperm carry 2.8% more DNA than Y-bearing sperm
  • Techniques to separate X/Y sperm exploit: differential swimming speed, electrophoretic migration, DNA content differences (flow cytometry)
  • Selected sperm can be used in IVF to achieve sex selection

PART 3: IMPLANTATION

3.1 Pre-implantation Development (Zygote to Blastocyst)

Between fertilisation (~Day 0) and implantation (~Days 6–10), the embryo undergoes:
DayStageLocation
Day 0–1ZygoteAmpulla
Day 2–32–16 cell stage (cleavage/morula)Tube → uterus
Day 4Compacted morula (16+ cells)Uterine cavity
Day 4–5Blastocyst — cavitationUterine cavity
Day 5–6Hatching blastocyst (zona shed)Uterine cavity
Day 6–10Implantation beginsPosterior wall of uterine body
Blastocyst structure:
  • Trophoblast (TE) — outer single-cell layer; will form placenta and membranes
    • Polar trophectoderm — overlies inner cell mass; initiates implantation
    • Mural trophectoderm — remainder of outer shell
  • Inner cell mass (ICM/embryoblast) — gives rise to the embryo proper
  • Blastocoel — fluid-filled cavity
The zona pellucida must "hatch" before the blastocyst can attach to the endometrium.

3.2 Endometrial Receptivity — The "Window of Implantation"

The uterus is receptive for only a narrow window (~Days 20–24 of a 28-day cycle), created by estrogen and progesterone priming:
Key molecular mediators of endometrial receptivity:
FactorLocationRole
HB-EGF (heparin-binding EGF)Endometrial epithelium/pinopodiaCritical attachment signal; binds ErbB1/ErbB4 on polar TE
LIF (leukemia inhibitory factor)Luminal epitheliumSignals to blastocyst and endometrium for receptivity
IHH (Indian hedgehog)EpitheliumParacrine epithelial-stromal crosstalk
HOXA10/HOXA11StromaCrucial for decidualization
HAND2StromaDecidualization; suppresses epithelial differentiation
BMP2StromaRequired for decidualization and embryo spacing
WNT signalingEndometrial epitheliumBlastocyst attachment
MSX1EpitheliumActivates BMP2; inhibits WNTs; expressed during window
Pinopodia — finger-like projections on endometrial surface that appear only during the window of implantation; express HB-EGF and mediate initial contact.
Both estradiol (E2) and progesterone (P4) are necessary for HB-EGF expression and endometrial receptivity.

3.3 Stages of Implantation

Implantation proceeds through three overlapping stages:

Stage 1 — Apposition

  • Loose, initial contact between polar trophectoderm and luminal endometrial epithelium (typically posterior uterine wall)
  • Reversible at this stage

Stage 2 — Adhesion

  • Firm adhesion mediated by:
    • HB-EGF (endometrium) binding ErbB1/ErbB4 (on polar TE microvilli/podosomes)
    • Integrins on TE surface interacting with endometrial extracellular matrix (fibronectin, laminin)
    • LIF, blastocyst-to-endometrium signals
  • Trophoblast microvilli interdigitate with endometrial surface

Stage 3 — Invasion (Penetration)

  • Polar TE cells break through the endometrial epithelial barrier
  • Form a cytotrophoblast shell around the embryo
  • Cytotrophoblast cells fuse → primitive syncytiotrophoblast (invasive + secretory)
  • By Day 10–11: embryo is completely embedded in the endometrial stroma

3.4 Trophoblast Differentiation

Once the cytotrophoblast (CTB) shell forms, cells differentiate along two lineages:
CTB progenitor cell
      │
      ├──→ SYNCYTIOTROPHOBLAST (STB)
      │    • Multi-nucleated
      │    • Covers placenta
      │    • Transport + endocrine functions
      │    • Produces hCG, hPL, estrogens, progesterone
      │
      └──→ EXTRAVILLOUS CYTOTROPHOBLAST (EVT)
           │
           ├──→ Interstitial EVT (iEVT)
           │    • Invades endometrial stroma
           │    • Penetrates superficial 1/3 myometrium
           │
           └──→ Endovascular EVT (eEVT)
                • Invades maternal arterioles
                • Replaces arterial endothelium
                • Vascular remodeling → low-resistance, high-capacitance flow
EVT differentiation is driven by:
  • Physiologic hypoxia (<30 mmHg) → HIF stabilization
  • ASCL2 (helix-loop-helix factor) → promotes EVT, inhibits STB
  • Canonical WNT/β-catenin (TCF4) signaling
  • Integrin switch: loss of α6/β4 → gain of α5/α1 (fibronectin receptors)
  • MMPs (MMP-9) and plasminogen activators enable stromal invasion

3.5 Decidualization

The endometrial stroma transforms into the decidua in response to progesterone:
  • Stromal cells enlarge, become glycogen-rich, rounded
  • This transformation is regulated by HOXA10, HOXA11, HAND2, BMP2
  • The decidua provides nutritional support for the early embryo and modulates immune tolerance

3.6 hCG and Rescue of the Corpus Luteum

  • The syncytiotrophoblast begins secreting human chorionic gonadotropin (hCG) at implantation (~Day 6–8)
  • hCG peaks at ~10 weeks gestation, then falls
  • hCG acts like LH → maintains the corpus luteum of pregnancy → continuous progesterone/estrogen production prevents menstruation
  • The corpus luteum is essential for the first ~20 weeks until the placenta assumes steroidogenesis
  • hCG is the basis of all pregnancy tests

3.7 Normal Implantation Site

  • Normally occurs on the posterior wall of the uterine body (endometrium)
  • The most common site is the upper posterior uterine wall

3.8 Clinical Correlates of Implantation

ConditionMechanism
Ectopic pregnancyImplantation outside the uterine cavity (most often in the fallopian tube); risk factors: PID, tubal scarring, previous ectopic
Placenta previaImplantation over or near internal cervical os; BMP2 may play a role in embryo spacing defects
Failed implantation / recurrent miscarriageDefects in HB-EGF signaling, LIF, decidualization, EVT invasion
PreeclampsiaDefective eEVT vascular remodeling → high-resistance uteroplacental circulation; associated with HB-EGF pathway defects
IVF (In Vitro Fertilisation)Oocytes retrieved from stimulated follicles, fertilised with capacitated sperm in a Petri dish; embryos (4–8 cell or blastocyst stage) transferred to uterus; excess embryos cryopreserved

INTEGRATED TIMELINE: From Ovulation to Implantation

Day (relative to ovulation)Event
Day −2 to −1LH surge (6–10× rise)
Day 0Ovulation — secondary oocyte expelled; corpus luteum forms
Day 0Sperm undergo capacitation (7 hrs); fertilisation in ampulla
Day 0–1Fertilisation complete; zygote formed (2-cell by Day 1–2)
Day 2–4Cleavage divisions; morula enters uterine cavity
Day 4–5Blastocyst cavitation; zona hatching
Day 6–7Implantation begins — polar trophectoderm adheres to endometrium
Day 8–9Trophoblast invasion; syncytiotrophoblast forms; hCG secretion begins
Day 10–12Embryo fully embedded in endometrium
Day 28+hCG detectable in maternal blood/urine (basis of pregnancy test)

KEY HORMONES SUMMARY TABLE

HormoneSourceRole in Ovulation/Fertilisation/Implantation
GnRHHypothalamusPulsatile release → drives FSH/LH secretion
FSHAnterior pituitaryFollicular development; estrogen production by granulosa cells
LHAnterior pituitaryTriggers ovulation (surge); corpus luteum maintenance
Estrogen (E2)Granulosa cells / corpus luteum / syncytiotrophoblastFollicular growth; LH surge (positive feedback); endometrial proliferation; HB-EGF expression
Progesterone (P4)Corpus luteum / syncytiotrophoblastSecretory endometrium; inhibits new follicle development; thermogenic effect (BBT); decidualization
hCGSyncytiotrophoblastRescues corpus luteum; the basis of pregnancy tests
InhibinGranulosa cellsSuppresses FSH; dominant follicle selection
ProstaglandinsFollicular cellsFollicular wall contraction; facilitate oocyte expulsion

Sources: The Developing Human: Clinically Oriented Embryology (Moore et al.); Langman's Medical Embryology; Guyton & Hall Textbook of Medical Physiology; Creasy & Resnik's Maternal-Fetal Medicine; Berek & Novak's Gynecology.

Topic summary for each in pptx

Reading File
Reading File
Reading File
Running Command

ls /home/daytona/workspace/ 2>/dev/null || echo "workspace empty or missing"

Running Command

mkdir -p /home/daytona/workspace/reproductive-health-pptx

Writing File

~/reproductive-health-pptx/build.js

const pptxgen = require("pptxgenjs");
const { execSync } = require("child_process");

// ── Colour palette ──────────────────────────────────────────────
// Deep navy dominant + warm coral accent + soft lavender highlight
const C = {
  navy:     "0D1B2A",   // dominant background
  navyMid:  "1A2E45",   // card / panel background
  navyLight:"223354",   // lighter panel
  coral:    "E8503A",   // accent / heading bar
  corallg:  "F07A67",   // lighter coral for sub-headings
  gold:     "F5A623",   // data / highlight
  white:    "FFFFFF",
  off:      "D6E4F0",   // body text on dark bg
  slate:    "8BA7C4",   // muted text
  teal:     "2ABFBF",   // secondary accent (tables, icons)
};

// ── Image fetch helper ──────────────────────────────────────────
function fetchImages(urls) {
  const json = execSync(
    `node /home/daytona/skills/shared/scripts/fetch_images.js ${urls.map(u => `"${u}"`).join(" ")}`
  ).toString();
  return JSON.parse(json);
}

// Pre-fetch the three key diagrams used in the notes
const IMG_URLS = [
  "https://cdn.orris.care/cdss_images/9e9e325242f7f80ca26e1eb4bdfc1997008f88c8586a392e1d62c76ce021c264.png",  // hormonal cycle
  "https://cdn.orris.care/cdss_images/ea19901fe49dafcdfc83f44c2a624d54255962bafb5a3f6bf3b95f4c3410ae38.png",  // ovulation mechanism
  "https://cdn.orris.care/cdss_images/61f47b0929f1842175c20af1b4fd581ee6efb443b874f2f934f4d9fc23583ee4.png",  // fertilisation stages
];
console.log("Fetching images...");
const imgs = fetchImages(IMG_URLS);
const [imgCycle, imgOvMech, imgFert] = imgs;
console.log("Images fetched:", imgs.map(i => i.error || "OK"));

// ── Presentation setup ──────────────────────────────────────────
const pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.title = "Ovulation, Fertilisation & Implantation";
pres.author = "Reproductive Health Notes";

// ── Reusable helpers ────────────────────────────────────────────
function addSlideBg(slide) {
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.navy }, line: { color: C.navy }
  });
}

function addHeaderBar(slide, label) {
  // coral left accent stripe
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0, y: 0, w: 0.22, h: 5.625, fill: { color: C.coral }, line: { color: C.coral }
  });
  // topic label top-right pill
  slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
    x: 7.8, y: 0.18, w: 2.0, h: 0.36, fill: { color: C.coral }, line: { color: C.coral }, rectRadius: 0.05
  });
  slide.addText(label, {
    x: 7.8, y: 0.18, w: 2.0, h: 0.36, fontSize: 9, color: C.white, bold: true, align: "center", valign: "middle", margin: 0
  });
}

function sectionTitle(slide, title, subtitle) {
  slide.addText(title, {
    x: 0.5, y: 0.22, w: 7.1, h: 0.55, fontSize: 22, bold: true, color: C.white, align: "left", valign: "middle"
  });
  if (subtitle) {
    slide.addText(subtitle, {
      x: 0.5, y: 0.82, w: 7.1, h: 0.3, fontSize: 11, color: C.slate, align: "left", italic: true
    });
  }
}

function addDivider(slide, y) {
  slide.addShape(pres.shapes.RECTANGLE, {
    x: 0.5, y, w: 9.0, h: 0.025, fill: { color: C.corallg }, line: { color: C.corallg }
  });
}

function card(slide, x, y, w, h, color) {
  slide.addShape(pres.shapes.RECTANGLE, {
    x, y, w, h,
    fill: { color: color || C.navyMid },
    line: { color: C.navyLight, pt: 1 },
    shadow: { type: "outer", color: "000000", blur: 6, offset: 2, angle: 135, opacity: 0.2 }
  });
}

function bullets(slide, items, x, y, w, h, opts) {
  const o = opts || {};
  slide.addText(
    items.map((t, i) => ({ text: t, options: { bullet: { code: "25B8", color: o.bulletColor || C.teal }, breakLine: i < items.length - 1 } })),
    { x, y, w, h, fontSize: o.fontSize || 11.5, color: o.color || C.off, lineSpacingMultiple: 1.25 }
  );
}

// ════════════════════════════════════════════════════════════════
// SLIDE 1 — Cover
// ════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  addSlideBg(s);

  // large coral accent block left
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 0.55, h: 5.625, fill: { color: C.coral }, line: { color: C.coral } });

  // decorative circle top-right
  s.addShape(pres.shapes.OVAL, { x: 7.8, y: -1.2, w: 3.5, h: 3.5, fill: { color: C.navyMid }, line: { color: C.navyLight, pt: 2 } });
  s.addShape(pres.shapes.OVAL, { x: 8.2, y: -0.8, w: 2.7, h: 2.7, fill: { color: C.navyLight }, line: { color: C.coral, pt: 1 } });

  s.addText("REPRODUCTIVE HEALTH", {
    x: 0.75, y: 1.15, w: 8.5, h: 0.5, fontSize: 13, bold: true, color: C.teal,
    charSpacing: 4, align: "left"
  });
  s.addText("Ovulation,\nFertilisation &\nImplantation", {
    x: 0.75, y: 1.65, w: 8.5, h: 2.1, fontSize: 36, bold: true, color: C.white, align: "left", lineSpacingMultiple: 1.1
  });
  s.addShape(pres.shapes.RECTANGLE, { x: 0.75, y: 3.8, w: 2.2, h: 0.06, fill: { color: C.coral }, line: { color: C.coral } });
  s.addText("Comprehensive Topic Summary  •  Three Modules", {
    x: 0.75, y: 3.95, w: 8.5, h: 0.35, fontSize: 11, color: C.slate, align: "left"
  });

  // module tags bottom
  const tags = ["MODULE 1 — OVULATION", "MODULE 2 — FERTILISATION", "MODULE 3 — IMPLANTATION"];
  tags.forEach((tag, i) => {
    s.addShape(pres.shapes.ROUNDED_RECTANGLE, { x: 0.75 + i * 3.05, y: 4.9, w: 2.85, h: 0.45, fill: { color: C.navyMid }, line: { color: C.teal, pt: 1 }, rectRadius: 0.06 });
    s.addText(tag, { x: 0.75 + i * 3.05, y: 4.9, w: 2.85, h: 0.45, fontSize: 8.5, bold: true, color: C.teal, align: "center", valign: "middle", margin: 0 });
  });
}

// ════════════════════════════════════════════════════════════════
// ── MODULE 1: OVULATION ──────────────────────────────────────
// ════════════════════════════════════════════════════════════════

// SLIDE 2 — Module 1 Section Title
{
  const s = pres.addSlide();
  addSlideBg(s);
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 10, h: 5.625, fill: { color: C.navy }, line: { color: C.navy } });
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 2.3, w: 10, h: 1.05, fill: { color: C.coral }, line: { color: C.coral } });
  s.addText("MODULE 1", { x: 0.6, y: 0.6, w: 8.8, h: 0.5, fontSize: 14, bold: true, color: C.teal, charSpacing: 5 });
  s.addText("OVULATION", { x: 0.6, y: 2.3, w: 8.8, h: 1.05, fontSize: 48, bold: true, color: C.white, align: "left", valign: "middle" });
  s.addText("Hormonal control • Follicular development • Mechanism of rupture • Corpus luteum", {
    x: 0.6, y: 3.55, w: 8.8, h: 0.4, fontSize: 12, color: C.off, italic: true
  });
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 5.3, w: 10, h: 0.325, fill: { color: C.navyMid }, line: { color: C.navyMid } });
  s.addText("The Developing Human  •  Langman's Medical Embryology  •  Guyton & Hall", {
    x: 0, y: 5.3, w: 10, h: 0.325, fontSize: 8, color: C.slate, align: "center", valign: "middle"
  });
}

// SLIDE 3 — HPO Axis & Hormonal Events
{
  const s = pres.addSlide();
  addSlideBg(s);
  addHeaderBar(s, "MODULE 1 — OVULATION");
  sectionTitle(s, "Hormonal Control — The HPO Axis", "Hypothalamic-Pituitary-Ovarian feedback loop drives the menstrual cycle");
  addDivider(s, 1.15);

  // Left: hormonal steps
  card(s, 0.32, 1.25, 4.6, 3.95, C.navyMid);
  s.addText("Key Hormonal Events", { x: 0.45, y: 1.3, w: 4.35, h: 0.38, fontSize: 12, bold: true, color: C.teal });
  bullets(s, [
    "GnRH (hypothalamus) → pulsatile release → drives FSH & LH",
    "FSH stimulates follicular development and estrogen production",
    "Rising estrogen → negative feedback initially suppresses FSH/LH",
    "Pre-ovulatory estrogen peak (≥200 pg/mL for ≥50 hrs) → positive feedback → LH surge",
    "LH rises 6–10× ; peaks ~16 hrs before ovulation",
    "FSH rises 2–3× synergistically with LH",
    "Ovulation occurs 24–36 hrs after LH peak",
    "Post-ovulation: corpus luteum secretes progesterone → prepares endometrium",
  ], 0.45, 1.72, 4.35, 3.3, { fontSize: 10.5 });

  // Right: diagram
  if (!imgCycle.error) {
    s.addImage({ data: imgCycle.base64, x: 5.2, y: 1.22, w: 4.55, h: 4.0 });
  }
  s.addText("Fig: Hormonal fluctuations & endometrial changes — The Developing Human", {
    x: 5.2, y: 5.26, w: 4.55, h: 0.2, fontSize: 6.5, color: C.slate, align: "center", italic: true
  });
}

// SLIDE 4 — Follicular Maturation
{
  const s = pres.addSlide();
  addSlideBg(s);
  addHeaderBar(s, "MODULE 1 — OVULATION");
  sectionTitle(s, "Follicular Maturation to Ovulation", "Sequential stages from primordial follicle to Graafian follicle");
  addDivider(s, 1.15);

  const stages = [
    ["Primordial", "Oocyte arrested in prophase I\nFlat granulosa cells around oocyte"],
    ["Primary", "Cuboidal granulosa cells\nZona pellucida forms"],
    ["Secondary (Antral)", "Fluid-filled antrum develops\nTheca interna & externa appear"],
    ["Mature Graafian", "Grows to ~25 mm\nLH surge → meiosis I completes\nOocyte arrested in metaphase II"],
  ];

  stages.forEach(([title, body], i) => {
    const x = 0.32 + i * 2.38;
    const isLast = i === 3;
    card(s, x, 1.28, 2.2, 3.65, isLast ? C.coral : C.navyMid);
    if (isLast) {
      s.addShape(pres.shapes.RECTANGLE, { x: x + 0.06, y: 1.34, w: 2.08, h: 0.44, fill: { color: "A83020" }, line: { color: "A83020" } });
    }
    s.addText(`${i + 1}. ${title}`, {
      x: x + 0.1, y: 1.34, w: 2.05, h: 0.44, fontSize: 10.5, bold: true,
      color: isLast ? C.white : C.gold, valign: "middle"
    });
    s.addText(body, {
      x: x + 0.1, y: 1.82, w: 2.0, h: 3.0, fontSize: 10, color: isLast ? "FFD9D3" : C.off,
      lineSpacingMultiple: 1.3
    });
  });

  // Arrow connectors between cards
  for (let i = 0; i < 3; i++) {
    const ax = 2.48 + i * 2.38;
    s.addText("▶", { x: ax, y: 2.75, w: 0.3, h: 0.3, fontSize: 12, color: C.teal, align: "center" });
  }

  // LH surge callout bottom
  card(s, 0.32, 5.05, 9.35, 0.46, "1A2E45");
  s.addText("⚡  LH surge triggers: Meiosis I completion  •  Metaphase II arrest  •  Collagenase ↑  •  Prostaglandins ↑  •  Follicle rupture", {
    x: 0.45, y: 5.05, w: 9.1, h: 0.46, fontSize: 10, color: C.gold, bold: true, valign: "middle"
  });
}

// SLIDE 5 — Mechanism of Follicle Rupture
{
  const s = pres.addSlide();
  addSlideBg(s);
  addHeaderBar(s, "MODULE 1 — OVULATION");
  sectionTitle(s, "Mechanism of Follicle Rupture", "LH-driven cascade leading to oocyte expulsion");
  addDivider(s, 1.15);

  // Mechanism diagram (left)
  if (!imgOvMech.error) {
    s.addImage({ data: imgOvMech.base64, x: 0.32, y: 1.22, w: 3.5, h: 4.0 });
  }
  s.addText("Fig: Postulated mechanism of ovulation — Guyton & Hall", {
    x: 0.32, y: 5.26, w: 3.5, h: 0.2, fontSize: 6.5, color: C.slate, align: "center", italic: true
  });

  // Right: Step-by-step
  card(s, 4.1, 1.22, 5.6, 3.95, C.navyMid);
  s.addText("Step-by-Step Sequence", { x: 4.25, y: 1.28, w: 5.3, h: 0.38, fontSize: 12, bold: true, color: C.teal });

  const steps = [
    ["1", "Stigma", "Small avascular spot appears at apex of bulging follicle"],
    ["2", "Enzymatic", "Proteolytic enzymes (collagenase, MMP, plasmin) dissolve follicle capsule"],
    ["3", "Vascular", "Prostaglandins → vasodilation, hyperemia, plasma transudation into follicle"],
    ["4", "Swelling", "Follicle swells; stigma balloons outward then ruptures (~2 min)"],
    ["5", "Expulsion", "Oocyte-cumulus complex expelled: secondary oocyte + corona radiata + zona pellucida"],
    ["6", "Regulators", "MAPK3/1 (ERK1/2) signaling; smooth muscle in theca externa contracts"],
  ];
  steps.forEach(([num, label, desc], i) => {
    const y = 1.7 + i * 0.6;
    s.addShape(pres.shapes.OVAL, { x: 4.2, y: y + 0.04, w: 0.28, h: 0.28, fill: { color: C.coral }, line: { color: C.coral } });
    s.addText(num, { x: 4.2, y: y + 0.04, w: 0.28, h: 0.28, fontSize: 8, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    s.addText(`${label}: `, { x: 4.55, y, w: 1.3, h: 0.36, fontSize: 10, bold: true, color: C.corallg, valign: "top" });
    s.addText(desc, { x: 5.7, y, w: 3.85, h: 0.36, fontSize: 10, color: C.off, valign: "top" });
  });
}

// SLIDE 6 — Corpus Luteum
{
  const s = pres.addSlide();
  addSlideBg(s);
  addHeaderBar(s, "MODULE 1 — OVULATION");
  sectionTitle(s, "Corpus Luteum & Post-Ovulatory Events", "The ruptured follicle transforms; two possible outcomes");
  addDivider(s, 1.15);

  // Formation (left card)
  card(s, 0.32, 1.28, 4.3, 2.6, C.navyMid);
  s.addText("Formation & Function", { x: 0.45, y: 1.33, w: 4.1, h: 0.38, fontSize: 12, bold: true, color: C.teal });
  bullets(s, [
    "Granulosa + theca interna cells luteinize under LH",
    "Cells enlarge 2×, fill with lipid → yellow appearance",
    "Secretes progesterone (primary) and estrogen",
    "Progesterone → secretory endometrium for implantation",
    "Also raises basal body temperature (BBT) by 0.3–0.5°C",
  ], 0.45, 1.75, 4.1, 2.0, { fontSize: 10.5 });

  // Two outcomes (right)
  // No fertilisation
  card(s, 4.82, 1.28, 4.85, 1.2, "1A2E45");
  s.addShape(pres.shapes.RECTANGLE, { x: 4.82, y: 1.28, w: 4.85, h: 0.38, fill: { color: C.navyLight }, line: { color: C.navyLight } });
  s.addText("❌  No Fertilisation", { x: 4.95, y: 1.28, w: 4.6, h: 0.38, fontSize: 11, bold: true, color: C.corallg, valign: "middle" });
  bullets(s, [
    "Corpus luteum involutes after 10–12 days",
    "Called corpus luteum of menstruation",
    "Becomes corpus albicans (white scar)",
    "Progesterone/estrogen fall → menstruation",
  ], 4.95, 1.7, 4.6, 0.8, { fontSize: 10 });

  // Fertilisation outcome
  card(s, 4.82, 2.6, 4.85, 1.28, "1A2E45");
  s.addShape(pres.shapes.RECTANGLE, { x: 4.82, y: 2.6, w: 4.85, h: 0.38, fill: { color: C.navyLight }, line: { color: C.navyLight } });
  s.addText("✅  Fertilisation Occurs", { x: 4.95, y: 2.6, w: 4.6, h: 0.38, fontSize: 11, bold: true, color: C.teal, valign: "middle" });
  bullets(s, [
    "hCG (from syncytiotrophoblast) rescues corpus luteum",
    "Corpus luteum of pregnancy; hCG peaks at ~10 wks",
    "Maintains progesterone/estrogen for first 20 weeks",
    "Placenta takes over steroidogenesis thereafter",
  ], 4.95, 3.02, 4.6, 0.8, { fontSize: 10 });

  // Clinical bottom
  card(s, 0.32, 4.0, 9.35, 1.2, "1A2E45");
  s.addText("Clinical Notes", { x: 0.45, y: 4.05, w: 9.1, h: 0.35, fontSize: 10.5, bold: true, color: C.gold });
  bullets(s, [
    "Mittelschmerz — mid-cycle pain from peritoneal irritation by follicular fluid",
    "Anovulation — inadequate gonadotropins; treated with clomiphene citrate (risk: multiple gestation ×10)",
    "OCP — E+P suppress GnRH/FSH/LH → no dominant follicle → no ovulation",
  ], 0.45, 4.42, 9.1, 0.75, { fontSize: 10 });
}

// ════════════════════════════════════════════════════════════════
// ── MODULE 2: FERTILISATION ──────────────────────────────────
// ════════════════════════════════════════════════════════════════

// SLIDE 7 — Module 2 Section Title
{
  const s = pres.addSlide();
  addSlideBg(s);
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 2.3, w: 10, h: 1.05, fill: { color: C.teal }, line: { color: C.teal } });
  s.addText("MODULE 2", { x: 0.6, y: 0.6, w: 8.8, h: 0.5, fontSize: 14, bold: true, color: C.teal, charSpacing: 5 });
  s.addText("FERTILISATION", { x: 0.6, y: 2.3, w: 8.8, h: 1.05, fontSize: 42, bold: true, color: C.white, align: "left", valign: "middle" });
  s.addText("Sperm transport • Capacitation • Acrosome reaction • Three phases • Zygote formation", {
    x: 0.6, y: 3.55, w: 8.8, h: 0.4, fontSize: 12, color: C.off, italic: true
  });
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 5.3, w: 10, h: 0.325, fill: { color: C.navyMid }, line: { color: C.navyMid } });
  s.addText("Langman's Medical Embryology  •  The Developing Human  •  Ganong's Review of Medical Physiology", {
    x: 0, y: 5.3, w: 10, h: 0.325, fontSize: 8, color: C.slate, align: "center", valign: "middle"
  });
}

// SLIDE 8 — Sperm Transport & Capacitation
{
  const s = pres.addSlide();
  addSlideBg(s);
  addHeaderBar(s, "MODULE 2 — FERTILISATION");
  sectionTitle(s, "Sperm Transport & Capacitation", "From ejaculation to the site of fertilisation in the ampulla");
  addDivider(s, 1.15);

  // Transport card
  card(s, 0.32, 1.28, 4.5, 2.5, C.navyMid);
  s.addText("Sperm Transport", { x: 0.45, y: 1.33, w: 4.25, h: 0.38, fontSize: 12, bold: true, color: C.teal });
  bullets(s, [
    "~200–300 million sperm deposited; only 300–500 reach ampulla",
    "~1% of sperm enter the cervix; survive many hours there",
    "Transport via uterine smooth muscle contractions (not sperm motility)",
    "Journey: cervix → isthmus: 30 min to 6 days",
    "At isthmus: sperm pause, become less motile",
    "At ovulation: cumulus cell chemoattractants re-activate sperm",
    "Oocyte viable for 12–24 hrs; sperm viable for up to 5–7 days",
  ], 0.45, 1.75, 4.25, 1.9, { fontSize: 10.5 });

  // Capacitation card
  card(s, 5.0, 1.28, 4.65, 2.5, C.navyMid);
  s.addText("Capacitation (~7 hours)", { x: 5.12, y: 1.33, w: 4.4, h: 0.38, fontSize: 12, bold: true, color: C.gold });
  bullets(s, [
    "Conditioning in the female reproductive tract (uterine tube epithelium)",
    "Glycoprotein coat + seminal plasma proteins removed from acrosomal plasma membrane",
    "Membrane destabilized → primed for acrosome reaction",
    "Only capacitated sperm can penetrate corona radiata",
    "Speeding to the ampulla confers NO advantage — capacitation must complete first",
  ], 5.12, 1.75, 4.4, 1.9, { fontSize: 10.5 });

  // Acrosome reaction
  card(s, 0.32, 3.9, 9.35, 1.38, C.navyMid);
  s.addText("Acrosome Reaction", { x: 0.45, y: 3.95, w: 9.1, h: 0.38, fontSize: 12, bold: true, color: C.corallg });
  s.addText("Triggered when capacitated sperm bind to ZP3 (zona pellucida glycoprotein). Outer acrosomal membrane fuses with plasma membrane → releases acrosomal enzymes: hyaluronidase (corona dispersal), acrosin (serine protease — zona lysis), esterase, neuraminidase. These digest a path through the zona pellucida.", {
    x: 0.45, y: 4.35, w: 9.1, h: 0.85, fontSize: 10.5, color: C.off, lineSpacingMultiple: 1.25
  });
}

// SLIDE 9 — Three Phases of Fertilisation
{
  const s = pres.addSlide();
  addSlideBg(s);
  addHeaderBar(s, "MODULE 2 — FERTILISATION");
  sectionTitle(s, "Three Phases of Fertilisation", "Sequential events from corona penetration to zygote formation");
  addDivider(s, 1.15);

  // Diagram left
  if (!imgFert.error) {
    s.addImage({ data: imgFert.base64, x: 0.32, y: 1.22, w: 3.35, h: 4.05 });
  }
  s.addText("Fig: A–E Fertilisation stages — The Developing Human", {
    x: 0.32, y: 5.3, w: 3.35, h: 0.2, fontSize: 6.5, color: C.slate, align: "center", italic: true
  });

  // Phase cards right
  const phases = [
    {
      num: "Phase 1", label: "Penetration of Corona Radiata",
      color: C.navyMid, accent: C.coral,
      points: ["Capacitated sperm pass freely through corona cells", "Hyaluronidase + tubal enzymes disperse follicular cells", "Sperm tail movements aid mechanical penetration"],
    },
    {
      num: "Phase 2", label: "Penetration of Zona Pellucida",
      color: C.navyMid, accent: C.gold,
      points: ["Acrosin + enzymes lyse zona, form a pathway", "Zona reaction: cortical granules release lysosomal enzymes", "Zona becomes impermeable → blocks polyspermy (primary block)"],
    },
    {
      num: "Phase 3", label: "Fusion of Plasma Membranes",
      color: C.navyMid, accent: C.teal,
      points: ["Posterior sperm head membrane fuses with oocyte membrane", "Sperm head + tail enter cytoplasm; sperm membrane stays on surface", "Oocyte responds: ① cortical/zona reaction ② meiosis II resumes → 2nd polar body + female pronucleus ③ metabolic activation"],
    },
  ];
  phases.forEach((p, i) => {
    const y = 1.22 + i * 1.35;
    card(s, 3.87, y, 5.78, 1.22, p.color);
    s.addShape(pres.shapes.RECTANGLE, { x: 3.87, y, w: 5.78, h: 0.38, fill: { color: C.navyLight }, line: { color: C.navyLight } });
    s.addText(`${p.num}: ${p.label}`, { x: 4.0, y, w: 5.5, h: 0.38, fontSize: 10.5, bold: true, color: p.accent, valign: "middle" });
    bullets(s, p.points, 4.0, y + 0.4, 5.5, 0.8, { fontSize: 9.5 });
  });
}

// SLIDE 10 — Pronuclei & Results of Fertilisation
{
  const s = pres.addSlide();
  addSlideBg(s);
  addHeaderBar(s, "MODULE 2 — FERTILISATION");
  sectionTitle(s, "Pronuclei, Syngamy & Results", "Formation of the zygote and significance of fertilisation");
  addDivider(s, 1.15);

  // Left: pronuclei steps
  card(s, 0.32, 1.28, 4.6, 2.95, C.navyMid);
  s.addText("Pronuclear Development → Zygote", { x: 0.45, y: 1.33, w: 4.35, h: 0.38, fontSize: 11.5, bold: true, color: C.teal });
  bullets(s, [
    "Sperm nucleus decondenses → male pronucleus (22+X or 22+Y)",
    "Oocyte completes meiosis II → female pronucleus (22+X) + 2nd polar body",
    "Both pronuclei are haploid; each replicates DNA independently",
    "Nuclear envelopes break down (syngamy)",
    "Chromosomes align on first mitotic spindle",
    "Centromeres split; sister chromatids move to opposite poles",
    "Deep cleavage furrow → 2-cell zygote (46 chromosomes, diploid)",
    "Total fertilisation duration: ~24 hours",
  ], 0.45, 1.74, 4.35, 2.4, { fontSize: 10 });

  // Right: results table
  card(s, 5.1, 1.28, 4.55, 2.95, C.navyMid);
  s.addText("Key Results of Fertilisation", { x: 5.22, y: 1.33, w: 4.3, h: 0.38, fontSize: 11.5, bold: true, color: C.gold });
  const results = [
    ["Diploid restoration", "46 chromosomes; new maternal-paternal combination"],
    ["Sex determination", "X sperm → 46,XX (♀); Y sperm → 46,XY (♂)"],
    ["Meiosis II completion", "Mature ovum + second polar body formed"],
    ["Cleavage initiation", "Metabolic activation → embryonic development begins"],
    ["Genetic variability", "Novel combination of parental chromosomes"],
  ];
  results.forEach(([key, val], i) => {
    const y = 1.75 + i * 0.48;
    s.addText(`${key}:`, { x: 5.22, y, w: 1.85, h: 0.38, fontSize: 9.5, bold: true, color: C.corallg, valign: "middle" });
    s.addText(val, { x: 7.1, y, w: 2.4, h: 0.38, fontSize: 9.5, color: C.off, valign: "middle" });
    if (i < results.length - 1)
      s.addShape(pres.shapes.RECTANGLE, { x: 5.22, y: y + 0.38, w: 4.3, h: 0.01, fill: { color: C.navyLight }, line: { color: C.navyLight } });
  });

  // Polyspermy block summary
  card(s, 0.32, 4.35, 9.35, 0.95, "1A2E45");
  s.addText("Prevention of Polyspermy", { x: 0.45, y: 4.4, w: 9.1, h: 0.32, fontSize: 10.5, bold: true, color: C.corallg });
  s.addText("Primary block: Zona reaction (cortical granule release → zona modification → impermeable to further sperm).  Secondary: Cortical reaction modifies oocyte plasma membrane.", {
    x: 0.45, y: 4.74, w: 9.1, h: 0.5, fontSize: 10, color: C.off
  });
}

// ════════════════════════════════════════════════════════════════
// ── MODULE 3: IMPLANTATION ───────────────────────────────────
// ════════════════════════════════════════════════════════════════

// SLIDE 11 — Module 3 Section Title
{
  const s = pres.addSlide();
  addSlideBg(s);
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 2.3, w: 10, h: 1.05, fill: { color: C.gold }, line: { color: C.gold } });
  s.addText("MODULE 3", { x: 0.6, y: 0.6, w: 8.8, h: 0.5, fontSize: 14, bold: true, color: C.gold, charSpacing: 5 });
  s.addText("IMPLANTATION", { x: 0.6, y: 2.3, w: 8.8, h: 1.05, fontSize: 40, bold: true, color: C.navy, align: "left", valign: "middle" });
  s.addText("Blastocyst development • Endometrial receptivity • Stages of implantation • Trophoblast differentiation", {
    x: 0.6, y: 3.55, w: 8.8, h: 0.4, fontSize: 12, color: C.off, italic: true
  });
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 5.3, w: 10, h: 0.325, fill: { color: C.navyMid }, line: { color: C.navyMid } });
  s.addText("Creasy & Resnik's Maternal-Fetal Medicine  •  The Developing Human  •  Langman's Medical Embryology", {
    x: 0, y: 5.3, w: 10, h: 0.325, fontSize: 8, color: C.slate, align: "center", valign: "middle"
  });
}

// SLIDE 12 — Pre-implantation Development
{
  const s = pres.addSlide();
  addSlideBg(s);
  addHeaderBar(s, "MODULE 3 — IMPLANTATION");
  sectionTitle(s, "Pre-Implantation Development", "Zygote → Blastocyst: cleavage, compaction, and hatching");
  addDivider(s, 1.15);

  const timeline = [
    ["Day 0", "Zygote", "Fertilisation in ampulla; diploid (46 chr)"],
    ["Day 1–2", "2–4 Cell", "First cleavage divisions (cells = blastomeres)"],
    ["Day 3–4", "Morula", "16+ cells; compaction; enters uterine cavity"],
    ["Day 4–5", "Blastocyst", "Cavitation; zona pellucida hatching begins"],
    ["Day 6–7", "Hatched", "Zona shed; polar TE attaches to endometrium"],
  ];
  timeline.forEach(([day, stage, desc], i) => {
    const x = 0.32 + i * 1.88;
    card(s, x, 1.28, 1.76, 3.6, C.navyMid);
    s.addShape(pres.shapes.RECTANGLE, { x, y: 1.28, w: 1.76, h: 0.42, fill: { color: i === 4 ? C.coral : C.navyLight }, line: { color: C.navyLight } });
    s.addText(day, { x, y: 1.28, w: 1.76, h: 0.42, fontSize: 9.5, bold: true, color: i === 4 ? C.white : C.teal, align: "center", valign: "middle", margin: 0 });
    s.addText(stage, { x: x + 0.08, y: 1.74, w: 1.6, h: 0.42, fontSize: 11.5, bold: true, color: i === 4 ? C.gold : C.corallg, align: "center" });
    s.addText(desc, { x: x + 0.08, y: 2.2, w: 1.6, h: 2.5, fontSize: 9.5, color: C.off, align: "center", lineSpacingMultiple: 1.3 });
    if (i < timeline.length - 1)
      s.addText("▶", { x: x + 1.76, y: 2.8, w: 0.12, h: 0.3, fontSize: 10, color: C.teal, align: "center" });
  });

  // Blastocyst structure
  card(s, 0.32, 4.98, 9.35, 0.5, C.navyMid);
  s.addText("Blastocyst Structure:  ", { x: 0.45, y: 4.98, w: 2.0, h: 0.5, fontSize: 10.5, bold: true, color: C.teal, valign: "middle" });
  s.addText("Trophectoderm (TE) — outer layer → placenta/membranes  |  Inner Cell Mass (ICM) — embryo proper  |  Blastocoel — fluid cavity  |  Polar TE — over ICM → initiates implantation", {
    x: 2.3, y: 4.98, w: 7.2, h: 0.5, fontSize: 10, color: C.off, valign: "middle"
  });
}

// SLIDE 13 — Endometrial Receptivity
{
  const s = pres.addSlide();
  addSlideBg(s);
  addHeaderBar(s, "MODULE 3 — IMPLANTATION");
  sectionTitle(s, "Endometrial Receptivity — Window of Implantation", "Days 20–24 of a 28-day cycle; estrogen + progesterone priming required");
  addDivider(s, 1.15);

  // Left: key molecular mediators
  card(s, 0.32, 1.28, 5.0, 3.95, C.navyMid);
  s.addText("Key Molecular Mediators", { x: 0.45, y: 1.33, w: 4.75, h: 0.38, fontSize: 12, bold: true, color: C.teal });

  const meds = [
    ["HB-EGF", "Endometrial epithelium/pinopodia", "Critical attachment signal; binds ErbB1/ErbB4 on polar TE"],
    ["LIF", "Luminal epithelium", "Signals blastocyst and endometrium for receptivity"],
    ["IHH", "Epithelium", "Paracrine epithelial-stromal interaction"],
    ["HOXA10/11", "Stroma", "Crucial for decidualization"],
    ["HAND2", "Stroma", "Decidualization; suppresses epithelial differentiation"],
    ["BMP2", "Stroma", "Required for decidualization; embryo spacing"],
    ["WNT", "Endometrial epithelium", "Blastocyst attachment signaling"],
  ];
  meds.forEach(([factor, loc, role], i) => {
    const y = 1.75 + i * 0.49;
    s.addText(factor, { x: 0.45, y, w: 1.1, h: 0.38, fontSize: 9.5, bold: true, color: C.gold, valign: "middle" });
    s.addText(loc, { x: 1.58, y, w: 1.55, h: 0.38, fontSize: 8.5, color: C.slate, valign: "middle", italic: true });
    s.addText(role, { x: 3.16, y, w: 2.0, h: 0.38, fontSize: 8.5, color: C.off, valign: "middle" });
    if (i < meds.length - 1)
      s.addShape(pres.shapes.RECTANGLE, { x: 0.45, y: y + 0.38, w: 4.65, h: 0.01, fill: { color: C.navyLight }, line: { color: C.navyLight } });
  });

  // Right: hormone requirements + pinopodia
  card(s, 5.52, 1.28, 4.12, 1.8, C.navyMid);
  s.addText("Hormonal Requirements", { x: 5.65, y: 1.33, w: 3.85, h: 0.38, fontSize: 11.5, bold: true, color: C.corallg });
  bullets(s, [
    "Both E2 (estradiol) AND P4 (progesterone) are required",
    "E2 + P4 → HB-EGF expression on pinopodia",
    "Pinopodia appear only during implantation window",
    "Progesterone from corpus luteum drives decidualization",
  ], 5.65, 1.74, 3.85, 1.2, { fontSize: 10 });

  card(s, 5.52, 3.18, 4.12, 2.05, C.navyMid);
  s.addText("Pinopodia", { x: 5.65, y: 3.23, w: 3.85, h: 0.38, fontSize: 11.5, bold: true, color: C.gold });
  bullets(s, [
    "Finger-like projections on luminal endometrial surface",
    "Appear exclusively during the window of implantation",
    "Express HB-EGF in both soluble and membrane-bound forms",
    "HB-EGF receptors (ErbB1/ErbB4) on polar TE microvilli mediate first contact",
  ], 5.65, 3.65, 3.85, 1.45, { fontSize: 10 });
}

// SLIDE 14 — Three Stages of Implantation
{
  const s = pres.addSlide();
  addSlideBg(s);
  addHeaderBar(s, "MODULE 3 — IMPLANTATION");
  sectionTitle(s, "Three Stages of Implantation", "Apposition → Adhesion → Invasion; complete by Day 10–12");
  addDivider(s, 1.15);

  const stageData = [
    {
      num: "1", name: "Apposition",
      color: C.navyMid, accent: C.teal,
      points: ["Loose, initial contact of polar TE with luminal endometrium", "Typically on posterior uterine wall", "Reversible at this stage", "Blastocyst orientates ICM toward endometrium"],
    },
    {
      num: "2", name: "Adhesion",
      color: C.navyMid, accent: C.corallg,
      points: ["Firm, irreversible attachment", "HB-EGF (endometrium) binds ErbB1/ErbB4 (polar TE)", "TE integrins bind endometrial fibronectin/laminin", "LIF + blastocyst-to-endometrium cross-signals", "TE microvilli interdigitate with endometrial surface"],
    },
    {
      num: "3", name: "Invasion",
      color: C.navyMid, accent: C.gold,
      points: ["Polar TE cells break through endometrial epithelium", "Cytotrophoblast (CTB) shell forms around embryo", "CTB differentiates → primitive syncytiotrophoblast (STB)", "STB: invasive + secretory (begins hCG secretion)", "Embryo fully embedded by Day 10–12"],
    },
  ];
  stageData.forEach((st, i) => {
    const x = 0.32 + i * 3.18;
    card(s, x, 1.28, 3.0, 3.95, st.color);
    s.addShape(pres.shapes.OVAL, { x: x + 1.12, y: 1.34, w: 0.76, h: 0.76, fill: { color: st.accent }, line: { color: st.accent } });
    s.addText(st.num, { x: x + 1.12, y: 1.34, w: 0.76, h: 0.76, fontSize: 22, bold: true, color: C.navy, align: "center", valign: "middle", margin: 0 });
    s.addText(st.name, { x: x + 0.1, y: 2.2, w: 2.8, h: 0.42, fontSize: 13, bold: true, color: st.accent, align: "center" });
    bullets(s, st.points, x + 0.15, 2.65, 2.7, 2.45, { fontSize: 9.8 });
  });

  // Arrow connectors
  for (let i = 0; i < 2; i++) {
    s.addText("▶", { x: 3.27 + i * 3.18, y: 3.15, w: 0.3, h: 0.35, fontSize: 14, color: C.coral, align: "center" });
  }
}

// SLIDE 15 — Trophoblast Differentiation
{
  const s = pres.addSlide();
  addSlideBg(s);
  addHeaderBar(s, "MODULE 3 — IMPLANTATION");
  sectionTitle(s, "Trophoblast Differentiation & Decidualization", "Post-implantation: two lineages with distinct roles");
  addDivider(s, 1.15);

  // Central node: CTB
  card(s, 3.9, 1.28, 2.2, 0.68, C.coral);
  s.addText("CTB Progenitor Cell", { x: 3.9, y: 1.28, w: 2.2, h: 0.68, fontSize: 11, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });

  // Arrow down-left (STB)
  s.addText("↙", { x: 2.5, y: 1.95, w: 0.5, h: 0.5, fontSize: 20, color: C.teal, align: "center" });
  // Arrow down-right (EVT)
  s.addText("↘", { x: 7.0, y: 1.95, w: 0.5, h: 0.5, fontSize: 20, color: C.gold, align: "center" });

  // STB card
  card(s, 0.32, 2.5, 4.3, 2.7, C.navyMid);
  s.addShape(pres.shapes.RECTANGLE, { x: 0.32, y: 2.5, w: 4.3, h: 0.4, fill: { color: C.teal }, line: { color: C.teal } });
  s.addText("Syncytiotrophoblast (STB)", { x: 0.32, y: 2.5, w: 4.3, h: 0.4, fontSize: 11, bold: true, color: C.navy, align: "center", valign: "middle", margin: 0 });
  bullets(s, [
    "Multi-nucleated; covers the placental surface",
    "Transport and endocrine functions throughout pregnancy",
    "Produces hCG, hPL, estrogens, progesterone",
    "hCG rescues corpus luteum; forms basis of pregnancy test",
    "Placenta takes over steroidogenesis by week 20",
  ], 0.45, 2.95, 4.05, 2.1, { fontSize: 10 });

  // EVT card
  card(s, 5.35, 2.5, 4.32, 2.7, C.navyMid);
  s.addShape(pres.shapes.RECTANGLE, { x: 5.35, y: 2.5, w: 4.32, h: 0.4, fill: { color: C.gold }, line: { color: C.gold } });
  s.addText("Extravillous Cytotrophoblast (EVT)", { x: 5.35, y: 2.5, w: 4.32, h: 0.4, fontSize: 11, bold: true, color: C.navy, align: "center", valign: "middle", margin: 0 });
  bullets(s, [
    "iEVT: invades endometrial stroma + superficial 1/3 myometrium",
    "eEVT: invades arterioles → replaces endothelium → vascular remodeling",
    "Driven by hypoxia (HIF) + ASCL2 + WNT/β-catenin signaling",
    "Integrin switch: α6/β4 → α5/α1 (fibronectin receptors)",
    "MMP-9 and plasminogen activators enable stromal invasion",
  ], 5.48, 2.95, 4.05, 2.1, { fontSize: 10 });

  // Decidualization footer
  card(s, 0.32, 5.3, 9.35, 0.2, "1A2E45");
  s.addText("Decidualization: Stromal cells enlarge under progesterone influence → glycogen-rich decidua (HOXA10/11, HAND2, BMP2). Provides nutrition and immune tolerance for embryo.", {
    x: 0.45, y: 5.2, w: 9.1, h: 0.3, fontSize: 8.5, color: C.slate, valign: "middle"
  });
}

// SLIDE 16 — Clinical Correlates of Implantation
{
  const s = pres.addSlide();
  addSlideBg(s);
  addHeaderBar(s, "MODULE 3 — IMPLANTATION");
  sectionTitle(s, "Clinical Correlates of Implantation", "When implantation goes wrong — and ART solutions");
  addDivider(s, 1.15);

  const conditions = [
    {
      name: "Ectopic Pregnancy",
      color: C.coral,
      points: ["Implantation outside uterine cavity (most often fallopian tube)", "Risk factors: PID, tubal scarring, previous ectopic, IUD", "Life-threatening if tube ruptures → surgical/medical (methotrexate) management"],
    },
    {
      name: "Placenta Previa",
      color: C.gold,
      points: ["Implantation over or near internal cervical os", "Defect in embryo spacing mechanisms (BMP2 pathway)", "Painless antepartum haemorrhage; managed by C-section"],
    },
    {
      name: "Preeclampsia",
      color: C.teal,
      points: ["Defective eEVT vascular remodeling → high-resistance circulation", "Shallow EVT invasion; spiral arteries not adequately remodeled", "Associated with HB-EGF pathway defects; new-onset hypertension + proteinuria"],
    },
    {
      name: "Recurrent Miscarriage",
      color: C.corallg,
      points: ["Defects in HB-EGF/LIF signaling, decidualization, or EVT invasion", "Genetic (aneuploidies), anatomical, immunological or thrombophilic causes", "Investigated from ≥3 consecutive losses"],
    },
    {
      name: "IVF / ART",
      color: C.slate,
      points: ["Stimulated follicles → oocyte retrieval; fertilised in Petri dish", "4–8 cell or blastocyst stage transferred to uterus via catheter", "Excess embryos cryopreserved; multiple pregnancy risk monitored"],
    },
  ];

  conditions.forEach((c, i) => {
    const col = i < 3 ? 0 : 1;
    const row = i < 3 ? i : i - 3;
    const x = col === 0 ? 0.32 : 5.18;
    const y = 1.28 + row * 1.43;
    card(s, x, y, 4.62, 1.3, C.navyMid);
    s.addShape(pres.shapes.RECTANGLE, { x, y, w: 0.22, h: 1.3, fill: { color: c.color }, line: { color: c.color } });
    s.addText(c.name, { x: x + 0.32, y: y + 0.06, w: 4.2, h: 0.34, fontSize: 11, bold: true, color: c.color });
    bullets(s, c.points, x + 0.32, y + 0.42, 4.2, 0.85, { fontSize: 9.2 });
  });
}

// SLIDE 17 — Integrated Timeline
{
  const s = pres.addSlide();
  addSlideBg(s);
  addHeaderBar(s, "INTEGRATED SUMMARY");
  sectionTitle(s, "Integrated Timeline: Ovulation → Implantation", "Key events mapped to days relative to ovulation");
  addDivider(s, 1.15);

  const events = [
    { day: "−2 to −1", event: "LH Surge", desc: "6–10× rise; FSH also rises 2–3×", color: C.coral },
    { day: "Day 0", event: "Ovulation", desc: "Oocyte expelled; corpus luteum forms", color: C.corallg },
    { day: "Day 0–1", event: "Fertilisation", desc: "Capacitation → acrosome reaction → zygote in ampulla", color: C.gold },
    { day: "Day 2–4", event: "Cleavage", desc: "2-cell → morula; enters uterine cavity", color: C.teal },
    { day: "Day 4–5", event: "Blastocyst", desc: "Cavitation; zona hatching", color: C.slate },
    { day: "Day 6–7", event: "Implantation Begins", desc: "Polar TE adheres to endometrium (apposition → adhesion)", color: C.coral },
    { day: "Day 8–9", event: "Invasion", desc: "CTB shell; STB forms; hCG secretion starts", color: C.corallg },
    { day: "Day 10–12", event: "Fully Embedded", desc: "Embryo completely within endometrium", color: C.gold },
    { day: "~Day 28+", event: "Pregnancy Test +ve", desc: "hCG detectable in blood/urine", color: C.teal },
  ];

  // Timeline bar
  s.addShape(pres.shapes.RECTANGLE, { x: 0.5, y: 3.0, w: 9.0, h: 0.08, fill: { color: C.navyLight }, line: { color: C.navyLight } });

  events.forEach((ev, i) => {
    const x = 0.45 + i * 1.02;
    const above = i % 2 === 0;

    // dot on timeline
    s.addShape(pres.shapes.OVAL, { x: x + 0.2, y: 2.96, w: 0.18, h: 0.18, fill: { color: ev.color }, line: { color: ev.color } });

    if (above) {
      // card above timeline
      card(s, x, 1.28, 0.95, 1.6, C.navyMid);
      s.addShape(pres.shapes.RECTANGLE, { x, y: 1.28, w: 0.95, h: 0.28, fill: { color: ev.color }, line: { color: ev.color } });
      s.addText(ev.day, { x, y: 1.28, w: 0.95, h: 0.28, fontSize: 7, bold: true, color: C.navy, align: "center", valign: "middle", margin: 0 });
      s.addText(ev.event, { x: x + 0.05, y: 1.58, w: 0.85, h: 0.38, fontSize: 8.5, bold: true, color: ev.color, align: "center" });
      s.addText(ev.desc, { x: x + 0.04, y: 1.98, w: 0.88, h: 0.7, fontSize: 7, color: C.off, align: "center", lineSpacingMultiple: 1.2 });
      // connector line
      s.addShape(pres.shapes.RECTANGLE, { x: x + 0.45, y: 2.88, w: 0.02, h: 0.1, fill: { color: ev.color }, line: { color: ev.color } });
    } else {
      // card below timeline
      s.addShape(pres.shapes.RECTANGLE, { x: x + 0.45, y: 3.12, w: 0.02, h: 0.1, fill: { color: ev.color }, line: { color: ev.color } });
      card(s, x, 3.22, 0.95, 1.6, C.navyMid);
      s.addShape(pres.shapes.RECTANGLE, { x, y: 3.22, w: 0.95, h: 0.28, fill: { color: ev.color }, line: { color: ev.color } });
      s.addText(ev.day, { x, y: 3.22, w: 0.95, h: 0.28, fontSize: 7, bold: true, color: C.navy, align: "center", valign: "middle", margin: 0 });
      s.addText(ev.event, { x: x + 0.05, y: 3.52, w: 0.85, h: 0.38, fontSize: 8.5, bold: true, color: ev.color, align: "center" });
      s.addText(ev.desc, { x: x + 0.04, y: 3.92, w: 0.88, h: 0.7, fontSize: 7, color: C.off, align: "center", lineSpacingMultiple: 1.2 });
    }
  });
}

// SLIDE 18 — Hormone Summary Table
{
  const s = pres.addSlide();
  addSlideBg(s);
  addHeaderBar(s, "INTEGRATED SUMMARY");
  sectionTitle(s, "Key Hormones — Integrated Summary", "Role of each hormone across ovulation, fertilisation, and implantation");
  addDivider(s, 1.15);

  const rows = [
    ["GnRH", "Hypothalamus", "Pulsatile release drives FSH & LH secretion from anterior pituitary"],
    ["FSH", "Anterior pituitary", "Follicular development; estrogen production from granulosa cells"],
    ["LH", "Anterior pituitary", "Triggers ovulation (surge); corpus luteum maintenance"],
    ["Estradiol (E2)", "Granulosa / corpus luteum / STB", "Follicular growth; positive feedback → LH surge; endometrial proliferation; HB-EGF expression"],
    ["Progesterone (P4)", "Corpus luteum / STB", "Secretory endometrium; inhibits new follicle development; thermogenic (BBT); decidualization"],
    ["hCG", "Syncytiotrophoblast", "Rescues corpus luteum; maintains P4/E2 in early pregnancy; basis of pregnancy tests"],
    ["Inhibin", "Granulosa cells", "Suppresses FSH; dominant follicle selection"],
    ["Prostaglandins", "Follicular cells", "Follicular wall smooth muscle contraction; vasodilation; facilitate oocyte expulsion"],
  ];

  // Header row
  s.addShape(pres.shapes.RECTANGLE, { x: 0.32, y: 1.28, w: 9.35, h: 0.4, fill: { color: C.coral }, line: { color: C.coral } });
  const headers = ["Hormone", "Source", "Role"];
  const colW = [1.7, 2.5, 5.0];
  const colX = [0.42, 2.15, 4.68];
  headers.forEach((h, i) => {
    s.addText(h, { x: colX[i], y: 1.28, w: colW[i], h: 0.4, fontSize: 10.5, bold: true, color: C.white, valign: "middle" });
  });

  rows.forEach((row, ri) => {
    const y = 1.72 + ri * 0.47;
    const bg = ri % 2 === 0 ? C.navyMid : C.navyLight;
    s.addShape(pres.shapes.RECTANGLE, { x: 0.32, y, w: 9.35, h: 0.44, fill: { color: bg }, line: { color: bg } });
    row.forEach((cell, ci) => {
      s.addText(cell, {
        x: colX[ci], y: y + 0.02, w: colW[ci] - 0.1, h: 0.4, fontSize: ci === 0 ? 10 : 9.5,
        color: ci === 0 ? C.gold : C.off, bold: ci === 0, valign: "middle"
      });
    });
  });
}

// SLIDE 19 — Summary & Sources
{
  const s = pres.addSlide();
  addSlideBg(s);
  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 0, w: 0.55, h: 5.625, fill: { color: C.teal }, line: { color: C.teal } });
  s.addShape(pres.shapes.OVAL, { x: 7.5, y: 3.5, w: 3.2, h: 3.2, fill: { color: C.navyMid }, line: { color: C.teal, pt: 1 } });

  s.addText("Key Takeaways", { x: 0.75, y: 0.3, w: 8.5, h: 0.5, fontSize: 22, bold: true, color: C.white });
  addDivider(s, 0.9);

  const takeaways = [
    "OVULATION is triggered by the LH surge (24–36 hrs prior); the secondary oocyte is arrested in metaphase II until fertilisation",
    "CORPUS LUTEUM is maintained by hCG after fertilisation; its progesterone output is critical for the first 20 weeks",
    "FERTILISATION occurs in the ampulla; requires capacitation (~7 hrs) + acrosome reaction; takes ~24 hours; restores diploidy and determines sex",
    "POLYSPERMY is prevented by the zona reaction (primary block) — cortical granules modify the zona pellucida immediately after sperm entry",
    "IMPLANTATION begins Day 6–7; requires a receptive endometrium (Days 20–24); HB-EGF/ErbB signaling mediates initial attachment",
    "TROPHOBLAST differentiates into STB (endocrine/transport) and EVT (iEVT invades stroma; eEVT remodels spiral arteries)",
    "Defective EVT invasion → preeclampsia; ectopic implantation → ectopic pregnancy — both are clinical emergencies",
  ];
  takeaways.forEach((t, i) => {
    const y = 1.0 + i * 0.59;
    s.addShape(pres.shapes.RECTANGLE, { x: 0.75, y: y + 0.1, w: 0.22, h: 0.22, fill: { color: C.teal }, line: { color: C.teal } });
    s.addText(t, { x: 1.05, y, w: 6.7, h: 0.54, fontSize: 10, color: C.off, lineSpacingMultiple: 1.2 });
  });

  s.addShape(pres.shapes.RECTANGLE, { x: 0, y: 5.3, w: 10, h: 0.325, fill: { color: C.navyMid }, line: { color: C.navyMid } });
  s.addText("Sources: The Developing Human (Moore)  •  Langman's Medical Embryology  •  Guyton & Hall Medical Physiology  •  Creasy & Resnik's Maternal-Fetal Medicine  •  Berek & Novak's Gynecology", {
    x: 0, y: 5.3, w: 10, h: 0.325, fontSize: 7.5, color: C.slate, align: "center", valign: "middle"
  });
}

// ── Write file ──────────────────────────────────────────────────
const outPath = "/home/daytona/workspace/reproductive-health-pptx/Ovulation_Fertilisation_Implantation.pptx";
pres.writeFile({ fileName: outPath }).then(() => {
  console.log("✅  Written to:", outPath);
}).catch(err => {
  console.error("Error:", err);
  process.exit(1);
});
Your credits are exhausted. Your daily credits reset tomorrow, or you can purchase a top-up for more.
This is a shared conversation. Sign in to Orris to start your own chat.