The world never looks quite as grim with a cup of coffee in hand. But coffee, like all agricultural products, could be thrown into upheaval by climate change, making an already terrifying situation even bleaker. And a new study published in the Proceedings of the National Academy of Sciences offers a different perspective on the challenges that may block coffee fiends from a good cup of their necessary beverage.

When looking at the risks of climate change, two key factors have to be taken into account. The first is whether the species you're worried about—coffee plants, in this case—can withstand temperature and precipitation changes to their habitat.

But crops aren't totally isolated: Even though their lives are mostly managed by humans, they can still form ecological communities with other species. One particularly crucial relationship is with their pollinators. Some species can reproduce all on their own or with a helpful breeze, but others need a critter to carry their pollen—the botanical equivalent of sperm—to another plant's stigma, where it can create a seed or fruit.

That means that even if a plant itself is perfectly happy in its environment, if its pollinators have disappeared, the plant won't be able to reproduce.

Scientists have long been interested in how climate change could affect popular crops like chocolate, wine grapes and maple syrup, and coffee is no different. Studies have looked at how the Arabica coffee plant's habitat could shift with climate change and at how climate change could give a boost to a key coffee pest, the coffee berry borer.

The new study takes a different approach—it looks at the fate of bees, which pollinate coffee plants. When we think about bees, we tend to picture the basic honey bee, hive-dweller and agricultural superstar. But there are actually thousands of species of bees, which each fit into an ecosystem.

In addition to mapping how coffee-suitable habitat in Central and South America may shift with climate change, the scientists looked at how bee-suitable habitat may shift, then they combined those factors.

The coffee habitat predictions are grim: The scientists think good coffee ground in 2050 will span only a fifth to a quarter of current coffee-friendly habitat. That's a more dire picture than global estimates have suggested.

But pollination is also an important piece of the puzzle, since although coffee plants can create berries without help, insect pollination means better fruit. And there's a little bit of good news here: The team found that for all of the areas that should be good for coffee plants in the area, at least five bees should also be able to hang on. Growers looking to encourage insects could also give bees a boost by carefully choosing the trees they plant to offer the shade coffee trees need.