It looked like a mathematical impossibility. In November, every Democrat running for re-election to the New Jersey Senate won with a bigger victory margin than had been the case during their previous efforts back in 2013. On the Republican side, the reverse was true: Every single incumbent did worse. In other words, Democrats improved on their performance everywhere in the state. Despite the impressive showing, however, they didn’t come away with much to show for it. Democrats added only a single seat to their majority.

The mismatch was more striking in Virginia. There, Democrats went into the November election facing an enormous deficit in the state House. Republicans held 66 of the 100 seats in the chamber. No one believed that Democrats would gain more than a half-dozen seats, at best. Instead, they captured 15. It appeared they had gained one more seat in a recount, but the race proved to be tied. The final result -- and control of the chamber -- will be determined by drawing a name from an old film canister on Dec. 27. Recounts are pending in two other contests.

It was a terrific showing for Virginia Democrats, yet still short of a complete victory. Although Democrats did well, they won in places that were fairly easy targets. Of the 15 districts they flipped, all but one voted for Hillary Clinton for president in 2016. Out of the chamber’s 100 districts, 96 of them voted for the same party they’d supported for president the year before. These days, fewer voters split their tickets than they used to and there’s simply more territory -- way more states and counties and arguably more legislative districts -- that tends to favor Republicans.

Nationwide, the Democrats will almost certainly be in better shape in state politics a year from now than they are at the moment. They are starting at such a low ebb -- with a smaller share of offices than at any time since the 1920s -- that they’re due to bounce back. History is on their side as well. The president’s party nearly always loses seats in midterms. That effect will be amplified by President Trump’s approval ratings, which have been mired in the 30s for most of his term. What 2017 showed is that intangibles like energy and enthusiasm, along with more measurable factors such as recruiting and fundraising, are all looking better for Democrats than has been the case for a long time. “Voters are looking for some balance to Republican dominance of Washington and also in the states,” says Jared Leopold, communications director for the Democratic Governors Association.

But as both New Jersey and Virginia showed, Democrats can achieve notable improvement in their electoral performance and yet not achieve much more power. Republicans are all but willing to concede, even with the election year just getting underway, that they’re going to give up some legislative seats and governorships. But the GOP has become so dominant at the state level that the party can stand to suffer a large number of losses and still retain control in a majority of legislative chambers and governors’ mansions. Republicans hold 34 of the 50 governorships and 68 of the 99 chambers. In most of those 68, the GOP holds at least two-thirds of the seats.

All the evidence currently points to the possibility of a wave election that will favor the Democrats. No doubt many Republicans will be washed away by it. But the party as a whole has built a seawall tall enough to withstand much of the damage. “Democrats are very energized about 2018, but Republicans at the state level have such a huge advantage that Democrats are not going to take that away,” says Jaclyn Kettler, an expert on state politics at Boise State University. “They’re still going to face challenges in actually becoming majorities in a lot of these chambers.”

Something similar is true when it comes to gubernatorial elections. Republicans will be defending 26 governorships this year, compared with just nine for the Democrats. Some of the GOP-held seats are practically gimmes for the Democrats, such as Maine and New Mexico. But there aren’t a lot of those. Democrats do have a shot at electing governors in Florida, Nevada and Ohio. Republican Bruce Rauner of Illinois starts the year as the most vulnerable incumbent, facing a battle against Democrat and fellow-billionaire J.B. Pritzker in what could well be the most expensive nonpresidential election in U.S. history, perhaps topping $300 million.

Other states are longshots for the Democrats. Most of the Republican-held seats are in states where Democrats have little to no chance of winning, such as Arkansas, Idaho, South Carolina and Texas. In some states, they’re struggling even to recruit serious candidates. And even in typically blue states such as Maryland, Massachusetts and Vermont, Republicans have incumbents seeking reelection whose approval ratings are solidly in the 60s. “In Maryland, Larry Hogan is still a very popular Republican incumbent,” says Mileah Kromer, a pollster at Goucher College in Baltimore. “People are not drawing that connection between him and Trump at all.”

