:root {
    --bg_0: #fef3da;
    --bg_1: #f0e4cc;
    --bg_2: #d6cbb4;
    --dim_0: #8f9894;
    --fg_0: #52666d;
    --fg_1: #384c52;
    --unused_0: #0e4956;
    --unused_1: #053d48;
    --red: #d4212b;
    --orange: #c75d20;
    --magenta: #cb4c99;
    --green: #539100;
    --cyan: #009c8f;
    --blue: #0073d2;
    --dark-blue: #00437a;
    --yellow: #b38800;
    --violet: #7d64c5;
    --dark-violet: #563da4;
    --sm-text: 0.6rem;
    --md-text: 0.8rem;
    --lg-text: 1rem;

    /* Text versions of the accents: same hue, darkened just enough for WCAG
       AA contrast (>= 4.5:1) on both bg_0 and bg_1. Use these for text; the
       originals stay for icons, borders and fills, which only need 3:1. */
    --dim_0-text: #5f6764;
    --blue-text: #0066bb;
    --yellow-text: #7f6000;
    --green-text: #417100;
    --cyan-text: #007269;
    --violet-text: #6e52be;
    --orange-text: #a34c1a;
    --red-text: #c51f28;
    --magenta-text: #af337e;
}

* {
    box-sizing: border-box;
}

html {
    overflow-y: scroll;
}

html,
body {
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100vh;
    width: 100%;
    font-family: sans-serif;
    background-color: var(--bg_0);
    color: var(--fg_1);
}

h1,
h2,
h3,
h4 {
    margin: 1rem 0 0.2rem;
}

main h2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

h1 + p,
h2 + p,
h3 + p,
h4 + p {
    margin: 0;
}

p {
    margin: 1rem 0 0;
    line-height: 1.5rem;
}

.blog-list,
#search-list,
#about-list {
    list-style-type: none;
    margin-block-start: 0;
    margin-block-end: 0;
    padding-inline-start: 0;
}

a {
    color: var(--blue-text);
    text-decoration: none;
    font-weight: 600;
}

a:active,
a:visited {
    color: var(--dark-violet);
    opacity: 0.8;
}

.til-list-item > article > p:first-of-type,
.search-list-item > p:first-of-type {
    margin-block-start: 0;
}

.til-list-item-header,
.search-list-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.published {
    display: inline-block;
    margin-top: 0.2rem;
}

.til-date,
.published {
    font-style: italic;
    background-color: var(--bg_1);
    padding: 0.4rem;
    border-radius: 0.2rem;
}

.post-details {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.2rem;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.post-details .tag-list,
.post-details .published {
    margin-top: 0;
}

.tag {
    font-style: italic;
    font-size: 0.85em;
    background-color: var(--bg_1);
    color: var(--fg_1);
    padding: 0.2rem 0.4rem;
    border-radius: 0.2rem;
    text-decoration: none;
}

.tag:hover {
    background-color: var(--bg_2);
}

.tag-hit {
    color: var(--yellow-text);
    font-weight: bold;
}

.search-matched-in {
    font-size: 0.85em;
    color: var(--dim_0-text);
    margin-bottom: 0;
}

.blog-list-item a:active {
    color: var(--fg_1);
}

.blog-list-item p {
    margin: 0;
}

#about-list {
    padding-inline-start: 0;
}

#about-intro {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.5rem;
}

#about-photo {
    display: block;
    width: 10rem;
    height: 10rem;
    border-radius: 50%;
    object-fit: cover;
    border: solid var(--bg_2) 3px;
}

#content-wrapper {
    width: 66ch;
    flex-grow: 1;
    padding: 1em;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.image-wrapper {
    aspect-ratio: 1 / 1;
    width: calc(66ch - 2em);
    margin-top: 1rem;
    background-color: var(--bg_1);
    overflow: hidden;
}

.image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ---- Images (asciidoctor) ------------------------------------------------ */

/* image:: blocks keep their own aspect ratio, at most the text's width. */
.imageblock {
    margin-top: 1rem;
}

.imageblock img,
.image img {
    display: block;
    max-width: 100%;
    height: auto;
}

.image img {
    display: inline;
    vertical-align: middle;
}

/* .Caption above an image:: block, which asciidoctor puts under it. */
.imageblock .title {
    margin-top: 0.4rem;
    font-size: var(--md-text);
    font-style: italic;
    color: var(--dim_0-text);
}

