How to layer control rig with a state machine?

I strongly suggest you to take a look at Lincoln Margison on Udemy, he made some pretty good Control Rig focused tutorials which may help you understanding how Control Rig works in detail and allows you to build whatever you need.