Not every Republican governor, or gubernatorial hopeful, is distancing himself or herself from Trump. Many are embracing the president, which may be good politics, at least in the primaries. The vast majority of Republican voters support Trump. The tricky part will come in the fall, when GOP candidates will face a broader electorate that, assuming conditions hold, will be largely sour on Trump. That shapes up as a particular problem for Republicans in more competitive states. Susan Demas, the editor and publisher of Inside Michigan Politics, notes that voters in that state are already “antsy” after eight years of increasingly unpopular rule under GOP Gov. Rick Snyder. Bill Schuette, the state attorney general and a leading Republican candidate for governor, has given Trump his full embrace, which might not play so well come November should he be the Republican nominee. “He’s going to have to keep going hard to Trump to keep the base energized,” Demas says. “That’s going to put Schuette in a perilous position in the general, when he will have to defend a lot of unpopular ideas and unpopular rhetoric.”

By the nature of their jobs, Republican legislative candidates will have a harder time separating themselves from an unpopular president, given the limited amount of media and voter attention their individual races will receive. They face other headwinds as well. Rank-and-file Democrats and party donors seem finally to have discovered the importance of legislative elections, mirroring the level of focus and fundraising that Republicans have brought to this particular cause for years. In most recent cycles, the two parties have left about 40 percent of legislative seats uncontested. As Democrats have already shown in Virginia, that may not happen this time. Democrats seem to be eager to run in many more places, and they’re finding unprecedented numbers of volunteers ready to lend them a hand. “There is a fascinating change that happened after 2016, where people perked up and remembered there are such things as state legislative elections,” says Nily Rozic, a Democratic state assembly member in New York. “When I ran in 2012, it was difficult to get donors, let alone voters, to focus on state races.”

That’s all changed. A welter of new groups has sprung up to recruit and support Democratic candidates, including Future Now, Forward Majority, Run for Something, Sister District and Flippable. They join older groups such as Daily Kos, EMILY’s List and Emerge America. The National Democratic Redistricting Committee, which is being run by former U.S. Attorney General Eric Holder and is backed by former President Barack Obama, has pledged to spend $30 million on legislative contests this year. Some of the other new groups have the backing of wealthy donors, including the free-spending billionaires Tom Steyer and George Soros. Forward Majority, run largely by Obama administration alumni and chaired by Colorado Gov. John Hickenlooper, claims it can raise $100 million. “We know there is going to be a new level of interest in the states and an increased level of spending,” says Matt Walter, president of the Republican State Leadership Committee. “In Virginia, the level of engagement of their donor groups was even higher and stronger than we anticipated. It should be a cause of deep concern for anyone who supports Republicans and conservative government.”

It became a political truism during the Obama years that midterms favor Republicans, because the electorate tends to be whiter and older than during presidential years. After this year, we may hear that midterms favor Democrats, because they have the educated voters, and educated voters have higher turnout. The reality is, it’s the president’s supporters, regardless of party, who tend with rare exceptions to be less enthusiastic in midterms.

But even if this is the year Democrats start their comeback, it could end up being more of a rebuilding year than an unadulterated triumph. It’s a safe bet that Democrats will take some governorships and chambers back from Republicans, but they may have to wait until 2020 to claw their way back to parity. “It might be unrealistic for us to flip entire chambers this year,” says Catherine Vaughan, CEO of Flippable, one of the new Democratic campaign groups. “That’s the trickiest piece, getting people to think of a two-cycle strategy.”

One of the known unknowns heading into campaign season is redistricting. In October, the U.S. Supreme Court heard a case challenging the Wisconsin Assembly map, with plaintiffs arguing it amounted to an unconstitutional gerrymander for the GOP’s benefit. There’s no telling how the court will rule, but there’s a chance the justices will make good on their decade-old threat to disallow maps that tilt too far to one party or the other. Even if the justices agree that there can be such a thing as an unconstitutional partisan gerrymander, they may not agree on how to identify or measure such a thing, which would present an open invitation to more lawsuits all over the country. Last month, the court agreed to hear a separate partisan-gerrymandering case regarding Maryland’s congressional map.

