// lipid_metabolism.sy -- Fatty acid synthesis, beta-oxidation, cholesterol,
// lipoproteins, and eicosanoids as native Scyla.
//
// Lipid metabolism is the metabolic axis that separates fed from fasted,
// anabolic from catabolic, survival from ketoacidosis. Every pathway
// here is a regulatory target: statins (HMG-CoA reductase), aspirin
// (COX), fibrates (PPAR-alpha), PCSK9 inhibitors (LDLR recycling).
//
// This module encodes the complete enzymology with UniProt accessions,
// regulatory logic, and clinical connections. It is the pharmacological
// backbone of cardiovascular medicine, endocrinology, and oncology.
//
// Sources:
//   Lehninger Principles of Biochemistry, 8th ed, 2021.
//   Stryer Biochemistry, 9th ed, 2019.
//   Wakil SJ. Biochemistry 28:4523-4530, 1989 (fatty acid synthase).
//   Brown MS, Goldstein JL. Science 232:34-47, 1986 (LDLR/cholesterol, Nobel 1985).
//   Vane JR. Nature New Biol 231:232-235, 1971 (aspirin/COX mechanism, Nobel 1982).
//   McGarry JD, Foster DW. Annu Rev Biochem 49:395-420, 1980 (ketogenesis).
//   Horton JD et al. J Clin Invest 109:1125-1131, 2002 (SREBP regulation).
//
// Marjorie McCubbins + Aether, April 2026
// Patent pending: 64/034,536

// ═══════════════════════════════════════════════════════════════════
// SECTION A: FATTY ACID SYNTHESIS (de novo lipogenesis)
// ═══════════════════════════════════════════════════════════════════
// Occurs in cytoplasm. Acetyl-CoA (from citrate shuttle) is carboxylated
// to malonyl-CoA, then elongated 2C at a time by fatty acid synthase.
// Net: 8 Acetyl-CoA + 7 ATP + 14 NADPH -> Palmitate (C16:0) + 8 CoA + 7 ADP + 7 Pi + 14 NADP+ + 6 H2O

struct FASynthStep {
    step_number: Int,
    enzyme_name: String,
    enzyme_accession: String,
    enzyme_gene: String,
    substrate: String,
    product: String,
    cofactor: String,
    reversible: Bool,
    regulatory: Bool,
    regulation_note: String,
    citation: String,
}

fn fas(sn: Int, en: String, ea: String, eg: String, su: String, pr: String, co: String, re: Bool, rg: Bool, rn: String, ci: String) -> FASynthStep {
    return FASynthStep { step_number: sn, enzyme_name: en, enzyme_accession: ea, enzyme_gene: eg, substrate: su, product: pr, cofactor: co, reversible: re, regulatory: rg, regulation_note: rn, citation: ci }
}

// Step zero: citrate shuttle exports acetyl-CoA from mitochondria to cytoplasm
// Steps one through three: ACC commits acetyl-CoA to fatty acid synthesis
// Steps four through ten: FASN elongation cycle (repeated seven times for palmitate)

fn fa_synthesis_step(step: Int) -> FASynthStep {
    if step == 0 { return fas(0, "Citrate synthase (mito) + ATP-citrate lyase (cyto)", "P53396", "ACLY", "Acetyl-CoA (mito) + OAA -> Citrate; Citrate (cyto) + ATP + CoA", "Acetyl-CoA (cyto) + OAA + ADP + Pi", "ATP, CoA", false, false, "Citrate shuttle exports acetyl groups from mitochondria. ACLY is the cytoplasmic enzyme. Inhibited by hydroxycitrate (weight loss supplement).", "Lehninger 8th ed, Ch 21") }

    if step == 1 { return fas(1, "Acetyl-CoA carboxylase (ACC1)", "Q13085", "ACACA", "Acetyl-CoA + CO2 + ATP", "Malonyl-CoA + ADP + Pi", "Biotin (vitamin B7), ATP, Mn2+", false, true, "THE committed step. Activated by insulin (dephosphorylation via PP2A), citrate (allosteric, promotes polymerization). Inhibited by glucagon/epinephrine (phosphorylation via AMPK), palmitoyl-CoA (product feedback). AMPK Ser79 phosphorylation inactivates ACC.", "Lehninger 8th ed, Ch 21; Stryer 9th ed, Ch 22") }

    if step == 2 { return fas(2, "Acetyl-CoA carboxylase (ACC2, mitochondrial)", "O00763", "ACACB", "Acetyl-CoA + CO2 + ATP", "Malonyl-CoA + ADP + Pi", "Biotin (vitamin B7), ATP", false, true, "ACC2 is on outer mitochondrial membrane. Its malonyl-CoA inhibits CPT-I, blocking beta-oxidation. When ACC2 is active (fed state), fat synthesis is on and fat burning is off. Reciprocal regulation.", "McGarry JD, Foster DW. Annu Rev Biochem 49:395-420, 1980") }

    // FASN cycle: condensation, first reduction, dehydration, second reduction
    // These four reactions repeat seven times to build palmitate from acetyl primer + seven malonyl-CoA

    if step == 3 { return fas(3, "Fatty acid synthase - Malonyl/Acetyl transferase (MAT domain)", "P49327", "FASN", "Acetyl-CoA + Malonyl-CoA", "Acetyl-ACP + Malonyl-ACP (loaded onto phosphopantetheine arm)", "ACP (acyl carrier protein, built into FASN)", false, false, "FASN is a single 272 kDa polypeptide with seven catalytic domains. Functions as a homodimer. Loading step transfers acyl groups onto the ACP swinging arm.", "Wakil SJ. Biochemistry 28:4523-4530, 1989") }

    if step == 4 { return fas(4, "Fatty acid synthase - Ketoacyl synthase (KS domain)", "P49327", "FASN", "Acetyl-ACP + Malonyl-ACP", "Acetoacetyl-ACP + CO2 + ACP-SH", "None", false, false, "Claisen condensation. CO2 released (same CO2 added by ACC, making carboxylation thermodynamically favorable via decarboxylative condensation). Chain extends by 2 carbons per cycle.", "Lehninger 8th ed, Ch 21") }

    if step == 5 { return fas(5, "Fatty acid synthase - Ketoacyl reductase (KR domain)", "P49327", "FASN", "Acetoacetyl-ACP + NADPH", "D-3-Hydroxybutyryl-ACP + NADP+", "NADPH", true, false, "First reduction. NADPH from pentose phosphate pathway (G6PD, 6PGDH) and malic enzyme. D-stereochemistry (opposite of beta-oxidation which uses L).", "Lehninger 8th ed, Ch 21") }

    if step == 6 { return fas(6, "Fatty acid synthase - Dehydratase (DH domain)", "P49327", "FASN", "D-3-Hydroxybutyryl-ACP", "Crotonyl-ACP (trans-2-enoyl-ACP) + H2O", "None", true, false, "Dehydration creates trans double bond.", "Lehninger 8th ed, Ch 21") }

    if step == 7 { return fas(7, "Fatty acid synthase - Enoyl reductase (ER domain)", "P49327", "FASN", "Crotonyl-ACP + NADPH", "Butyryl-ACP + NADP+", "NADPH", false, false, "Second reduction. Saturates the double bond. After this step, one cycle is complete: chain is 2C longer. Cycle repeats with another malonyl-CoA condensation.", "Lehninger 8th ed, Ch 21") }

    if step == 8 { return fas(8, "Fatty acid synthase - Thioesterase (TE domain)", "P49327", "FASN", "Palmitoyl-ACP (C16, after seven cycles)", "Palmitate (free C16:0) + ACP-SH", "H2O", false, false, "Hydrolytic release after seven elongation cycles. FASN specifically releases C16 (palmitate). Further elongation and desaturation occur in ER by separate enzymes.", "Wakil SJ. Biochemistry 28:4523-4530, 1989") }

    return fas(0, "", "", "", "", "", "", false, false, "", "")
}

