The realignment of southern democrats is due more to the fact that, once segregation--which democrats tolerated and republicans didn't--was off the table, they were more aligned with republicans on other issues, such as religion, gun control, abortion, business regulation, taxes, etc.
Looking at the union numbers, DNC had 46 senators of whom 45 voted for the act while the GOP had 32 of which 27 voted for it. So in union numbers the DNC senators voted 98% for it, while GOP did so with 84%.
Here is a longer article with this information: https://www.theguardian.com/commentisfree/2013/aug/28/republ...
As a result of this both parties changed. The DNC took a stand for civil rights and the southern democrats left. At the same time the GOP got a lot new members that influenced the party and created the new power base for it. Later GOP close victories all relied on the previous southern democrats.
Bigger picture, it is clear that the party depending on the south needs to cater to a voting base that is not very positive to civil rights movement, and the opposite for a party that wants to hold the north. It is important to understand that the DNC took a stand here that lost them the south long term because it was the right thing to do (in their minds).
You are also not really correct in claiming that "later GOP close victories all relied on the previous southern democrats." The 1976 Carter-Ford election was pretty close, with Carter winning by 2% overall. In North Carolina, Carter won by 10 points, while he won New York by less than 5 points. Regan won North Carolina by 2 points and New York by 3 points 1980.
It's no doubt that Republicans gained a decisive advantage in the south eventually, but that happened decades later.