Does the `mdls` terminal command access metadata in resource forks? I always knew that Mac operating systems had a concept of "resource forks" but have just learned that this feature has in fact been deprecated since the arrival of OS X.

I also just discovered the mdls terminal command that lists metadata.

Does some or any of this metadata come from resource forks? If not, where is the metadata stored? Or is the metadata generated each time it's needed?
The meta data is stored in so called extended file attributes. The extended file attributes are stored in a named fork.

So in essence forks are still very much used on OS X. However, the specific "resource fork" as managed by the Resource Manager API is deprecated, as you describe.