fn fa_synthesis_nadph_cost() -> Int {
    // Seven cycles, each consuming 2 NADPH = 14 NADPH per palmitate
    return 14
}

fn fa_synthesis_atp_cost() -> Int {
    // Seven ATP for seven malonyl-CoA (ACC reaction) + one acetyl-CoA primer
    return 7
}

fn fa_synthesis_acetyl_coa_cost() -> Int {
    // Eight acetyl-CoA total: one primer + seven via malonyl-CoA
    return 8
}

fn fa_synthesis_step_count() -> Int {
    return 9
}

// ═══════════════════════════════════════════════════════════════════
// SECTION B: BETA-OXIDATION (fatty acid catabolism)
// ═══════════════════════════════════════════════════════════════════
// Occurs in mitochondrial matrix. Fatty acids are activated, shuttled in
// via carnitine, and oxidized 2C at a time releasing acetyl-CoA, NADH, FADH2.

struct BetaOxStep {
    step_number: Int,
    phase: String,
    enzyme_name: String,
    enzyme_accession: String,
    enzyme_gene: String,
    substrate: String,
    product: String,
    cofactor: String,
    energy_product: String,
    regulation_note: String,
    citation: String,
}

fn box_step(sn: Int, ph: String, en: String, ea: String, eg: String, su: String, pr: String, co: String, ep: String, rn: String, ci: String) -> BetaOxStep {
    return BetaOxStep { step_number: sn, phase: ph, enzyme_name: en, enzyme_accession: ea, enzyme_gene: eg, substrate: su, product: pr, cofactor: co, energy_product: ep, regulation_note: rn, citation: ci }
}

fn beta_oxidation_step(step: Int) -> BetaOxStep {
    // Activation (cytoplasm)
    if step == 1 { return box_step(1, "activation", "Acyl-CoA synthetase (long-chain, ACSL1)", "P33121", "ACSL1", "Fatty acid + CoA + ATP", "Acyl-CoA + AMP + PPi", "ATP, CoA, Mg2+", "Costs 2 ATP equivalents (ATP->AMP = 2 high-energy bonds)", "Pyrophosphate immediately hydrolyzed by pyrophosphatase, making reaction irreversible. Located on outer mitochondrial membrane.", "Lehninger 8th ed, Ch 17") }

    // Carnitine shuttle (outer membrane -> matrix)
    if step == 2 { return box_step(2, "carnitine_shuttle", "Carnitine palmitoyltransferase I (CPT-I)", "P50416", "CPT1A", "Acyl-CoA + Carnitine", "Acylcarnitine + CoA", "Carnitine (from lysine/methionine)", "None", "THE rate-limiting step of beta-oxidation. Inhibited by malonyl-CoA (from ACC2, linking synthesis to oxidation). Located on outer mitochondrial membrane. CPT-I deficiency causes hypoketotic hypoglycemia.", "McGarry JD, Foster DW. Annu Rev Biochem 49:395-420, 1980") }

    if step == 3 { return box_step(3, "carnitine_shuttle", "Carnitine-acylcarnitine translocase (CACT)", "O43772", "SLC25A20", "Acylcarnitine (cytoplasmic side)", "Acylcarnitine (matrix side)", "None", "None", "Antiporter: acylcarnitine in, free carnitine out. Spans inner mitochondrial membrane. CACT deficiency is fatal in neonates.", "Lehninger 8th ed, Ch 17") }

    if step == 4 { return box_step(4, "carnitine_shuttle", "Carnitine palmitoyltransferase II (CPT-II)", "P23786", "CPT2", "Acylcarnitine + CoA (matrix)", "Acyl-CoA (matrix) + Carnitine", "CoA (matrix pool)", "None", "Regenerates acyl-CoA inside matrix. Carnitine recycled back out via CACT. CPT-II deficiency: most common inherited disorder of fatty acid oxidation (muscle form: exercise-induced rhabdomyolysis).", "Lehninger 8th ed, Ch 17") }

    // The four-step spiral (repeats, shortening chain by 2C each cycle)
    if step == 5 { return box_step(5, "spiral", "Acyl-CoA dehydrogenase (VLCAD/LCAD/MCAD/SCAD)", "P11310", "ACADM", "Acyl-CoA", "trans-2-Enoyl-CoA", "FAD -> FADH2", "FADH2 (-> 1.5 ATP via ETF -> CoQ)", "Four chain-length-specific isozymes. MCAD deficiency (P11310, ACADM) is most common: 1/15000 live births. Presents with hypoketotic hypoglycemia, Reye-like episodes. On newborn screen.", "Lehninger 8th ed, Ch 17; Stryer 9th ed, Ch 22") }

    if step == 6 { return box_step(6, "spiral", "Enoyl-CoA hydratase (crotonase)", "P30084", "ECHS1", "trans-2-Enoyl-CoA + H2O", "L-3-Hydroxyacyl-CoA", "H2O", "None", "Hydration across double bond. L-stereochemistry (opposite of fatty acid synthesis which produces D). Stereospecificity prevents futile cycling.", "Lehninger 8th ed, Ch 17") }

    if step == 7 { return box_step(7, "spiral", "L-3-Hydroxyacyl-CoA dehydrogenase (HAD)", "Q16836", "HADH", "L-3-Hydroxyacyl-CoA + NAD+", "3-Ketoacyl-CoA + NADH", "NAD+ -> NADH", "NADH (-> 2.5 ATP via Complex I)", "Oxidation of hydroxyl to keto group. LCHAD deficiency can cause maternal HELLP syndrome / acute fatty liver of pregnancy when fetus is homozygous.", "Lehninger 8th ed, Ch 17") }

    if step == 8 { return box_step(8, "spiral", "Thiolase (beta-ketothiolase, acetyl-CoA acetyltransferase)", "P24752", "ACAT1", "3-Ketoacyl-CoA + CoA", "Acetyl-CoA + Acyl-CoA (2C shorter)", "CoA", "Acetyl-CoA (-> TCA -> ~10 ATP)", "Thiolytic cleavage releases acetyl-CoA. Shortened acyl-CoA re-enters spiral at step five. Final cycle yields two acetyl-CoA molecules. Inhibited by product accumulation.", "Lehninger 8th ed, Ch 17") }

    return box_step(0, "", "", "", "", "", "", "", "", "", "")
}

