Democratic presidential candidate Hillary Clinton celebrates with her vice presidential running mate Tim Kaine as balloons drop from the ceiling on the final day of the Democratic National Convention in Philadelphia.

July 28, 2016 Democratic presidential candidate Hillary Clinton celebrates with her vice presidential running mate Tim Kaine as balloons drop from the ceiling on the final day of the Democratic National Convention in Philadelphia. Michael Robinson Chavez/The Washington Post

A look at what happened at the convention in Philadelphia before Hillary Clinton accepts the nomination.

A look at what happened at the convention in Philadelphia before Hillary Clinton accepts the nomination.

A look at what happened at the convention in Philadelphia before Hillary Clinton accepts the nomination.

What happened on the fourth day at the Democratic National Convention

What happened on the fourth day at the Democratic National Convention

The country’s two major political parties, emerging from their conventions to square off in the general election, are speaking to Americas unrecognizable to each other in voices that sound like a political and ideological role reversal.

For Republicans, the country is a place of near-apocalyptic gloom whose best days are fast receding.

“Our convention occurs at a moment of crisis for our nation. The attacks on our police, and the terrorism in our cities, threaten our very way of life,” GOP presidential nominee Donald Trump declared in Cleveland in his acceptance speech, in which he described a country gripped by “violence in our streets and the chaos in our communities.”

The nation of the Democrats who met here this week to nominate former secretary of state Hillary Clinton, meanwhile, is a vibrant and diverse place. First lady Michelle Obama summarized it in her address on the first night of the convention: “Don’t let anyone ever tell you that this country isn’t great, that somehow we need to make it great again. Because this, right now, is the greatest country on Earth.”

Clinton stressed that sentiment in her address Thursday night.

President Obama's speech electrified the crowd in Philadelphia on July 28, leaving some with chills and others in tears. (Alice Li,Jenny Starrs/The Washington Post)

“He’s taken the Republican Party a long way from ‘Morning in America’ to ‘Midnight in America,’ ” she said, recalling Ronald Reagan’s 1984 reelection slogan. “So don’t let anyone tell you that our country is weak. We’re not. Don’t let anyone tell you we don’t have what it takes. We do.”

The sights and sounds of the convention hall echoed that pitch. Chants rose up Thursday night — “U-S-A! U-S-A! — as John R. Allen, the retired Marine general, thunderously addressed the Democratic convention. Delegates waved American flags in the air and held up signs that formed a sea of red, white and blue.

The visceral shift in the parties’ political narratives represents a profound break from the way they have often spoken about the country and themselves.

Going at least as far back as Reagan, Republicans have prided themselves as being the party of optimism and confidence, leading an exceptional country whose greatness was coded into its DNA.

Going back further, to Franklin D. Roosevelt, it has been the Democrats who have made common cause with the aggrieved and the left behind, who have been criticized for dwelling too much on the nation’s flaws and being squeamish about asserting power internationally.

[Can Democrats beat Trump with his own words? (It didn’t work in the GOP primaries.)]

For some Republicans, it is an unsettling juxtaposition.

Democrats in Philadelphia reflect on the significance of nominating Hillary Clinton for president – the first time a major party has nominated a woman for the nation's highest office. (Peter Stevenson,Alice Li,Sarah Parnass,Jayne Orenstein,Nikita Mandhani,Adriana Usero/The Washington Post)

“The Democrats used to be the party that said people are being taken advantage of and it’s time to settle the score. Now that’s the Republicans’ message,” said Stuart Stevens, who in 2012 was GOP nominee Mitt Romney’s chief strategist. “To let them become the optimistic party that wants to lift us up and unify America, it’s a disaster for Republicans.”

Or maybe it is smart positioning, given that parts of the country are in a prolonged funk, as evidenced by the fact that polls since 2009 have consistently shown more people believe it to be headed in the wrong direction than the right one.

