As long as we are talking about the Ottomans, is there any scholarly consensus on why the Ottomans sort of stagnated and fell behind European states during the 18th and 19th centuries?
All I can remember is some vaguely Orientalist stuff about the decadence of the Ottoman court and how they weren't under the pressures that European states were and thus never "modernized". Given that historians have been attacking super-broad terms like "decadence" and "modernized" recently, I suspect that narrative doesn't hold water.
I think the reason why we are surprised should not be searched for in the circumstances of the Ottoman Empire. We should rather look at the situation of the UK, France, Germany, etc.
Lack of natural resources was an insurmountable obstacle to being a great power, during the first industrial revolution. Trade could still allow a country to be wealthy, but without heavy industry - which needed coal and iron close by - there would be no big military industry. Battleships would have to be ordered from factories in the industrializes countries, and so would artillery. Coal would have to be traded for, meaning that an embargo by those who controlled the seas could defeat a country. And governments were very much conscious of this. Those without an industrial base could not play the big power game, they had to be allies of one.
But there were two other scarce essential "resources" necessary to play the big power game: organization and financial capital. Size/population was also important, of course, but many weak polities had plenty of those in the 19th century.
Access to financial capital was critical to be able to develop and trade, as with the industrial era the world entered an epoch when no country (until, later on in the 20th century, the big continental-sized ones like the US and the USSR explored their territories) had all the resources it needed. Even those resources that did exist had to be brought to market. China had coal, but it was in a far-away region without a rail network - one had to be built. Russia lagged for the same reasons, albeit less. The ottomans actually had plenty of resources right in Anatolia and in their extended empire, but they needed the capital to build up the infrastructure to use them. The UK, France, Germany, Belgium, and even the US were blessed with plenty of industrial resources near its better-developed lands, thus they took the lead in the industrial age. And among those the UK, the first state to industrialize, also took the lead in finance - industry was profitable! But capital could be obtained by other countries from abroad if there was a profit to be made - the US accelerated its industry with a lot of british capital. So this was critical, but not a limiting factor.
Organization is where I think the explanation for the lead taken by some countries over others (among those with the natural resources) may be found. The UK didn't lead the industrial revolution just because it had the cola and the iron: it led it because they could
use it. Branches of science and engineering fundamental to the industrial revolution (mathematics, chemistry, physics, biology) developed during the 17th and 18th centuries in a few regions of Western Europe. By the 19th century there was an undeniable scientific lead that had also caused political changes in the polities occupying those regions. We could discuss cause and effect here, though I personally believe that technology pushes philosophy and politics. But what is a fact is that regions of Europe such as the Iberian Peninsula or the Ottoman Empire failed to keep up with the scientific revolution happening West-central Europe. And that translated to a lag in developing the local natural resources that were available.
France and the UK, just to use the two original big industrial powers, had gone through dangerous political changes as industry developed and caused new social classes to emerge and the old political order to change. There were wars, most notably the French Revolution and its sequels. But there were no much more powerful external enemies capable of beating these countries to an extent where they could be dismembered or utterly ruined. France lost its wars but was not destroyed, it never really lost its role of big power. The UK had a civil war ever earlier, lost pieces of its empire due to new political ideas (the US) but could not be attacked in its homeland and also stabilized as a great power.
Germany came slightly later to the industrial age and the state that founded the german empire only got it done though excellent diplomacy and a lucky break against the french.
When Spain, or the Ottoman Empire (to use two other examples of late attempts at development) had their own political turmoil caused by economic changes, there were already big powers ready to intervene with comparatively much stronger power. Spain had its homeland regularly raided by the much stronger french and later the remnants of its colonial empire crushed by the US; the 19th century was a "lost century" for Spain. The Ottomans had their provinces gradually amputated as the increasingly powerful western and central european states moved to extend their spheres of influence. Both these countries suffered through weak governments as military defeats caused crisis and internal strife. Trying to fight in the stage of the "great powers" while being late in the development race created a feedback loop of political weakness and under-development. Breaking away from that pattern of internal political weakness and foreign intervention was finally achieved by Spain and Turkey during periods of isolationism when they withdrew from international ambitions and the "world outside" was too busy with power games elsewhere.
I won't claim that we can generalize just from a couple of examples. But there are portions of the patters that applied to these countries that I can see in others also.