You'd have to go back to the 17th century when the Bourbon army seized the province for Spain and it all went downhill from there as alluded to by
aristoi bcn
Another civil war began again in 1936 when Real Madrid benefactor and all round bad hombre Franco crushed the Catalonians, outlawing their language, culture, subjugating them as downstairs folk.
And that resentment has been stewing ever since.
Rajoy is an idiot btw with his belligerence. I think this is exactly the response the Catalan gov't was hoping for. Spain's ruling PP party has acted not with the national interest in mind, but their own, as their heavy-handedness with the Catalonians may well be a vote winner for them on a country level.
Bear in mind that the Catalan separatist movements had been carrying out unofficial polls on the streets for years.
It's only since recently though -some 5 years or so- that the actual Catalan government also got involved with the drive for independence.
Even though the Catalonia comedy is in international news now, it has been in the local news on a daily basis in Spain for a while now.
PS
I am neither Catalonian nor Spanish but i visit several times a year to partly escape the gloomy British winter.