/* Light terminal: every page is the output of a shell command. One
   82-column monospace column, system fonts only, no images. */

:root {
    --bg: #fafaf7;
    --bar: #f3f3ee;
    --fg: #24292f;
    --muted: #6e7781;
    --prompt: #7f1a1a;
    --path: #0550ae;
    --date: #b0662e;
    --rule: #e4e4dc;
    --chrome: #a3a8ae;      /* commands and front matter: quiet */
    --chrome-p: #9cc5a5;    /* the "$" of a command */
    --faint: #c3c6c9;       /* ls permission columns */
    --small: 16px;          /* type size of all of the above */
    --box: #f1f1ea;
    --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    color-scheme: light dark;
}

/* Dark mode: soft charcoal, not black. It follows the system setting
   unless the button in the bar chose light or dark (data-theme on <html>).
   Screen only, so printing stays black on white. */
@media screen and (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #1c1e22;
        --bar: #23262b;
        --fg: #d6d8dc;
        --muted: #8b929a;
        --prompt: #f0857d;
        --path: #79b8ff;
        --date: #e0a36a;
        --rule: #33373d;
        --chrome: #6b7179;
        --chrome-p: #6f9a7a;
        --faint: #4d535a;
        --box: #24272c;
    }
}

@media screen {
    :root[data-theme="dark"] {
        --bg: #1c1e22;
        --bar: #23262b;
        --fg: #d6d8dc;
        --muted: #8b929a;
        --prompt: #f0857d;
        --path: #79b8ff;
        --date: #e0a36a;
        --rule: #33373d;
        --chrome: #6b7179;
        --chrome-p: #6f9a7a;
        --faint: #4d535a;
        --box: #24272c;
    }
}

.print-only {
    display: none;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font: 16px/1.65 var(--mono);
}

.col {
    max-width: 82ch;
    margin: 0 auto;
    padding: 0 24px;
}

a {
    color: var(--path);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    text-decoration-thickness: 2px;
}

.p { color: var(--prompt); }
.d { color: var(--path); }
.c { color: var(--muted); }
.y { color: var(--date); }

/* Prompt bar: the prompt is the home link, the menu sits beside it */

.bar {
    background: var(--bar);
    border-bottom: 1px solid var(--rule);
}

.bar .col {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px 16px;
    padding-top: 10px;
    padding-bottom: 10px;
}

.bar a.prompt {
    color: var(--fg);
    text-decoration: none;
}

.bar nav a, .bar nav .theme {
    margin-left: 14px;
}

/* The light/dark switch: set apart from the pages by a faint bar, and
   quieter than them, since it is a setting rather than a place to go */
.bar nav .sep {
    color: var(--faint);
    margin-left: 14px;
}

.bar nav .theme {
    font: inherit;
    color: var(--muted);
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    text-decoration: none;
    text-underline-offset: 3px;
}

.bar nav .theme:hover {
    color: var(--path);
    text-decoration: underline;
}

/* Commands and their output */

main {
    padding-bottom: 8px;
}

.cmd {
    margin-top: 22px;
    color: var(--chrome);
    font-size: var(--small);
}

.cmd .p {
    color: var(--chrome-p);
}

.out {
    margin: 0;
}

.cur {
    display: inline-block;
    width: 0.6em;
    height: 1.1em;
    background: var(--fg);
    vertical-align: -0.2em;
    animation: blink 1.1s steps(1) infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .cur { animation: none; }
}

/* "ls -l" listings */

ul.ls, ul.tagls {
    list-style: none;
    margin: 0;
    padding: 0;
}

ul.ls li {
    display: grid;
    grid-template-columns: 11ch 5ch 11ch 1fr;
    column-gap: 1.5ch;
    align-items: baseline;
}

ul.ls .pm {
    color: var(--faint);
    font-size: var(--small);
}

ul.ls .sz {
    text-align: right;
}

ul.ls time {
    color: var(--date);
}

ul.ls a {
    text-decoration: none;
}

ul.ls a:hover {
    text-decoration: underline;
}

/* Posts */

article.post, article.page {
    margin-top: 6px;
    overflow-wrap: break-word;
}

article pre.fm {
    color: var(--chrome);
    background: none;
    border: 0;
    padding: 0;
    margin: 6px 0 0;
    font-size: var(--small);
    line-height: 1.5;
}

