As heavy winds heralded the approach of Superstorm Sandy, the US Coast Guard's regional command centre on Staten Island lost power and its hulking backup generators hummed into action.
Commander Linda Sturgis, who oversees emergency prevention at the Port of New York, was buzzed through two thick security doors into the Port's hive-like vessel traffic centre, the maritime equivalent of an air traffic control tower.
The Port had been bracing for Sandy for days, and a few hours earlier, its Captain had halted all commercial vessel traffic, an emergency lockdown known as Condition Zulu.
Shipping delays during storms are common.
What few people could foresee was how Sandy's 16-hour assault on a major oil hub would result in the worst regional fuel supply collapse in decades, delaying disaster relief, triggering panic-buying, and raising questions about energy security in the country's most densely populated area.
As Sandy approached, Commander Sturgis and her staff were in a unique position to watch it hammer the harbour.
On dozens of blinking monitors that track marine vessels by satellite, they verified that oil tankers, barges, container ships and recreational boats were hunkered down. Then, around 8pm local time on Monday 29 October, Commander Sturgis's sense of alarm began to rise with the tide.
Live feeds allowed her to watch Sandy raise sea levels by as much as 14 feet.
"When I saw that surge, I knew it would impact oil supplies," she says. "The public probably doesn't realize how critical the harbour is. It's the epicentre of fuel distribution for the whole Northeast."
Sandy's death toll stands at 132; thousands have been left homeless; economic damage estimates top $50 billion, and more than eight million homes and businesses lost power, some for weeks.
Supply and demand
But in some respects, it is Sandy's impact on oil supplies that posed the biggest and most unexpected challenge to resuming day-to-day activities, including in areas only lightly damaged.
As the heart of the East Coast fuel market, the harbour covers an area of 125 square miles in New York and New Jersey and takes in around 1.5 million barrels a day of oil from the US and overseas.
The region of 60 million, which consumes 6% of the world's oil, relies in part on harbour supplies.
Panic buying depleted stocks at fuel pumps even before Sandy hit.
Around 8am on Tuesday 30 October, the Coast Guard held the first of many post-storm conference calls with shippers, fuel terminal operators, and other harbour stakeholders. Reports from the field were sobering.
Sturgis said Phillips 66, operator of the 238,000 barrel per day Bayway refinery in Linden, New Jersey, reported that a 13-foot surge of corrosive saltwater had inundated parts of the plant.
Its power was out, and the plant - known among oil traders as "the gasoline machine" because it produces enough fuel to meet half of New Jersey's demand - had no timeline for restarting.
Another low-lying refinery, Hess Corp's 70,000 barrel-per-day plant in Port Reading, New Jersey, was also incapacitated by power outages.
Along the coast, two dozen major fuel terminals were inoperable. Tanks at the terminals store and blend oil to ship around the region.
The Coast Guard told shippers that harbour channels were still too hazardous to navigate. Buoys were blown out of place, and debris posed threats to tankers and barges.
No quick fix
Following the storm, oil workers were ready to spring into action, and the Coast Guard, with help from Army engineers and private pilot vessels, raced to re-open the port.
But many operators found there was no quick fix to the harbour's broader problems.
"It was really bad," said Scott Hellmann, a petroleum barge dispatcher for Harley Marine, whose work trailer in Brooklyn's Navy Yard was destroyed. "For about a week, barges just stopped." Fuel terminals could not receive them.
Much of Linden, New Jersey, a city of 41,000 around 13 miles southwest of Manhattan, was severed from the Northeast fuel supply chain.
Perched beside the hard-hit Arthur Kill, Linden is the harbour's pipeline crossroads and a staging point for oil shipments. Storm surges left boats piled up along the town's main industrial street.
Terminals in the area store bulk deliveries from tankers, refineries and pipelines and ship them out to 4,000 filling stations in the region.
Power was not restored to many Linden fuel terminals until 11 November. Five terminals remained completely shut as 26 November, government data shows.
Searching for fuel
Three days after Sandy, more than 70% of filling stations in New York and New Jersey had no gas for sale, according to Travel group AAA. As temperatures dropped to near freezing, the supply of heating oil was also strained.
Thousands of fuel truckers were forced to improvise. One national shipper, Mansfield Logistics, diverted trucks for hundreds of miles in every direction, bringing fuel from as far as North Carolina to northeastern customers, some located just a few miles from the harbour's tanks.
The crunch was worsened because many regional filling stations lacked generators and could not dispense gasoline.
Ultimately, New Jersey imposed fuel rationing based on license plate numbers, with New York City following suit six days later.
Most shipping lanes and facilities around the harbour are now operating normally, and power has been restored to millions.
But Sandy's fuel supply collapse has left a policy conundrum for officials, now more aware of the region's vulnerability.
Long before Sandy, cracks had begun to appear in the harbour's energy security. Even as oil and gas drilling booms in US shale formations, the East Coast has grown less capable of supplying its own fuel.
Citing poor profit margins, oil companies shuttered three northeastern refineries over the past two years, eliminating 24% of regional capacity. That increases reliance on supply from tankers and Colonial's pipeline.
Oil companies' penchant for just-in-time fuel deliveries raises further supply concerns. East Coast gasoline inventories were already near record seasonal lows before the storm, government data shows.
After two hurricanes hit the New York region in less than two years, the region could look south for energy security ideas.
When Hurricane Ike hit Texas in 2008, energy companies and emergency responders near a refining hub were ready, after storms Katrina and Rita in 2005 had hammered the energy industry.
As Ike approached, state governments and oil companies stationed fuel storage tanks and pumping trucks along evacuation routes.
Utilities gave priority to restoring power to refineries, fuel terminals and gas stations, after tending to hospitals and relief centres.
Some oil companies took the precaution of installing barriers or levees around their operations. Others readied meals and housing for their personnel to bring plants back quickly.