When a star leaves the main sequence and expands toward the red giant region, what is happening inside the star?