Phase behavior in shale remains a mystery because of various complexities and effects. One complexity is from nanopores, in which phase behavior is significantly affected by the interaction between the pore surfaces and fluid molecules. The result is the heterogeneous distribution of molecules that cannot be described by bulk-phase thermodynamic approaches. Statistical thermodynamic methods can describe the phase behavior in nanopores. In this work, we apply an engineering density functional theory (DFT) combined with the Peng-Robinson equation of state (EOS) to investigate the adsorption and phase behavior of pure substances and mixtures in nanopores, and include the characterization of pore structure of porous media. The nanopores are represented by carbon-slit pores each consisting of two parallel planar-infinite structureless graphite surfaces. The porous media are activated carbons and dry coal, each modeled by an array of polydisperse carbon-slit pores. We study the influence of multiple factors on phase transitions of various pure light species and their mixtures in nanopores. We find that capillary condensation and hysteresis are more likely in heavier hydrocarbons, at lower temperatures, and in smaller pores. For pure hydrocarbons in nanopores, the phase change always occurs below the critical temperature and saturation pressure. For mixtures in nanopores, there may be a phase change above the cricondentherm. We characterize the pore structure of porous media to obtain the pore-size distribution (PSD), surface area (SA), and pore volume (PV) on the basis of the measured adsorption isotherms of pure substances. Then, we use the computed PSD to predict the adsorption of mixtures in porous media. There is agreement between the experiments and our predictions. This work is in the direction of phase-behavior modeling and understanding in shale media.