/* [.square] crops an image to 1:1, filling the text's width. */
.imageblock.square img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background-color: var(--bg_1);
}

strong:not(p > strong) {
    display: inline-block;
    margin-top: 0.5rem;
}

@keyframes fade {
    0% {
        opacity: 0;
    }
    75% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

.fade-animation {
    animation: 0.5s fade;
}

/* ---- Footnotes (asciidoctor) -------------------------------------------- */

/* References in the text sit in the line at full size, like "[1]", rather
   than as raised superscripts. Other superscripts (x^2^) stay raised. */
sup.footnote,
sup.footnoteref {
    display: inline;
    font-size: 1em;
    line-height: inherit;
    vertical-align: baseline;
    color: var(--fg_1);
    text-decoration: none;
}

/* The notes themselves, under a short rule at the end of the post. */
#footnotes {
    margin-top: 2rem;
    font-size: 0.9em;
    line-height: 1.4;
}

#footnotes hr {
    width: 6rem;
    margin: 0 0 0.75rem;
    border: none;
    border-top: 2px solid var(--bg_2);
}

/* Hanging indent so wrapped lines line up after the "1." */
#footnotes .footnote {
    padding: 0.2rem 0.4rem 0.2rem 2rem;
    text-indent: -1.6rem;
    margin-bottom: 0.25rem;
    border-radius: 0.2rem;
}

/* Highlight a note when jumping to it, and its reference when jumping back. */
#footnotes .footnote:target,
sup.footnote a:target {
    background-color: var(--bg_1);
}

#footnotes .footnote:target {
    box-shadow: inset 3px 0 0 var(--yellow);
}

#footnotes .footnote > a:first-child {
    display: inline-block;
    min-width: 1.2rem;
    text-indent: 0;
    text-align: right;
}

/* ---- Lists (asciidoctor) ------------------------------------------------- */

/* asciidoctor wraps every item in a <p>; without this each item gets a
   paragraph's top margin and lists look double spaced. */
.ulist,
.olist {
    margin-top: 1rem;
}

.ulist ul,
.olist ol {
    margin: 0;
    padding-inline-start: 1.5rem;
}

.ulist li,
.olist li {
    margin-top: 0.3rem;
    line-height: 1.5rem;
}

.ulist li > p,
.olist li > p {
    margin: 0;
}

/* Nested lists sit snug under their parent item. */
li > .ulist,
li > .olist {
    margin-top: 0.1rem;
}

.ulist li::marker {
    color: var(--dim_0-text);
}

.olist li::marker {
    color: var(--dim_0-text);
    font-variant-numeric: tabular-nums;
}

main {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

footer {
    margin: 4em 0 0;
    font-style: italic;
    font-size: var(--md-text);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* The site's own SVG icons. Scoped to svg so it doesn't catch asciidoctor's
   td.icon, which holds an admonition's label. */
svg.icon {
    height: 16px;
    width: 16px;
    fill: var(--blue);
}

.icon-ctr {
    display: flex;
    align-items: flex-end;
}

.search-term {
    font-style: italic;
    font-weight: bold;
    color: var(--yellow-text);
}

header {
    display: flex;
    flex-wrap: wrap-reverse;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
}

nav {
    flex: 1;
    padding: 1em 0 1em;
}

nav > ul {
    list-style-type: none;
    padding-inline-start: 0;
    margin-block-start: 0;
    margin-block-end: 0;
    display: flex;
}

nav > ul > li {
    margin-right: 1em;
}

#search-form > button {
    align-items: center;
    background-color: var(--yellow-text);
    border: 2px solid var(--dim_0);
    border-radius: 0.2em;
    color: var(--bg_0);
    display: flex;
    font-size: var(--lg-text);
    font-weight: bold;
    height: 2.5em;
    justify-content: center;
    padding: 0.5em 1em;
}

#search-form > button:hover,
button:active {
    background-color: var(--bg_2);
}

#search-form {
    display: flex;
    width: 300px;
    padding: 1em 0 1em;
}

#search-form > input {
    font-size: var(--lg-text);
    background-color: var(--bg_1);
    border: 2px solid var(--dim_0);
    border-radius: 0.2em;
    color: var(--fg_1);
    font-weight: bold;
    height: 2.5em;
    margin-right: 0.5em;
    padding: 0.5em;
    width: 100%;
}

input:-webkit-autofill {
    background-color: var(--bg_1) !important;
    color: var(--fg_1) !important;
    box-shadow: 0 0 0px 1000px var(--bg_1) inset;
    transition: background-color 5000s ease-in-out 0s;
}

