Voters cast their ballots in Dane, Wis., on Nov. 8, 2016. (Amber Arnold/Wisconsin State Journal/AP)

Behind the locked doors of a "map room," in a politically connected law firm's offices across from the historic Capitol, three men worked in secret to ensure the future of the state's newly triumphant Republican Party.

They were drawing the legislative districts in which members of the Wisconsin Senate and State Assembly would be elected. When the men — two aides to legislative leaders and a lobbyist brought in to help — finished in the early summer of 2011, they headed across the street to present their work.

“The maps we pass will determine who’s here 10 years from now,” read the notes for the meeting, which were made public as part of a lawsuit. “We have an opportunity and an obligation to draw these maps that Republicans haven’t had in decades.”

The maps are now at the center of a Supreme Court case to be argued next month that could change the dynamics of American politics — if the justices decide for the first time that a legislative map is so infected with political favoritism that it violates the Constitution.

“The evidence of extreme partisan gerrymandering cannot be clearer than it is here in Wisconsin,” said state Sen. Mark Miller (D), who opposed the redistricting plan and later played a key role in revealing the process that produced it.

Of course, that's not the same thing as saying that extreme partisan gerrymandering is unique to Wisconsin. There are lawsuits nationwide that make that charge — Maryland's congressional districts, drawn by Democrats, are being challenged by the state's minority Republicans, for instance — and fed-up voters in other states have taken the redistricting process away from politicians.

But extraordinary developments in Wisconsin have given the public an inside look at what usually is a top-secret process — and confirmation of the adage that in redistricting, legislators choose their constituents, not the other way around.

Among those developments:

●A panel of federal judges delivered a stinging rebuke to Republican legislative leaders and their attorneys, ordering the release of records the GOP had tried hard to conceal.

●Recall elections yielded an unexpected shift of power in the legislature, giving Democrats a chance to make even more evidence available to the public.

●A forensic analysis of secret computer spreadsheets revealed a painstaking step-by-step process that resulted in maps as favorable to Republicans as science allowed.

Republican leaders and their attorneys have declined to discuss the litigation but describe in their brief to the Supreme Court a process like other states have used for decades.

"The staffers focused on creating various draft maps that complied with the Voting Rights Act (VRA), equal-population requirements, and traditional districting principles, while also taking politics into account," says the brief filed in Gill v. Whitford.

But two panels of federal judges have found fault, with one especially concerned about attempts to stonewall plaintiffs seeking records about the redistricting.

"The Legislature has taken action that affects the voting rights of Wisconsin's citizens," a three-judge panel wrote in 2012.

The judges said they had lost patience with “litigation tactics being used by public officials or their private counsel in what has quickly become a poorly disguised attempt to cover up a process that should have been public from the outset.”

‘A desperate attempt to hide’

In 2010, Wisconsin voters elected a GOP majority in the Assembly and the Senate and chose Republican Scott Walker as governor. It was the first time in decades in Wisconsin that one party was completely in charge as the state began redrawing the legislative maps to reflect population changes revealed by the recently completed census.

GOP leaders seized the opportunity. To keep the process out of the public eye, leaders moved the operation away from the Capitol, paying hundreds of thousands of dollars to retain lawyer Eric McLeod and the law firm of Michael Best & Friedrich. The firm supervised the work of legislative aides Tad Ottman and Adam Foltz and former state representative Joseph Handrick.

The process of carving up 99 Assembly districts and 33 Senate seats was closely held. The mappers loaded data from past elections and current demographics into their computers. The latest redistricting software calculated the effects of even tiny changes to district lines.

Republican incumbents were admitted to the map room and shown their districts — and only their districts — after agreeing not to disclose the new boundaries. Although the Republican National Committee got a sneak peek at the plan, Democratic incumbents saw it only when it was publicly revealed.

“So glad we are in control,” a Republican senator wrote in one of the emails uncovered in the lawsuits. Republican lawmakers with safe seats offered to transfer areas populated with GOP voters to neighboring districts to help make them safer for other Republicans.

The redistricting process was only one of the controversies that engulfed state politics as the state’s progressive past gave way to a new Republican reality. Walker’s battle with public employee unions became national news, sparking an effort to recall him.

“The atmosphere at the time was incredibly politically charged,” said Douglas Poland, a lawyer who was part of the team that challenged the redistricting plan. “I had a floor-to-ceiling window that faced the Capitol, and every day there was somewhere between hundreds to thousands to tens of thousands of people who were protesting, yelling, blowing horns, beating drums, you name it. It was a very wild time.”

Poland’s team took the first swing at the redistricting plan, in a case that eventually focused on whether districts around the Democratic stronghold of Milwaukee should have been more favorable to Latinos. The lawyers said they were continually stymied in getting information about how the districts were drawn.

The judges overseeing the case agreed.