fn palmitate_oxidation_atp() -> Int {
    // Palmitate (C16:0): seven cycles of beta-oxidation
    // Seven FADH2 x 1.5 = 10.5 ATP
    // Seven NADH x 2.5 = 17.5 ATP
    // Eight Acetyl-CoA x 10 (via TCA + ETC) = 80 ATP
    // Subtotal: 108 ATP
    // Minus 2 ATP equivalents for activation (ATP -> AMP)
    // Net: 106 ATP per palmitate
    return 106
}

fn palmitate_beta_ox_cycles() -> Int {
    // C16 fatty acid: (16/2) - 1 = 7 cycles
    return 7
}

fn palmitate_acetyl_coa_yield() -> Int {
    return 8
}

fn beta_oxidation_step_count() -> Int {
    return 8
}

// ═══════════════════════════════════════════════════════════════════
// SECTION C: KETONE BODY METABOLISM
// ═══════════════════════════════════════════════════════════════════
// Liver produces ketone bodies from excess acetyl-CoA during fasting,
// starvation, uncontrolled diabetes. Brain and muscle use them as fuel.
// Three ketone bodies: acetoacetate, beta-hydroxybutyrate, acetone.

struct KetoneStep {
    step_number: Int,
    phase: String,
    enzyme_name: String,
    enzyme_accession: String,
    enzyme_gene: String,
    substrate: String,
    product: String,
    tissue: String,
    clinical_note: String,
    citation: String,
}

fn kstep(sn: Int, ph: String, en: String, ea: String, eg: String, su: String, pr: String, ti: String, cn: String, ci: String) -> KetoneStep {
    return KetoneStep { step_number: sn, phase: ph, enzyme_name: en, enzyme_accession: ea, enzyme_gene: eg, substrate: su, product: pr, tissue: ti, clinical_note: cn, citation: ci }
}

fn ketone_step(step: Int) -> KetoneStep {
    // Synthesis (ketogenesis) -- liver mitochondria only
    if step == 1 { return kstep(1, "synthesis", "Thiolase (acetyl-CoA acetyltransferase)", "P24752", "ACAT1", "2 Acetyl-CoA", "Acetoacetyl-CoA + CoA", "liver", "Reverse of thiolytic cleavage in beta-oxidation. Driven forward by next step pulling product.", "Lehninger 8th ed, Ch 17") }

    if step == 2 { return kstep(2, "synthesis", "HMG-CoA synthase (mitochondrial)", "P54868", "HMGCS2", "Acetoacetyl-CoA + Acetyl-CoA + H2O", "HMG-CoA (3-hydroxy-3-methylglutaryl-CoA) + CoA", "liver", "THE committed step of ketogenesis. Mitochondrial isozyme (HMGCS2) distinct from cytoplasmic (HMGCS1 for cholesterol). Upregulated by PPAR-alpha in fasting. Succinylation inhibits.", "McGarry JD, Foster DW. Annu Rev Biochem 49:395-420, 1980") }

    if step == 3 { return kstep(3, "synthesis", "HMG-CoA lyase", "P35914", "HMGCL", "HMG-CoA", "Acetoacetate + Acetyl-CoA", "liver", "Cleavage releases first ketone body (acetoacetate). HMG-CoA lyase deficiency: rare autosomal recessive, presents with hypoketotic hypoglycemia and metabolic acidosis in neonates.", "Lehninger 8th ed, Ch 17") }

    if step == 4 { return kstep(4, "synthesis", "Beta-hydroxybutyrate dehydrogenase (BDH1)", "Q02338", "BDH1", "Acetoacetate + NADH", "D-beta-Hydroxybutyrate + NAD+", "liver", "Reduction. Beta-hydroxybutyrate is the predominant circulating ketone body (ratio BHB:AcAc reflects mitochondrial NADH/NAD+ ratio). BHB is technically not a ketone (no keto group).", "Lehninger 8th ed, Ch 17") }

    if step == 5 { return kstep(5, "synthesis", "Spontaneous decarboxylation", "none", "none", "Acetoacetate", "Acetone + CO2", "liver", "Non-enzymatic. Acetone is volatile, exhaled by lungs (fruity breath in DKA). Cannot be remetabolized to acetyl-CoA. Clinically: fruity breath = ketoacidosis until proven otherwise.", "Stryer 9th ed, Ch 22") }

    // Utilization (ketolysis) -- extrahepatic tissues (brain, muscle, heart, kidney)
    if step == 6 { return kstep(6, "utilization", "Beta-hydroxybutyrate dehydrogenase (BDH1)", "Q02338", "BDH1", "D-beta-Hydroxybutyrate + NAD+", "Acetoacetate + NADH", "brain, muscle, heart", "Reverse of synthesis step four. Oxidation regenerates acetoacetate in target tissues.", "Lehninger 8th ed, Ch 17") }

    if step == 7 { return kstep(7, "utilization", "Succinyl-CoA:3-oxoacid CoA-transferase (SCOT, thiophorase)", "P55809", "OXCT1", "Acetoacetate + Succinyl-CoA", "Acetoacetyl-CoA + Succinate", "brain, muscle, heart", "THE reason liver cannot use its own ketone bodies: liver LACKS SCOT (OXCT1). This is an elegant one-enzyme gate. SCOT deficiency: episodic ketoacidosis. Brain upregulates SCOT during prolonged fasting.", "Lehninger 8th ed, Ch 17; Stryer 9th ed, Ch 22") }

    if step == 8 { return kstep(8, "utilization", "Thiolase (acetyl-CoA acetyltransferase)", "P24752", "ACAT1", "Acetoacetyl-CoA + CoA", "2 Acetyl-CoA", "brain, muscle, heart", "Thiolytic cleavage regenerates two acetyl-CoA molecules that enter TCA cycle. Net yield: approximately 22 ATP per acetoacetate, 24 ATP per beta-hydroxybutyrate (extra NADH from BDH1).", "Lehninger 8th ed, Ch 17") }

    return kstep(0, "", "", "", "", "", "", "", "", "")
}

fn ketone_step_count() -> Int {
    return 8
}

fn dka_context() -> String {
    return "Diabetic ketoacidosis (DKA): in type 1 diabetes, absolute insulin deficiency causes (a) unrestrained lipolysis in adipose releasing free fatty acids, (b) unrestrained beta-oxidation in liver producing excess acetyl-CoA, (c) acetyl-CoA exceeds TCA capacity (OAA diverted to gluconeogenesis), (d) excess acetyl-CoA shunted to ketogenesis. Acetoacetate and BHB are acids (pKa ~3.6 and ~4.7). Accumulation overwhelms bicarbonate buffer. Blood pH drops below 7.35. Anion gap metabolic acidosis. Kussmaul breathing (deep, rapid) attempts respiratory compensation. Fruity breath (acetone). Dehydration from osmotic diuresis. FATAL if untreated. Treatment: insulin + fluids + electrolytes. Cited: Kitabchi AE et al. Diabetes Care 32:1335-1343, 2009."
}

