// cascade_demo.sy — A biological cascade in Scyla
// Tests: use statements, nested structs, method chains,
//        named args, if/else, for loops, match expressions
// Aislinn McCubbins, April 2, 2026

use std::cascade

temporal struct Serotonin {
    state concentration: Float = 0.5,
    state vesicles: Float = 1.0,
    const half_life: Float = 360.0,
    const reuptake_rate: Float = 0.12,
    const synthesis_rate: Float = 0.003,
}

impl Evolve for Serotonin {
    fn evolve(&mut self, dt: Duration) {
        let decay = self.reuptake_rate * self.concentration
        let synthesis = self.synthesis_rate * (1.0 - self.concentration)
        self.concentration += (synthesis - decay) * dt.seconds()
        self.vesicles += 0.01 * (1.0 - self.vesicles) * dt.seconds()
    }
}

impl Serotonin {
    fn release(&mut self, intensity: Float) {
        let released = intensity * self.vesicles
        self.concentration += released
        self.vesicles -= released * 0.25
    }

    fn is_depleted(&self) -> Bool {
        self.vesicles < 0.1
    }

    fn status(&self) -> String {
        if self.concentration > 0.7 {
            return "elevated"
        } else if self.concentration > 0.3 {
            return "normal"
        } else {
            return "depleted"
        }
    }
}

fn main() {
    let mut serotonin = Serotonin {}

    // Stimulate
    serotonin.release(0.5)

    // Evolve for 10 minutes
    for step in 0..600 {
        serotonin.evolve(1.0.seconds)
    }

    // Check status
    let status = serotonin.status()
    println(status)

    if serotonin.is_depleted() {
        println("Warning: vesicle pool depleted")
    } else {
        println("Vesicles healthy")
    }

    // Report
    let conc = serotonin.concentration
    let pool = serotonin.vesicles
    println("Serotonin report complete")
}