article.post h1 {
    font-size: 22px;
    line-height: 1.35;
    margin: 12px 0 16px;
}

article.post h1::before { content: "# "; color: var(--muted); }
article.post h2::before { content: "## "; color: var(--muted); }
article.post h3::before { content: "### "; color: var(--muted); }

article h1 a {
    color: inherit;
    text-decoration: none;
}

article h2 {
    font-size: 18px;
    margin: 32px 0 8px;
}

article h3, article h4 {
    font-size: 16px;
    margin: 24px 0 8px;
}

article p {
    margin: 0 0 16px;
}

article ul, article ol {
    padding-left: 3ch;
    margin: 0 0 16px;
}

article ul > li::marker {
    content: "- ";
    color: var(--muted);
}

article li {
    margin: 2px 0;
}

article img, article video, article svg, article canvas {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 16px auto;
    border: 1px solid var(--rule);
}

article code {
    font: inherit;
    font-size: 0.94em;
    background: var(--box);
    padding: 0.1em 0.3em;
    border-radius: 3px;
}

article pre {
    font: 14.5px/1.5 var(--mono);
    background: var(--box);
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 12px 14px;
    margin: 0 0 16px;
    overflow-x: auto;
}

article pre code {
    background: none;
    padding: 0;
    font-size: inherit;
}

article blockquote {
    margin: 0 0 16px;
    padding: 0 0 0 2ch;
    border-left: 2px solid var(--rule);
    color: var(--muted);
}

article table {
    border-collapse: collapse;
    margin: 0 0 16px;
    display: block;
    overflow-x: auto;
}

article th, article td {
    border: 1px solid var(--rule);
    padding: 4px 10px;
    text-align: left;
}

article hr {
    border: 0;
    border-top: 1px dashed var(--rule);
    margin: 24px 0;
}

article .video-container {
    margin: 16px 0;
}

article .video-container iframe {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    border: 1px solid var(--rule);
}

/* Previous / next */

.pn {
    border-top: 1px dashed var(--rule);
    margin-top: 24px;
}

.pnrow {
    display: flex;
    justify-content: space-between;
    gap: 2ch;
}

.pnrow .newer {
    margin-left: auto;
    text-align: right;
}

/* Pages written in Markdown + HTML (about, projects, talks, uses) */

article.page pre {
    background: none;
    border: 0;
    padding: 0;
    font-size: inherit;
}

.man-head {
    display: flex;
    justify-content: space-between;
    margin: 8px 0 4px;
}

.man h2 {
    font-size: inherit;
    margin: 20px 0 0;
}

.man p {
    margin: 0 0 0 6ch;
}

.tk {
    margin: 0 0 16px;
}

.tk > div {
    display: grid;
    grid-template-columns: 2ch 5ch 22ch 1fr;
    column-gap: 1.5ch;
}

.nf {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 3ch;
    align-items: start;
}

.nf pre {
    color: var(--prompt);
    margin: 0;
}

.nf b {
    color: var(--prompt);
}

/* Footer: a comment line with links */

footer {
    color: var(--muted);
    font-size: 14px;
    padding-top: 16px;
    padding-bottom: 32px;
    border-top: 1px dashed var(--rule);
    margin-top: 32px;
}

footer a {
    margin-left: 1ch;
}

/* Narrow screens: drop the ls permission columns and long comments */

@media screen and (max-width: 640px) {
    body {
        font-size: 14.5px;
    }

    .col {
        padding: 0 14px;
    }

    .bar nav a, .bar nav .theme {
        margin: 0 10px 0 0;
    }

    .bar nav .sep {
        margin: 0 10px 0 0;
    }

    .pm, .cm, .ev {
        display: none;
    }

    ul.ls li {
        grid-template-columns: 11ch 1fr;
    }

    .tk > div {
        grid-template-columns: 2ch 5ch 1fr;
    }

    .nf {
        grid-template-columns: 1fr;
    }

    .nf pre {
        display: none;
    }

    .man p {
        margin-left: 2ch;
    }

    .pnrow {
        flex-direction: column;
    }
}