fn ketone_atp_per_acetoacetate() -> Int {
    // Two acetyl-CoA -> TCA -> 20 ATP, plus activation cost from succinyl-CoA (-1 GTP equivalent)
    // But SCOT bypasses GTP: net ~22 ATP (accounting for NADH produced)
    return 22
}

fn ketone_atp_per_bhb() -> Int {
    // Same as acetoacetate plus one extra NADH from BDH1 oxidation (2.5 ATP)
    // approximately 24 ATP
    return 24
}

// ═══════════════════════════════════════════════════════════════════
// SECTION D: CHOLESTEROL SYNTHESIS (mevalonate pathway)
// ═══════════════════════════════════════════════════════════════════
// All 27 carbons from acetyl-CoA. Occurs in cytoplasm and ER.
// HMG-CoA reductase is the rate-limiting enzyme and THE statin target.

struct CholesterolStep {
    step_number: Int,
    enzyme_name: String,
    enzyme_accession: String,
    enzyme_gene: String,
    substrate: String,
    product: String,
    cofactor: String,
    regulatory: Bool,
    regulation_note: String,
    clinical_note: String,
    citation: String,
}

fn chol(sn: Int, en: String, ea: String, eg: String, su: String, pr: String, co: String, rg: Bool, rn: String, cn: String, ci: String) -> CholesterolStep {
    return CholesterolStep { step_number: sn, enzyme_name: en, enzyme_accession: ea, enzyme_gene: eg, substrate: su, product: pr, cofactor: co, regulatory: rg, regulation_note: rn, clinical_note: cn, citation: ci }
}

fn cholesterol_step(step: Int) -> CholesterolStep {
    if step == 1 { return chol(1, "Thiolase (cytoplasmic)", "Q9BWD1", "ACAT2", "2 Acetyl-CoA", "Acetoacetyl-CoA + CoA", "None", false, "", "Same condensation as ketogenesis step one, but this is the CYTOPLASMIC isozyme (ACAT2). Ketogenesis uses mitochondrial ACAT1.", "Lehninger 8th ed, Ch 21") }

    if step == 2 { return chol(2, "HMG-CoA synthase (cytoplasmic)", "Q01581", "HMGCS1", "Acetoacetyl-CoA + Acetyl-CoA", "HMG-CoA", "None", false, "", "Cytoplasmic isozyme (HMGCS1). Mitochondrial HMGCS2 feeds ketogenesis. Compartmentalization determines metabolic fate.", "Lehninger 8th ed, Ch 21") }

    if step == 3 { return chol(3, "HMG-CoA reductase", "P04035", "HMGCR", "HMG-CoA + 2 NADPH", "Mevalonate + CoA + 2 NADP+", "NADPH (x2)", true, "THE most regulated enzyme in the body. Four levels of control: (a) Transcriptional: SREBP-2 activates HMGCR gene when cholesterol is low. (b) Translational: regulated by mevalonate. (c) Post-translational: phosphorylation by AMPK inactivates; dephosphorylation activates. (d) Degradation: sterol-accelerated ubiquitination via Insig proteins. Diurnal variation: peak synthesis at midnight.", "THE STATIN TARGET. Statins (lovastatin, atorvastatin, rosuvastatin) are competitive inhibitors of HMG-CoA reductase. Statins structurally resemble mevalonate. Reduce LDL-C by 30-50%. Upregulate hepatic LDLR (compensatory). Most prescribed drug class worldwide. Cited: Istvan ES, Deisenhofer J. Science 292:1160-1164, 2001 (statin binding crystal structure).", "Brown MS, Goldstein JL. Science 232:34-47, 1986") }

    if step == 4 { return chol(4, "Mevalonate kinase", "Q03426", "MVK", "Mevalonate + ATP", "Mevalonate-5-phosphate + ADP", "ATP", false, "", "MVK deficiency: mevalonic aciduria (severe) and hyper-IgD syndrome (HIDS, mild). Both are autoinflammatory.", "Lehninger 8th ed, Ch 21") }

    if step == 5 { return chol(5, "Phosphomevalonate kinase", "Q15126", "PMVK", "Mevalonate-5-phosphate + ATP", "Mevalonate-5-pyrophosphate + ADP", "ATP", false, "", "", "Lehninger 8th ed, Ch 21") }

    if step == 6 { return chol(6, "Mevalonate-5-pyrophosphate decarboxylase", "P53602", "MVD", "Mevalonate-5-pyrophosphate + ATP", "Isopentenyl pyrophosphate (IPP) + ADP + CO2 + Pi", "ATP", false, "", "IPP is the 5-carbon isoprene unit, the universal building block for isoprenoids (cholesterol, CoQ10, dolichol, prenylated proteins, vitamin A).", "Lehninger 8th ed, Ch 21") }

    if step == 7 { return chol(7, "IPP isomerase", "Q13907", "IDI1", "Isopentenyl pyrophosphate (IPP)", "Dimethylallyl pyrophosphate (DMAPP)", "None", false, "", "Isomerization. Both IPP and DMAPP are needed: DMAPP is the starter, IPP is added.", "Stryer 9th ed, Ch 26") }

    if step == 8 { return chol(8, "Farnesyl pyrophosphate synthase", "P37268", "FDPS", "DMAPP + 2 IPP", "Farnesyl pyrophosphate (FPP, C15)", "Mg2+", false, "", "FPP is the branch point: two FPP -> squalene -> cholesterol. FPP also used for protein prenylation (Ras farnesylation, critical in cancer). Bisphosphonates (alendronate) inhibit FDPS for osteoporosis treatment.", "Lehninger 8th ed, Ch 21") }

    if step == 9 { return chol(9, "Squalene synthase", "P37268", "FDFT1", "2 Farnesyl pyrophosphate (C15 each) + NADPH", "Squalene (C30) + 2 PPi + NADP+", "NADPH, Mg2+", false, "", "Head-to-head condensation of two FPP. Squalene is a linear triterpene. Named after shark liver (Squalus) where it was discovered. First committed step exclusive to cholesterol pathway.", "Stryer 9th ed, Ch 26") }

    if step == 10 { return chol(10, "Squalene epoxidase (monooxygenase)", "Q14534", "SQLE", "Squalene + O2 + NADPH", "2,3-Oxidosqualene + NADP+ + H2O", "NADPH, O2, FAD", true, "SQLE is the second rate-limiting step. Also regulated by SREBP. Terbinafine (antifungal) inhibits fungal squalene epoxidase.", "Allantoin (antifungal target). SQLE amplification found in breast cancer.", "Lehninger 8th ed, Ch 21") }

    if step == 11 { return chol(11, "Oxidosqualene cyclase (lanosterol synthase)", "P48449", "LSS", "2,3-Oxidosqualene", "Lanosterol", "None", false, "", "The most extraordinary single-enzyme reaction in biochemistry: cyclization of linear squalene oxide into four-ring steroid nucleus in one step. Creates six C-C bonds, six stereocenters. Lanosterol is the first sterol.", "Stryer 9th ed, Ch 26") }

    if step == 12 { return chol(12, "Lanosterol-to-cholesterol enzymes (19 steps)", "multiple", "CYP51A1, DHCR7, others", "Lanosterol", "Cholesterol (C27)", "NADPH, O2", false, "", "Nineteen enzymatic steps convert lanosterol to cholesterol: three demethylations, one desaturation, one double bond migration, one reduction. Key enzyme: DHCR7 (P51659) catalyzes final step. DHCR7 deficiency: Smith-Lemli-Opitz syndrome (intellectual disability, dysmorphic features, low cholesterol).", "Lehninger 8th ed, Ch 21") }

    return chol(0, "", "", "", "", "", "", false, "", "", "")
}

