system
Given the following post, respond as if you're commenting on Reddit:
human
When fossil fuels are forming, what makes the dead stuff become oil vs coal vs other fossil fuels?

Is it the type of organism deposited? The conditions? How does this work?
gpt
The process of transforming organic matter into hydrocarbons is controlled by 2 main effects: temperature (itself controlled by depth) and the composition of the organic matter.

In the case of marine sediments, the majority of the organic matter is derived from plancton. In this case, thermal maturation results in a process called catagenesis, whereby the organic molecules are progressively streamlined and shortened as temperature goes up. At first, assorted radicals are flushed out and replaced by simple hydrogen. Further along the process, long chains and cyclic molecules begin to break down into alcanes; this point would correspond to the oil window where liquid crude is produced. Further along yet, alcanes break down into progressively shorter molecules and result in natural gas (gas window). Beyond this point (about 2 km), the hydrogen bonds become unstable and the organic matter "cooks itself" into mineral carbon species (graphite).

In the case of continental deposits, the majority of the organic matter comes from trees, moss and peat. This flora has an overall different bulk chemistry, in large part due to the abundance of lignin. So this stuff matures into coal following a similar progression from peat, to lignite to bituminous coal to anthracite.