The text does a good job of describing this behavior, I like its analogy of the boiling water in the lidded pan. Core produces energy. Outer layers opaque, trap radiation. Outer layers heat and expand. Layer becomes transparent and cools.
Gases fall back inwards, become denser and opaque again.
Named for the first studied stars of these types. All low mass stars will become RR Lyrae or Cepheid variables stars during their life. So these star types are very common. Our sun will remain as a Giant star for a long time. But not nearly as long as it was a main-sequence star.