Redistricting is clearly a top-of-mind factor for many donors and strategists on the Democratic side. The Republican sweep in 2010 was a huge head start for the party’s dominance of both state legislatures and the U.S. House during this decade, putting the GOP in position to draw highly favorable maps for itself in key states such as North Carolina and Pennsylvania. Most of the governors elected in 2018, as well as state senators with four-year terms, will be in office during the next round of redistricting, following the 2020 Census. Where they can’t win control this year, Democrats will be seeking to put themselves in place to take over in 2020, or at least break up some veto-proof GOP supermajorities. “So many of the races that matter for redistricting are going to be up in this cycle, in a lot of places where Democrats have been hampered by bad maps,” says Leopold, who also serves as spokesman for the National Democratic Redistricting Committee.

Redistricting has undoubtedly given Republicans a strong edge in many states, with the party packing as many Democratic voters into as few districts as possible. But Democrats have packed themselves as well. The party’s support increasingly comes from people who cluster in dense places -- city centers and the most populous suburban counties. In a lot of states, that has meant there aren’t enough districts in play to build Democratic majorities. Consider Minnesota, where Republicans took control of the state House in 2014 and the state Senate last year. Democrats haven’t lost a statewide race in Minnesota since 2006, thanks to strong support in the Twin Cities area around Minneapolis and St. Paul. But Republicans have picked up so many legislative seats in smaller towns and rural areas, that even in a wave year it’s going to be tough for Democrats to take back the House. (The Senate is not up in 2018.) “The map in Minnesota favors Republicans by a few seats,” says Paul Thissen, a former Democratic leader in the state House. “It remains an uphill battle.”

Democrats were cheered by the results in November that hinted they might make inroads into new territory. Ralph Northam, the new Democratic governor of Virginia, dominated the once-competitive suburbs around Washington, D.C. He took a higher percentage of the vote in suburban Fairfax County, the most populous jurisdiction in the state, than Bill de Blasio got in his reelection as mayor of New York City. Northam also won by 20 points in Loudoun County, a wealthy suburban enclave, which his Republican opponent, Ed Gillespie, had carried as recently as 2014 in a U.S. Senate race. Northam became the first Democratic candidate for governor to carry Chesterfield County, outside Richmond, since 1961, when Virginia, like most of the South, was still solidly Democratic.

Inroads among affluent suburban voters were essential to Democrat Doug Jones’ startling upset victory in the U.S. Senate race in Alabama last month. What’s more, Democrats won contests for local office last year in suburban jurisdictions around New York and Philadelphia where they’d been shut out of power for years and even decades. Democrats won the race for town supervisor in Hempstead, N.Y., which has a population of 760,000, for the first time in more than a hundred years. “All the Democratic changes in these suburbs are bad news for Republicans,” says Lawrence Levy, dean of the National Center for Suburban Studies at Hofstra University in Hempstead. “The inner-ring suburbs are increasingly well-off and well-educated, or poor and more minority.” In other words, ripe to trend Democratic.

Michigan GOP candidate Bill Schuette's full embrace of Trump could put him in a perilous position. (AP)

But not every suburb flipped to the Democrats. In Huntington, about 20 miles farther out on Long Island from Hempstead, Republican Chad Lupinacci was elected supervisor, succeeding a Democratic incumbent who held the office for 24 years. In Michigan, Democrats have earned an advantage in Oakland County, an affluent suburban area north of Detroit that formerly favored Republicans. In exchange, however, they’ve lost their traditional hold on neighboring blue-collar Macomb County. Macomb is famous in political circles as the original home of the so-called Reagan Democrats, the working-class voters who had mostly been with the Democratic Party since the days of Franklin Roosevelt but started voting Republican with Ronald Reagan. Now, those Reagan Democrats are simply Republicans. “Macomb County is solidly for Trump,” says Marjorie Sarbaugh-Thompson, a political scientist at Wayne State University. Meanwhile, she says, Republicans in Oakland County are “horrified by the Donald Trumps and the Roy Moores and the turn the Republican Party is taking.”

Trump’s national advantage in 2016 among whites lacking a college degree was 30 percentage points. Democrats have picked up more support from college-educated whites, but even in the Trump era they don’t dominate that category. According to exit polls, the vote among college-educated whites was split evenly in the gubernatorial races in both New Jersey and Virginia in 2017.

In order to win more legislative elections, Democrats need minorities to turn out. Unfortunately for them, most minority voters -- along with most educated professionals -- are still clustered in metropolitan areas, where their votes simply push up the totals in lopsidedly Democratic constituencies. Whites without college degrees, by contrast, are spread like peanut butter all over the country. The nation’s demographic changes as a whole may favor the Democratic Party, but clustering has given Republicans disproportionate strength in many states.

