I suppose it could be an allergy, but my brain fog is clearly caused by anxiety. It's one of the symptoms you see listed everywhere. So is dizziness. Same goes for depression. When I have a day like that I joke with my friends that I've lost 30 IQ points, but it's not really a joke because that's what it does feel like.
And I have the sneaking suspicion that SOMETIMES (not all the time) my anxiety will actually make me think more clearly and effectively than usual. I've never been the type of person that could do anything but the simplest arithmetic in my head, for example, but now and then I have this weird clarity that allows me to do it. And that's not all. I can DESTROY people in Trivial Pursuit. But when I'm like that I'm sort of nervous or hyperactive. Acutely aware, easily startled. But it's not a panic attack, really. It doesn't feel unpleasant at all.
So, the point is, I think whatever chemicals cause us to have anxiety sometimes have different effects, too.