Andrea Johnson had little warning before the attack.
A recent Harvard graduate, she had spent several months in Borneo tracking orangutans. It was hot, sticky, and she was fighting boredom as she watched one of the rare orange-furred apes stuff herself with fruit in the rainforest canopy above.
Then she heard heavy breathing from a dead tree trunk, and looked down in surprise. "At first, I thought the noise was bees," she says.
That's when a furry black missile landed on her backpack and "knocked me to the ground as I turned to run," Ms. Johnson says. "It gashed my leg with its claws, and after I shouted and kicked, it took off.
"I'm really lucky," she says, rolling back her pant leg to show a still-red scar more than 16-months after the January 2000 attack. Johnson, an assistant on a long-term orangutan study, ruefully laughs at her encounter with a sun bear, the muppetlike smallest member of the ursine family. Yet the attack, in Gunung Palung National Park, was the start of a disturbing trend: There have been four more since then, after 16 years without a single incident.
Scientists say the attacks, by a normally shy and passive creature, are another indication that the natural balance of the Borneo's rainforest is skewed, after decades of logging.
"The bears are stressed, the whole system is stressed," says Johnson.
Intense logging in Kalimantan, Indonesia's two-thirds of the Pacific island of Borneo, isn't news. But when Gunung Palung was created in the 1980s, like other national parks it was meant to act as an ark of biological diversity amid a sea of logged-over grasslands and palm-oil plantations.
Instead, a study published in the journal Science last year shows that even where virgin forest still stands, the Borneo rainforest's biggest trees have stopped reproducing in response to climate change and the canopy fragmentation caused by massive logging in surrounding areas.
"We're coming to the end of the line," warns Lisa Curran, an ecologist with Yale University who led the 15-year study, most of which was conducted in Gunung Palung.
Scientists say the breakdown of Borneo's rainforest ecosystem is a stark reminder of the connections between biodiversity loss and the changing climate: A hotter globe is helping to kill the forest, and dwindling forests are among the factors contributing to global warming.
Protecting Indonesia's forests is critical to preserving global diversity, scientists say, because islands like Borneo are biological treasure troves.
The 19th-century English naturalist Alfred Russel Wallace, considered the father of "island biogeography," was the first to explain why. Traveling in what was then the Malay archipelago (now Indonesia and Malaysia) he observed that the isolation of island life encourages speciation - the process by which living things diverge from their ancestors.
Wallace showed that large islands hold more species than small ones, and tropical islands hold the most diversity of all. With 17,000 islands straddling the equator, Indonesia is a speciation machine. Borneo, the world's third-largest island, holds more native plants than all of Africa.
The most majestic of those plants are the dipterocarps - a tree family of 250 species that dominates the rainforest canopies of Sumatra, Borneo, and much of Malaysia.
These 150-foot giants are the keystone of the forest, which is why they were the focus of Ms. Curran's study. She found that the trees use a rare cooperative reproductive strategy that makes them unusually vulnerable to change: Almost all dipterocarps fruit in a simultaneous, six-week flurry every few years, in an event spanning hundreds of square miles.
The fruiting starts rush-hour in the rainforest. Long-tailed parakeets migrate inland, and macaques, or leaf monkeys, and orangutans converge to eat. They are followed by bearded pigs, who live for years in solitude before forming huge herds that sweep across the landscape during the fruiting.
No matter how the animals gorge, they are overwhelmed by the abundance - which is the point of the event, called a "mast" after an Old English word for nuts. The leftovers have time to germinate.
But that finely tuned system - the result of millions of years of evolution - has stopped working: Since 1991, every mast event in Gunung Palung has failed. No new seedlings have taken hold, a disturbing mystery that Curran's research helped unearth.
"It means the forest may not have a future," she says.
The reasons why get back to the suddenly aggressive sun bears. Habitat destruction concentrates their numbers, creating more competition for fewer resources. Throughout the 1980s, almost every part of Borneo that wasn't protected forest was intensely logged. In the late 1990s, illegal logging in national parks boomed as Indonesia's legal infrastructure collapsed amid political instability. In the past 15 years, forest the size of Ohio was cleared.
But the mast can only work on a huge scale. If too few trees are involved, or if the trees are so weakened by climate change that they put out only small amounts of fruit, animals like the bearded pig don't sweep across the landscape. They circle, and every seed is eaten.
"People still think of Kalimantan as this endless rainforest," says Izefri Caniago, who participated in the dipterocarp study and now works on a conservation project funded by the US Agency for International Development. "We can't afford to lose much more."
The climate change that's hurting the surviving trees is both local - as deforestation has made Borneo hotter and drier - and global, as the earth warms and the erratic El Niño weather pattern, which causes droughts across Southeast Asia, gains in intensity.
Though El Niño, a warming of the Pacific Ocean that changes global weather patterns, is now one of the factors contributing to the decline of the dipterocarps, it's also the key to the rainforest's explosive reproductive season.
Cooperative reproductive strategies have been observed in other ecosystems, including on Australia's Great Barrier Reef, where more than 100 coral species spawn simultaneously each year. There is always a coordinating trigger. Corals use the phases of the moon, for instance.
But the mast seemed to occur at random intervals - sometimes every five years, sometimes seven, sometimes three - leaving biologists scratching their heads. How were so many species coordinating a random event over hundreds of square miles?
Then they compared the mast intervals with El Niño. "It fit," says Curran.
The El Niño drought was the signal to start fruiting, and the irregularity of the signal helped the plants outwit the animals. Had the mast occurred on a regular cycle, animal populations would have ballooned to exploit the available food.
This synchrony made Borneo's big trees more successful than their cousins in other rainforests. Draped with creeping lianas and thigh-thick vines, it's a jungle out of a children's book.
So are the animals. The canopy's height and size have fostered the world's greatest array of gliding creatures - flying squirrels, gliding frogs, lizards with winglike flaps of skin, and paradise snakes that flatten their bodies and soar.
What breeds such diversity is poverty. When soils are sandy and poor, like Borneo's, an intricate, co-evolved network of life is favored over the handful of species that dominate richer landscapes such as North America's.
But after adapting for eons, Borneo's web of life is disappearing on a human timescale. In the past 10 years, the dwindling world orangutan population has been cut in half, to about 20,000.
Some scientists say that logging is contributing to global warming and more intense El Niños, since living trees absorb carbon dioxide - a greenhouse gas - and exchange it for oxygen. Forest fires release CO2.
Poorly managed logging leaves behind enough dead wood to create devastating wildfires, and Indonesia has ranked with industrialized countries in recent years as a producer of greenhouse gasses.
During the major El Niño drought of 1998, fires in logged-over Indonesian forests pumped an estimated 700 million tons of CO2, according to the Center for International Forestry Research in Bogor, Indonesia.
Gunung Palung has been ravaged by logging. As recently as two years ago, four hours of the five hour hike into Cabang Ponti, a research station where Curran and dozens of others have worked since the mid-1980s, was under rainforest canopy. Back then, researchers say, the eerie calls of gibbons and the squawks of hornbills broke the silence.
Today, the first four hours of the hike are through logged-over forest, along rivers choked with wood being floated downstream. The loudest call is the screech of the chainsaw.
"It's heartbreaking," says Curran. "You walk in parts of the forest that used to be these beautiful cathedrals. Now you want to cry." Researchers say logging already affects more than 50 percent of the park.
Cabang Ponti remains an oasis - a cluster of open huts overlooking a river where pythons sometimes still come down to hunt. But illegal chainsaw gangs are at work everywhere else in the park.
Though the researchers have been complaining for two years park officials say they're powerless, because logging is done with the cooperation of the local government and powerful business interests.
"Too many officials profit from this to want to stop it," says a park office official, who asked not to be named.
Park rangers confiscated chainsaws from loggers in the park earlier this year - only to have police confiscate the chainsaws from the park office and hand them back to the loggers.
Logging trails crisscross the lowlands, and piles of recently sawn lumber are stacked at a logging camp on the shore of the Rangkung River, waiting to be floated down river to market.
The rate of destruction is furious and wasteful. Loggers an hour's hike from Cabang Ponti are cutting bungkarai, a dense tree that sinks in water. So they're also cutting trees of a lighter species to serve as pontoons to float the bungkarai timber to market. The lighter trees are thrown away when the job is done.
And the loggers are drawing closer. One logger says he'll move his camp farther toward Cabang Ponti by October. "The researchers can't stop us," he says.
Gary Paoli, a University of Michigan PhD candidate in tropical biology, was to complete his field research by the end of July. "I'll be getting out just in time. It's awful to watch such a beautiful place get trashed."
There is still hope. Perhaps the remaining trees, which can live for 400 hundred years or more, will find a new equilibrium if logging slows, say researchers like Curran.
But there are few signs of that happening. While Indonesian forestry officials have promised repeatedly to stop all illegal logging, conservationists and forest companies say no action has been taken anywhere in the country, as far as they can tell.