Three months ago, Xisco Gràcia experienced what he describes as every diver's worst nightmare - he found himself in an underwater cave, relying on an air pocket for survival. As hours turned into days he realised he might not be found in time.
On Saturday 15 April, Xisco Gràcia slipped into the water in Mallorca for a routine dive. The geology teacher spent most weekends exploring and mapping the island's complex system of underwater caves.
"Mallorca is much more beautiful underground than above ground," he says.
He and his dive buddy, Guillem Mascaró, wanted to explore Sa Piqueta, a cave with numerous chambers 1km from the entrance of the labyrinth. They swam underwater for an hour to get there.
While Gràcia spent time collecting rock samples, Mascaró swam off to chart a nearby chamber.
It was as they headed for home that several things went wrong at once. Gràcia met Mascaró by chance at a junction, and they stirred up silt from the ground, making it difficult to see.
They then realised that their guideline - a narrow nylon wire which led back to the entrance - had either broken or slipped.
"The wire is for guiding purposes. It is left behind once you enter the cave and you can follow it out again afterwards," Gràcia, 54, says.
"We can only guess some rocks had fallen on it. We spent a precious hour trying to find it by touch, but without success."
By this point the pair were in grave danger. They had consumed the air they had brought to get them in and out as well as most of their emergency air.
Luckily, Gràcia remembered that other divers had talked of an air pocket in a chamber nearby. He tugged Mascaró to it, and there they talked through their options.
Both knew they only had enough air for one of them to make it out.
"We decided I would stay and Guillem would go for help. He was skinnier than me and needed less air for breathing. I was also more experienced at breathing cave air, which has higher carbon dioxide levels," Gràcia says.
They planned an alternative, longer route out on a map. Mascaró would have to travel along some of it without a guideline and could potentially get lost.
"It would have been like trying to drive a car in a very foggy night," Gràcia says.
"Guillem was reluctant to leave me on my own but we knew it was our only chance."
Once Mascaró had left, Gràcia took off most of his equipment and explored the chamber. It was about 80m (260ft) long and 20m wide, with a gap of 12m between the water and the ceiling.
He realised the water at the surface of the lake was drinkable. He also discovered a large flat rock and pulled himself out of the water to rest.
Gràcia decided he would have to manage without light. Two of his three torches no longer worked and the third was low on battery.
"I only turned it on when I went to pee or to climb down to get fresh water," he says.
There was little he could do now but wait, in complete darkness, and hope to be rescued.
"I asked myself why this had happened to me now after so many years of diving," Gràcia says.
"But I was hopeful during the first seven or eight hours as I thought Guillem would make it out. As time passed, though, I started to lose hope. I thought, 'Guillem has got lost and died and no-one knows I am down here.'"
Gràcia began to think about his loved ones above ground.
"I have two children, a son of 15 and a daughter of nine. I thought about how they were too young to lose their father and what would happen to them," he says.
Although he managed to remain calm, he began experiencing the effects of breathing in high levels of carbon dioxide. While the air we breathe above ground is 0.04% carbon dioxide, in the cave the level was as high as 5%.
"I had a headache and although I was exhausted through lack of oxygen it was impossible to sleep. My brain was whirring," he says.
His mind began playing tricks on him.
"I got the feeling there were lights in the lake and I heard the sound of bubbles of a diver emerging.
"But when I turned my head I saw nothing. It was a hallucination."
Gràcia lost track of time but after what felt like days he heard a loud noise above him. He realised Mascaró must have made it out.
"I thought at first I could hear the sound of tanks being filled with air for the rescue team. Later I realised they must be trying to drill through the rock.
"I was really happy as I realised they were looking for me."
But then the noises stopped and Gràcia faced his darkest moment.
"I thought about how I could die in the way divers most fear - without food or air," he says.
"My light was almost spent and I knew I wouldn't be able to climb down to get water in the dark.
"I decided to swim across to where I left my gear and get a knife. I wanted to have it as a last resort if I needed to choose whether to die quickly or slowly."
Shortly after this Gràcia thought he heard the sound of bubbles again.
"I looked and saw a diver's light that seemed to be getting brighter and brighter," he says.
"I thought it was another hallucination but then I realised it was real and I saw a helmet emerging."
It was Bernat Clamor, an old friend.
"I jumped in to the water and embraced him. He was asking me how I was, and telling me that he had been afraid I had died."
Gràcia learnt that Mascaró had managed to raise the alarm but that rescue efforts had been hampered by poor visibility.
Rescuers had then tried to drill a hole through the rocks to supply him with food and water - which explained the noises he had heard - but this attempt had also failed. Finally, Clamor and fellow diver John Freddy had made it through, after waiting a day for the silt to settle.
Gràcia's ordeal was still not over. Clamor had to leave him to contact the rescue team, but gave him some glucose pouches to boost his energy levels.
"It would take eight more hours to get me out of that cave, but they were eight happy hours," Gràcia says.
Gràcia was given air enriched with oxygen to breathe and slowly guided to the entrance. He emerged late on Monday 17 April, 60 hours after he went in. Guillem Mascaró was there to meet him.
"We embraced but didn't have time to speak as they took me off in an ambulance.
"It hit me physically as soon as I left the water. My temperature was 32C so I was at risk of hypothermia. I was given pure oxygen to breathe overnight."
Gràcia had kept his emotions in check the whole way through his experience.
"You have to be able to control your emotions with diving. But the next day I watched coverage of the big rescue operation on TV and I cried. I was so thankful."
Gràcia has not turned his back on diving, despite his narrow escape. A month after the incident he went back to Sa Piqueta. He has even visited the chamber where he was stuck for so long.
"I don't hold any grudges against that cave - it's not like it's the cave's fault," he says.
Gràcia says he will continue mapping Mallorca's underwater heritage.
"My children don't like it much but they don't tell me not to do it," he says.
"I have spent 24 years exploring underground. It's in my blood."
Listen to Xisco Garcia talking to Anu Anand on Outlook, on the BBC World Service
You may also like:
In February 2014 two divers died at a depth of more than 100m in a huge cave system in Norway. The authorities said it was too dangerous to retrieve their bodies, but four friends of the men decided to take the risk - and seven weeks later they descended into the dark and glacial waters.
It's well known that some of the world's most challenging peaks are dotted with the remains of mountaineers whose bodies could not be safely retrieved, but Finnish diver Sami Paakkarinen says that leaving bodies in the Norwegian cave would have been like leaving victims of a car crash by the side of the road.
"It's a code that no-one is left behind," he says. "You always have to do your best to get your friends out, wherever they are."
Claire Bates can be found tweeting @batesybates