So I’m going off an assumption that in the 12th century, cousins Alfonso VII of Leon and Alfonso I of Portugal both spoke the same language and general dialect, and that the language divide happened later over time. And my question I guess is kind of just “why?”
Seemingly they wouldn’t have been that isolated from the rest of Castile/Spain for them to unintentionally drift away into a new language by accident. Was there ever any explicit policies or leadership decisions ever made that set out to differentiate or define the differences in their languages? Or was it more of a situation where the dialect just shifted over generations until it was considered an entirely new language?
Like when Ceuta went from Portugal to Spain in the 17th century, at the time would there have been a significant language barrier between the Portuguese residents and their new Spanish overlords?
And was the Portuguese language’s evolution connected to their colonization efforts? Like would the language mutate and shift even faster in Brazilian isolation away from Spanish influence, and then make its way back to influence Portugal?
Edit: and after reading a bit more about it, was my original assumption that it was Portuguese that did the heavy lifting with the shifting even accurate? Is Portuguese actually closer to the “Vulgar Latin” they were speaking 1000 years ago, and could it actually be that the rest of Spain did most of the big fluid language shifting?
Disclaimer that I'm much more well-versed in Spanish than Portuguese, the former's my first language and I don't speak the latter with any sort of fluency, they're close enough that when I have to communicate in "Portuguese", I just speak slow Spanish haha. So I might lean a bit more towards examples of Spanish than Portuguese.
Anyway, this is a hard question to answer because it's very difficult to define what separates two languages. The common saying "a language is a dialect with an army and a navy" comes to mind. There is no purely linguistic reason, in fact, to necessarily view Spanish and Portuguese, or even the Romance languages in general, as separate languages. We could just call them dialects of Modern Latin. But we don't. And the reason we don't is based in historical, cultural, and social reasons.
Because these reasons are fluid and at times, subject to individual perception, there is no hard break between Spanish and Portuguese. We can only look back on events and impose artificial boundaries that are unavoidably teleological, we know that in the present, Spanish and Portuguese are separate languages; the speakers of these languages don't consider themselves to be part of one linguistic community. How did this come to happen?
Let's start at the beginning. Classical Latin was brought to the Iberian peninsula by the Romans. Eventually, it came to displace all the native languages except Basque. As people began speaking the language, they naturally began to develop differences. Just as the English spoken in Atlanta, USA, is not the same as the English spoken in Kingston, Jamaica, or Lagos, Nigeria, or even just a few hours away, in New York, USA. But all of these varieties do share a speech community, they communicate with each other, and vocabulary as well as pronunciation and grammar changes diffuse throughout the community.
Iberia was much the same. Sure, there were differences, but occasionally these even spread and influenced the neighboring dialect. Because of the limitations on communication, the spread was much more localized and what tended to form was what is called a dialect continuum. This is when the language spoken in one town is only slightly different from the language in the next town which is only slightly different from the one in the next and so on. As Latin continued to develop and as the Western Roman Empire collapsed, these differences became much larger. But in broad terms, the Latin-speaking world still operated under these basic principles, from what is now Portugal to Spain to France and even further.
But this obviously isn't the case now, you cross the border from Spain to France and there's no gradual shift, it's a hard transition. What happened? Well, some of these towns decided to impose their language on others. This might have been a literal imposition, as in banning the local language and forcing children to learn a different dialect, as happened in the modern era. But it might have also been soft pressure to skew your pronunciation and grammar towards the way your neighbors spoke. As new community units and regional identities formed, speech patterns developed to express these identities, and occasionally various varieties contributed to the final result.
All of these processes were at work in the development of Portuguese and Spanish as separate varieties. And the way people perceived their language varied, even what name they gave it depended on who they were speaking to and why they were referencing their language. For a long time, Spanish was just called "the Christian tongue" in many contexts, and you can see this in modern phrases like "háblame en cristiano", a Spanish phrase that literally means "speak to me in Christian", but is used to say something like "give it to me in plain English". It was also just called Latin, and the descendant of Old Spanish spoken by exiled Sephardi Jews is still called Ladino.
And it was sometimes called "the Roman tongue", a way of referring to the modern forms of Latin that originated in France during the Carolingian era. This distinguished the spoken vernacular from the written Latin, which coexisted as the formal version of the language until the high middle ages when the vernaculars began to be written down. Notably, for a long time, only certain types of texts, epics, and songs, were written in "Roman", that's why our modern term "Romance" refers to concepts of love; these sorts of things were common themes in those popular genres. For more serious fare, Classical Latin continued to be used. This situation was probably very similar to Arabic, which has a more conservative standard form as well as local "dialects" that are at times mutually unintelligible.
Notably, none of these terms really differentiate between the various types of Romance that we have today. It's not until the 13th century that we start to more consistent separation between "Castillian" and "Portuguese". It's important to note that these terms refer to regional identities, they didn't always necessarily have to mean separate languages, just the way people spoke in a particular region.
Castillian likely first developed in Burgos and then imported to Toledo sometime after that city was captured by Alfonso VI of Castille in 1085. As that city became an important center of culture, the dialect spoken there began to acquire prestige and become common throughout Castille, until the 12th century, when Ferdinand III and especially his son, Alfonso the Wise began to use it in a more official capacity. This is the beginning of Castillian becoming the official language of Castille and later, of all Spain.
The origin of the name español, by the way, is a bit controversial. The Real Academia Española says it comes from an Occitan term referring to the region of Spain. This makes sense because if it were a native Spanish word, it would be españuelo.
Portuguese developed in the region of Galicia and had a similar history. The early form of Portuguese is called Galician-Portuguese because the split between these two didn't happen until the modern era and the line between language and dialect is even fuzzier there. Galician-Portuguese also moved south with the Reconquista and it became a very popular variety throughout Iberia, particularly for writing musical poetry. Notably, Alfonso the Wise of Castille wrote prose in Castillian, but poetry in Galician.