Source for css
Table of Contents
This file is the source for css settings used in myzettel.
Initialisation
/* This file is maintained as a literate file in 20260926215135-source_for_css.org */
Base variables
The variables used by rainbow-delimiters are prefixed with rd. The color palette originally used were not pleasing. For light mode, Nord hues darkened so every text colour reaches WCAG AA (4.5:1). For Dark mode, soft blue-grey instead of pure black (less glare/halation), panels one step lighter, borders clearly visible.
/* --- Base Variables & Mode Logic --- */ :root { --bg: #ffffff; --accent-bg: #f3f5f8; --text: #2e3440; --text-light: #4c566a; --accent: #3b6a99; --code: #a5482b; --border: #aeb6c4; --graph-label: #1a1a2a; --graph-node-default: #4a5060; --graph-node-dim: #c0c0cc; --graph-edge-default: #c8ccd8; --graph-edge-dim: #e8e8ee; --graph-edge-hi: #1a6ecc; --graph-edge-bi: #c8ccd8; --graph-edge-uni: #dcdee6; --graph-palette-s: 70%; --graph-palette-l: 42%; --topnav-height: 3rem; --rd-1: #3b6a99; --rd-2: #b03a48; --rd-3: #8a6d0b; --rd-4: #4d7a35; --rd-5: #8a4f84; --rd-6: #2f7a7a; --rd-7: #b0532b; --rd-8: #3f6494; --rd-9: #6f4f98; } @media (prefers-color-scheme: dark){ :root { --bg: #1e222a; --accent-bg: #282d37; --text: #e5e9f0; --text-light: #a9b3c4; --accent: #88c0d0; --code: #ebcb8b; --border: #4c566a; --graph-label: #a9b3c4; --graph-node-default: #5b6478; --graph-node-dim: #3a3f55; --graph-edge-default: #343b55; --graph-edge-dim: #2a2f3f; --graph-edge-hi: #58a6ff; --graph-edge-bi: #3a4260; --graph-edge-uni: #2f3548; --graph-palette-s: 65%; --graph-palette-l: 65%; --rd-1: #88c0d0; --rd-2: #e07882; --rd-3: #ebcb8b; --rd-4: #a3be8c; --rd-5: #b48ead; --rd-6: #8fbcbb; --rd-7: #d08770; --rd-8: #81a1c1; --rd-9: #a692cc; } }
Global reset
A global reset is done first. In addition, definitions needed for syntax highlighting in org-mode is included. This is implemented using (org-html-htmlize-output-type 'css). The rainbow-delimiters can either be enabled or disabled below. The color variants can be reduced to four, and depths 5 through 9 reuse them.
body { margin: 0; padding: 0; font:1.2em/1.62em sans-serif; min-height: 100vh; background: var(--bg); color: var(--text); word-wrap: break-word; overflow-wrap: break-word; } h1, h2, h3 { line-height: 1.2; color: var(--text); } a { color: var(--accent); transition: color 0.2s; } pre, img { max-width: 100%; overflow-x: auto; display: block; } pre.src { background: var(--accent-bg); border: 1px solid var(--border); padding: 0.75rem 1rem; font-size: 0.85em; line-height: 1.45; } .org-keyword, .org-builtin, .org-function-name { color: var(--accent); } .org-string, .org-constant, .org-variable-name, .org-type, .org-regexp-grouping-construct, .org-regexp-grouping-backslash { color: var(--code); } .org-comment, .org-comment-delimiter, .org-doc { color: var(--text-light); font-style: italic; } @for $i from 1 through 9 { .org-rainbow-delimiters-depth-#{$i} { color: var(--rd-#{$i}); } /* .org-rainbow-delimiters-depth-#{$i} { color: var(--rd-#{($i - 1) % 4 + 1}); } */ } /* [class*="org-rainbow-delimiters-depth-"] { color: var(--text-light); } */ table { width: 100%; max-width: 100%; border-collapse: collapse; border: 1px solid var(--border); } th,td{ padding: 0.5rem; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); } th:last-child, td:last-child { border-right: none; } .list-header { font-weight: bold; border-bottom: 1px solid var(--text); padding-bottom: 0.25rem; margin-bottom: 0.5rem; color: var(--text); list-style: none; } * { scrollbar-width: thin; scrollbar-color: var(--accent) transparent; } .site-date { font-size: 0.7rem; font-family: monospace; } @media print{ body{ max-width:none } }
Extra element defaults
Elements including org-specific, plus browser-level polish that cover form controls, scrollbars, focus ring, text selection follow the theme.
:root { color-scheme: light dark; } ::selection { background: var(--accent); color: var(--bg); } :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } h4, h5, h6 { color: var(--text); line-height: 1.2; } hr { border: 0; border-top: 1px solid var(--border); } blockquote { margin: 1rem 0; padding: 0.25rem 1rem; border-left: 4px solid var(--border); background: var(--accent-bg); color: var(--text-light); } /* org ~code~ and =verbatim= both export as <code> */ code { background: var(--accent-bg); color: var(--code); border: 1px solid var(--border); border-radius: 3px; padding: 0.1em 0.35em; font-size: 0.9em; } pre code { background: none; border: 0; padding: 0; color: inherit; } pre.example, pre.verse { background: var(--accent-bg); border: 1px solid var(--border); padding: 0.75rem 1rem; } thead th { background: var(--accent-bg); } .org-outshine-level-1 { color: var(--accent); font-weight: bold; } .todo { color: var(--rd-2); font-weight: bold; } .done { color: var(--rd-4); font-weight: bold; } input, button { background: var(--accent-bg); color: var(--text); border: 1px solid var(--border); border-radius: 3px; padding: 0.35rem 0.6rem; font: inherit; } input::placeholder { color: var(--text-light); } button:hover { border-color: var(--accent); cursor: pointer; }
Layout Structure
#preamble { position: sticky; top: 0; z-index: 100; background: var(--bg); } .topnav { // position: sticky; // top: 0; // z-index: 100; display: flex; align-items: center; justify-content: center; background: var(--bg); border-bottom: 1px solid var(--border); box-sizing: border-box; padding: 0.6rem 0; } .topnav-links { display: flex; align-items: center; gap: 1.5rem; width: 100%; max-width: 40em; margin: 0 auto; padding: 0 3.24em; box-sizing: border-box; .topnav-title { font-weight: bold; font-size: 1.25rem; text-decoration: none; color: var(--text); white-space: nowrap; &:hover { color: var(--accent); } margin-right: auto; padding-right: 2rem; // border-right: 1px solid var(--border); letter-spacing: 0.02em; } a:not(.topnav-title) { text-decoration: none; font-size: 1.05rem; color: var(--text-light); transition: color 0.2s; &:hover { color: var(--accent); } } } #content { display: grid; // grid-template-columns: 15rem 1fr; grid-template-columns: 1fr 15rem; column-gap: 2rem; max-width: 65rem; margin: 0 auto; padding: 0 3.24em .62em 3.24em; box-sizing: border-box; } #content:not(:has(#table-of-contents)) { display: block; max-width: 40em; } #content > h1.title { grid-column: 1 / -1; } #table-of-contents { grid-column: 2; grid-row: 2 / span 999; position: sticky; top: calc(var(--topnav-height) + 1rem); max-height: calc(100vh - var(--topnav-height) - 2rem); overflow-y: auto; margin: 0; a { color: var(--text-light); font-size: 0.85rem; line-height: 1.3; display: block; padding: 2px 0; text-decoration: none; &:hover { color: var(--accent); } } ul { list-style: none; padding-left: 0.75rem; } } #table-of-contents ~ * { grid-column: 1; max-width: 48rem; }
Postamble
The postamble is outside #content, so it needs its own width and padding to line up with the page text.
#postamble { max-width: 65rem; margin: 2rem auto 0; padding: 1rem 3.24em; box-sizing: border-box; border-top: 1px solid var(--border); color: var(--text-light); font-size: 0.85rem; line-height: 1.4; p { margin: 0.2rem 0; } } /* pages without a table of contents use the narrower column */ body:has(#content:not(:has(#table-of-contents))) #postamble { max-width: 40em; }
Wide-screen monitors
For wide screens: keep the text column where it is on pages without a TOC, and hang the TOC in the right margin instead of beside the text.
@media (min-width: 1280px) { #content:has(#table-of-contents) { max-width: 40em; grid-template-columns: minmax(0, 1fr) 0; column-gap: 0; } #table-of-contents { width: 15rem; margin-left: 2rem; } body:has(#table-of-contents) #postamble { max-width: 40em; } }
Mobile customisations
@media (max-width: 768px) { html, body { height: auto !important; overflow: auto !important; } .topnav { padding: 0; position: relative; z-index: auto; min-height: var(--topnav-height); pointer-events: auto; } .topnav-links { padding: 0 20px; } #content { display: block; max-width: 100% !important; padding: 20px; box-sizing: border-box; overflow-x: hidden; margin: 0 ; } #table-of-contents { // display: none; position: static; max-height: none; width: auto; margin: 0 0 1.5rem 0; } #postamble { padding: 1rem 20px; } }