Ever since early November, Republicans have dismissed the results in New Jersey and Virginia as not much more than Democrats winning home games. Both states have been trending blue and the last five presidents have watched their party lose those governorships during their first year in office. Democrats dismiss that argument -- “horse hockey,” Jessica Post, executive director of the Democratic Legislative Campaign Committee (DLCC), calls it. And certainly the GOP was singing a different tune about those states before the results came in. But there’s some truth to the notion that New Jersey and Virginia, demographically speaking, represent best-case scenarios for the Democrats. “There just aren’t that many states in the country that have this mix of educated white voters, plus large numbers of black and Latino voters,” says Patrick Egan, a professor of politics and public policy at New York University. “That’s really the best recipe for Democrats right now.”

The pull of midterms toward the opposition party, as well as Trump’s sustained and even deepening unpopularity, guarantee some good news for Democrats. There are states where legislative margins are tight, or where gubernatorial performance might normally have opened up some space for the GOP, but where Democrats can now probably rest pretty easy, such as Colorado, Connecticut, Pennsylvania and Rhode Island. “One result of the political environment may be that Democrats will ultimately be less accountable because of the president,” says Kyle Kondik, managing editor of Crystal Ball, a political newsletter put out by the University of Virginia. “If Hillary Clinton were in the White House, Connecticut might be favored to elect a Republican, but because of national politics, it might be too much of an ask.”

If Democrats won’t have to worry much about playing defense, there clearly are a lot of places where they can go on offense. In New York, they are hoping to gain enough seats in the state Senate for the party to take real control of the chamber, rather than watching a Democratic rump group keep Republicans in power. There are other chambers where the Republican majorities are sufficiently slight that it wouldn’t take all that many breaks for Democrats to gain power, such as the state senates in Arizona, Florida, Iowa, Maine and New Hampshire.

But then there are chambers where Republican margins are so large it’s difficult to imagine Democrats winning enough seats to cobble together a majority. The GOP has enormous advantages in reliably red states such as Indiana, Missouri, South Carolina, Tennessee and Wyoming, among others. Then there are states like Pennsylvania, which is competitive when it comes to statewide elections, but where Democrats would have to win 20 seats to take back control of the state House. And then there’s Michigan. “It’s almost statistically impossible for them to take back the state Senate,” says Demas, the Michigan analyst. “I don’t think that’s even on the table.”

Demas points to a potential bright spot for Democrats. In a special election in November, they easily won a state House seat on Michigan’s Upper Peninsula in a district that Trump had carried the year before. The most promising portent for Democrats, in fact, is their performance in recent special legislative elections. These are low turnout affairs and each has its own dynamic. Still, some of them amounted to wake-up calls for Republicans, as even Republican strategists will concede. Democrats took 14 legislative seats from Republicans in special elections last year, in districts that had supported Trump in 2016 by margins as great as 39 percentage points. Republicans, by contrast, picked up just a single seat each in Louisiana, Massachusetts and Mississippi.

Democrats in these special elections typically ran well ahead of Hillary Clinton’s performance in their districts. That spoke to greater turnout and enthusiasm on their side, in many instances, than among Republicans. Winning in midterms has always been about turning out supporters, but it’s especially pressing these days when partisan voting habits have hardened and persuading anyone to swing to the other side has become difficult.

That could be a saving grace for Republicans. In contrast to elections even in the early 2000s, fewer voters are willing to support candidates of the other party. That might put a limit on the size of the wave Democrats are counting on. The results in New Jersey and Virginia, although clearly good outcomes for Democrats, didn’t suggest that the bottom had totally fallen out for Republicans when it came to turnout.

Some of the special elections, though, told a different story. And the fact that Democrats captured so many seats in the Virginia House makes the gains they’ll need to flip more chambers this year seem conceivable, if not easily doable. “Our swings sometimes come in big numbers,” says Post of the DLCC. “After winning 15 seats in Virginia, suddenly the nine seats we need in the Michigan House don’t look quite as intimidating anymore, or the 11 seats in Minnesota.”