// receptor_pharmacology.sy -- Drug-receptor interactions, signal transduction,
// and clinical pharmacology as native Scyla.
//
// Sources:
//   Brunton LL et al. Goodman and Gilman's, 14th ed, McGraw-Hill, 2023.
//   Rang HP et al. Rang and Dale's Pharmacology, 9th ed, Elsevier, 2020.
//   Kenakin T. A Pharmacology Primer, 6th ed, Academic Press, 2019.
//
// Marjorie McCubbins + Aether, April 2026
// Patent pending: 64/034,536

struct ReceptorEntry {
    name: String,
    superfamily: String,
    g_protein: String,
    mechanism: String,
    endogenous_ligand: String,
    tissue: String,
    clinical_drugs: String,
    citation: String,
}

struct DrugReceptorPair {
    drug_name: String,
    receptor: String,
    action_type: String,
    clinical_use: String,
    citation: String,
}

struct SignalCascadeEntry {
    name: String,
    pathway: String,
    citation: String,
}

fn rentry(n: String, sf: String, gp: String, m: String, el: String, ti: String, cd: String, ci: String) -> ReceptorEntry {
    return ReceptorEntry { name: n, superfamily: sf, g_protein: gp, mechanism: m, endogenous_ligand: el, tissue: ti, clinical_drugs: cd, citation: ci }
}

fn drpair(dn: String, r: String, at: String, cu: String, ci: String) -> DrugReceptorPair {
    return DrugReceptorPair { drug_name: dn, receptor: r, action_type: at, clinical_use: cu, citation: ci }
}

fn scentry(n: String, p: String, ci: String) -> SignalCascadeEntry {
    return SignalCascadeEntry { name: n, pathway: p, citation: ci }
}

fn unknown_receptor() -> ReceptorEntry {
    return rentry("", "", "", "", "", "", "", "")
}

fn unknown_drug_receptor() -> DrugReceptorPair {
    return drpair("", "", "", "", "")
}

// =========================================================
// GPCR -- Gs COUPLED (stimulate adenylyl cyclase, increase cAMP)
// =========================================================

