[Feature request] Export SASS variables to CSS variables

IAmAPony
Speaking Fancy - For helping with translations

Description
 
You’ve shared SASS sources to make writing custom user styles easier. While this is awesome, it works only for the theme kind of user styles. Any user styles which rearrange elements and any user scripts which add new elements would benefit from being able to read the current values, in order to make rearranged and new elements match the rest of the page’s style.
 
Suggestion #1 (simple part)
 
Export common SASS variables to custom CSS properties aka variables so that $background_color: #ffffff !default; in SASS becomes --background-color: #ffffff; in :root in CSS.
 
Suggestion #2 (optional hard part)
 
If you not only export CSS variables but switch to using them when assigning values to normal properties, any theming user styles will be ten times simpler and future-proof. Instead of generating the whole CSS, all they would need is to modify the CSS variables.
 
This can be seen on modern YouTube, for example. To change link text color, all I need is to set :root { --yt-endpoint-color: red !important; }. If a user script adds an element, it can style it by using background: var(--yt-app-background). This makes user styles and user scripts much more reliable, compatible with each other and future-proof.
 
However, CSS variables have only recently been added to Edge, so switching to their usage over SASS variables may be a bit too early, just a future plan if you want to gain the benefits of CSS variables.
Luna
Luna - For Patreon supporters
Woona - Derpi Supporter
Pixel Perfection - I still call her Lightning Bolt
Flower Trio - Helped others get their OC into the 2023 Derpibooru Collab.
Roseluck - Had their OC in the 2023 Derpibooru Collab.
Solar Supporter - Fought against the New Lunar Republic rebellion on the side of the Solar Deity (April Fools 2023).
Lunar Supporter - Helped forge New Lunar Republic's freedom in the face of the Solar Empire's oppressive tyrannical regime (April Fools 2023).
Princess of Love - Extra special version for those who participated in the Canterlot Wedding 10th anniversary event by contributing art.
Tree of Harmony - Drew someone's OC for the 2022 Community Collab
Elements of Harmony - Had an OC in the 2022 Community Collab

Luna Best Pony~
CSS variables is something we looked into a while ago, but never actually implemented due to not all relevant browsers supporting them. Also AFAIK you can’t modify colors the same way you can in SASS (lighten, saturate) if using CSS variables. Unless you mean just exporting the pre-compiled values of the variables into css variables, which is possible.
IAmAPony
Speaking Fancy - For helping with translations

@Luna  
Just exporting all variables to CSS would be a good start.
 
For example, my user style merges top menus in the header, but can’t get the colors of the menus, so works correctly only in the default light theme. A similar problem with my user script (unpublished yet) which adds subheaders to thumbnails (JS can get computed CSS colors, I admit, but it’s more code).  

 
As for color modification, there’re no functions similar to what exist in popular CSS preprocessors, but there’s a somewhat unorthodox way which I’m currently using in user styles (AO3 style, for example). It involves specifying colors through HSL values, modifying individual components, and using calc function to get the final values. Looks verbose and theming isn’t 100% flexible as HSL color space is uneven in different hues, but works. :)
 
Looks like the people designing the CSS standard went crazy when asked for those lighten and darken functions and are proposing some crazy color modification functions (similar to transform property functions) and even crazier color spaces in new CSS Color 4. It’s an early Working Draft currently, so unless you switch from SASS to something like PostCSS, no luck with using it (and it’ll function as preprocessor, so no real benefits).
Luna
Luna - For Patreon supporters
Woona - Derpi Supporter
Pixel Perfection - I still call her Lightning Bolt
Flower Trio - Helped others get their OC into the 2023 Derpibooru Collab.
Roseluck - Had their OC in the 2023 Derpibooru Collab.
Solar Supporter - Fought against the New Lunar Republic rebellion on the side of the Solar Deity (April Fools 2023).
Lunar Supporter - Helped forge New Lunar Republic's freedom in the face of the Solar Empire's oppressive tyrannical regime (April Fools 2023).
Princess of Love - Extra special version for those who participated in the Canterlot Wedding 10th anniversary event by contributing art.
Tree of Harmony - Drew someone's OC for the 2022 Community Collab
Elements of Harmony - Had an OC in the 2022 Community Collab

Luna Best Pony~
@IAmAPony  
I’ll export all SCSS variables into CSS vars with the same names and set their values to the evaluated values of SCSS vars.  
We will maybe switch to using those on the site in the future, but I can’t say anything more specific at this time.
byte[]
Solar Supporter - Fought against the New Lunar Republic rebellion on the side of the Solar Deity (April Fools 2023).
Non-Fungible Trixie -
Verified Pegasus - Show us your gorgeous wings!
Preenhub - We all know what you were up to this evening~
An Artist Who Rocks - 100+ images under their artist tag
Artist -

Philomena Contributor
@Luna  
You act like it’s a secret decision full of red tape :p
 
The reality is that we just don’t like browser support as is, so we’re waiting for people to update to more current ones that support the standard.
stsyn
Lunar Supporter - Helped forge New Lunar Republic's freedom in the face of the Solar Empire's oppressive tyrannical regime (April Fools 2023).
Elements of Harmony - Had an OC in the 2022 Community Collab
Non-Fungible Trixie -
Twinkling Balloon - Took part in the 2021 community collab.
Notoriously Divine Tagger - Consistently uploads images above and beyond the minimum tag requirements. And/or additionally, bringing over the original description from the source if the image has one. Does NOT apply to the uploader adding several to a dozen tags after originally uploading with minimum to bare tagging.
Best Artist - Providing quality, Derpibooru-exclusive artwork
Fine Arts - Two hundred uploads with a score of over a hundred (Safe/Suggestive)
Economist -
Cool Crow - "Caw!" An awesome tagger
The Power of Love - Given to a publicly verified artist with an image under their artist’s tag that has reached 1000 upvotes

Moderator
@IAmAPony  
A few days ago to body tag was added attribute data-theme with the name of theme. So, you may add style for dark theme by selector body[data-theme*=dark]
IAmAPony
Speaking Fancy - For helping with translations

StSyaN  
Yes, I noticed this yesterday while trying to figure out how to differentiate between logged in and logged out states in CSS. :) Need to fix the style. (Haven’t found a clean way to detect logged out state, by the way, so a similar attribute would be appreciated.)
 
It won’t work with external non-standard themes. However, not sure how popular they are, considering damn UserStyles.org doesn’t accept DerpiBooru styles and there’re no alternative websites besides Gist and the like (.user.css convention only being supported in Stylus doesn’t help).
Interested in advertising on Derpibooru? Click here for information!
My Little Ties crafts shop

Help fund the $15 daily operational cost of Derpibooru - support us financially!

Syntax quick reference: **bold** *italic* ||hide text|| `code` __underline__ ~~strike~~ ^sup^ %sub%

Detailed syntax guide