fn cholesterol_step_count() -> Int {
    return 12
}

fn srebp_regulation() -> String {
    return "SREBP (Sterol Regulatory Element-Binding Proteins): master transcription factors for lipid metabolism. SREBP-2 (Q12772, SREBF2): primarily controls cholesterol synthesis genes (HMGCR, HMGCS1, LDLR, SQLE). SREBP-1c (P36956, SREBF1): primarily controls fatty acid synthesis genes (FASN, ACC, SCD1). Mechanism: SREBPs are synthesized as ER-membrane-bound precursors. When cholesterol is HIGH: SCAP-SREBP complex binds Insig in ER (retained). When cholesterol is LOW: Insig releases SCAP-SREBP, which transits to Golgi. Site-1 protease (S1P) and Site-2 protease (S2P) cleave SREBP, releasing N-terminal transcription factor domain. Active SREBP enters nucleus and binds SRE (sterol regulatory elements) in target gene promoters. Insulin activates SREBP-1c (promotes lipogenesis in fed state). Cited: Horton JD et al. J Clin Invest 109:1125-1131, 2002."
}

fn statin_mechanism() -> String {
    return "Statins are competitive inhibitors of HMG-CoA reductase (Ki ~1 nM vs Km ~4 uM for HMG-CoA). Structural mimicry of mevalonate transition state. Direct effect: reduced hepatic cholesterol synthesis. Indirect (more important) effect: low intracellular cholesterol activates SREBP-2, which upregulates LDLR expression. More LDLRs on hepatocyte surface clear more LDL from blood. Net result: LDL-C reduction of 30-50%. Also modest HDL increase and triglyceride reduction. Side effects: myalgia (common), rhabdomyolysis (rare, especially with gemfibrozil co-administration via CYP3A4 competition). Cited: Istvan ES, Deisenhofer J. Science 292:1160-1164, 2001."
}

// ═══════════════════════════════════════════════════════════════════
// SECTION E: LIPOPROTEINS
// ═══════════════════════════════════════════════════════════════════
// Lipid transport vehicles in blood. Core: triglycerides + cholesteryl esters.
// Shell: phospholipid monolayer + apolipoproteins + free cholesterol.

struct Lipoprotein {
    name: String,
    density_range: String,
    diameter_nm: String,
    primary_lipid: String,
    key_apolipoprotein: String,
    apo_accession: String,
    source: String,
    function_note: String,
    receptor: String,
    clinical_note: String,
    citation: String,
}

fn lipo(n: String, dr: String, di: String, pl: String, ka: String, kaa: String, so: String, fn_note: String, re: String, cn: String, ci: String) -> Lipoprotein {
    return Lipoprotein { name: n, density_range: dr, diameter_nm: di, primary_lipid: pl, key_apolipoprotein: ka, apo_accession: kaa, source: so, function_note: fn_note, receptor: re, clinical_note: cn, citation: ci }
}

fn lookup_lipoprotein(name: String) -> Lipoprotein {
    if name == "chylomicron" { return lipo("Chylomicron", "<0.95 g/mL", "75-1200", "Dietary triglycerides (85-90%)", "ApoB-48 (intestinal, one per particle)", "P04114", "Intestinal enterocytes (absorb dietary fat)", "Transport dietary lipids from gut to tissues. Lipoprotein lipase (LPL, P06858) on capillary endothelium hydrolyzes TG, releasing fatty acids to tissues. Chylomicron remnants (depleted of TG) taken up by liver via ApoE receptor.", "Remnant receptor (LRP1, Q07954) via ApoE", "Type I hyperlipoproteinemia (LPL deficiency): massive chylomicronemia, eruptive xanthomas, pancreatitis. Lipemia retinalis. Plasma looks milky (cream layer on standing).", "Lehninger 8th ed, Ch 21; Stryer 9th ed, Ch 26") }

    if name == "VLDL" { return lipo("VLDL", "0.95-1.006 g/mL", "30-80", "Endogenous triglycerides (55-65%)", "ApoB-100 (hepatic, one per particle)", "P04114", "Liver hepatocytes", "Export endogenous triglycerides from liver to peripheral tissues. LPL hydrolyzes TG. As VLDL loses TG, it shrinks and becomes denser: VLDL -> IDL -> LDL. Each particle retains its single ApoB-100 throughout. Also carries ApoC-II (LPL activator) and ApoE.", "LPL-mediated TG hydrolysis in capillaries", "Elevated VLDL: hypertriglyceridemia. Insulin resistance increases VLDL secretion (hepatic lipogenesis increased). Fibrates (PPAR-alpha agonists) reduce VLDL production. Niacin inhibits hepatic TG synthesis.", "Brown MS, Goldstein JL. Science 232:34-47, 1986") }

    if name == "IDL" { return lipo("IDL", "1.006-1.019 g/mL", "25-35", "Triglycerides + cholesteryl esters (intermediate)", "ApoB-100 + ApoE", "P04114", "Intravascular (VLDL remnant)", "Transient intermediate. Half taken up by liver via LDLR (ApoB-100 and ApoE both bind LDLR). Half further processed by hepatic lipase to LDL. IDL retains ApoE; LDL loses it.", "LDLR (P01130) via ApoB-100 and ApoE", "IDL accumulation: Type III hyperlipoproteinemia (dysbetalipoproteinemia). ApoE2/E2 homozygosity impairs receptor binding. Palmar xanthomas pathognomonic.", "Lehninger 8th ed, Ch 21") }

    if name == "LDL" { return lipo("LDL", "1.019-1.063 g/mL", "18-25", "Cholesteryl esters (50%)", "ApoB-100 (sole apolipoprotein remaining)", "P04114", "Intravascular (IDL remnant, fully processed)", "Primary cholesterol delivery vehicle to peripheral cells. Cells internalize LDL via LDLR-mediated endocytosis (clathrin-coated pits). In endosome: low pH releases LDL from receptor. LDLR recycled to surface. LDL degraded in lysosome. Cholesteryl esters hydrolyzed by acid lipase. Free cholesterol suppresses HMGCR and LDLR (feedback).", "LDLR (P01130) via ApoB-100. Also PCSK9-regulated degradation.", "Elevated LDL: THE causal risk factor for atherosclerosis. Oxidized LDL taken up by macrophage scavenger receptors (no feedback inhibition) -> foam cells -> fatty streak -> plaque. Familial hypercholesterolemia (FH): LDLR mutations (heterozygous 1/250, LDL ~300; homozygous 1/1M, LDL >500, MI in childhood). PCSK9 gain-of-function also causes FH. Statins, ezetimibe, PCSK9 inhibitors (evolocumab, alirocumab) all lower LDL.", "Brown MS, Goldstein JL. Science 232:34-47, 1986 (Nobel Prize 1985)") }

    if name == "HDL" { return lipo("HDL", "1.063-1.210 g/mL", "5-12", "Cholesteryl esters + phospholipids", "ApoA-I (primary, 70% of HDL protein)", "P02647", "Liver and intestine (secreted as nascent discoidal HDL)", "REVERSE CHOLESTEROL TRANSPORT: HDL extracts cholesterol from peripheral cells via ABCA1 (O95477) transporter. LCAT (P04180, lecithin:cholesterol acyltransferase) esterifies free cholesterol, pulling it into HDL core. Mature spherical HDL delivers cholesterol to liver via SR-BI (Q8WTV0) receptor (selective uptake). Also via CETP (P11597): transfers cholesteryl esters from HDL to VLDL/LDL in exchange for triglycerides. HDL also has anti-inflammatory, antioxidant, and anti-thrombotic properties.", "SR-BI (Q8WTV0, SCARB1) in liver and steroidogenic tissues", "High HDL is cardioprotective (inverse correlation with CVD risk). Low HDL: metabolic syndrome, type 2 diabetes. Tangier disease: ABCA1 mutations cause near-absent HDL, orange tonsils, cholesterol accumulation in macrophages. CETP inhibitors (torcetrapib, anacetrapib) raised HDL but did not reduce CVD events, challenging the 'HDL hypothesis.'", "Rader DJ, Hovingh GK. Lancet 384:618-625, 2014") }

    return lipo("", "", "", "", "", "", "", "", "", "", "")
}

