The easy thing for Republicans to tell themselves after the stinging loss of a Senate seat in Alabama is that they only went down to defeat because the party had the misfortune to nominate someone accused of preying on teenage girls.

And there is something to that. But the Republican Party nominated a man accused of sexual misconduct to run for president in 2016, and that didn’t stop him from winning 62 percent of the vote in Alabama. Donald Trump didn’t just win Alabama a year ago — he won by a larger margin than Mitt Romney, John McCain, or George W. Bush. So while it’s undoubtedly true that the allegations played a role in the race, they hardly work as a comprehensive explanation of the outcome.

The larger issue is that the Republican Party is led by an unpopular president and unpopular congressional leaders who are pursuing an unpopular agenda, and it’s putting them in massive electoral peril.

Republicans have been ignoring warning signs all year

It is entirely normal for the party that occupies the White House to lose ground down ballot during midterm elections. That said, the GOP’s results in 2017 have really been quite bad:

Republicans in Washington are aware of all these facts, but seem, strangely, a bit indifferent to them. The experience of watching Trump — whom they all expected to lose as late as 7 o’clock on the evening of the 2016 election — triumphing against the odds has them dazzled. And the fact that in office, Trump, despite considerable speculation that he wouldn’t, has pursued a very orthodox Republican Party agenda has them pleased.

At the nexus of these two factors, they’ve decided to bank as many policy wins as they can and then hope to hit a stroke of good luck.

Sometimes you get bad luck

In the Alabama race, Senate Republicans suffered fundamentally from bad timing.

If the allegations of sexual misconduct against Roy Moore had surfaced during the primary, he likely would have lost to either Luther Strange or Mo Brooks, either of whom likely would have beaten Jones. If the allegations about Moore’s misconduct had surfaced after the general election, he might have been forced from office, but Alabama’s Republican governor would have appointed his replacement. Having this information come out during the window between the primary and the general election was a fluke, and absent that fluke, it’s hard to imagine Jones winning.

That said, Republicans have spent the past year acting as if a narrow — and extremely flukey — Trump Electoral College win made him an unstoppable man of destiny.

Alabama is a reminder that luck can cut in either direction. It’s also the case that to an extent, Democrats made their own luck in Alabama by recruiting a very strong candidate in Doug Jones at a time when the race seemed impossible to win. The freakishly large number of Democrats who want to run for office in 2018 is an indication that Democrats will be able to take advantage of whatever good luck comes their way next year, with decent candidates in the field almost everywhere.

Meanwhile, though Trump’s decision to hew to ideological orthodoxy has pleased GOP congressional leaders, those leaders are, themselves, unpopular. And in doing so, Trump has ditched most of the economic populism that helped him win white working-class crossover voters without ditching any of the bizarre personal behavior that cost him white college graduate crossover voters.

The resulting profound national popularity isn’t enough to put a state as red as Alabama at risk on its own. But it does put it within striking distance for a weak candidate like Moore to lose, and of course most Republicans don’t have the luxury of running in a place as conservative as Alabama.

Republicans still have 11 months in which to try to turn things around, but so far nothing has deterred them from pursuing this course, and there’s little immediate indication that losing in Alabama will change that.