Venezuela is in the midst of a stunning social, political, and economic collapse. The country of 30 million people is facing dire food and medicine shortages, frequent power outages, serious political unrest, the world’s highest inflation rate, rampant violent crime, and one of the world’s highest murder rates. Earlier this month, Venezuela’s president, Nicolás Maduro, declared a state of emergency.

In short, Venezuela has become the world’s most visibly failing state.

It wasn’t supposed to go like this. Not so long ago, Venezuela’s socialist revolution attracted its share of fellow travelers — first-world idealists hungry for the next earthly utopia. Those folks are thin on the ground these days.

Here, then, is the story of how a relatively wealthy, relatively sophisticated country suddenly imploded under the weight of its own terrible choices — and why the worst may still be to come.

Chavismo’s disastrous policies created this nightmare

Venezuela’s collapse is the end result of two decades of chavismo: Venezuela’s own brand of aggressive left-wing populism, founded by the late Hugo Chávez and carried on today by his hand-picked successor, Maduro.

Taking his cue from Cuba’s Fidel Castro, Chávez saw the partnership between Venezuela’s business elite and the United States as the source of all of his country’s problems. To bring dignity and inclusion to Venezuela’s poor, he aggressively set out to break up that US-bourgeois alliance by minutely regulating every aspect of economic life and centralizing all decisions in his own hands.

The humanitarian tragedy these policies were creating was kept at bay, for much of the decade and a half, by sky-high oil prices, which buried Venezuela — a big-time oil exporter — under a tsunami of petrodollars.

Today that tsunami has receded, and what's left behind is the catastrophic consequences of the world’s most garishly mismanaged economy.

A wave of expropriations beginning in 2005 left most medium and large companies in state hands, to be run by bureaucrats who proved often venal and almost always incompetent. Even businesses left in private hands faced an unmanageable thicket of regulation over every imaginable aspect of their operations, hemming them in on all sides.

To take one example out of a million possibilities, it is now illegal for a dairy company to move raw milk from a collection center it owns to a processing facility it also owns 2 kilometers away without an explicit permit signed and stamped by a slew of government officials.

It is also illegal to fire a worker for basically any reason, including making threats of physical violence against a manager. And, needless to say, it is illegal to set your own prices: The state does that, often setting them below the cost of production, especially for basic goods. Under such circumstances, even "private" firms are in essence state run.

The Venezuelan economy today is a kind of caricature of US Republicans’ worst nightmares. The difference is that for us, it’s not just empty rhetoric: We actually do have a government that’s fanatically hostile to private enterprise and convinced that business poses an existential threat to it.

Fiscal policy is a disaster, too. Venezuela has been running enormous, unmanageable GDP deficits of more than 10 percent for years, even back when oil prices were high. Needless to say, it didn’t bother to save when the takings were good, and so it now finds itself facing a kind of fiscal Armageddon.

The government is so broke it can no longer afford to fly in the planefuls of fast-depreciating bolivar bills (the Venezuelan currency) it gets printed abroad; in effect, the country doesn’t have the money to pay for its money.

Unable to find enough investors foolhardy enough to lend it the shortfall, the government has given in to the temptation to just create money out of thin air to cover the difference, setting off a breathless monetary expansion that could see inflation top 2,200 percent in 2017.

In Venezuela today, more and more cash is chasing after fewer and fewer goods. The result looks very much like the old Soviet bloc economies, where people had plenty of money in their pockets but it didn’t help them because there were no goods on offer. In a strange way, chavismo has realized the old socialist dream of abolishing money: When there’s nothing to buy, money is useless.

Having either the world’s most punitively misconceived microeconomic policies or the world’s most mindlessly self-destructive macroeconomic policies would be bad enough, but having both of them at the same time is just killer.

Instead of trying to fix the economy, the government is blaming everything on a CIA conspiracy

One of the most fascinating twists of the past few years has been the government’s almost catatonic failure to grasp the connection between the policy choices it has made and the crisis raging all around it.