fn receptor(name: String) -> ReceptorEntry {
    // Gs-coupled
    if name == "beta1" { return rentry("Beta-1 adrenergic", "GPCR", "Gs", "Increases cAMP via adenylyl cyclase. Increases heart rate (chronotropy), contractility (inotropy), conduction velocity (dromotropy), renin release.", "Norepinephrine, epinephrine", "Heart (SA node, AV node, ventricles), JG cells of kidney", "Agonists: dobutamine, isoproterenol. Antagonists: metoprolol, atenolol, bisoprolol, esmolol, nebivolol", "Goodman and Gilman 14th ed Ch 12") }
    if name == "beta2" { return rentry("Beta-2 adrenergic", "GPCR", "Gs", "Increases cAMP. Bronchodilation, vasodilation, uterine relaxation, glycogenolysis, tremor.", "Epinephrine", "Bronchial smooth muscle, vascular smooth muscle, uterus, liver, skeletal muscle", "Agonists: albuterol, salmeterol, formoterol, terbutaline. Antagonists: propranolol (non-selective)", "Goodman and Gilman 14th ed Ch 12") }
    if name == "D1" { return rentry("Dopamine D1", "GPCR", "Gs", "Increases cAMP. Vasodilation (renal, mesenteric, coronary). Smooth muscle relaxation.", "Dopamine", "Renal vasculature, brain (cortex, striatum), smooth muscle", "Agonist: fenoldopam (renal vasodilation). No selective D1 antagonist in clinical use.", "Goodman and Gilman 14th ed Ch 13") }
    if name == "H2" { return rentry("Histamine H2", "GPCR", "Gs", "Increases cAMP. Stimulates gastric acid secretion (parietal cells). Increases heart rate.", "Histamine", "Gastric parietal cells, heart, vascular smooth muscle", "Antagonists: famotidine, ranitidine (withdrawn), cimetidine. PPIs largely replaced H2 blockers.", "Goodman and Gilman 14th ed Ch 39") }
    if name == "V2" { return rentry("Vasopressin V2", "GPCR", "Gs", "Increases cAMP in collecting duct. Inserts aquaporin-2 (AQP2) into apical membrane. Water reabsorption.", "ADH (vasopressin)", "Kidney collecting duct principal cells", "Agonist: desmopressin (DDAVP, for diabetes insipidus, von Willebrand). Antagonist: tolvaptan (SIADH).", "Goodman and Gilman 14th ed Ch 25") }
    if name == "5HT4" { return rentry("Serotonin 5-HT4", "GPCR", "Gs", "Increases cAMP. Enhances GI motility (prokinetic). Enhances ACh release in GI tract.", "Serotonin (5-HT)", "GI tract (enteric neurons), heart, brain", "Agonists: prucalopride (chronic constipation), tegaserod (IBS-C, restricted).", "Rang and Dale 9th ed Ch 30") }

    // Gi-coupled (inhibit adenylyl cyclase, decrease cAMP)
    if name == "alpha2" { return rentry("Alpha-2 adrenergic", "GPCR", "Gi", "Decreases cAMP. Presynaptic: inhibits NE release (autoreceptor). Central: decreases sympathetic outflow. Peripheral: vasoconstriction (postsynaptic).", "Norepinephrine", "CNS (locus coeruleus), presynaptic nerve terminals, platelets, pancreas", "Agonists: clonidine (hypertension, ADHD, withdrawal), dexmedetomidine (sedation), brimonidine (glaucoma). Antagonist: yohimbine.", "Goodman and Gilman 14th ed Ch 12") }
    if name == "D2" { return rentry("Dopamine D2", "GPCR", "Gi", "Decreases cAMP. Inhibits prolactin release. Modulates motor control. Presynaptic autoreceptor.", "Dopamine", "Brain (striatum, limbic, pituitary), CTZ", "Antagonists: haloperidol, chlorpromazine, risperidone (antipsychotics). Agonists: bromocriptine, cabergoline (prolactinoma). Partial agonist: aripiprazole.", "Goodman and Gilman 14th ed Ch 16") }
    if name == "mu_opioid" { return rentry("Mu opioid (MOR)", "GPCR", "Gi", "Decreases cAMP. Opens K+ channels (hyperpolarization). Closes Ca2+ channels. Analgesia, euphoria, respiratory depression, miosis, constipation, physical dependence.", "Beta-endorphin, enkephalins", "Brain (PAG, thalamus, cortex), spinal cord (dorsal horn), GI tract (myenteric plexus)", "Agonists: morphine, fentanyl, oxycodone, hydromorphone, methadone. Partial: buprenorphine. Antagonists: naloxone, naltrexone.", "Goodman and Gilman 14th ed Ch 20") }
    if name == "delta_opioid" { return rentry("Delta opioid (DOR)", "GPCR", "Gi", "Decreases cAMP. Analgesia (spinal, supraspinal), antidepressant-like effects. Less respiratory depression than mu.", "Enkephalins (met-enkephalin, leu-enkephalin)", "Brain, spinal cord, peripheral sensory neurons", "No selective agonist in clinical use. Naltrexone blocks delta and mu.", "Goodman and Gilman 14th ed Ch 20") }
    if name == "kappa_opioid" { return rentry("Kappa opioid (KOR)", "GPCR", "Gi", "Decreases cAMP. Analgesia (spinal), dysphoria, sedation, diuresis. Does NOT cause respiratory depression at analgesic doses.", "Dynorphins", "Brain (hypothalamus, cortex), spinal cord", "Agonist: pentazocine (mixed agonist-antagonist). Antagonist: norbinaltorphimine (research). Salvinorin A (Salvia divinorum, selective KOR agonist).", "Goodman and Gilman 14th ed Ch 20") }
    if name == "M2" { return rentry("Muscarinic M2", "GPCR", "Gi", "Decreases cAMP. Opens GIRK K+ channels. Decreases heart rate (negative chronotropy). Decreases AV conduction.", "Acetylcholine", "Heart (SA node, AV node, atria)", "Non-selective antagonist: atropine (bradycardia). No selective M2 drugs in clinical use.", "Goodman and Gilman 14th ed Ch 9") }
    if name == "5HT1A" { return rentry("Serotonin 5-HT1A", "GPCR", "Gi", "Decreases cAMP. Somatodendritic autoreceptor on serotonin neurons (raphe nuclei). Presynaptic: decreases 5-HT release. Postsynaptic: hyperpolarization.", "Serotonin (5-HT)", "Brain (raphe nuclei, hippocampus, cortex)", "Partial agonist: buspirone (generalized anxiety). SSRIs indirectly desensitize 5-HT1A autoreceptors (delayed therapeutic effect).", "Goodman and Gilman 14th ed Ch 15") }
    if name == "CB1" { return rentry("Cannabinoid CB1", "GPCR", "Gi", "Decreases cAMP. Inhibits presynaptic neurotransmitter release (retrograde signaling). Analgesia, appetite stimulation, antiemesis, euphoria.", "Anandamide (AEA), 2-arachidonoylglycerol (2-AG)", "Brain (cortex, hippocampus, basal ganglia, cerebellum), peripheral nerves", "Agonist: dronabinol (THC, appetite/nausea). Inverse agonist: rimonabant (withdrawn, psychiatric ADRs).", "Goodman and Gilman 14th ed Ch 21") }

    // Gq-coupled (activate PLC, increase IP3 + DAG -> Ca2+ + PKC)
    if name == "alpha1" { return rentry("Alpha-1 adrenergic", "GPCR", "Gq", "Activates PLC -> IP3 + DAG. IP3 releases Ca2+ from SR. Vasoconstriction, mydriasis, urethral contraction, glycogenolysis.", "Norepinephrine, epinephrine", "Vascular smooth muscle, iris radial muscle, bladder/prostate, liver", "Agonists: phenylephrine (nasal decongestant, hypotension). Antagonists: prazosin, doxazosin, tamsulosin, terazosin (BPH, hypertension).", "Goodman and Gilman 14th ed Ch 12") }
    if name == "M1" { return rentry("Muscarinic M1", "GPCR", "Gq", "Activates PLC. Increases IP3/DAG. Enhances cognitive function. Stimulates gastric acid secretion.", "Acetylcholine", "Brain (cortex, hippocampus), gastric parietal cells, autonomic ganglia", "Antagonist: pirenzepine (peptic ulcer, some countries). Donepezil increases ACh at M1 indirectly.", "Goodman and Gilman 14th ed Ch 9") }
    if name == "M3" { return rentry("Muscarinic M3", "GPCR", "Gq", "Activates PLC. Smooth muscle contraction (bronchi, GI, bladder). Glandular secretion (salivary, lacrimal, sweat). Endothelial NO release (vasodilation).", "Acetylcholine", "Smooth muscle (bronchi, GI, bladder), exocrine glands, vascular endothelium, eye (ciliary muscle)", "Agonist: pilocarpine (glaucoma, dry mouth). Antagonists: ipratropium (COPD), tiotropium (COPD), oxybutynin (overactive bladder), scopolamine (motion sickness).", "Goodman and Gilman 14th ed Ch 9") }
    if name == "H1" { return rentry("Histamine H1", "GPCR", "Gq", "Activates PLC. Vasodilation (NO-mediated), increased vascular permeability, bronchoconstriction, pruritus, wakefulness.", "Histamine", "Vascular endothelium, bronchial smooth muscle, sensory nerves, brain (tuberomammillary nucleus)", "First-gen antagonists (sedating): diphenhydramine, chlorpheniramine, hydroxyzine. Second-gen (non-sedating): cetirizine, loratadine, fexofenadine.", "Goodman and Gilman 14th ed Ch 39") }
    if name == "5HT2A" { return rentry("Serotonin 5-HT2A", "GPCR", "Gq", "Activates PLC. Vasoconstriction. Platelet aggregation. Hallucinations (cortical). Smooth muscle contraction.", "Serotonin (5-HT)", "Brain (cortex layer V pyramidal neurons), platelets, vascular smooth muscle", "Antagonists: risperidone, olanzapine, quetiapine (atypical antipsychotics). Agonists: psilocybin, LSD, DMT (psychedelics, research).", "Goodman and Gilman 14th ed Ch 16") }
    if name == "AT1" { return rentry("Angiotensin AT1", "GPCR", "Gq", "Activates PLC. Vasoconstriction. Aldosterone secretion. Cardiac hypertrophy. Sympathetic activation. Renal sodium reabsorption.", "Angiotensin II", "Vascular smooth muscle, adrenal cortex (zona glomerulosa), heart, kidney, brain", "Antagonists (ARBs): losartan, valsartan, irbesartan, olmesartan, candesartan, telmisartan. ACE inhibitors block Ang II formation upstream.", "Goodman and Gilman 14th ed Ch 26") }

    // Ion channels
    if name == "nAChR_Nm" { return rentry("Nicotinic ACh receptor (neuromuscular, Nm)", "Ligand-gated ion pore", "", "Na+/K+ nonselective cation influx. Endplate depolarization -> muscle contraction.", "Acetylcholine", "Neuromuscular junction (motor end plate)", "Depolarizing blocker: succinylcholine (Phase I block). Non-depolarizing: rocuronium, vecuronium, cisatracurium, pancuronium. Reversal: neostigmine, sugammadex (rocuronium).", "Goodman and Gilman 14th ed Ch 11") }
    if name == "GABA_A" { return rentry("GABA-A receptor", "Ligand-gated ion pore", "", "Cl- influx -> hyperpolarization -> inhibition. Major inhibitory receptor in CNS. Five subunits (2a, 2b, 1g most common).", "GABA", "Brain (ubiquitous), spinal cord", "Positive allosteric modulators (PAMs): benzodiazepines (diazepam, midazolam, lorazepam -- bind alpha/gamma interface), barbiturates (phenobarbital), propofol, etomidate, neurosteroids, alcohol. Antagonist: flumazenil (benzo reversal).", "Goodman and Gilman 14th ed Ch 15") }
    if name == "NMDA" { return rentry("NMDA glutamate receptor", "Ligand-gated ion pore", "", "Ca2+/Na+ influx. Voltage-dependent Mg2+ block (removed by depolarization). Requires glutamate + glycine co-agonist. Learning, memory (LTP), excitotoxicity.", "Glutamate + glycine", "Brain (hippocampus, cortex), spinal cord", "Antagonists: memantine (Alzheimer, low-affinity open-channel block), ketamine (anesthesia, depression at sub-anesthetic doses), MK-801 (research), phencyclidine (PCP, abuse). Mg2+ is endogenous blocker.", "Goodman and Gilman 14th ed Ch 14") }
    if name == "AMPA" { return rentry("AMPA glutamate receptor", "Ligand-gated ion pore", "", "Na+/K+ influx (Ca2+ if GluA2 subunit absent). Fast excitatory transmission. Depolarizes membrane to relieve NMDA Mg2+ block.", "Glutamate", "Brain (ubiquitous, all excitatory synapses)", "Antagonist: perampanel (epilepsy, selective AMPA antagonist). No agonists in clinical use.", "Goodman and Gilman 14th ed Ch 14") }
    if name == "5HT3" { return rentry("Serotonin 5-HT3", "Ligand-gated ion pore", "", "Na+/K+ cation influx. Depolarization. Located on vagal afferents in GI (triggers vomiting). Also in area postrema (CTZ).", "Serotonin (5-HT)", "GI tract (vagal afferents), brain (area postrema, NTS), peripheral sensory neurons", "Antagonists: ondansetron, granisetron, palonosetron (antiemetics, chemotherapy-induced and post-op nausea/vomiting).", "Goodman and Gilman 14th ed Ch 50") }

    // Receptor tyrosine kinases
    if name == "EGFR" { return rentry("Epidermal Growth Factor Receptor (EGFR/HER1/ErbB1)", "Receptor Tyrosine Kinase", "", "Ligand binding -> dimerization -> autophosphorylation -> Ras/MAPK, PI3K/AKT, STAT pathways. Cell proliferation, survival, migration.", "EGF, TGF-alpha, amphiregulin", "Epithelial cells (lung, colon, breast, brain)", "TKIs: erlotinib, gefitinib, osimertinib (NSCLC, EGFR-mutant). mAbs: cetuximab, panitumumab (colorectal, head/neck). Resistance: T790M mutation (osimertinib overcomes).", "Goodman and Gilman 14th ed Ch 66") }
    if name == "HER2" { return rentry("HER2 (ErbB2)", "Receptor Tyrosine Kinase", "", "No known ligand (orphan receptor). Preferred dimerization partner for other ErbB receptors. Amplified/overexpressed in ~20% breast cancers. Constitutive kinase activity when overexpressed.", "None (orphan, heterodimerizes)", "Normal: low levels ubiquitous. Cancer: amplified in breast, gastric, esophageal", "mAbs: trastuzumab (Herceptin), pertuzumab. ADC: trastuzumab-emtansine (T-DM1), trastuzumab-deruxtecan (T-DXd). TKI: lapatinib, tucatinib, neratinib.", "Goodman and Gilman 14th ed Ch 66") }
    if name == "VEGFR" { return rentry("VEGF Receptor (VEGFR-2/KDR)", "Receptor Tyrosine Kinase", "", "VEGF binding -> dimerization -> angiogenesis (new blood vessel formation). Tumors require angiogenesis to grow beyond 1-2 mm.", "VEGF-A, VEGF-B, VEGF-C, PlGF", "Vascular endothelial cells", "Anti-VEGF mAb: bevacizumab (Avastin, colorectal, NSCLC, renal, GBM). VEGF trap: aflibercept. TKIs: sunitinib, sorafenib, pazopanib, axitinib, cabozantinib, lenvatinib.", "Goodman and Gilman 14th ed Ch 66") }
    if name == "insulin_receptor" { return rentry("Insulin Receptor", "Receptor Tyrosine Kinase", "", "Insulin binds alpha subunit -> beta subunit autophosphorylation -> IRS-1 -> PI3K -> AKT -> GLUT4 translocation, glycogen synthesis, lipogenesis, protein synthesis. Also Ras/MAPK (growth).", "Insulin", "Liver, muscle, adipose (metabolic). Ubiquitous (growth).", "Insulin analogs: rapid (lispro, aspart, glulisine), long (glargine, detemir, degludec). Sensitizers: metformin (not receptor), thiazolidinediones (PPAR-gamma).", "Goodman and Gilman 14th ed Ch 47") }
    if name == "c_KIT" { return rentry("c-KIT (CD117)", "Receptor Tyrosine Kinase", "", "SCF binding -> dimerization -> autophosphorylation -> Ras/MAPK, PI3K/AKT. Hematopoietic stem cell proliferation, mast cell development, melanocyte migration, GI pacemaker (ICC).", "Stem Cell Factor (SCF)", "Hematopoietic stem cells, mast cells, interstitial cells of Cajal, melanocytes", "TKI: imatinib (GIST with KIT mutation, first-line). Sunitinib, regorafenib (GIST second/third line). Avapritinib (PDGFRA D842V GIST).", "Goodman and Gilman 14th ed Ch 66") }

    // Nuclear receptors
    if name == "GR" { return rentry("Glucocorticoid Receptor (NR3C1)", "Nuclear Receptor", "", "Ligand crosses membrane -> binds cytoplasmic GR -> HSP90 dissociates -> GR dimerizes -> translocates to nucleus -> binds GRE -> transactivation (anti-inflammatory genes) and transrepression (NF-kB, AP-1). Genomic effects take hours.", "Cortisol", "Ubiquitous (every nucleated cell)", "Agonists: prednisone, prednisolone, methylprednisolone, dexamethasone, hydrocortisone, budesonide, fluticasone. Antagonist: mifepristone (RU-486, also PR antagonist).", "Goodman and Gilman 14th ed Ch 46") }
    if name == "ER_alpha" { return rentry("Estrogen Receptor alpha (ESR1)", "Nuclear Receptor", "", "Estrogen binds ER -> dimerizes -> binds ERE -> transcription of target genes. Breast proliferation, endometrial growth, bone maintenance, cardiovascular protection, hepatic protein synthesis.", "Estradiol (E2), estrone (E1), estriol (E3)", "Breast, uterus, ovary, bone, liver, brain, cardiovascular", "SERMs: tamoxifen (ER antagonist in breast, agonist in bone/endometrium), raloxifene (bone, no endometrial stimulation). Aromatase inhibitors: letrozole, anastrozole, exemestane. SERD: fulvestrant. GnRH agonists suppress E2.", "Goodman and Gilman 14th ed Ch 45") }
    if name == "AR" { return rentry("Androgen Receptor (NR3C4)", "Nuclear Receptor", "", "Testosterone/DHT binds AR -> translocates to nucleus -> binds ARE -> transcription. Male sexual development, muscle mass, bone density, erythropoiesis, prostate growth, hair (androgenic alopecia).", "Testosterone, dihydrotestosterone (DHT)", "Prostate, seminal vesicles, muscle, bone, hair follicles, brain", "Antagonists: enzalutamide, apalutamide, darolutamide (prostate cancer). Bicalutamide, flutamide (older). 5-alpha reductase inhibitors: finasteride, dutasteride (block T->DHT). GnRH agonists/antagonists suppress T.", "Goodman and Gilman 14th ed Ch 45") }
    if name == "PPAR_gamma" { return rentry("PPAR-gamma (NR1C3)", "Nuclear Receptor", "", "Ligand binds -> heterodimerizes with RXR -> binds PPRE -> transcription of adipogenesis, glucose uptake, insulin sensitization genes (GLUT4, adiponectin). The insulin sensitizer target.", "Fatty acids, prostaglandin J2", "Adipose tissue (primary), macrophages, muscle, liver", "Agonists: pioglitazone, rosiglitazone (thiazolidinediones, T2DM). ADRs: weight gain, fluid retention, HF exacerbation, fractures, bladder cancer (pioglitazone).", "Goodman and Gilman 14th ed Ch 47") }
    if name == "VDR" { return rentry("Vitamin D Receptor (NR1I1)", "Nuclear Receptor", "", "Calcitriol (1,25-dihydroxyvitamin D3) binds VDR -> heterodimerizes with RXR -> binds VDRE -> transcription. Increases intestinal Ca2+ absorption, bone mineralization, immune modulation.", "Calcitriol (1,25(OH)2D3)", "Intestine, bone, kidney, immune cells, skin", "Calcitriol, alfacalcidol (active vitamin D analogs). Cholecalciferol (D3), ergocalciferol (D2) = precursors requiring hepatic/renal activation.", "Goodman and Gilman 14th ed Ch 48") }

    return unknown_receptor()
}

