What most people haven't realized yet is the extent to which Donald Trump's election victory is the unintended legacy of President Obama.

When a party loses a presidential election, especially one as eminently winnable as this, the primary blame has to go to the candidate. Hillary Clinton was a deeply flawed, uncharismatic, scandal-plagued candidate who ran a lackluster, uninspiring campaign where her main strategy was simply to run out the clock. After this, Democrats are going to have to retire “Dukakis” as their byword for electoral failure and replace it with “Hillary.”

But what most people haven’t realized yet is the extent to which this election loss is also the legacy of President Obama, on five different levels.

1) Obama discouraged more electable alternatives to Hillary Clinton.

Over the course of last night, I watched a lot of Democrats talking themselves into the notion that they could have won this election if only they had nominated Bernie Sanders. That is almost certainly a delusion. Bernie Sanders is far, far to the left of the majority of voters, and if we weren’t talking about Hillary Clinton’s scandals, we’d be talking about how Jane Sanders pocketed big paychecks while running a college into the ground.

The fact is that the Democratic Party had a terrible roster of big-name political talent. The tragedy for Republicans is that they won this year with their worst candidate. The tragedy for Democrats is that they lost because they had no better candidate to offer. But why didn’t they? A lot of this has to do with Barack Obama’s unexpected victory in the 2008 Democratic primaries.

Obama defeated Hillary Clinton in 2008 by moving the Democrats to the left. He told them that they didn’t have to accept the compromises and pragmatic “triangulation” of the old Clinton administration. He swept them up in the belief in an idealistic leader who would pursue the full agenda of the left. His success swept away the last remnants of the old Democratic Leadership Caucus that had urged compromise and accommodation with the Reagan agenda.

The consequence of this is that the only viable alternative to Hillary Clinton was someone who opposed her from the far left, while an old-fashioned conservative Democrat like Jim Webb seemed obsolete and out of place. This, in turn, made it possible for Donald Trump to sweep away the votes of the blue-collar “Reagan Democrats” with no real resistance.

2) Obama’s mania for unpopular policies ran his party into the ground.

The other reason the Democrats had such a poor bench of presidential contenders is that their roster of elected officials has been severely diminished during the Obama years. President Obama’s re-election in 2012 may have been a big success at the top level of politics, but it helped Democrats ignore a series of devastating defeats on every level below that. Over the past eight years, Democrats lost control of both houses of Congress and got shellacked in governors’ races and in state legislatures.

It’s not difficult to explain why. President Obama stubbornly pursued a series of deeply unpopular policies, the crown jewel of which is Obamacare. To pass Obamacare, President Obama sacrificed his party’s congressional majority, on the assumption that the program would prove overwhelmingly popular once it was in place. In reality, Obamacare has vindicated all of its critics’ dire warnings, with a new round of double-digit premium hikes hitting just before Election Day this year.

But Democrats were so busy congratulating themselves on beating Mitt Romney that they totally failed to notice their underlying electoral weakness.

An added level of irony: one of the advisors who encouraged President Obama to ram Obamacare through Congress after it was clear the voters had rejected it was Tim Kaine—who will now, as a result, never be vice president of the United States.

3) Instead of transcending racial politics, Obama revived it.

Part of the reason Democrats failed to realize the precariousness of their situation is because they talked themselves into the theory of an Emerging Democratic Majority. The idea was that racial minorities will inevitably constitute a growing portion of voters, while old white men are inevitably dying off.

So even as President Obama was elected on an illusory image as someone who could unite the country and put racial politics behind us, the Democrats’ whole electoral strategy was based on appealing to racial politics. Obama’s two election victories depended in large part on increased turnout by minority voters, who voted in unusually high percentages to elect and re-elect the first black president.

This electoral strategy fit well with the inclinations of a politician who had actually been brought up neck deep in racial politics. So we saw President Obama pass up every opportunity to be a calming and uniting figure in racial controversies from the Beer Summit to Trayvon Martin to Ferguson to Black Lives Matter. While he quietly demurred to the idea that all of his critics must be racists, he didn’t exactly go out of his way to discourage his supporters from making that argument.

It’s not just that Hillary Clinton couldn’t replicate Obama’s mobilization of minority voters. (It appears, against all logic and reason, that Donald Trump got a higher percentage of the black and Hispanic vote than the earnest, innocuous Mitt Romney.) Even worse, the Democrats’ constant stoking of racial politics provoked a backlash, often in ugly forms, among blue-collar whites who are tired of being targeted as the enemy—which once again delivered the Reagan Democrats to Trump.

I have been grieved to see increasingly overt racial politics gain a foothold on the right, and I expect the so-called “alt-right” to be insufferable as they claim credit for Trump’s victory. But the left has to do a lot of introspection of their own and come to terms with the way they helped create a mirror image of their own racially charged electoral strategy.

4) Obama’s stagnant economy bred hopelessness.

Idle hands are the devil’s workshop, and a politics of racial resentment festers best when it seems like opportunities for others have been purchased at the expense of your own diminished future. Which is precisely how Obama’s economy feels.

President Obama came into office at a moment of financial crisis, and he promised that government “stimulus” would get the economy moving again. But the stimulus never really stimulated, and the economy has just dragged along in the slowest and most lackluster recovery in memory.

Instead of “Morning Again in America” where we experience a burst of 7 percent annual growth, we have yet to regain even the old long-term average of 3 percent growth. The result is stagnant wages, high unemployment, reduced labor force participation, and more people on welfare and food stamps. These problems have been particularly devastating for non-college-educated, blue-collar whites, feeding an atmosphere of rage and hopelessness. That is part of the reason they apparently surged to the polls to give Trump crucial victories in blue-collar strongholds like Ohio, Pennsylvania, and Michigan.

Plus, America hasn’t just been struggling economically.

5) Obama cultivated the sense of a diminished America.

President Obama made it a centerpiece of his foreign policy to cast suspicion on American intervention overseas (without actually ending or withdrawing from any of our wars). He expressed skepticism about “American exceptionalism” and projected a view of America as just one nation among many, with nothing that makes us important or indispensable. He made it seem that way, too, presiding over an indecisive and unassertive foreign policy whose signature event was the murder of our ambassador in Libya after we totally failed to follow up on an intervention there.

This disaster sullied the reputation of his secretary of state, and led to the discovery of her insecure private e-mail server. More broadly, it led to the general sense that American power and status in the world was being allowed to slip away, which gave a big electoral opening to someone who promised to “Make America Great Again.” We certainly haven’t seemed all that great under Obama and Clinton.

This part of President Obama’s legacy could end up wiping out all of the rest. President Obama has pushed through many of his policies in the form of unilateral executive orders, particularly on immigration, which can now all be reversed by President Trump. As I warned a while back, “If [the Democrats’] entire agenda is enacted by executive fiat, then everything depends on an unbroken string of victories in presidential campaigns,” which has now been broken.

If Trump and the new Republican Congress choose to repeal Obamacare and appoint a solid, respectable constitutionalist to the Supreme Court—and both of those are big “ifs”—then the rest of Obama’s legacy could also be swept away.

And it will all be because of the Pyrrhic victories President Obama won and the disastrous political legacy he left for his party.

Follow Robert on Twitter.