My (limited) understanding is that the Sun is in equilibrium. Gravity pulls in, Radiation pressure pushes out. Gravity forces are a function of its mass which decreases as it burns its fuel. So as gravity decreases its atmosphere layers will expand outwards during the red giant phases. Then collapse again when nothing's left to burn.