fn lipoprotein_count() -> Int {
    return 5
}

// Key apolipoproteins reference
fn apolipoprotein_info(name: String) -> String {
    if name == "ApoB-48" { return "P04114 (APOB) | Intestinal form, 48% of full ApoB. Produced by RNA editing (APOBEC1 introduces stop codon). One per chylomicron. Cannot bind LDLR (lacks C-terminal LDLR-binding domain). Chylomicron remnants cleared via ApoE instead." }
    if name == "ApoB-100" { return "P04114 (APOB) | Full-length hepatic form, 4536 amino acids, 515 kDa. One of the largest human proteins. One per VLDL/IDL/LDL particle. Contains LDLR-binding domain near C-terminus. THE ligand for LDL receptor-mediated endocytosis." }
    if name == "ApoE" { return "P02649 (APOE) | 34 kDa. Three isoforms: E2 (Cys112/Cys158), E3 (Cys112/Arg158, most common), E4 (Arg112/Arg158). ApoE binds LDLR and LRP1, mediating remnant clearance. ApoE4: major genetic risk factor for Alzheimer disease (3x heterozygous, 12x homozygous). ApoE2: poor receptor binding -> Type III hyperlipoproteinemia." }
    if name == "ApoA-I" { return "P02647 (APOA1) | Primary HDL protein. Activates LCAT. Mediates ABCA1-dependent cholesterol efflux. ApoA-I Milano (R173C natural variant): enhanced cardioprotection despite low HDL. Basis for recombinant HDL therapy research." }
    if name == "ApoC-II" { return "P02655 (APOC2) | Activator of lipoprotein lipase (LPL). Present on chylomicrons and VLDL. ApoC-II deficiency phenocopies LPL deficiency: severe hypertriglyceridemia, pancreatitis." }
    if name == "ApoC-III" { return "P02656 (APOC3) | Inhibitor of LPL and hepatic lipase. Inhibits remnant clearance. ApoC-III antisense (volanesorsen) approved for familial chylomicronemia syndrome. Loss-of-function mutations associated with lower TG and reduced CVD risk." }
    return ""
}

fn familial_hypercholesterolemia() -> String {
    return "Familial hypercholesterolemia (FH): autosomal dominant. Mutations in LDLR (most common, >1600 known mutations), APOB (ApoB-100 binding domain), PCSK9 (gain-of-function, increased LDLR degradation), or LDLRAP1 (recessive form). Heterozygous FH: 1/250, LDL 200-400, premature CVD. Homozygous FH: 1/1,000,000, LDL 500-1000, aortic stenosis, MI before age 20. Treatment: high-dose statin + ezetimibe + PCSK9 inhibitor. Homozygous may need LDL apheresis or lomitapide (MTP inhibitor). Nobel Prize 1985 to Brown and Goldstein for LDLR-mediated endocytosis and cholesterol regulation."
}

fn atherosclerosis_pathogenesis() -> String {
    return "Response-to-retention model: LDL particles penetrate endothelium and bind proteoglycans in subendothelial space. Retained LDL undergoes oxidative modification. Oxidized LDL (oxLDL) activates endothelial cells (adhesion molecules VCAM-1, ICAM-1). Monocytes recruited, differentiate to macrophages. Macrophage scavenger receptors (SR-A, CD36) internalize oxLDL WITHOUT feedback inhibition (unlike LDLR). Cholesterol accumulation -> foam cells. Foam cells + T cells + smooth muscle cells form fatty streak -> fibrous plaque -> complicated plaque (necrotic core, thin fibrous cap). Plaque rupture exposes tissue factor -> thrombosis -> MI or stroke. Cited: Tabas I et al. J Cell Biol 209:13-22, 2015."
}

// ═══════════════════════════════════════════════════════════════════
// SECTION F: EICOSANOID METABOLISM
// ═══════════════════════════════════════════════════════════════════
// Eicosanoids: signaling lipids derived from arachidonic acid (C20:4, omega-6).
// Prostaglandins, thromboxanes (COX pathway), leukotrienes (LOX pathway).
// Extremely short half-lives (seconds to minutes). Local (paracrine/autocrine).

struct EicosanoidStep {
    step_number: Int,
    pathway: String,
    enzyme_name: String,
    enzyme_accession: String,
    enzyme_gene: String,
    substrate: String,
    product: String,
    inhibitor: String,
    clinical_note: String,
    citation: String,
}

fn eico(sn: Int, pw: String, en: String, ea: String, eg: String, su: String, pr: String, inh: String, cn: String, ci: String) -> EicosanoidStep {
    return EicosanoidStep { step_number: sn, pathway: pw, enzyme_name: en, enzyme_accession: ea, enzyme_gene: eg, substrate: su, product: pr, inhibitor: inh, clinical_note: cn, citation: ci }
}