#search-form > input::placeholder {
    color: var(--dim_0-text);
}

.material-symbols-outlined {
    font-variation-settings:
        "FILL" 0,
        "wght" 400,
        "GRAD" 0,
        "opsz" 24;
}

#footer-details {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
}

/* asciidoctor wraps quotes as .quoteblock > blockquote > .paragraph > p, so
   the paragraph margins are reset here to keep the padding even. */
.quoteblock {
    margin-top: 1rem;
}

blockquote {
    border-left: solid var(--dim_0) 4px;
    background-color: var(--bg_1);
    margin: 1rem 0 0;
    padding: 0.8rem 1rem;
}

.quoteblock > blockquote {
    margin: 0;
}

blockquote p {
    margin: 0.75rem 0 0;
}

blockquote > :first-child,
blockquote > :first-child > p:first-child {
    margin-top: 0;
}

/* Inline code needs a different background to show up on the quote's. */
blockquote code:not(pre code) {
    background-color: var(--bg_0);
}

.quoteblock .attribution {
    margin-top: 0.4rem;
    padding-left: 1.25rem;
    font-size: 0.9em;
    font-style: italic;
    color: var(--dim_0-text);
}

/* ---- Admonitions (asciidoctor) ------------------------------------------ */

/* asciidoctor lays an admonition out as a one-row table: the label
   ("Note") in td.icon, then the content. Stack them as a panel with a
   colored edge, the label as a small heading. */
.admonitionblock {
    --admonition: var(--blue);
    --admonition-text: var(--blue-text);
    margin-top: 1rem;
    padding: 0.8rem 1rem;
    background-color: var(--bg_1);
    border-left: 4px solid var(--admonition);
    border-radius: 0.2rem;
}

.admonitionblock.tip {
    --admonition: var(--green);
    --admonition-text: var(--green-text);
}

.admonitionblock.important {
    --admonition: var(--violet);
    --admonition-text: var(--violet-text);
}

.admonitionblock.warning {
    --admonition: var(--orange);
    --admonition-text: var(--orange-text);
}

.admonitionblock.caution {
    --admonition: var(--red);
    --admonition-text: var(--red-text);
}

.admonitionblock table,
.admonitionblock tbody,
.admonitionblock tr,
.admonitionblock td {
    display: block;
    padding: 0;
    border: none;
}

.admonitionblock td.icon .title {
    font-size: var(--md-text);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--admonition-text);
}

.admonitionblock td.content {
    margin-top: 0.3rem;
}

/* A title of its own (".Watch out" above the block). */
.admonitionblock td.content > .title,
.sidebarblock .title {
    font-weight: bold;
    color: var(--fg_1);
}

.admonitionblock td.content > :first-child > p:first-child,
.sidebarblock .content > :first-child > p:first-child {
    margin-top: 0;
}

.admonitionblock code:not(pre code),
.sidebarblock code:not(pre code) {
    background-color: var(--bg_0);
}

/* ---- Sidebars (asciidoctor) --------------------------------------------- */

/* Asides set off from the text in a bordered panel. */
.sidebarblock {
    margin-top: 1rem;
    padding: 0.8rem 1rem;
    background-color: var(--bg_1);
    border: 2px solid var(--bg_2);
    border-radius: 0.4rem;
}

.sidebarblock .title + * > p:first-child {
    margin-top: 0.3rem;
}

pre {
    background-color: var(--bg_0);
    overflow-x: auto;
    border: solid var(--dim_0) 2px;
    padding: 1em 0.4em 1em 0.4em;
}

code {
    font-size: var(--md-text);
}

/* Rouge syntax highlighting (asciidoctor rouge-css=class) in the selenized
   palette, following selenized's own vim mapping */
