You’re probably doing this inside your xxxx.css asset.
These files are not processed by Liquid and you wouldn’t be able to do it this way anyway – even if it was xxxx.css.liquid, assets are compiled once for all site pages and ignore variables like template.
You could do this in layouts/theme.liquid as suggested in another reply, but I do not recommend it because every edit to the theme code will make updating to a newer version of the theme more complex.
Ideally, you should be able to create a CSS rule which will work either in section “Custom CSS” setting or in Theme Settings “Custom CSS”.
If this does not work for your particular task (header may have elements which are not inside section element) , you should be able to paste your CSS code wrapped with .. into a “Custom Liquid” section added to index template – this way it will only run on your homepage.