fn eicosanoid_step(step: Int) -> EicosanoidStep {
    // Liberation of arachidonic acid
    if step == 1 { return eico(1, "liberation", "Phospholipase A2 (cytosolic, cPLA2)", "P47712", "PLA2G4A", "Membrane phospholipids (sn-2 position)", "Arachidonic acid (C20:4, omega-6) + lysophospholipid", "Corticosteroids (indirectly via lipocortin/annexin A1, which inhibits PLA2). Explains anti-inflammatory potency of steroids.", "Arachidonic acid is the universal precursor for all eicosanoids. Released from membrane phospholipids on demand (not stored). Calcium-dependent activation. Arachidonic acid from diet (omega-6) or synthesized from linoleic acid (C18:2).", "Lehninger 8th ed, Ch 21; Stryer 9th ed, Ch 22") }

    // COX pathway -> prostaglandins and thromboxanes
    if step == 2 { return eico(2, "COX", "Cyclooxygenase-1 (COX-1, prostaglandin-endoperoxide synthase 1)", "P23219", "PTGS1", "Arachidonic acid + 2 O2", "PGG2, then PGH2 (prostaglandin H2)", "Aspirin (irreversible acetylation of Ser530). NSAIDs (ibuprofen, naproxen: reversible, competitive).", "COX-1 is constitutive (housekeeping): gastric cytoprotection (PGE2 maintains mucus), platelet TXA2 synthesis, renal blood flow. Low-dose aspirin (81 mg) selectively inhibits platelet COX-1 (platelets cannot resynthesize COX-1 because they lack nuclei). Cardioprotective antiplatelet effect lasts lifetime of platelet (7-10 days).", "Vane JR. Nature New Biol 231:232-235, 1971 (Nobel Prize 1982)") }

    if step == 3 { return eico(3, "COX", "Cyclooxygenase-2 (COX-2, prostaglandin-endoperoxide synthase 2)", "P35354", "PTGS2", "Arachidonic acid + 2 O2", "PGG2, then PGH2", "COX-2 selective inhibitors (celecoxib, rofecoxib). Aspirin and non-selective NSAIDs also inhibit.", "COX-2 is INDUCIBLE: upregulated by inflammation (NF-kB, cytokines), mitogens, growth factors. Major source of prostaglandins in inflammation, fever, pain. Rofecoxib (Vioxx) withdrawn 2004: increased MI risk because COX-2 inhibition removes endothelial PGI2 (vasodilatory, antithrombotic) while leaving platelet TXA2 (prothrombotic) unopposed.", "FitzGerald GA. N Engl J Med 351:1709-1711, 2004") }

    if step == 4 { return eico(4, "COX", "Prostaglandin E synthase (mPGES-1)", "O14684", "PTGES", "PGH2", "PGE2 (prostaglandin E2)", "None selective in clinical use", "PGE2: THE inflammatory prostaglandin. Fever (acts on hypothalamus), pain (sensitizes nociceptors), vasodilation, gastric mucus secretion, renal blood flow. EP receptors (EP1-EP4). Also immunosuppressive in tumor microenvironment. PGE2 dinoprostone used for cervical ripening in labor induction.", "Lehninger 8th ed, Ch 21") }

    if step == 5 { return eico(5, "COX", "Prostacyclin synthase", "Q16647", "PTGIS", "PGH2", "PGI2 (prostacyclin)", "None", "PGI2: produced by vascular endothelium. Potent vasodilator and platelet aggregation inhibitor. Opposes TXA2. The PGI2/TXA2 balance determines vascular tone and thrombotic tendency. Epoprostenol (synthetic PGI2) used IV for pulmonary arterial hypertension. Half-life only 3 minutes.", "Lehninger 8th ed, Ch 21; Stryer 9th ed, Ch 22") }

    if step == 6 { return eico(6, "COX", "Thromboxane synthase", "P24557", "TBXAS1", "PGH2", "TXA2 (thromboxane A2)", "Aspirin (upstream COX-1 inhibition). Ozagrel (direct TBXAS1 inhibitor, Japan).", "TXA2: produced by activated platelets. Potent vasoconstrictor and platelet aggregator. Binds TP receptor. Half-life 30 seconds (hydrolyzes to inactive TXB2). Aspirin prevents MI by blocking platelet COX-1 -> TXA2 synthesis. Thromboxane is why aspirin saves lives.", "Vane JR. Nature New Biol 231:232-235, 1971") }

    if step == 7 { return eico(7, "COX", "Prostaglandin D synthase", "P41222", "PTGDS", "PGH2", "PGD2 (prostaglandin D2)", "None", "PGD2: produced in brain (sleep regulation, acts on DP1 receptor in VLPO), mast cells (allergic inflammation via DP2/CRTH2). PGD2 metabolized to 15d-PGJ2, a natural PPAR-gamma ligand with anti-inflammatory properties. Role in male-pattern baldness (PGD2 inhibits hair follicle growth).", "Stryer 9th ed, Ch 22") }

    if step == 8 { return eico(8, "COX", "Prostaglandin F synthase (AKR1C3)", "P42330", "AKR1C3", "PGH2", "PGF2-alpha", "None", "PGF2-alpha: potent uterine smooth muscle contraction. Carboprost (15-methyl-PGF2-alpha) used for postpartum hemorrhage and second-trimester abortion. Latanoprost (PGF2-alpha analog): glaucoma treatment (increases aqueous humor outflow). Also causes eyelash growth (bimatoprost).", "Lehninger 8th ed, Ch 21") }

    // LOX pathway -> leukotrienes
    if step == 9 { return eico(9, "LOX", "5-Lipoxygenase (5-LOX)", "P09917", "ALOX5", "Arachidonic acid + O2", "5-HPETE, then LTA4 (leukotriene A4)", "Zileuton (direct 5-LOX inhibitor, for asthma). Corticosteroids (reduce ALOX5 expression indirectly via PLA2 inhibition).", "5-LOX requires FLAP (5-lipoxygenase activating protein, P20292) for activity at nuclear membrane. 5-LOX translocates to nuclear envelope on activation. Leukotrienes named because discovered in leukocytes and contain a triene (three conjugated double bonds). Samuelsson B. Science 220:568-575, 1983 (Nobel Prize 1982).", "Samuelsson B. Science 220:568-575, 1983") }

    if step == 10 { return eico(10, "LOX", "LTA4 hydrolase", "P09960", "LTA4H", "LTA4 + H2O", "LTB4 (leukotriene B4)", "None in clinical use", "LTB4: potent neutrophil chemoattractant. Activates neutrophils via BLT1 receptor. Important in acute inflammation, host defense, inflammatory bowel disease. LTB4 antagonists under development.", "Lehninger 8th ed, Ch 21") }

    if step == 11 { return eico(11, "LOX", "LTC4 synthase", "Q16873", "LTC4S", "LTA4 + Glutathione", "LTC4 (leukotriene C4)", "None directly", "LTC4 is the first cysteinyl leukotriene (contains glutathione). LTC4 -> LTD4 -> LTE4 by sequential peptide cleavage. Cysteinyl leukotrienes (formerly SRS-A: slow-reacting substance of anaphylaxis). 1000x more potent than histamine for bronchoconstriction.", "Samuelsson B. Science 220:568-575, 1983") }

    if step == 12 { return eico(12, "LOX", "Gamma-glutamyl transpeptidase + dipeptidase", "P36269", "GGT1", "LTC4 -> LTD4 -> LTE4", "LTD4 and LTE4 (cysteinyl leukotrienes)", "Montelukast, zafirlukast (CysLT1 receptor antagonists, NOT enzyme inhibitors but block downstream signaling).", "Cysteinyl leukotrienes bind CysLT1 receptor on bronchial smooth muscle: bronchoconstriction, mucus secretion, vascular permeability. Central mediators of asthma. Montelukast (Singulair): leukotriene receptor antagonist, used daily for asthma maintenance. Also effective in exercise-induced and aspirin-exacerbated asthma. FDA black box warning (2020) for neuropsychiatric events.", "Stryer 9th ed, Ch 22; Lehninger 8th ed, Ch 21") }

    return eico(0, "", "", "", "", "", "", "", "", "")
}