.rouge .c, .rouge .c1, .rouge .cm, .rouge .cs, .rouge .ch, .rouge .cd {
    color: var(--dim_0-text);
    font-style: italic;
}
.rouge .k, .rouge .kd, .rouge .kn, .rouge .kr, .rouge .kv, .rouge .ow {
    color: var(--yellow-text);
}
.rouge .kt, .rouge .nc, .rouge .nn, .rouge .ne {
    color: var(--green-text);
}
.rouge .s, .rouge .s1, .rouge .s2, .rouge .sb, .rouge .sc, .rouge .sd,
.rouge .sh, .rouge .sx, .rouge .ss, .rouge .dl, .rouge .cpf {
    color: var(--cyan-text);
}
.rouge .m, .rouge .mi, .rouge .mf, .rouge .mh, .rouge .mo, .rouge .il,
.rouge .kc, .rouge .no {
    color: var(--violet-text);
}
.rouge .nf, .rouge .fm, .rouge .nb, .rouge .bp, .rouge .nv, .rouge .vc,
.rouge .vg, .rouge .vi {
    color: var(--blue-text);
}
.rouge .cp, .rouge .nd, .rouge .nt, .rouge .na, .rouge .nl {
    color: var(--orange-text);
}
.rouge .se, .rouge .si, .rouge .sr, .rouge .err {
    color: var(--red-text);
}
.rouge .gd {
    color: var(--red-text);
}
.rouge .gi {
    color: var(--green-text);
}
.rouge .gh, .rouge .gu {
    color: var(--blue-text);
    font-weight: bold;
}
.rouge .o, .rouge .p, .rouge .n {
    color: var(--fg_1);
}
/* P (internal/asciidoc/rouge/p.rb) tells parameters and local variables
   from machine variables and fields, which are blue. */
.rouge code[data-lang="p"] .nv {
    color: var(--magenta-text);
}

code:not(pre code) {
    background: var(--bg_1);
    font-size: var(--md-text);
    padding: 0 0.5rem;
    border-radius: 0.2rem;
    white-space: nowrap;
}

::-webkit-scrollbar {
    height: 12px;
    width: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg_1);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--blue);
    border-radius: 6px;
    border: 2px solid var(--bg_1);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--cyan);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--dim_0) var(--bg_1);
}

.anchor {
    color: var(--bg_2);
    transition-duration: 2ms;
    text-decoration: none;
}

.anchor:hover {
    color: var(--fg_0);
}

/* asciidoctor's sectanchors emit an empty link before the heading text;
   show it as a trailing § on h2s like the old markdown renderer did */
h2:has(> a.anchor) {
    display: flex;
    gap: 0.5ch;
}

h2 > a.anchor {
    order: 1;
}

h2 > a.anchor::before {
    content: "§";
}

#feed {
    display: flex;
    align-items: flex-end;
}

#feed img {
    height: 14px;
    width: 14px;
    margin-right: 0.25rem;
}

#to-top {
    display: block;
    width: 100%;
    text-align: right;
}

@media (max-width: 650px) {
    #search-form {
        padding: 1em 0 0;
        width: 100%;
    }

    #content-wrapper {
        width: 100%;
    }

    .image-wrapper {
        width: 100%;
    }

    main {
        overflow-y: auto;
    }

    #footer-details {
        justify-content: space-around;
    }
}

/* Headings are focused from script after htmx page swaps (see a11y.js) so
   screen readers announce the new page. They aren't interactive, so never
   draw a focus ring on them, even after keyboard navigation such as Enter in
   the command palette. */
[tabindex="-1"]:focus {
    outline: none;
}

/* ---- Search page ------------------------------------------------------- */

.search-examples {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85em;
    color: var(--dim_0-text);
}

.search-examples > span {
    font-style: italic;
    margin-right: 0.2rem;
}

.search-example {
    font-weight: normal;
}

.search-example code,
.search-example:visited code {
    display: inline-block;
    color: var(--fg_1);
}

.search-example:hover code {
    background-color: var(--bg_2);
}

.search-error {
    line-height: 1.5rem;
}

.search-correction {
    line-height: 1.5rem;
}

.search-correction b {
    font-style: italic;
    text-decoration: underline;
    text-decoration-color: var(--yellow);
}

/* Closed, the guide is a small "syntax ›" link at the end of the example
   row; open, it wraps onto its own line as a panel. */
.search-help > summary {
    list-style: none;
    cursor: pointer;
    color: var(--blue-text);
    font-weight: 600;
}

.search-help > summary::-webkit-details-marker {
    display: none;
}

.search-help-open,
.search-help[open] .search-help-closed {
    display: none;
}

.search-help[open] .search-help-open {
    display: inline;
}

.search-help[open] {
    flex-basis: 100%;
    margin-top: 0.6rem;
    padding: 1rem;
    background-color: var(--bg_1);
    border-radius: 0.2rem;
    font-size: var(--lg-text);
    color: var(--fg_1);
}

.search-help[open] > summary {
    color: var(--fg_1);
    font-size: 1.1em;
}

