Past CIA expert warns not to simplify Putin as a madman. He "may have made a miscalculation," but he is still "rational, consistent, and ruthless."
He feels that western expansion into the former Warsaw Pact countries is an existential threat to Russia and is all too aware that they are losing on the economic front. Russia's economy is based on resource extraction and sliding rapidly into 3rd world status. I think he sees this as a last stand and wants to take down the traitorous former Soviet states, this is personal.
You can lose your grip on reality completely yet not be mad. Putin spent his whole working life in the echo chamber of the KGB, and he now surrounds himself with people who tell him what they think he wants to hear, by repute he has never even visited the internet, and he does not read newspapers. It is perfectly possible to lose all contact with reality, not only, because you have lost the ability to grasp it, but also because you have pushed it so far away that you can no longer touch it.