At the time, it was a great leap forward in sanitation, even though it overflowed during rainstorms and dumped raw sewage into the bay. By the 1970s, with the passing of the Clean Water Act, that was a no-no. So the city built a ring of giant underground chambers around the peninsula—some as big as 25 feet wide by 45 feet tall. During dry weather, sewage collects at one of two treatment plants. But when it rains, storm runoff and sewage run downhill through a single set of pipes and drain into the big chambers. They function like waiting rooms, detaining stormwater until the treatment plants can process it all.

Today, overflow only happens during big storms, when the chambers and treatment stations fill to capacity. Then, sewage and stormwater have nowhere to go but out of 36 discharge outfalls located around the city, several feet below street elevation. But if especially wet weather happens to coincide with peak high tides, those outfalls become submerged, flooding any areas of the city at or below bay level with a mix of sewage and stormwater. This has been happening more frequently lately, as climate change has already raised sea levels around San Francisco by a few inches. And it’s expected to happen a lot more in the coming decades, with levels estimated to increase by up to 24 inches by 2050—enough to put most outfalls underwater daily.

Rising seas aren’t just a problem during the rainy season. In dry weather, big tides can breach the outfalls, flow into the collection containers, and wind up in the treatment plants. Corrosive saltwater wreaks havoc on the pumps, filters, and other equipment keeping San Franciscans from living in a cesspool. Today, that happens fairly infrequently. But more ocean means more ocean water entering and damaging the system.

A backseat engineer might ask at this point, “Why not just raise the outfalls a few feet?”

Oh, were it only so simple. But because the sewers are built on the city’s existing gravity-driven hydraulic gradient, you can’t go tweaking one part without feeling the effects system-wide. Higher outfalls won’t get submerged as often, but during storm events there will be less room for all that water to go. Which would mean even more flooding during the rainy season, even with the outfalls clear of the tides. And, don’t forget, those outfalls lead to containers and treatment plants that are mostly all underground, directly in the path of shoreline erosion caused by rising sea levels.

Without upgrades, here’s what will be inundated by the end of the century: SFO International Airport, the Giants Stadium, the site of the new Warriors Stadium. And, oh yeah, headquarters for companies like Facebook, Google, Airbnb, and the brand-spanking new Salesforce building, now the skyline’s tallest spire. Models project 6 percent of San Francisco will be inundated by normal, daily tides by 2100.

Last year San Francisco Mayor Ed Lee committed an initial $8 million to begin fortifying the city’s seawall. But shoring it up in the short-term will cost about $500 million—long-term, $5 billion. Add to that another $350 million to protect all the wastewater infrastructure and limit how much seawater makes it inside, and the climate change costs quickly add up. Costs, the city now says, should be shouldered by the corporations that still produce vast quantities of fossil fuels, despite having known for decades their role in driving climate change and accelerated sea level rise.

“These fossil fuel companies profited handsomely for decades while knowing they were putting the fate of our cities at risk,” San Francisco City Attorney Dennis Herrera said at a press conference announcing the lawsuit in September, which named BP, Chevron, ConocoPhillips, Exxon Mobil, and Royal Dutch Shell as defendants. “Now, the bill has come due.”