// =========================================================
// PHARMACOLOGY CALCULATIONS
// =========================================================

// Hill equation dose-response: E = Emax * D^n / (EC50^n + D^n)
fn dose_response(dose: Float, emax: Float, ec50: Float, hill_n: Float) -> Float {
    let d_n = pow(dose, hill_n)
    let ec_n = pow(ec50, hill_n)
    return emax * d_n / (ec_n + d_n)
}

// Receptor occupancy (Clark equation): fraction = [D] / ([D] + Kd)
// Clark AJ. J Physiol 61:530-546, 1926.
fn receptor_occupancy(conc: Float, kd: Float) -> Float {
    return conc / (conc + kd)
}

// Cheng-Prusoff equation: Ki = IC50 / (1 + [L]/Kd)
// Converts IC50 (competition assay) to true Ki (binding affinity).
// Cheng Y, Prusoff WH. Biochem Pharmacol 22:3099-3108, 1973.
fn ic50_to_ki(ic50: Float, ligand_conc: Float, kd: Float) -> Float {
    return ic50 / (1.0 + ligand_conc / kd)
}

// Selectivity ratio: fold = Ki_off_target / Ki_target
// Higher = more selective for target.
fn selectivity_ratio(ki_target: Float, ki_off_target: Float) -> Float {
    return ki_off_target / ki_target
}

