The US coal industry is imploding. And here's the biggest casualty yet: Peabody Energy, the world's largest private-sector coal company, filed for Chapter 11 bankruptcy in St. Louis on Wednesday.

It's hard to overstate what a seismic shift this is. Peabody has been a giant in the mining industry seemingly forever, after starting out in Chicago in 1880 with just a wagon and two mules. A decade ago, coal provided fully half of America's electricity, much of it dug up by Peabody in Illinois, Kentucky, Wyoming, Colorado. At its peak in 2008, the company had a market cap of $20 billion, supplying coal to 26 countries worldwide.

But then came the fall. The rise of fracking and cheap shale gas in the United States, coupled with stricter environmental regulations, has helped push hundreds of coal-fired power plants out of business in recent years. US coal production has nosedived from 1.17 billion metric tons in 2008 to just 752.5 million in 2016. Coal consumption in China, another crucial market, has also cooled off of late.

Between 2012 and 2015, Peabody laid off more than 20 percent of its global workforce and started closing some of its US mines. Today, the company is saddled with $10.1 billion in debt and its future looks much bleaker than it once did. Hence the bankruptcy filing.

Peabody made a disastrously bad bet on selling coal to China

Arguably Peabody's biggest mistake came in 2011, when it made a disastrous bet on Chinese coal demand.

At the time, the Chinese steel industry was roaring and the country's appetite for metallurgical coal — a lower-moisture type of coal used in coke production — appeared bottomless. Met coal prices were at an all-time high. So Peabody plunked down $5.1 billion to acquire Macarthur Coal, an Australian mining firm that supplied the steel industry.

That move blew up in Peabody's face. In the years since, China's demand for metallurgical coal has waned, as the nation's rapid industrial growth hit a saturation point. In the 2000s, China's steel production was growing a whopping 15.7 percent each year. In 2015, it actually declined 2.1 percent:

As the coal market started softening, Peabody CEO Gregory Boyce kept insisting that demand would rebound. It never did. The price of met coal ultimately fell 75 percent from its peak in 2011.

In the end, a number of US coal companies, including Peabody and Walter Energy, were stuck with a bunch of unprofitable met-coal investments at the exact same moment that demand for the thermal coal (or "steam coal") used in US power plants was also declining.

The result was a bloodbath across the entire industry:

On Wednesday, Peabody conceded that the situation had developed not necessarily to its advantage. "The factors affecting the global coal industry in recent years have been unprecedented," the company said in announcing its Chapter 11 filing. "Industry pressures in recent years include a dramatic drop in the price of metallurgical coal, weakness in the Chinese economy, overproduction of domestic shale gas and ongoing regulatory challenges."

Peabody clarified that all of its active mines and offices would continue to operate during the bankruptcy process. That includes the North Antelope Rochelle mine in Wyoming, the largest coal mine in America. The US filing would also not affect its mining operations in Australia.

Peabody is now the fifth US coal company to declare bankruptcy, joining giants such as Alpha Natural Resources and Arch Coal. Some of these companies will reorganize under Chapter 11 and carry on in diminished form — after all, coal still provides 28 percent of the nation's electricity, so someone has to mine it. But that fraction is expected to keep shrinking in the coming years, especially if Obama's Clean Power Plan pushes utilities to clean up their carbon-dioxide emissions. Coal will likely never regain the dominance it once enjoyed in the US.

Instead, Peabody is looking abroad. "Globally, thermal coal is expected to continue to fuel hundreds of existing coal generating plants as well as scores more that are under construction," the company said in a statement. (I've recently written about the hundreds of new coal plants being planned worldwide — it's unclear how many will get built.)

Peabody has been shedding obligations to retired miners (while executives got big bonuses)

Typically in bankruptcies, a big looming question is how any restructuring might affect pension and health care promises to workers. Peabody still has hundreds of millions of dollars in obligations to workers who helped dig up all of that coal, many of whom have developed serious health problems in the mines.

