Turkey is confronting what amounts to a strategic nightmare as bombs explode in its cities, its enemies encroach on its borders and its allies seemingly snub its demands.
As recently as four years ago, Turkey appeared poised to become one of the biggest winners of the Arab Spring, an ascendant power hailed by the West as a model and embraced by a region seeking new patrons and new forms of governance.
All that has evaporated in the wake of the failure of the Arab revolts, shifts in the geopolitical landscape and the trajectory of the Syrian war.
Russia, Turkey's oldest and nearest rival, is expanding its presence around Turkey's borders - in Syria to the south, in Crimea and Ukraine to the north, and in Armenia to the east. On Saturday, Russia's Defense Ministry announced the deployment of a new batch of fighter jets and combat helicopters to an air base outside the Armenian capital, Yerevan, 25 miles from the Turkish border.
Blowback from the Syrian war in the form of a string of suicide bombings in Istanbul and Ankara, most recently on Wednesday, has brought fear to Turkish streets and dampened the vital tourist industry.
The collapse of a peace process with Turkey's Kurds has plunged the southeast of the country into war between Kurds and the Turkish military just as Syrian Kurds carve out their own proto-state in territories adjacent to Turkey's border.
The economy is in the doldrums, hit by fears of instability and by sanctions from Moscow targeting such goods and revenue sources including Turkish tomatoes and tourism in retaliation for the downing of a Russian plane in November.
Worries that the tensions could escalate further are spreading, both in Turkey and in the wider international community, prompting French President François Hollande to warn on Friday that "There is a risk of war between Turkey and Russia."
"Turkey is facing a multifaceted catastrophe," said Gokhan Bacik, professor of international relations at Ankara's Ipek University. "This is a country that has often had problems in the past, but the scale of what is happening now is beyond Turkey's capacity for digestion."
A rift with the United States, Turkey's closest and most vital ally, over the status of the main Syrian Kurdish militia, the People's Protection Units (YPG), has further exposed Turkey's vulnerability. A demand by President Recep Tayyep Erdogan that Washington choose between NATO ally Turkey and the YPG, its main Syrian ally in the fight against the Islamic State, was rebuffed by the State Department this month, despite Turkish allegations that the YPG had carried out the bombing in Ankara.
On Saturday, Turkey dug in, demanding unconditional support from the United States. "The only thing we expect from our U.S. ally is to support Turkey with no ifs or buts," Prime Minister Ahmet Davutoglu told journalists in Ankara.
Turkey now stands completely isolated, trapped in a maze of quandaries that are partly of its own making, said Soli Ozel, professor of international relations at Istanbul's Kadir Has University.
"It has so alienated everyone it cannot convince anyone to do anything," he said. "It is a country whose words no longer carry any weight. It bluffs but does not deliver. It cannot protect its vital interests, and it is at odds with everyone, including its allies.
"For a country that was until very recently seen as a consequential regional power, these facts strike me as quite disastrous," he added.
Most immediately, Turkey is agonizing over the fast-changing dynamics along its southern border with Syria, where Russia is bombing, Kurds are advancing and the rebels it has supported against President Bashar Assad for the past five years are facing defeat.
Sending troops into Syria, as Ankara has hinted it might, would risk a confrontation with Russia that Turkey would almost certainly lose. The downing of a Russian plane in November was, in retrospect, a major miscalculation, analysts say, one that has hamstrung Turkey's ability to project its influence into Syria and prevented it from flying missions there even in support of the U.S.-led coalition against the Islamic State.
Not to intervene would mean bowing to the inevitability of an autonomous Kurdish enclave in northern Syria bordering Turkey's own restive Kurdish region, as well as the defeat of the rebels Turkey had hoped would topple Assad and project Turkish influence into the Arab world.
For now, Turkey has confined its response in Syria to artillery shelling against the advancing Kurdish forces and efforts to reinforce the rebels. A rebel fighter in the border town of Azaz, who spoke on the condition of anonymity because the issue is sensitive, confirmed multiple reports that Turkey has facilitated the deployment of several hundred rebel fighters from the province of Idlib into Aleppo, via Turkish territory.
At the same time, Erdogan has sought, without success, to revive pressure on the United States to agree to long-standing Turkish proposals for the creation of a safe zone in northern Syria that would protect Syrian civilians who have sought refuge from the fighting along Turkey's border.
Most observers think direct Turkish intervention unlikely, at least for now. There is no public support for a war and no support for one within the Turkish armed forces. A group of more than 200 academics signed a petition last week urging Turkey not to go to war in Syria, and the military has publicly stated that it is not willing to send troops across the border without U.N. Security Council approval.
But that has not deterred Erdogan from continuing to threaten action, drawing supposed red lines and seemingly digging Turkish policymakers deeper into a hole from which there is no obvious escape. He recently said the fall of rebel-held Azaz to the advancing Kurds would be a "red line" and vowed that Turkey would not allow the creation of a refuge for militant Kurds in Syria.
Turkey's predicament is not entirely self-inflicted. Some of the broader global trends - such as Russia's increasing assertiveness and the United States' waning interest in the Middle East - could not readily have been foreseen when Turkey set about crafting its ambitious foreign policy earlier in the decade, analysts say.
But Erdogan appears to have misjudged the extent to which the shifting parameters have constrained Turkey's room to maneuver, according to Henri Barkey, a Turkey expert at the Wilson Center in Washington.
"Erdogan has mismanaged foreign policy because of hubris," Barkey said. "He was overconfident in 2010 that Turkey was the darling of the world, and that went to his head. There are setbacks that are not of his doing, but how he managed those setbacks are his doing."
At a time when Erdogan is also confronting unforeseen challenges to his domestic ambitions, notably his plans to amend Turkey's constitution to enhance his presidential powers, further Turkish missteps cannot be ruled out, said Bacik, the professor in Ankara.
"I'm not saying that Turkey has lost its mind and is poised for war, but the posture in Ankara is very strange and could lead to surprises," he said. "What's happening in Syria is a question of survival for Erdogan, so it is not possible to rule anything out."
"For Turkey," he added, "there is no good scenario from now on."