Decline is relative. I’m not really inclined to agree with Trinopus above, because IMHO any of those military victories wouldn’t have led to much. None of them really shattered the balance of power per se, they’re just big showy landmarks in history that I think some historians have exaggerated to make them seem more decisive than they were. Vienna was already at the end of Ottoman logistics train in 1529 ( they didn’t even bother retaining all of Hungary ), the Ottomans rebuilt their fleet after Lepanto and continued to dominate North Africa through proxies and the Eastern Mediterranean Basin generally and the 1683 battle of Vienna was just the opening volley in a war that lasted until 1699 and outcome of which was largely undone in 1739.
The decline of the Ottoman state is the subject of many, many books and papers, many of which disagree. You’re not going to get a definitive answer here :).
What I would argue is that the decline was mostly quite gradual, had multiple complex reasons, was discontinuous ( the Ottman state was probably structurally healthier in the mid-19th century than it had been in the mid-18th ) and internal rates were uneven ( i.e. some parts of the state atrophied a lot faster than the other). For example one reason the Ottoman state managed to hold out so long from a military perspective was, as I’ve discussed before, its military retained its defensive effectiveness long after it had lost a lot of its offensive punch. The very general notion is that Ottoman armies had maybe a mild superiority relative to European militaries in the 15th -16th centuries, were perhaps on a rough par in the 17th and began to decline in 18th ( accelerating rapidly after the mid-18th ). But battlefield success aside, Western militaries paid dearly for every yard of Ottoman territory they took in 17th-19th centuries. Ottoman wars in that period were often long, slow, hideously grinding and costly affairs.
One notion of Ottoman decline was that it was failure at the top. The Ottomans had really an almost unprecedented run of mostly highly competent rulers from the 14th-16th centuries. But from the 1570’s on the previous system where royal princes had served terms as military governors and at other independent stations was replaced by the harem system. Princes were kept incommunicado vis-a-vis the outside world and came to the throne pretty much unprepared for rule. It is common for older histories to emphasize the dissolution of these pampered latter day sultans as a symptom of the Ottoman disease - sorta a Gibbons-style failure by moral degeneracy. But frankly it probably wasn’t the primary issue - basically despite being technically autocrats, from the mid-16th century on the sultans were more figureheads. The Ottoman system became very highly bureaucratized. Much as with contemporary Ming China it was mostly those bureaucrats that ran the state, not the sultans.
The main issue was economics. Simplifying enormously, certain cultural emphases in Ottoman ruling culture led to a large medieval agricultural empire dependent largely on land revenue, becoming very roughly a large modern agricultural empire dependent on land revenues. But land revenue doesn’t pay the bills in a modern or early modern state. A very strong “if it ain’t broke, don’t fix it” attitude, combined with an obsession with maintaining both full state coffers( “ficalism” )and full internal markets( labeled “provisionism” and leading to heavy importation and ultimately very unequal economic treaties ), led to a hugely overcautious approach to economic development. Virtually none in fact that wasn’t very state-centered ( arms manufacture for example, occasionally left to atrophy as well ) or at the small craft-shop level. So what worked splendidly in the 16th century when the Ottomans were much more wealthy than any European competitor, choked on its own senile dementia in the 18th-19th centuries. There are plenty of other factors like the bypassing of the overland Asian trade routes and the like, but in a nutshell I think that is much of it.
The state did reform itself to some extent. Both economically and politically( i.e. the endemic warlordism of the 18th century and the rebellious praetorianism of the kapikulu regiments was reigned in or snuffed out ). But in part it did so on the back of both a greater emphasis of the sultans standing as Caliph and unifying Turkish nationalism. Given the rise of ethnic nationalism generally I’m not sure if the first( claim to universal Sunni leadership )would have trumped the second( ethnic nationalism ). I suspect the Ottoman state might have survived immediately if it had chosen sides correctly in WW I. But only for awhile. Intellectual Arab nationalism for example was already a thing before it went down. It’s fall might have been more gradual, but I dvery much oubt we’d still see an Ottoman state into the 21rst century.