How did Pennsylvania go from a state that leaned Democratic at the federal level to the biggest battleground of them all?

Pennsylvania was reliably Democratic from 1992-2016, even voting for John Kerry in 2004 as he lost the popular vote nationwide. That is until Trump came along, he narrowly won it in 2016, while Biden flipped it back in 2020, it was still an underperformance compared to Kerry and Gore.

But this election, there was over 1 trillion spent on advertising in the state and both campaigns campaigned here with a vengence.

Pennsylvania Dems are also getting crushed in registration as the registered number of Dems aren't going up.

So, how did PA go from a reliably Dem state to a battleground?