For now, the company says it does not expect any changes "to the vast majority of pension benefits" for current workers and retirees.

But that's not the end of the story. There's another gruesome twist here: Over the past decade, Peabody has been trying to get rid of obligations for thousands of other retired miners.

That story starts in 2007, when Peabody spun off 13 percent of its coal reserves into a brand-new company, Patriot Coal. It also, curiously, transferred 40 percent of its health obligations at the time, covering some 8,400 retired miners. Later on, Patriot also assumed some retiree obligations from Arch Coal, ending up with more than $3 billion in liabilities for some 22,000 miners, retirees, and spouses in all.

Then... Patriot went bankrupt. I'll let my colleague David Roberts tell the sordid tale:

Patriot Coal filed for bankruptcy in 2012. And it wasted no time asking a bankruptcy judge to let it jettison health care liabilities. (The judge said yes, just as she said yes two weeks prior when Patriot asked for permission to pay their executives almost $7 million in "retention bonuses.") Patriot had no loyalty to these retirees, of course. For the most part, they'd never even worked for Patriot. ... Ditching its obligations to workers — "restructuring," in the antiseptic language of corporate law — didn't save Patriot. It filed for bankruptcy again in 2015. Its efforts to escape its liabilities are ongoing.

Coal-employee pension funds have subsequently sued Peabody and Arch, accusing them of setting up Patriot to fail as a way of squirming out of their obligations. These "liabilities" included promised medical benefits to retired miners who are now dealing with black lung and other health problems. (I talked to a few of those retirees here.) The legal battles around responsibility for these workers are likely to rage for years to come.

By the way, if you're wondering how Peabody's executives are faring... A 2015 report from the Institute for Energy Economics and Financial Analysis found that the top five Peabody executives continued to reap their usual multimillion-dollar salaries during the period the company was careening toward ruin:

But even that's finally changing. According to Ben Storrow of Wyoming's Caspar-Star Tribune, Peabody is overhauling its management team and announced that "it has decreased annual cash incentive awards for executives and salaried employees by 50 percent."

Another big question: Will Peabody clean up its old coal mines?

It's not just miners and retirees who could be affected by the bankruptcy. Peabody Energy also has dozens of strip mines and underground coal mines in the West and Midwest that will ultimately need to be rehabbed once the digging stops. Clean-up typically involves restoring the scarred landscape, cleaning up water pollution, making sure there are no toxic metals leaking into nearby streams and groundwater sources.

According to a 1977 federal law, Peabody is technically responsible for cleaning up this mess. That cost has been estimated at around $1.4 billion.

But the company could try to wiggle out of some of those obligations in bankruptcy — which could in turn leave taxpayers on the hook for clean-up costs. A recent piece in the Washington Post by Steven Mufson and Joby Warrick explained the situation well:

The biggest coal companies typically pay third parties to ensure that mine sites are cleaned up in the event of financial hardship. But in recent years, many coal companies have relied on a cheaper technique called "self-bonding," pledging only their own names and financial wherewithal to guarantee their cleanup obligations. With mounting losses and debt loads, the companies do not have enough money to pay for all their obligations, and self-bonding is "not worth [the] paper [it’s] written on," Steve Jakubowski, a bankruptcy lawyer with the firm Robbins, Salomon & Patt, said in an email. ... Bankruptcy restructuring could provide coal companies with a way of escaping obligations to restore land.

This is a big story in Illinois, where, Mufson and Warrick write, "environmental groups and industry experts are closely watching three Peabody mines with cleanup obligations of $92 million covered by self-bonding."

Further reading:

-- 11 maps that explain energy in America

-- David Roberts took a longer look at Peabody's maneuvers to get rid of its obligations to former workers.

-- The real war on coal is happening in China right now

-- From a global perspective, note that hundreds of coal plants are still being planned worldwide.