// Therapeutic window: toxic_conc / ec50
fn therapeutic_window(ec50: Float, toxic_conc: Float) -> Float {
    return toxic_conc / ec50
}

// Potency comparison: fold = ec50_b / ec50_a
// If >1, drug A is more potent. Lower EC50 = more potent.
fn potency_comparison(ec50_a: Float, ec50_b: Float) -> Float {
    return ec50_b / ec50_a
}

// Schild equation: log(DR-1) = log[B] - log(Kb)
// DR = dose ratio in presence of competitive antagonist
fn schild_dose_ratio(antagonist_conc: Float, kb: Float) -> Float {
    return 1.0 + antagonist_conc / kb
}

// =========================================================
// SIGNAL TRANSDUCTION CASCADES
// =========================================================

fn signal_cascade(name: String) -> SignalCascadeEntry {
    if name == "gs" { return scentry("Gs pathway", "Agonist binds GPCR -> Gs alpha subunit exchanges GDP for GTP -> Gs-alpha activates adenylyl cyclase (AC) -> AC converts ATP to cAMP -> cAMP activates protein kinase A (PKA) -> PKA phosphorylates target proteins. Terminated by PDE (phosphodiesterase) degrading cAMP. PDE inhibitors: sildenafil (PDE5), milrinone (PDE3), caffeine (nonselective).", "Goodman and Gilman 14th ed Ch 3") }
    if name == "gi" { return scentry("Gi pathway", "Agonist binds GPCR -> Gi alpha subunit exchanges GDP for GTP -> Gi-alpha INHIBITS adenylyl cyclase -> decreased cAMP -> decreased PKA activity. Gi beta-gamma subunit opens GIRK K+ channels (cardiac slowing) and inhibits voltage-gated Ca2+ channels. Pertussis toxin ADP-ribosylates Gi, locking it inactive.", "Goodman and Gilman 14th ed Ch 3") }
    if name == "gq" { return scentry("Gq pathway", "Agonist binds GPCR -> Gq alpha activates phospholipase C-beta (PLC-beta) -> PLC cleaves PIP2 into IP3 + DAG. IP3 binds IP3R on ER -> releases Ca2+ into cytoplasm -> activates calmodulin, contraction, secretion. DAG activates protein kinase C (PKC) -> phosphorylation of targets. Terminated by DAG kinase and IP3 phosphatases.", "Goodman and Gilman 14th ed Ch 3") }
    if name == "rtk_mapk" { return scentry("RTK/MAPK pathway", "Ligand binds RTK -> receptor dimerization -> autophosphorylation of tyrosine residues -> Grb2 adaptor binds -> SOS (GEF) activates Ras (GDP->GTP) -> Ras activates Raf (MAPKKK) -> Raf phosphorylates MEK (MAPKK) -> MEK phosphorylates ERK (MAPK) -> ERK enters nucleus -> activates transcription factors (Elk-1, c-Myc, c-Fos). Drives cell proliferation. Mutations in Ras (~30% cancers) and Raf (BRAF V600E in melanoma).", "Goodman and Gilman 14th ed Ch 3") }
    if name == "jak_stat" { return scentry("JAK-STAT pathway", "Cytokine binds receptor -> receptor-associated JAK kinases (JAK1, JAK2, JAK3, TYK2) transphosphorylate -> phosphorylated receptor recruits STAT proteins -> JAK phosphorylates STATs -> STAT dimerizes -> enters nucleus -> binds DNA response elements -> transcription. JAK inhibitors: tofacitinib (JAK1/3, RA), baricitinib (JAK1/2, RA, COVID), ruxolitinib (JAK1/2, myelofibrosis, polycythemia vera).", "Goodman and Gilman 14th ed Ch 35") }
    if name == "nuclear_receptor" { return scentry("Nuclear receptor pathway", "Lipophilic ligand (steroid, thyroid hormone, vitamin D, retinoid) crosses plasma membrane by diffusion -> binds intracellular/nuclear receptor -> receptor undergoes conformational change -> dimerizes (homodimer: steroid receptors; heterodimer with RXR: thyroid, vitamin D, PPAR) -> binds hormone response element (HRE) on DNA -> recruits coactivators or corepressors -> modulates gene transcription. Genomic effects: hours to days. Nongenomic effects: seconds to minutes (membrane-associated receptors).", "Goodman and Gilman 14th ed Ch 3") }
    return scentry("", "", "")
}