“Quite frankly, the Legislature and the actions of its counsel give every appearance of flailing wildly in a desperate attempt to hide from both the court and the public the true nature of exactly what transpired in the redistricting process,” U.S. District Judge J.P. Stadtmueller wrote for himself and his colleagues.

The court demanded that more information be turned over, hit some of the state’s lawyers in the case with sanctions, and eventually ordered that two of the districts be redrawn.

But Poland and others still suspected they had not received a full accounting of the process. And then another convulsion in Wisconsin politics gave them a chance to find out for sure.

A guaranteed GOP majority

The effort to recall Walker proved unsuccessful.

Less noticed were recall elections aimed at several state senators. As a result, Democrats briefly took control of the Senate and installed Miller as majority leader.

Because the lawyers at Michael Best & Friedrich officially worked for the legislature, they were now taking directions from Miller, who ordered the firm to turn over all of its records.

He published them online.

The records proved to be a gold mine when a group of Democratic voters in 2015 filed a new lawsuit — the one now before the Supreme Court — saying they were harmed by partisan gerrymandering. Although the justices often intervene when shown that redistricting hurts minority voters, they never have found a state plan invalid because of partisan gerrymandering. This was to be the test case.

The first thing the new plaintiffs would have to prove was an intent by the legislature to create districts that favored one party over another. Poland told them, “We’ve got that in spades.”

But they did not realize the magnitude of what they had until they asked a forensic computer specialist to look at the files. Computer expert Mark Lanterman discovered that spreadsheets from a critical point in the map-drawing process were missing and that software to wipe the files had been used.

Lanterman was able to reconstruct some of the files. They showed that the map drawers had estimated that if the existing districts were retained, Republicans probably would win only 49 of the 99 Assembly seats. And so they drew new maps with scenarios labeled “assertive” and “aggressive.”

“You’ve got one plan in April that predicts 49 seats,” Poland said in an interview. “And they fiddle with the lines and come up with a new plan, and that one says it’s going to be 51 seats. And you fiddle with it some more and it will be 53 seats. And then it was build, build, build until you can’t squeeze any more seats out of it. And that’s the plan they go with.”

In their 2-to-1 decision, U.S. District Court judges concluded that the final maps "demonstrated that Republicans would maintain a majority under any likely voting scenario; indeed, they would maintain a 54 seat majority while garnering only 48 percent of the statewide vote. The Democrats, by contrast, would need 54 percent of the statewide vote to capture a majority."

In fact, the GOP did better than predicted. The maps were first used in the 2012 elections, in which Republicans won just over 48 percent of the vote but captured 60 of the Assembly’s 99 seats.

Partisan process

The challengers say that the map drawers diminished Democratic influence by packing as many Democratic voters as possible into as few districts as possible and then spreading the rest across districts where their numbers were too small to matter.

But Wisconsin — now firmly back in Republican control — responds in filings at the Supreme Court that the results reflect political reality in the state. Democrats are concentrated in urban areas such as Milwaukee and Madison. Even under past maps drawn by neutral federal judges, Republicans were elected in greater numbers in the legislature.

And some partisanship is always expected when politicians are put in charge of redistricting. U.S. District Judge William C. Griesbach, who dissented from the decision of the three-judge panel, said it was unrealistic to think Republicans would draw plans that hurt their chances.

“It is hardly surprising that the maps they ultimately created increased their advantage somewhat,” he wrote. “In fact, under the plaintiffs’ proposed test the Republicans were obligated not only to draw fairer maps, but to engage in heroic levels of nonpartisan statesmanship.”

The Supreme Court has never required that. In fact, the most common defense for states accused of racial gerrymandering is that their plans are the result of partisan gerrymandering, which the justices in the past have tolerated.

In their brief, Republican legislative leaders spend little time on the mechanics of the mapmaking. But the brief reminds the court that drawing electoral districts has always been considered the province of legislators and that the courts should stay out of political matters.

Allowing challenges of partisan gerrymandering would encourage the losing side in any election to run to court, the brief says: It will be impossible for courts to know whether the results reflect gerrymandering, candidates who run better campaigns with more attractive messages, or the changing views of voters.

The brief notes that in the 2008 presidential election, Barack Obama carried 59 of Wisconsin’s 72 counties. In 2016, Donald Trump won 60, including 47 counties that Obama had won.

“As that reflects, voters’ party affiliation is simply not set in stone, and seats held by one party can (and do) change hands when effective candidates run effective campaigns,” the brief said.

But when the contested map was initially revealed, Miller immediately understood the effect on his district. He got more of solidly Democratic Madison — the state capital and home to the University of Wisconsin — and lost some rural areas with Republican constituents. He was safe — and didn’t have to worry as much about people who disagree with him, he said.

“I don’t think that makes me a better legislator, though,” he added.