treehouse/static/css/doc.css

245 lines
5.8 KiB
CSS
Raw Permalink Normal View History

main.doc {
2025-08-17 22:22:00 +02:00
--doc-text-width: 85ch;
display: flex;
flex-direction: row;
align-items: start;
& .vertical-center {
2025-08-24 13:18:51 +02:00
--article-padding: 12rem;
min-height: 100vh;
2025-08-24 13:18:51 +02:00
padding: var(--article-padding) 0;
max-width: 100%; /* prevent from blowing up */
flex-grow: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
& .doc-text {
--doc-padding: 1.6rem;
--code-block-h-padding: 1.2rem;
--code-block-grid-space: var(--code-block-h-padding);
/* max-width: min(100%, var(--doc-text-width)); */
width: 100%;
padding: var(--doc-padding);
display: grid;
grid-template-columns:
[left] 1fr
[left-wide] 1fr
[left-code] var(--code-block-grid-space)
[main] minmax(0, var(--doc-text-width))
[right-code] var(--code-block-grid-space)
[right-wide] 1fr
[right] 1fr;
line-height: 1.6;
/* I was thinking a bunch about whether documents should be justified, and it honestly
causes more awkwardness than it solves. Web pages aren't quite books, unfortunately.
A cool feature that would help is text-wrap: pretty; but only Safari implements a nice
text layout algorithm for it. (Chrome prevents short last lines, Firefox doesn't
implement it at all) */
/* text-align: justify;
hyphens: auto; */
& > * {
grid-column: main;
}
& p {
padding-top: 0.5lh;
padding-bottom: 0.5lh;
}
& h2 {
margin: 0;
padding-top: 1lh;
padding-bottom: 0.5lh;
}
& h3 {
margin: 0;
padding-top: 0.5lh;
padding-bottom: 0.5lh;
}
& ul,
& ol {
margin-top: 0;
margin-bottom: 0;
2025-08-26 12:46:50 +02:00
padding-top: 0.5lh;
padding-bottom: 0.5lh;
2025-07-14 20:55:37 +02:00
padding-left: 3.2em;
}
2025-08-17 22:22:00 +02:00
& ul {
2025-08-26 12:46:50 +02:00
/* Is there a better way to add spacing to the marker, other than adding whitespace? */
2025-08-17 22:22:00 +02:00
list-style: "- ";
}
& pre,
& th-literate-program {
padding: 0.8rem var(--code-block-h-padding);
grid-column: left-code / right-wide;
& code {
2025-08-21 19:50:58 +02:00
--recursive-wght: 500;
--recursive-mono: 0.5; /* You didn't expect a proportional font being used for code, did you. */
2025-08-21 19:50:58 +02:00
font-size: 95%;
2025-08-30 13:13:29 +02:00
tab-size: 3ch;
}
&.monospaced code {
--recursive-mono: 1;
}
2025-08-23 00:48:38 +02:00
&.proportional code {
--recursive-mono: 0;
}
}
2025-08-26 20:19:25 +02:00
& figure {
margin: 0.5lh 0;
position: relative;
& p:has(img.pic) {
padding: 0;
}
& img {
display: block;
margin: 0;
}
& figcaption {
padding: 0.25lh 0.5lh;
text-align: center;
& p {
padding: 0;
}
&.overlay-bottom-right {
position: absolute;
right: 0;
bottom: 0;
background-color: var(--background-color);
border-top-left-radius: 0.8rem;
border-bottom-right-radius: 0.4rem;
text-align: left;
}
}
2025-08-30 13:13:29 +02:00
}
& p:has(img.pic),
& figure p:has(img.pic) {
text-align: center;
}
& .wide {
grid-column: left-wide / right;
}
2025-08-26 20:19:25 +02:00
& header {
& h1 {
padding-bottom: 0.25lh;
}
padding-bottom: 1.5lh;
}
}
& section.feed {
2025-08-26 12:46:50 +02:00
max-width: 40ch;
2025-08-24 13:18:51 +02:00
flex-shrink: 0;
padding: 0.8rem;
padding-top: 3.2rem;
}
}
@media (max-width: 1500px) {
main.doc {
flex-direction: column;
align-items: center;
& .vertical-center {
min-height: 0;
2025-08-26 12:46:50 +02:00
flex-grow: 1;
}
& footer {
padding: 0.8rem;
}
& section.feed {
width: 100%;
2025-08-26 12:46:50 +02:00
max-width: var(--doc-text-width);
flex-grow: 1;
margin-top: 2.4em;
padding: 1.6rem;
border-top: 1px solid var(--border-1);
}
}
}
@media (max-width: 1280px) {
main.doc {
& .vertical-center {
--article-padding: 0rem;
}
}
}
@media (max-width: 850px) {
main.doc {
& .doc-text {
--code-block-grid-space: 0;
& pre,
& th-literate-program {
/* Stretch to whole page.
This way of doing it feels a bit brittle, though.
It might be good to refactor this to CSS grid at some point. */
padding-left: var(--doc-padding);
padding-right: var(--doc-padding);
margin-left: calc(var(--doc-padding) * -1);
margin-right: calc(var(--doc-padding) * -1);
border-radius: 0;
border-left: none;
border-right: none;
& code {
2025-08-21 19:50:58 +02:00
--recursive-wght: 520;
font-size: 90%;
2025-08-30 13:13:29 +02:00
tab-size: 2ch;
}
}
& figure figcaption {
&.overlay-bottom-right {
position: static;
background: none;
border-radius: 0;
text-align: center;
}
}
}
}
}