Costa Rica modernized without wrecking the environment. Here’s how.