You wasnt lucid, It was a daydream from concentrating so long and sitting in the same position, your body must have relaxed to the point you went into minor sleep paralysis from not having enough sleep from the night before, though you didnt fall asleep because your main intention was to listen to the teacher.
I could be wrong, though i fell asleep in class a lot, due to not having enough sleep, and being really relaxed from sitting in one seat doing nothing but listening.