fn eicosanoid_step_count() -> Int {
    return 12
}

fn aspirin_mechanism() -> String {
    return "Aspirin (acetylsalicylic acid) irreversibly acetylates Ser530 in COX-1 (P23219) and Ser516 in COX-2 (P35354). Acetyl group covalently blocks the cyclooxygenase active site channel, preventing arachidonic acid access. Irreversible because the acetyl group is permanently attached (unlike ibuprofen which is reversible). Platelet-specific effect at low dose (81 mg): platelets express only COX-1 and CANNOT resynthesize it (anucleate). Single dose inhibits all existing platelet TXA2 production for platelet lifetime (7-10 days). Endothelial COX-2 IS resynthesized, so PGI2 production recovers. Net low-dose effect: anti-thrombotic. Discovery: Vane JR. Nature New Biol 231:232-235, 1971 (Nobel Prize 1982). Aspirin also triggers production of lipoxins (anti-inflammatory resolvins) via acetylated COX-2, a mechanism discovered by Serhan CN, contributing to aspirin's anti-inflammatory resolution effects."
}

fn nsaid_comparison(drug: String) -> String {
    if drug == "aspirin" { return "Irreversible COX-1/COX-2 inhibitor. Low dose (81mg): antiplatelet. High dose (650-1000mg): analgesic, antipyretic, anti-inflammatory. Reye syndrome risk in children with viral illness." }
    if drug == "ibuprofen" { return "Reversible, non-selective COX-1/COX-2 inhibitor. 200-800mg. Analgesic, antipyretic, anti-inflammatory. GI and renal side effects. Can interfere with aspirin's antiplatelet effect if taken concurrently (competes for COX-1 Ser530 access)." }
    if drug == "naproxen" { return "Reversible, non-selective COX inhibitor. Longer half-life (12-17h) than ibuprofen. Possibly lowest cardiovascular risk among NSAIDs. GI side effects." }
    if drug == "celecoxib" { return "COX-2 selective inhibitor (Celebrex). Sulfonamide. Less GI toxicity than non-selective NSAIDs (spares COX-1 gastroprotection). Cardiovascular risk: lower than rofecoxib but still debated. Contraindicated in sulfonamide allergy." }
    if drug == "indomethacin" { return "Non-selective, very potent COX inhibitor. Used for gout, patent ductus arteriosus closure in neonates (PGE2 keeps ductus open; indomethacin closes it). High GI toxicity." }
    return ""
}

// ═══════════════════════════════════════════════════════════════════
// SECTION G: QUICK-ACCESS COUNTS AND SUMMARIES
// ═══════════════════════════════════════════════════════════════════

fn lipid_module_total_steps() -> Int {
    // FA synthesis (nine) + beta-ox (eight) + ketones (eight) + cholesterol (twelve) + eicosanoids (twelve) = forty-nine
    return 49
}

fn lipid_module_total_enzymes() -> Int {
    // Unique enzymes encoded across all sections (approximate, counting distinct accessions)
    return 42
}

fn lipid_module_sections() -> Int {
    return 6
}

fn fed_vs_fasted_summary() -> String {
    return "FED STATE (insulin high, glucagon low): ACC active (dephosphorylated) -> malonyl-CoA HIGH -> CPT-I inhibited -> beta-oxidation OFF. FASN active. SREBP-1c active -> lipogenesis genes ON. VLDL export from liver. Adipose LPL active (insulin-induced) -> TG uptake. FASTED STATE (glucagon high, insulin low): AMPK phosphorylates ACC -> malonyl-CoA LOW -> CPT-I active -> beta-oxidation ON. Hormone-sensitive lipase (HSL, Q05469) active in adipose -> free fatty acid release. Hepatic ketogenesis activated (HMGCS2). SREBP processing reduced. This reciprocal regulation through malonyl-CoA is THE master switch between lipid synthesis and oxidation. McGarry JD, Foster DW. Annu Rev Biochem 49:395-420, 1980."
}

fn omega3_vs_omega6() -> String {
    return "Omega-6 (linoleic acid C18:2 -> arachidonic acid C20:4): precursor to pro-inflammatory eicosanoids (PGE2, TXA2, LTB4). Omega-3 (alpha-linolenic acid C18:3 -> EPA C20:5 -> DHA C22:6): EPA competes with arachidonic acid for COX and LOX, producing less inflammatory series-3 prostaglandins (PGE3, PGI3) and series-5 leukotrienes (LTB5, weaker chemoattractant). Also precursor to resolvins and protectins (Serhan CN, pro-resolution mediators). Both are essential fatty acids (cannot be synthesized de novo). Western diet: omega-6/omega-3 ratio ~15:1 (pro-inflammatory). Target ratio ~4:1. Fish oil supplementation increases EPA/DHA, shifting eicosanoid balance toward anti-inflammatory. Cited: Calder PC. Am J Clin Nutr 83:S1505-S1519, 2006."
}

fn pcsk9_mechanism() -> String {
    return "PCSK9 (P04114... Q8NBP7, PCSK9): serine protease secreted by liver. Binds extracellular EGF-A domain of LDLR on hepatocyte surface. When LDLR-LDL complex is internalized, PCSK9 binding prevents LDLR recycling: receptor is directed to lysosome for degradation instead of recycling to surface. Net effect: fewer LDLRs -> less LDL clearance -> higher blood LDL. PCSK9 gain-of-function mutations: FH phenotype. PCSK9 loss-of-function (e.g., C679X in some African Americans): lifelong low LDL, 88% reduction in coronary events. PCSK9 inhibitors: evolocumab (Repatha) and alirocumab (Praluent) are monoclonal antibodies. Inclisiran is siRNA targeting hepatic PCSK9 mRNA (twice-yearly injection). All reduce LDL by 50-60% on top of statins. Cited: Cohen JC et al. N Engl J Med 354:1264-1272, 2006."
}
