| RIO DE JANEIRO
RIO DE JANEIRO Just five years ago, Brazil's mostly "green" energy landscape was the envy of nations dependent on dirtier sources of power and the pride of a government that believed it was leading the country to economic superpower status.
Three-quarters of electricity came from renewable hydro power and the main automobile fuel was home-grown sugarcane ethanol. Plus, Brazil had just found massive oil fields off its coast, putting it on a path to become the world's No. 3 oil producer after Russia and Saudi Arabia by 2020.
Today, the outlook is much darker. Oil output is falling, ethanol production has plunged, and fears have recently returned of electricity rationing that could further depress a stagnant economy and embarrass President Dilma Rousseff.
What went wrong?
Analysts and investors say the current troubles were bred from an excessive optimism during the rosy years, when Brazil's government tried to take greater control of the energy bonanza and ended up scaring off investors.
"Brazil has become a victim of the politics of economic plenty," said Christopher Garman, Latin American director of the Eurasia Group, a New York-based political risk and economic consulting group.
"When things were going so well for Brazil, and after they discovered oil, the administration was infused with a sense of hubris," he said. "They thought they had more room to conduct an active industrial policy and change the regulatory landscape."
Rousseff recently dismissed fears of energy rationing as "ridiculous," despite some energy analysts and investors who say the possibility is quite real.
One of the root problems is beyond her or any government's control: one of the worst droughts in decades in parts of Brazil depriving dams of the water they need to generate electricity.
Brazil's recent efforts to diversify its electrical grid - which have earned it plenty of criticism from environmental groups - may in fact end up protecting the country from the widespread rationing most recently seen in 2001. Hydro power now accounts for about two-thirds of electricity generation, down from about 80 percent in 2005.
Yet the troubles go much deeper than just a few impaired dams. Brazil's whole energy sector is riddled with inefficiencies and investor anxiety, from state-owned colossus Petroleo Brasileiro SA, known as Petrobras, to the recent multibillion-dollar losses in valuation at electrical companies such as Cemig and CESP.
The stakes are particularly high for Rousseff, who was elected president in 2010 in part because of her perceived competence in managing the energy sector.
As energy minister from 2003 to 2005, she was charged with making sure Brazil never experienced a big shortage again and with paving the way for the country to become an oil superpower in decades to come.
The problems in the sector also reflect a broader complaint from investors - that heavy-handed government intervention under Rousseff has increased the role of the state at the expense of the private sector. As a result of that and other problems, Brazil's economy likely grew less then 1 percent in 2012, one of the lowest rates in Latin America.
GOOD INTENTIONS GONE BAD
In recent years, Rousseff oversaw the rewriting of a decade-old legal framework for oil production, blocked efforts by Petrobras to raise gasoline and diesel prices, and forced Centrais Eletricas Brasileiras, a state-led utility, to cut power rates in exchange for hydro concession renewals.
Nearly all those measures backfired in one way or another.
The new oil law, passed in 2010, sought to maximize the government's control of the bonanza expected from the so-called subsalt fields, one of the world's largest recent oil finds with as much as 100 billion barrels of oil buried underneath a New York-state-sized area along Brazil's coast near Rio de Janeiro and Sao Paulo.
At current rates of consumption, that would provide enough oil for all U.S. needs for 14 years and all of Brazil's for a century.
Rather than immediately exploiting the oil and reaping the benefits primarily through royalties, the government hoped to use the subsalt fields as an opportunity to build an entire offshore oil industry.
It raised requirements for minimum Brazilian content in oilfield development and required that Petrobras increase its already dominant share of exploration and production.
It also wanted to ensure the royalties were used for long-term purposes such as education, and avoid "Dutch disease" - an overvaluation of the local currency as a result of oil and other commodities exports that devastates local manufacturing industries.
In practice, the uncertainty generated by the law has halted, since 2008, what had previously been annual oil-rights auctions. Leases sold through such auctions helped more than double Brazilian output from 1997 to 2008.
"The government took a law that worked, that was responsible for our oil industry's success, and changed it anyway," said Adriano Pires, head of the Brazilian Infrastructure Institute, a Rio de Janeiro energy research group. "The result is a mess."
The law's changes in royalty rules touched off a dispute between oil producing states and the rest of Brazil that could block auctions planned for this year.
The law also gave Petrobras the exclusive right to run all future exploration and output in the most promising areas of Brazil's Campos and Santos Basins, home to nearly 90 percent of Brazil's output.
Companies that had considered long-term commitments to Brazil such as Devon Energy and Exxon Mobil Corp have since scaled back Brazilian plans or left. In the case of Devon, easier- and cheaper-to-produce shale gas and oil in the United Sates seemed a better bet than Brazil's complex offshore options.
This has placed more responsibility on Petrobras and it is already unable to meet its production and expansion goals under a $237 billion five-year plan, the world's largest corporate-spending program.
Petrobras output has dropped for eight straight months. That has crimped cash flow just as the government is pushing it harder to build hundreds of ships, dozens of drill rigs and production platforms, and five new refineries needed to develop its new reserves.
Arguably the most damaging action, though, has been the government's fuel-pricing policies. The failure to allow Petrobras to raise domestic gasoline and diesel prices in line with world prices prompted its first loss in 13 years in the second quarter of 2012 and added more than $8 billion in 2012 losses at its refining unit.
The government has kept fuel prices low in an effort to control inflation in the wider economy. Inflation is already running above 5.7 percent on an annual basis, near the top of the central bank's target range, as a tight labor market and historically low interest rates push prices higher.
While saying fuel prices are likely to rise this year, Finance Minister Guido Mantega - who is also Petrobras' board chairman - has not set a date.
The impact on Petrobras shares has been significant. They now trade for less than they did before Petrobras made its first giant oil discoveries in 2007.
In 2008, Petrobras' discoveries helped make it, along with General Electric, Exxon Mobil and Microsoft, one of the world's 10 biggest companies by market value.
Today, despite the discovery of billions of barrels of reserves and a $78 billion share sale in 2010 - the largest sale of new stock in history - Petrobras's valuation on the stock market is about the same as Cia. de Bebidas das Americas SA (Ambev), a Brazilian brewer.
Artificially cheap gasoline has had another major, unintended side effect: it has hurt ethanol by making it uncompetitive. Sugar cane farmers responded by cutting production, and ethanol prices soared.
Ethanol demand peaked in 2009. Since then prices have more than doubled, even as sales plunged 41 percent.
Ethanol, which once made up more than a fifth of all Brazilian fuel sales and was more widely used than gasoline, was competitive on average in only two of Brazil's 27 states in each of the 12 months through November, Brazil's fuels distributors' association said.
But because ethanol also made up a quarter of all gasoline blends, the higher ethanol price also raised the pump price of regular gasoline. In response, the government cut the amount of ethanol in gasoline to 20 percent in late 2011 to prevent it from boosting the inflation rate.
With its refineries running at full capacity, Petrobras was then forced to import gasoline at world prices and sell it at a loss.
"You get the feeling that the government is improvising," said Luiz Pinguelli Rosa, a physicist and director of post-graduate engineering studies at the Federal University of Rio de Janeiro and formerly president of state-led utility Eletrobras under the previous government.
"These policies have hurt both Petrobras and the ethanol industry, which are important to our development," Rosa said.
FORCING ELECTRICITY PRICES DOWN
The other big chill in the energy industry has resulted from Rousseff's recent plan to force a decline in electricity prices. The measure was supposed to help stir the broader economy, but may prove to be a low point in her relationship with the private sector.
Brazil's electricity prices were until recently the world's third-highest, according to some studies. Rousseff announced a plan last year to push them down 20 percent.
The high prices are largely a result of taxes, which the government has had little success cutting. Lower rates will help consumers but could also make it hard for utilities to invest the tens of billions of dollars the government wants them to spend to expand service and build new dams to meet Brazil's growing electricity needs, Rosa and Garman said.
Brazilian officials have said electricity companies will simply have to operate with lower profit margins than before to help make up the difference. Investors have responded by selling utility stocks.
Declines over the past year in the stock of Eletrobras, Latin America's largest utility, have wiped out two decades of investors' gains.
"The government is in a tight spot. Energy is now their Achilles' heel," said Oswaldo Telles, an energy analyst at Espirito Santo Investment Bank in Sao Paulo. "The price moves are the last card up their sleeve. If they don't work, they will have to try something more drastic or give up on more goals."
(Reporting by Jeb Blount; Editing by Brian Winter, Kieran Murray and Jim Marshall)