To economists of pretty much every persuasion, from the far right to the far left, the solution to the crisis is pretty straightforward: stabilize the currency, eliminate those wildly destructive price controls, and make sure spending is at least in the same ballpark as tax revenues.

But steeped in the kind of Marxist phraseology that was already out of date a generation ago, the clique around President Maduro seems genuinely convinced that all of the country’s problems are the result of a sprawling CIA conspiracy — "economic warfare," as official propaganda puts it. It’s insane, but within the tightly sealed circle of Marxist true believers around the president, this kind of lunacy never faces any serious pushback.

Venezuela’s long-suffering opposition, which won a landslide victory in last December’s legislative elections only to see virtually all of the National Assembly’s power pulled out from under it by a slavishly pro-government Supreme Tribunal, is trying hard to put an end to this catastrophe without tipping the country into an even worse disaster.

Venezuela’s constitution, which chavismo enacted in 1999 and began ignoring wholesale shortly thereafter, does allow for a recall referendum to cut the president’s term short. The opposition has begun collecting signatures to trigger such a vote, only to face a wall of foot dragging from a government determined to hang on at least through January of 2017: The constitution says that if Maduro is recalled after that, his vice president would finish out his term until 2019, rather than setting off a snap election.

The government is therefore determined to stall, even in violation of the rules it unilaterally approved for the recall.

The situation is incredibly volatile and could erupt into serious armed conflict

The government is playing with fire. It’s hard to overstate how volatile the social situation gets when you face critical shortages of food. With people forced to stand in line for four, five, six hours or more for basic staples — and even then sometimes leaving empty-handed — the social situation is combustible.

So far, looting has been only sporadic and localized, and security forces have been able to stamp out disorder before it has spread. But there are more and more of these looting episodes, and Venezuela has traumatic recent memories of what happens when food riots spread into nationwide convulsions of violence and mayhem.

Venezuela’s armed forces are caught in the middle. Though never an especially formidable fighting force, they’re still the best-armed body in the country. Maduro has already militarized much of the country’s security apparatus; the recent state-of-emergency decree leaves the country within a hair’s breadth of martial law. As the social crisis escalates, the government is relying more and more on the army for help keeping control of the country.

But while the military brass enjoys all the perks of life atop the revolutionary elite, the rank-and-file members are having just as much trouble finding food and medicine as everyone else in the country, turning the military into a kind of wild card, its loyalties too uncertain for anyone to know how they might react when push comes to shove.

In a scenario were looting spins out of control and an order comes down to repress it with deadly violence, nobody in Venezuela can really be confident that the soldiers would do as they’re told. It’s just as likely that the military chain of command would break down — a possibility the brass is keenly aware of.

Many Venezuelans — including many in the government itself — are convinced that the current crisis is leading inexorably to a coup attempt. Stuck between the current catastrophe and a government determined to block any peaceful outcome, someone – most often, in Latin America, a mid-ranking officer — is bound to rise up sooner or later.

If and when that happens, Venezuela will hold its collective breath. Anything could happen, from a straightforward palace coup leading to a relatively orderly transition to, in the worst case, an open rift between more or less evenly matched parts of the military, leading to the kind of conflict you shudder to even picture.

Even in the "best" of cases, though, where the military maintains its cohesion, a coup would be a calamity for Venezuela. For years, the strange, cultlike political movement that is chavismo has invested huge sums to prepare for just such a scenario.

The chavistas have gone to great lengths to ensure that the hardest of their hardcore supporters are well armed and organized into effective irregular fighting forces. In fact, Venezuela may be the only country in the world with a government-funded and -organized urban guerrilla force, set up proactively precisely to destabilize the country should the government that created it lose power.

But that’s Venezuela today: a country past the event horizon. We already have wartime levels of violence, even without a war. What happens if you mix an actual armed conflict on top of this reality doesn’t bear even thinking about for those who still have friends and relatives there.

Francisco Toro is founder and editor of the website Caracas Chronicles.

Why cab drivers earn more than doctors in Cuba