It is the black of night.
A Canadian Pacific train barrels down the tracks in Banff National Park.
As it rounds the curve on the track, the light on the front of the locomotive illuminates an animal on the tracks.
As the train speeds closer, it becomes clear, it is a grizzly bear.
The next second or two will determine the grizzly's fate.
If it reacts quickly enough, it may make it off the tracks and into the brush on the side of the railway. If not, it will meet a near certain death.
When trains and wildlife collide, the wildlife rarely survives the violent impact.
It's a real life scenario playing out with alarming frequency on the tracks between Banff and Yoho National Parks. In the past 17 years, 17 grizzly bears have been struck and killed by trains.
"We're in Canada's first National Park with Canada's foundational transportation mode and dealing with grizzly bears which are threatened in Alberta and iconic to a lot of people," Cassady St. Clair explains.
Each grizzly that dies by train strike is a devastating blow to a population that already reproduces at an excruciatingly slow rate.
There are currently only 60 grizzly bears in Banff National Park and an estimated 700 in the province of Alberta.
And yet, there are signs that measures being taken by researchers, Parks Canada and the railway may be starting to stem the losses.
About a hundred metres down the railway track off Five Mile Bridge in Banff, Jonathan Backs is changing batteries in a device he hopes will be a key part of the solution to stop grizzly bears getting struck by trains.
The PhD candidate wanted to combine his engineering degree with his passion for wildlife conservation to help tackle the problem.
It starts, Backs says, with a hard truth about trains: "Trains can't slow down very fast, and they can't change direction."
With enough warning, however, bears can. That's what inspired Backs to invent a system to warn the bears.
With fresh batteries, Backs attaches the metal box slightly larger than a brick to the side of the tracks.
"It emits flashing lights and sounds, not unlike the railroad crossing signals that you would find anywhere in Canada," Backs explains, "But these are smaller, more portable and specifically designed to attract the attention of wildlife."
Unlike the warning systems used for humans, the bear-warning device works by feeling an oncoming train.
The devices are placed at so-called hotspots, where animals, including bears, have been most likely to be killed by trains.
"We detect the trains with both magnetic and vibration sensors. So, no matter which way the train is coming, these warning signals will go off 30 seconds before the train arrives."
The warning system isn't meant to frighten the bears, but rather teach them. The hope is they'll learn that when the lights start flashing and the loud beeping starts, a train is coming soon. Ideally, they will begin to move 30 seconds before the train arrives — plenty of time to avoid impact.
Why are grizzlies suddenly being killed?
And cameras in nearby trees are providing some anecdotal evidence to indicate the warning system is effective. It has captured both a bear and elk reacting to the lights and sound before a speeding train was visible to the animal.
To really know how to fix the problem, however, researchers needed to know why so many grizzlies were suddenly getting killed by trains. It's a phenomenon that only began at the turn of this century.
The railway from Calgary to Banff was built in 1883, part of a transcontinental railway that was practically and symbolically essential to Confederation.
'So we are all striving together … to come up with solutions to reduce mortality.' - Dwight Bourdin, Parks Canada
For well over a century, the trains came and went, but grizzly collisions were rare.
But around the turn of this century, something changed. So the team of researchers from the University of Alberta teamed up with CP Rail and Parks Canada to study the issue.
"We're a national park, we're a world leader in conservation, and it's one thing that the public is concerned about," says Parks Canada resource conservation manager Dwight Bourdin.
"So we are all striving together … to come up with solutions to reduce [grizzly] mortality."
They started by tracking grizzlies previously collared with GPS trackers by Parks Canada to learn which bears were frequenting the dangerous tracks.
They examined hair samples and bear droppings, or scat, to correlate the grizzly diets with thousands of travel points in the tracking area.
"If it's grain in the scat, it looks pretty much the same coming out as it is going in," Cassady St. Clair says. "We can also tell if the diet is mostly vegetation or whether there some animal in. We can usually tell from the hair in it and we can often see maggots in the scat."
Knowing what the bears were eating was essential to knowing what was drawing them to the tracks. There was a belief that bears were near the tracks to forage grain spilled from the cars.
But researchers discovered something suprising: far fewer bears were eating canola, barley and and lentils on the tracks than expected. Only four of the 21 collared bears were spending more than 20 per cent of their time on the railway to find grain.
"So that really switched our thinking from what we had believed, which is this is something all bears did some of the time. We learned that eating grain is something only a few bears specialized in doing." Cassady St. Clair says, "Three could be put into one category, they were teenagers and skinny and probably having a tough time making a living."
The fourth is Bear 122, also known as "The Boss". The giant, 270-kilogram grizzly rules the rail, and he's tough enough to have survived a train strike. Research revealed he was coming to the tracks not for grain but to feast on the carcasses of deer, elk and moose that had been killed on the tracks.
The researchers broadened their scope. It turned out there's a list of changes to their environment that may be contributing.
St. Clair and her team believe highways expanded to accommodate more park visitors have changed the bears' habitat.
Less meat available
As well, climate change is affecting hibernation patterns and the places where bears can access critical food sources.
But the most important change, Cassady St. Clair believes, is a depletion of available meat.
"The biggest effect we can see from the onset of the mortality of the grizzly bears is the reduction of the elk population that came after the colonization of the Bow Valley by wolves," she says. "When wolves recolonized in the mid-1990s, the elk began to crash by a little after 2000."
With less elk to eat, it's the protein-rich vegetation such as horsetail or sweet vetch that's the biggest draw to the areas around tracks, Cassady St. Clair and her team believe.
With so many contributing factors, the stakeholders are taking a multi-faceted approach to solutions.
Cutting back vegetation
In addition to Jonathan Back's bear-warning system, Canadian Pacific Railway's manager of environmental assessment, Joe Van Humbeck, says CP is working on the areas it controls..
"We certainly don't discount that grain is one of the contributors, so we do have a rail-mounted vacuum truck which we go and pick up piles whenever there is a large spill."
CP is cutting back vegetation so bears have the best chance of spotting oncoming trains as early as possible. The railway is clearing dandelions and berry bushes that grow near the tracks and draw the bears too close to the trains.
Parks Canada is focusing on off-track mitigations such as trails and travel routes that would keep grizzly bears away from the tracks. It is also researching the effectiveness of controlled burns and forest thinning to push bears to new habitats with good food sources away from the tracks.
There is reason to hope these measures are starting to work. Recently, the rate of trains killing one of Canada's most iconic, majestic and threatened animals has slowed significantly.