.search-help-hide {
    margin-left: 0.4rem;
    font-size: var(--md-text);
    font-weight: normal;
    color: var(--blue-text);
}

.search-help p {
    margin-top: 0.4rem;
}

.search-help table {
    margin-top: 0.6rem;
    border-collapse: collapse;
}

.search-help td {
    padding: 0.25rem 1rem 0.25rem 0;
    vertical-align: top;
}

.search-help td:first-child {
    white-space: nowrap;
}

.search-help code {
    background-color: var(--bg_0);
}

/* ---- Command palette (palette.js) ------------------------------------- */

#palette {
    width: min(36rem, calc(100vw - 2rem));
    margin: 12vh auto auto;
    padding: 0;
    border: 2px solid var(--dim_0);
    border-radius: 0.4rem;
    background-color: var(--bg_0);
    color: var(--fg_1);
    box-shadow: 0 1rem 3rem rgb(0 0 0 / 0.25);
    overflow: hidden;
}

#palette::backdrop {
    background: rgb(56 76 82 / 0.35);
}

#palette > input {
    width: 100%;
    padding: 0.9rem 1rem;
    font-size: var(--lg-text);
    font-weight: bold;
    border: none;
    border-bottom: 2px solid var(--bg_2);
    background-color: var(--bg_1);
    color: var(--fg_1);
    outline: none;
}

#palette > input::placeholder {
    color: var(--dim_0-text);
}

#palette-list {
    list-style: none;
    margin: 0;
    padding: 0.4rem;
    max-height: min(24rem, 60vh);
    overflow-y: auto;
}

.palette-item {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0.6rem;
    border-radius: 0.2rem;
    cursor: pointer;
}

.palette-item[aria-selected="true"] {
    background-color: var(--bg_2);
}

.palette-hint {
    flex-shrink: 0;
    font-size: var(--md-text);
    font-style: italic;
    color: var(--dim_0-text);
}

.palette-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.palette-verb {
    color: var(--dim_0-text);
    margin-right: 0.4ch;
}

.palette-label b {
    color: var(--blue-text);
}

/* ---- Printing ------------------------------------------------------------
   Make any single page print cleanly with Ctrl-P. */

@media print {
    @page {
        margin: 2cm;
    }

    html,
    body {
        height: auto;
        background: none;
        color: #000;
    }

    body {
        display: block;
        font-family: Georgia, "Times New Roman", serif;
    }

    #content-wrapper {
        width: auto;
        padding: 0;
        display: block;
    }

    main {
        height: auto;
        display: block;
    }

    /* Site chrome and anything interactive is meaningless on paper. */
    header,
    footer,
    #to-top,
    .anchor,
    canvas {
        display: none !important;
    }

    p,
    li,
    td,
    blockquote {
        font-size: 12pt;
        line-height: 1.4;
    }

    h1 { font-size: 20pt; }
    h2 { font-size: 15pt; }
    h3 { font-size: 13pt; }
    h4 { font-size: 12pt; }

    h1,
    h2,
    h3,
    h4 {
        break-after: avoid;
        page-break-after: avoid;
    }

    p,
    li {
        orphans: 3;
        widows: 3;
    }

    a,
    a:visited {
        color: #000;
        text-decoration: underline;
        font-weight: inherit;
        opacity: 1;
    }

    /* Paper can't be clicked, so spell out where links go. */
    article a[href^="http"]:not(.tag)::after {
        content: " (" attr(href) ")";
        font-size: 0.85em;
        word-break: break-all;
    }

    article a[href^="/"]:not(.tag)::after {
        content: " (bencornia.com" attr(href) ")";
        font-size: 0.85em;
    }

    /* Tags as plain text rather than buttons. */
    .tag,
    .published {
        background: none;
        padding: 0;
        text-decoration: none;
        color: #000;
    }

    .tag::before {
        content: "#";
    }

    /* Code stays in one piece where it fits on a page, and wraps instead of
       running off the edge of the paper. */
    pre {
        border: 1px solid #000;
        background: none;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    code,
    pre code {
        font-size: 9.5pt;
    }

    code:not(pre code) {
        background: none;
        padding: 0;
        white-space: normal;
    }

    blockquote {
        background: none;
        border-left: 3px solid #000;
    }

    img,
    .image-wrapper,
    .imageblock {
        max-width: 100%;
        break-inside: avoid;
    }

    .image-wrapper {
        width: 60%;
        background: none;
    }

    .fade-animation {
        animation: none;
    }
}
