Here is my theory: While we sleep, our blood becomes more viscous, or thicker, because we aren't eating and drinking. Our blood volume decreases due to the lack of fluid (we become a little dehydrated). It's harder for your heart to pump this "thicker" blood, so your brain didn't receive the proper blood supply, and you almost fainted.
Also, your heart was in the "sleep mode", and the sympathetic part of your nervous system was slow to respond to your awakening and walking to the br.
Statistics show that most heart attacks occur early in the morning.
If you consume a lot of alcohol the last 2-3 hours before you go to bed, it can dehydrate you. Alcohol is a type of diuretic. Thirst comes with a hangover, lol.
I would see a Doc about this. Good luck