@media print {
    @page {
        margin: 1in 1.5in 1in 1.5in;
    }

    header, footer, .cmd, .pn, pre.fm {
        display: none !important;
    }

    body {
        color: black;
        background: white;
        font: 11pt/1.5 Georgia, serif;
    }

    .col {
        max-width: none;
        padding: 0;
    }

    article.post h1::before, article.post h2::before, article.post h3::before {
        content: none;
    }

    main {
        margin: 0 auto;
    }

    main a:visited {
        /* Override */
        color: DarkSlateBlue;
    }

    .no-print {
        display: none;
    }

    .print-only {
        display: inherit;
    }

    main article {
        max-width: 100%;
        margin: 0;
        padding: 0;
        box-shadow: none;
    }

    article:after {
        display: none;
        visibility: hidden;
    }

    .date, .url {
        text-align: center;
        color: DimGray;
        font-size: 0.75em;
    }

    .date {
        margin: -1em 0 0 0;
    }

    h2 {
        font-weight: bold;
        page-break-after: avoid;
    }

    h3 {
        font-weight: bold;
        page-break-after: avoid;
    }

    h4 {
        font-weight: bold;
        page-break-after: avoid;
    }

    h5 {
        font-weight: bold;
        page-break-after: avoid;
    }

    h6 {
        font-weight: bold;
        page-break-after: avoid;
    }

    img {
        page-break-inside: avoid;
    }

    .highlight {
        page-break-inside: avoid;
    }

    p a, li a {
        color: navy;
        text-decoration: none;
    }

    main article p a,
    main article ol a,
    main article li a {
        text-decoration: none;
    }

    main article p, main article pre {
        line-height: 1.35;
    }

    main article code, main article pre {
        border: 0;
        background-color: white;
    }

    sup.cite {
        display: inline;
        font-size: 75%;
        color: DarkGray;
    }

    article .references {
        font-size: 75%;
        color: DarkGray;
    }
}

/* Syntax highlighting, for the token classes emitted by _ssg/highlight.cpp:
 * c comment, k keyword, t type, s string, m number, p preprocessor or
 * directive, v variable or register, f definition or label, and diff
 * lines gi (inserted), gd (deleted), gh (header). */

.highlight .c  { color: #6e6a60; font-style: italic; }
.highlight .k  { color: #7a2f8e; }
.highlight .t  { color: #256a36; }
.highlight .s  { color: #a33c26; }
.highlight .m  { color: #0b6b75; }
.highlight .p  { color: #8a5a00; }
.highlight .v  { color: #2b5797; }
.highlight .f  { color: #1a3e8c; font-weight: bold; }
.highlight .gi { color: #236b2a; }
.highlight .gd { color: #a8302a; }
.highlight .gh { font-weight: bold; }

@media screen and (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .highlight .c  { color: #8f8b82; }
    :root:not([data-theme="light"]) .highlight .k  { color: #cfa3e3; }
    :root:not([data-theme="light"]) .highlight .t  { color: #98cf9c; }
    :root:not([data-theme="light"]) .highlight .s  { color: #e59f86; }
    :root:not([data-theme="light"]) .highlight .m  { color: #78cbd3; }
    :root:not([data-theme="light"]) .highlight .p  { color: #dcb866; }
    :root:not([data-theme="light"]) .highlight .v  { color: #94bbe8; }
    :root:not([data-theme="light"]) .highlight .f  { color: #b9cdfa; }
    :root:not([data-theme="light"]) .highlight .gi { color: #8fcf8a; }
    :root:not([data-theme="light"]) .highlight .gd { color: #ef8f86; }
}

@media screen {
    :root[data-theme="dark"] .highlight .c  { color: #8f8b82; }
    :root[data-theme="dark"] .highlight .k  { color: #cfa3e3; }
    :root[data-theme="dark"] .highlight .t  { color: #98cf9c; }
    :root[data-theme="dark"] .highlight .s  { color: #e59f86; }
    :root[data-theme="dark"] .highlight .m  { color: #78cbd3; }
    :root[data-theme="dark"] .highlight .p  { color: #dcb866; }
    :root[data-theme="dark"] .highlight .v  { color: #94bbe8; }
    :root[data-theme="dark"] .highlight .f  { color: #b9cdfa; }
    :root[data-theme="dark"] .highlight .gi { color: #8fcf8a; }
    :root[data-theme="dark"] .highlight .gd { color: #ef8f86; }
}

