The yellow and red pigments are the caretonoids, which serve as some sort of pre-cursor in the photosynthesis process, by trapping energy and transferring it to chlorophyll, and anthocyanings
The red color is anthocyanins. They get produced in a layer above the thylacoids and function as sunshades, reflecting the red light that the photocenters predominantly adsorb.
The yellow carotenoids are xanthophylls. They are incorporated into the second type of photocenters (PSII where water gets reduced) to divert adsobed photon energy away from the reduction site so the thylakoids don't become damaged by high levels of protons (H+). These are very important to alpine conifers. The cold temperatures of winter dramatically reduce the enzyme reaction rates, whereas the sun light level (rate of incoming photons) is little changed from what it is during the growing season.
I highly recommend Kahn Academy's course on photosynthesis (the same info is available in Wikipedia, but much more difficult to digest). Once that is understood, many open access scholarly papers (via Google Scholar) explaining stuff like anthocyanins and xanthophylls will make sense. It will be a deep dive.
btw, one can grind up their own tree leaves in a mortise and pestle, add a bit of high proof, clear ethyl alcohol, and then dip the end of a strip of white coffee filter paper into it. Different colored bands will appear representing the different colored compounds in the leaf at the time. Xanthophylls are difficult to see, unfortunately.
Also, anthocyanins were used for the original litmus papers - their colors change according to pH.
go nerds!