Pegmatites

Note that the early part of this movie shows hot (red) magma intruding into the upper part of the Earth's crust. It does not manage to get all the way to the surface, so no volcano forms! Over time the magma cools - note how the color changes to orange and grey to indicate this. The rocks around the intrusion crack. In the final stages of crystallization of a granitic magma, water-rich magma containing lots of rare elements and volitles flows up and fills in fractures in preexisting rock.

As the fluids cool, quartz, feldspar, and micas crystallize along the outer edge next to the wall rock.

The remaining fluids are now highly rich with rare elements. The fractures or pockets begin to crystallize gem crystals. Green and purple shapes represent these crystals.