That creates a challenge for those who have been running the country during that time to make a stay-the-course argument. It is compounded by voters’ historic reluctance to leave the White House in any party’s hands for more than two consecutive terms.

“You really can’t afford to paint an unrelentingly dark picture of the country. To do that is to say, in effect, that your predecessor has failed,” said William A. Galston, a Brookings Institution senior fellow who was a top adviser to Bill Clinton’s 1992 presidential campaign.

So the themes being sounded by each party reflect the natural cycle of being in and out of power.

But there are other factors at play this year that amplify what would have been happening anyway.

The Republican Party’s once-omnipotent establishment has ceded control to a vocal faction fixated on issues such as illegal immigration and their angst over the reweaving of the social fabric.

“There have been so many changes in the culture that to many Americans, it’s an unrecognizable country,” said William J. Bennett, a prominent conservative voice going back to his time in Reagan’s Cabinet.

“It’s a country where you have to watch everything you say, and you can’t count on your kids to do better than you did, where the middle class doesn’t prosper and things that were once honored aren’t honored anymore.”

Then there is the unique figure they have embraced as their standard-bearer. Trump has a worldview in which there is no nuance or self-doubt.

The Republican nominee “very openly worships strength. His crucial dyads are strength and weakness, winning and losing,” Galston said.

The shape-shifting of the two parties goes beyond tone.

On many issues, Democrats and Republicans have drifted away from their traditional postures and orthodoxies.

Trump has excoriated free-trade agreements and resisted his party’s calls to revamp entitlement programs. And the hawkish instincts of the first woman to head a major political party’s ticket are putting a different stamp on what was once known as the “mommy party.”

Recent history might suggest that the sunnier candidate has the advantage.

When George W. Bush accepted the Republican nomination in this very city 16 years ago, he concluded his acceptance speech with a call to “live on the east side of the mountain. It is the sunrise side, not the sunset side.”

That year, then-Vice President Al Gore used his party’s convention in Los Angeles to pivot to a “people vs. the powerful” theme, rather than running on the prosperity of the Clinton years. That decision was later regarded as a strategic blunder.

Whatever the parties sought to project in their conventions, there remains a question of what will ring true to voters.

William Kristol, editor of the Weekly Standard magazine, said in an interview that he is dubious that the Democrats “can change who they are with a few phrases” and said the party’s soul is still “with George McGovern” and proudly liberal.

“Liberals kid themselves by thinking Nixon and Reagan won because they had rhetorical tricks about how they spoke about the country. They always make that mistake, not realizing it was about different policies,” Kristol said.

At the same time, Republicans in most respects remain the party of the corporate class, especially at the congressional level, where House Speaker Paul D. Ryan (R-Wis.) has been promoting a traditional agenda.

Trump believes that his message will resonate beyond his base to reach suburban swing voters in industrial regions.

Clinton and the Democrats are doing their best to persuade those same voters to celebrate the progress that has been made during the Obama era and build confidence that economic and social advances lay ahead.

In his convention speech Wednesday night, President Obama spoke directly to those voters — paradoxically enough, by quoting Reagan.

“It looks like they’re trying to play to the middle really hard and capture moderates and independents,” said Brett O’Donnell, a veteran Republican strategist who specializes in helping candidates use effective language.

The goal, O’Donnell said, is to “convince them the Democrats are better on national security and jobs, and at a more fundamental level, that they’re more American than Trump.”

Trump insisted on Twitter on Thursday that voters would not be swayed.

“President Obama spoke last night about a world that doesn’t exist. 70 percent of the people think our country is going in the wrong direction,” he wrote.

Bruce Reed, who was Vice President Biden’s chief of staff and head of domestic policy in the Clinton White House, said the Democratic message represents a natural progression.

He ticked off the campaign slogans of the two Democrats who have most recently occupied the Oval Office, and of the woman vying to be the next one: “We’ve done well with ‘a man from hope’ and ‘hope and change.’ And we’re going to do well with ‘stronger together.’ ”