Structural investigation of gaseous, liquid, and solid Br2 by x-ray absorption