Implement new css.Build.

This commit is contained in:
Fredrik Jonsson 2026-04-08 11:17:24 +02:00
commit d984bcaf5d
7 changed files with 1681 additions and 1695 deletions

View file

@ -1,22 +1,21 @@
/* Document */
@layer base {
html {
/* Change the default font family in all browsers. */
font-family: var(--ff-body);
html {
/* Change the default font family in all browsers. */
font-family: var(--ff-body);
/* Set base font size in percent. */
font-size: calc(var(--base-font-size) / 16 * 100%);
/* Set base font size in percent. */
font-size: calc(var(--base-font-size) / 16 * 100%);
/* Set text colour. */
color: var(--color-text);
}
body {
/* Correct the line height in all browsers. */
line-height: var(--base-line-height);
/* Accent colour for forms. */
accent-color: var(--color-accent);
}
/* Set text colour. */
color: var(--color-text);
}
body {
/* Correct the line height in all browsers. */
line-height: var(--base-line-height);
/* Accent colour for forms. */
accent-color: var(--color-accent);
}

View file

@ -1,89 +1,87 @@
/* Form defaults. */
@layer base {
form {
/* Add vertical rhythm margins. */
margin-block: 0 var(--spacing-m);
form {
/* Add vertical rhythm margins. */
margin-block: 0 var(--spacing-m);
}
input,
textarea,
select {
margin-block: 0 var(--spacing-m);
}
label {
font-weight: var(--fw-bold);
/* Display as block if before input. */
&:has(+ input),
&:has(+ textarea){
display: block;
}
input,
textarea,
select {
margin-block: 0 var(--spacing-m);
}
label {
font-weight: var(--fw-bold);
/* Display as block if before input. */
&:has(+ input),
&:has(+ textarea){
display: block;
/* Mark field as required if needed. */
&:has(+ :required) {
&::after {
content: '*';
color: var(--color-mark-highlight);
}
/* Mark field as required if needed. */
&:has(+ :required) {
&::after {
content: '*';
color: var(--color-mark-highlight);
}
}
}
/* Valid and invalid state. */
input,
textarea {
&:user-valid {
border-color: var(--color-success);
border-style: solid;
background-color: var(--color-success-bg);
}
&:focus:user-valid {
border-color: transparent;
}
&:user-invalid {
border-color: var(--color-error);
border-style: solid;
background-color: var(--color-error-bg);
}
&:focus:user-invalid {
border-color: transparent;
background-color: var(--color-warning-bg);
}
}
/* Set max text line width for readability. */
input,
label,
textarea,
select {
max-width: var(--max-line-width);
}
fieldset {
border: 1px solid var(--color-border);
}
/* Make field where you enter more info a bit wider. */
[type='email'],
[type='password'],
[type='range'],
[type='search'],
[type='url'] {
width: min(20em, 100%);
}
/* Make field where you enter more info a bit wider. */
[type='text'],
textarea {
width: min(30em, 100%);
}
/* Make sure textareas without a rows attribute are not tiny. */
textarea:not([rows]) {
min-height: 7lh;
}
}
/* Valid and invalid state. */
input,
textarea {
&:user-valid {
border-color: var(--color-success);
border-style: solid;
background-color: var(--color-success-bg);
}
&:focus:user-valid {
border-color: transparent;
}
&:user-invalid {
border-color: var(--color-error);
border-style: solid;
background-color: var(--color-error-bg);
}
&:focus:user-invalid {
border-color: transparent;
background-color: var(--color-warning-bg);
}
}
/* Set max text line width for readability. */
input,
label,
textarea,
select {
max-width: var(--max-line-width);
}
fieldset {
border: 1px solid var(--color-border);
}
/* Make field where you enter more info a bit wider. */
[type='email'],
[type='password'],
[type='range'],
[type='search'],
[type='url'] {
width: min(20em, 100%);
}
/* Make field where you enter more info a bit wider. */
[type='text'],
textarea {
width: min(30em, 100%);
}
/* Make sure textareas without a rows attribute are not tiny. */
textarea:not([rows]) {
min-height: 7lh;
}

View file

@ -1,107 +1,105 @@
/* Grouping content */
@layer base {
/* Block quotes */
/* Block quotes */
blockquote {
/* Add vertical rhythm margins. */
margin-block: 0 var(--spacing-m);
blockquote {
/* Add vertical rhythm margins. */
margin-block: 0 var(--spacing-m);
/* Nicer text wrap, e.g. no lone word on last line. */
text-wrap: pretty;
/* Nicer text wrap, e.g. no lone word on last line. */
text-wrap: pretty;
/* Also indent the quote on both sides. */
margin-inline: var(--indent-amount);
/* Also indent the quote on both sides. */
margin-inline: var(--indent-amount);
/* Set max text line width in main for readability. */
max-width: var(--max-line-width);
}
/* Set max text line width in main for readability. */
max-width: var(--max-line-width);
}
/* Lists */
/* Lists */
dl,
dl,
ol,
ul,
menu {
/* Add vertical rhythm margins. */
margin-block: 0 var(--spacing-m);
}
dt {
font-weight: var(--fw-bold);
}
dd {
margin: 0;
margin-inline-start: var(--indent-amount);
/* Nicer text wrap, e.g. no lone word on last line. */
text-wrap: pretty;
}
ol,
ul,
menu {
padding: 0;
padding-inline-start: var(--indent-amount);
/* Turn off margins on nested lists. */
ol,
ul,
menu {
/* Add vertical rhythm margins. */
margin-block: 0 var(--spacing-m);
}
dt {
font-weight: var(--fw-bold);
}
dd {
margin: 0;
margin-inline-start: var(--indent-amount);
/* Nicer text wrap, e.g. no lone word on last line. */
text-wrap: pretty;
}
ol,
ul,
menu {
padding: 0;
padding-inline-start: var(--indent-amount);
/* Turn off margins on nested lists. */
ol,
ul,
menu {
margin: 0;
}
}
li {
/* Nicer text wrap, e.g. no lone word on last line. */
text-wrap: pretty;
/* Set max text line width in main for readability. */
.main & {
max-width: var(--max-line-width);
}
}
/* Horizontal rule */
hr {
/* Add vertical rhythm margins. */
margin-block: var(--spacing-m);
border: 0;
border-block-start: 1px solid var(--color-border);
height: 0;
}
/* Paragraphs */
p {
/* Add vertical rhythm margins. */
margin-block: 0 var(--spacing-m);
/* Nicer text wrap, e.g. no lone word on last line. */
text-wrap: pretty;
/* Set max text line width in main for readability. */
.main & {
max-width: var(--max-line-width);
}
}
/* Preformatted text */
pre {
/* Add vertical rhythm margins. */
margin-block: 0 var(--spacing-m);
font-family: var(--ff-monospace);
}
/* Code */
/* Do not set colour for code with syntax highlighting. */
code:not([data-lang]),
kbd,
samp {
color: var(--color-code);
}
}
li {
/* Nicer text wrap, e.g. no lone word on last line. */
text-wrap: pretty;
/* Set max text line width in main for readability. */
.main & {
max-width: var(--max-line-width);
}
}
/* Horizontal rule */
hr {
/* Add vertical rhythm margins. */
margin-block: var(--spacing-m);
border: 0;
border-block-start: 1px solid var(--color-border);
height: 0;
}
/* Paragraphs */
p {
/* Add vertical rhythm margins. */
margin-block: 0 var(--spacing-m);
/* Nicer text wrap, e.g. no lone word on last line. */
text-wrap: pretty;
/* Set max text line width in main for readability. */
.main & {
max-width: var(--max-line-width);
}
}
/* Preformatted text */
pre {
/* Add vertical rhythm margins. */
margin-block: 0 var(--spacing-m);
font-family: var(--ff-monospace);
}
/* Code */
/* Do not set colour for code with syntax highlighting. */
code:not([data-lang]),
kbd,
samp {
color: var(--color-code);
}

View file

@ -2,58 +2,56 @@
All HTML headings, `<h1>` through `<h6>`, are available. */
@layer base {
h1,
h2,
h3,
h4,
h5,
h6 {
margin-block: 1.5em .5em;
color: var(--color-headings);
font-family: var(--ff-headings);
font-weight: var(--fw-headings);
line-height: var(--heading-line-height);
text-wrap: balance;
h1,
h2,
h3,
h4,
h5,
h6 {
margin-block: 1.5em .5em;
color: var(--color-headings);
font-family: var(--ff-headings);
font-weight: var(--fw-headings);
line-height: var(--heading-line-height);
text-wrap: balance;
/* Smaller margin when a headeing is right after another heading. */
& + & {
margin-block-start: .75em;
}
/* Set max text line width in main for readability. */
.main & {
max-width: var(--max-line-width);
}
/* Smaller margin when a headeing is right after another heading. */
& + & {
margin-block-start: .75em;
}
h1 {
/* h1 only on top of page so different margins. */
margin-block-start: var(--spacing-m);
margin-block-end: var(--spacing-xs);
font-size: var(--fs-xxl);
letter-spacing: -.01em;
}
h2 {
font-size: var(--fs-xl);
letter-spacing: -.01em;
}
h3 {
font-size: var(--fs-l);
letter-spacing: -.01em;
}
h4 {
font-size: var(--fs-m);
}
h5 {
font-size: var(--fs-s);
}
h6 {
font-size: var(--fs-xs);
/* Set max text line width in main for readability. */
.main & {
max-width: var(--max-line-width);
}
}
h1 {
/* h1 only on top of page so different margins. */
margin-block-start: var(--spacing-m);
margin-block-end: var(--spacing-xs);
font-size: var(--fs-xxl);
letter-spacing: -.01em;
}
h2 {
font-size: var(--fs-xl);
letter-spacing: -.01em;
}
h3 {
font-size: var(--fs-l);
letter-spacing: -.01em;
}
h4 {
font-size: var(--fs-m);
}
h5 {
font-size: var(--fs-s);
}
h6 {
font-size: var(--fs-xs);
}

View file

@ -1,89 +1,87 @@
/* Figure and image. */
@layer base {
figure,
img {
&.image {
--image-padding: .75rem;
figure,
img {
&.image {
--image-padding: .75rem;
@media (min-width: 666px) {
&.center {
margin-inline: auto;
}
&.left {
padding-inline-end: var(--image-padding);
padding-block-end: var(--image-padding);
margin: 0;
float: left;
clear: both;
}
&.right {
padding-inline-start: var(--image-padding);
padding-block-end: var(--image-padding);
margin: 0;
float: right;
clear: both;
}
}
}
}
figure {
/* Add vertical rhythm margins. */
margin-block: 0 var(--spacing-m);
&.image {
figcaption {
padding-block-start: var(--image-padding);
contain: inline-size;
/* Set max text line width in main for readability. */
max-width: var(--max-line-width);
/* Nicer text wrap, e.g. no lone word on last line. */
text-wrap: pretty;
@media (min-width: 666px) {
padding-block-start: 0;
}
p {
margin: 0;
}
@media (min-width: 666px) {
&.center {
margin-inline: auto;
}
@media (min-width: 666px) {
inline-size: fit-content;
&.left {
figcaption {
padding-inline-end: var(--image-padding);
padding-block-end: var(--image-padding);
}
}
&.right {
figcaption {
padding-inline-start: var(--image-padding);
padding-block-end: var(--image-padding);
}
}
&.left {
padding-inline-end: var(--image-padding);
padding-block-end: var(--image-padding);
margin: 0;
float: left;
clear: both;
}
}
&.podcast {
audio {
width: 95%;
&.right {
padding-inline-start: var(--image-padding);
padding-block-end: var(--image-padding);
margin: 0;
float: right;
clear: both;
}
}
}
}
img {
&.image {
/* Add vertical rhythm margins. */
margin-block: 0 var(--spacing-m);
figure {
/* Add vertical rhythm margins. */
margin-block: 0 var(--spacing-m);
&.image {
figcaption {
padding-block-start: var(--image-padding);
contain: inline-size;
/* Set max text line width in main for readability. */
max-width: var(--max-line-width);
/* Nicer text wrap, e.g. no lone word on last line. */
text-wrap: pretty;
@media (min-width: 666px) {
padding-block-start: 0;
}
p {
margin: 0;
}
}
@media (min-width: 666px) {
inline-size: fit-content;
&.left {
figcaption {
padding-inline-end: var(--image-padding);
padding-block-end: var(--image-padding);
}
}
&.right {
figcaption {
padding-inline-start: var(--image-padding);
padding-block-end: var(--image-padding);
}
}
}
}
&.podcast {
audio {
width: 95%;
}
}
}
img {
&.image {
/* Add vertical rhythm margins. */
margin-block: 0 var(--spacing-m);
}
}

View file

@ -11,71 +11,69 @@ http://meyerweb.com/eric/thoughts/2007/06/11/who-ordered-the-link-states
:focus - A link that has been given keyboard focus.
:active - A link that is being actively clicked. */
@layer base {
a {
color: var(--color-link);
}
/* Any element can receive focus, but only links can be visited, so we can
safely lower this selector's specificity. This also ensures visited links
with additional styles won't have their styles overridden. */
:visited {
color: var(--color-link-visited);
}
a:hover,
a:focus {
color: var(--color-link-hover);
}
a:active {
color: var(--color-link-active);
}
/* Remove underline from links to current page to */
/* indicate that there is no need to click on it. */
[aria-current] {
text-decoration: none;
}
/* Use smooth scrolling unless user prefer less motion. */
@media (prefers-reduced-motion: no-preference) {
:has(:target) {
scroll-behavior: smooth;
scroll-padding-block-start: var(--gutters);
}
}
.link-nav {
a {
color: var(--color-link);
}
/* Any element can receive focus, but only links can be visited, so we can
safely lower this selector's specificity. This also ensures visited links
with additional styles won't have their styles overridden. */
:visited {
color: var(--color-link-visited);
}
a:hover,
a:focus {
color: var(--color-link-hover);
}
a:active {
color: var(--color-link-active);
}
/* Remove underline from links to current page to */
/* indicate that there is no need to click on it. */
[aria-current] {
text-decoration: none;
}
/* Use smooth scrolling unless user prefer less motion. */
@media (prefers-reduced-motion: no-preference) {
:has(:target) {
scroll-behavior: smooth;
scroll-padding-block-start: var(--gutters);
&:hover,
&:focus {
text-decoration: underline;
}
}
}
.link-nav {
a {
text-decoration: none;
/* Inverted links, for dark backgrounds. */
.link-inverted {
a {
&:link {
color: var(--color-link-inverted);
}
&:hover,
&:focus {
text-decoration: underline;
}
&:visited {
color: var(--color-link-visited-inverted);
}
}
/* Inverted links, for dark backgrounds. */
.link-inverted {
a {
&:link {
color: var(--color-link-inverted);
}
&:visited {
color: var(--color-link-visited-inverted);
}
&:hover,
&:focus {
color: var(--color-link-hover-inverted);
}
&:hover,
&:focus {
color: var(--color-link-hover-inverted);
}
&:active {
color: var(--color-link-active-inverted);
}
&:active {
color: var(--color-link-active-inverted);
}
}
}

View file

@ -1,34 +1,32 @@
/* Tables */
@layer base {
table {
/* Add vertical rhythm margins. */
margin-block: 0 var(--spacing-m);
table {
/* Add vertical rhythm margins. */
margin-block: 0 var(--spacing-m);
/* Remove default spacing between table cells. */
border-collapse: collapse;
/* Remove default spacing between table cells. */
border-collapse: collapse;
/* Prevent cramped-looking tables */
width: 100%;
}
/* Prevent cramped-looking tables */
width: 100%;
}
td,
th {
/* Remove most spacing between table cells. */
padding: 0;
td,
th {
/* Remove most spacing between table cells. */
padding: 0;
/* Align content to top of cells. */
vertical-align: text-top;
}
/* Align content to top of cells. */
vertical-align: text-top;
}
th {
/* Align content to bottom of headers. */
vertical-align: bottom;
}
th {
/* Align content to bottom of headers. */
vertical-align: bottom;
}
caption,
th {
/* Align all text the same. */
text-align: start;
}
caption,
th {
/* Align all text the same. */
text-align: start;
}