// =========================================================
// DRUG-RECEPTOR PAIRS (top clinical drugs)
// =========================================================

fn drug_receptor(drug_name: String) -> DrugReceptorPair {
    if drug_name == "METOPROLOL" { return drpair("METOPROLOL", "Beta-1", "Selective antagonist", "Hypertension, HFrEF, post-MI, rate control in AFib", "G&G 14th ed Ch 12") }
    if drug_name == "ALBUTEROL" { return drpair("ALBUTEROL", "Beta-2", "Selective agonist", "Acute bronchospasm (asthma, COPD rescue inhaler)", "G&G 14th ed Ch 12") }
    if drug_name == "MORPHINE" { return drpair("MORPHINE", "Mu opioid", "Full agonist", "Severe pain, acute MI, pulmonary edema", "G&G 14th ed Ch 20") }
    if drug_name == "NALOXONE" { return drpair("NALOXONE", "Mu/delta/kappa opioid", "Competitive antagonist", "Opioid overdose reversal (Narcan)", "G&G 14th ed Ch 20") }
    if drug_name == "BUPRENORPHINE" { return drpair("BUPRENORPHINE", "Mu opioid", "Partial agonist (+ kappa antagonist)", "Opioid use disorder (Suboxone with naloxone), chronic pain", "G&G 14th ed Ch 20") }
    if drug_name == "LOSARTAN" { return drpair("LOSARTAN", "AT1", "Competitive antagonist", "Hypertension, diabetic nephropathy, HF if ACEi-intolerant", "G&G 14th ed Ch 26") }
    if drug_name == "SERTRALINE" { return drpair("SERTRALINE", "SERT (serotonin transporter)", "Reuptake inhibitor", "Depression, OCD, PTSD, panic disorder, social anxiety", "G&G 14th ed Ch 15") }
    if drug_name == "DIAZEPAM" { return drpair("DIAZEPAM", "GABA-A", "Positive allosteric modulator (alpha/gamma interface)", "Anxiety, seizures, muscle spasm, alcohol withdrawal, procedural sedation", "G&G 14th ed Ch 15") }
    if drug_name == "HALOPERIDOL" { return drpair("HALOPERIDOL", "D2", "Antagonist", "Schizophrenia, acute psychosis, Tourette syndrome, acute agitation", "G&G 14th ed Ch 16") }
    if drug_name == "ARIPIPRAZOLE" { return drpair("ARIPIPRAZOLE", "D2", "Partial agonist (+ 5HT1A partial agonist, 5HT2A antagonist)", "Schizophrenia, bipolar, MDD augmentation, irritability in autism", "G&G 14th ed Ch 16") }
    if drug_name == "TAMOXIFEN" { return drpair("TAMOXIFEN", "ER-alpha", "SERM (antagonist in breast, agonist in bone/endometrium)", "ER+ breast cancer treatment and prevention. Risk: endometrial cancer, VTE.", "G&G 14th ed Ch 45") }
    if drug_name == "IMATINIB" { return drpair("IMATINIB", "BCR-ABL / c-KIT / PDGFR", "TKI (competitive at ATP-binding site)", "CML (Ph+ BCR-ABL), GIST (c-KIT mutation). Paradigm of targeted therapy.", "G&G 14th ed Ch 66") }
    if drug_name == "TRASTUZUMAB" { return drpair("TRASTUZUMAB", "HER2", "Monoclonal antibody (extracellular domain)", "HER2+ breast cancer, HER2+ gastric cancer. ADCC + receptor internalization.", "G&G 14th ed Ch 66") }
    if drug_name == "PREDNISONE" { return drpair("PREDNISONE", "GR (glucocorticoid receptor)", "Agonist", "Inflammation, autoimmune diseases, allergic reactions, asthma exacerbation, transplant rejection, adrenal insufficiency", "G&G 14th ed Ch 46") }
    if drug_name == "CLONIDINE" { return drpair("CLONIDINE", "Alpha-2", "Agonist (central)", "Hypertension, ADHD, opioid withdrawal, Tourette, menopausal flushing", "G&G 14th ed Ch 12") }
    if drug_name == "PRAZOSIN" { return drpair("PRAZOSIN", "Alpha-1", "Antagonist", "BPH, hypertension, PTSD nightmares", "G&G 14th ed Ch 12") }
    if drug_name == "IPRATROPIUM" { return drpair("IPRATROPIUM", "M3 muscarinic", "Antagonist (inhaled, non-selective muscarinic)", "COPD, acute asthma (with albuterol in nebulizer)", "G&G 14th ed Ch 9") }
    if drug_name == "PILOCARPINE" { return drpair("PILOCARPINE", "M3 muscarinic", "Agonist", "Glaucoma (contracts ciliary muscle, opens trabecular meshwork), dry mouth (Sjogren)", "G&G 14th ed Ch 9") }
    if drug_name == "SUMATRIPTAN" { return drpair("SUMATRIPTAN", "5-HT1B/1D", "Agonist", "Acute migraine (vasoconstriction of meningeal vessels, inhibits trigeminal nociception)", "G&G 14th ed Ch 15") }
    if drug_name == "ONDANSETRON" { return drpair("ONDANSETRON", "5-HT3", "Antagonist", "Chemotherapy-induced nausea/vomiting, post-op nausea, hyperemesis gravidarum", "G&G 14th ed Ch 50") }
    if drug_name == "DIPHENHYDRAMINE" { return drpair("DIPHENHYDRAMINE", "H1", "Antagonist (first-gen, crosses BBB)", "Allergic rhinitis, urticaria, insomnia, motion sickness, drug-induced EPS", "G&G 14th ed Ch 39") }
    if drug_name == "FAMOTIDINE" { return drpair("FAMOTIDINE", "H2", "Antagonist", "GERD, peptic ulcer, Zollinger-Ellison (adjunct)", "G&G 14th ed Ch 49") }
    if drug_name == "INSULIN" { return drpair("INSULIN", "Insulin receptor (RTK)", "Agonist", "Type 1 DM (all), Type 2 DM (advanced), DKA, hyperkalemia (drives K+ into cells)", "G&G 14th ed Ch 47") }
    if drug_name == "ERLOTINIB" { return drpair("ERLOTINIB", "EGFR", "TKI (reversible)", "NSCLC (EGFR exon 19 del or L858R), pancreatic cancer", "G&G 14th ed Ch 66") }
    if drug_name == "MEMANTINE" { return drpair("MEMANTINE", "NMDA", "Low-affinity open-channel blocker (uncompetitive antagonist)", "Moderate-severe Alzheimer disease. Blocks excitotoxicity without blocking normal transmission.", "G&G 14th ed Ch 18") }
    if drug_name == "KETAMINE" { return drpair("KETAMINE", "NMDA", "Non-competitive antagonist (dissociative)", "Anesthesia, treatment-resistant depression (esketamine/Spravato), procedural sedation", "G&G 14th ed Ch 22") }
    if drug_name == "NIVOLUMAB" { return drpair("NIVOLUMAB", "PD-1", "Monoclonal antibody (checkpoint inhibitor)", "Melanoma, NSCLC, RCC, Hodgkin lymphoma, head/neck, urothelial. Blocks PD-1/PD-L1 interaction, restores T cell anti-tumor immunity.", "G&G 14th ed Ch 66") }
    if drug_name == "ADALIMUMAB" { return drpair("ADALIMUMAB", "TNF-alpha", "Monoclonal antibody (neutralizing)", "RA, psoriasis, Crohn, UC, ankylosing spondylitis, JIA. Risk: serious infections, TB reactivation, lymphoma.", "G&G 14th ed Ch 35") }
    if drug_name == "PIOGLITAZONE" { return drpair("PIOGLITAZONE", "PPAR-gamma", "Agonist (thiazolidinedione)", "Type 2 DM (insulin sensitizer). ADRs: weight gain, edema, HF, fractures.", "G&G 14th ed Ch 47") }
    if drug_name == "PROPRANOLOL" { return drpair("PROPRANOLOL", "Beta-1 and Beta-2", "Non-selective antagonist", "Hypertension, migraine prophylaxis, essential tremor, performance anxiety, portal hypertension, thyroid storm, infantile hemangioma", "G&G 14th ed Ch 12") }
    return unknown_drug_receptor()
}

// =========================================================
// COUNTS
// =========================================================

fn receptor_count() -> Int {
    return 30
}

fn drug_receptor_pair_count() -> Int {
    return 30
}

fn signal_cascade_count() -> Int {
    return 6
}
