/* Auto light / dark — follows prefers-color-scheme */
:root{
color-scheme: light dark;
--text-color: hsl(0, 0%, 18%);
--heading-color: hsl(0, 0%, 18%);
--background-color: hsl(0, 0%, 99%);
--bg-color: hsl(0, 0%, 99%);
--link-color: hsl(0, 0%, 18%);
--visited-color: hsl(0, 0%, 18%);
--blockquote-color: hsl(0, 0%, 18%);
--code-bg-color: hsl(0, 0%, 95%);
--code-color: hsl(0, 0%, 18%);
--sub-color: hsl(0, 0%, 29%);
}
@media (prefers-color-scheme: dark){
:root{
--text-color: hsla(0, 0%, 93%, 1);
--heading-color: hsla(0, 0%, 93%, 1);
--background-color: hsla(0, 0%, 0%, 1);
--bg-color: hsla(0, 0%, 0%, 1);
--link-color: hsla(0, 0%, 93%, 1);
--visited-color: hsla(0, 0%, 93%, 0.85);
--blockquote-color: hsla(0, 0%, 93%, 1);
--code-bg-color: hsla(0, 0%, 8%, 1);
--code-color: limegreen;
--sub-color: hsla(0, 0%, 93%, 0.78);
}
}
/* Preview layout */
body {
margin: 0;
min-height: 100vh;
display: grid;
place-items: center;
padding: 24px;
box-sizing: border-box;
background: var(--background-color);
color: var(--text-color);
font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.scramble{
font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
font-size:1rem;letter-spacing:.04em;min-height:1.5em;min-width:12ch;text-align:center;
}
Usage
From Mighil's animation sketches. Original demo and notes: https://mighil.com/animations/scramble-decode
The Theme block at the top of the CSS sets the light/dark variables; map them to your own design tokens.