How can I enqueue a CSS code only on the pages which use that CSS?
Usually it's quite easy to know if a particular CSS or JS is used on a WordPress Post: it's enough to check if the shortcode is used in that post.
Is there any WP functionality to support the developer in this task?
wp_enqueue_script()
asset in your shortcode method/function. So only when shortcode is used, asset loads.