/*
  The Alegreya SC-hypirion-min font is provided under the SIL Open Font License, and its license is
  available under https://neo.hypirion.com/licenses/alegreya-sc-hypirion-min-ofl.txt
*/
@font-face {
  font-family: 'Alegreya SC-hypirion-min';
  font-style: 400;
  font-weight: normal;
  src: url('/sha/755c66e3ca994a60b7ab49913332a7d8ed37b6eb57f488291bc741ca7e53a3a2.woff2') format('woff2');
  font-display: swap;
}

/* This is the font Heliotrope by Matthew Butterick. If you want to use
it yourself you must buy a license. See https://mbtype.com/ for information. */
@font-face {
  font-family: 'Heliotrope';
  font-style: normal;
  font-weight: normal;
  src: url('/sha/f2ff6c5e91b64047a553798a1495f797a23eca91a7cd60a3d0e5c86df924affb.woff2') format('woff2');
  font-display: swap;
}

/*
  The Source Code Pro font is provided under the SIL Open Font License, and its license is
  available under https://neo.hypirion.com/licenses/source-code-pro-ofl.txt
*/
@font-face {
  font-family: 'Source Code VF';
  font-style: normal;
  font-weight: 200 900;
  src: url('/sha/d95dc751b4d82141259f5c00c9838addaadd3b4eac30dd7db4a0da4921d77792.woff2') format('woff2');
  font-display: swap;
}

@font-face {
  font-family: 'Source Code VF';
  font-style: italic;
  font-weight: 200 900;
  src: url('/sha/720e47a2e54568db2908bfbb32894c1c298fd948cc8942426987c2d29f7ebd9e.woff2') format('woff2');
  font-display: swap;
}

:root {
    color-scheme: light dark;
}

@media (prefers-color-scheme: light) {
    :root {
        --font-color: #121212;

        --kbd-background: #eee;
        --kbd-border-color: #b4b4b4;
        --kbd-font-color: #333;

        --link-color: #0000EE;
        --link-visited-color: #551A8B;
        --link-hover-color: red;

        --outer-bg-color: #fffffb;
        --inner-bg-color: #fff;

        --code-bg-color: oklch(from var(--inner-bg-color) calc(l * 0.98) c h);
        --bg-box-shadow-color: oklch(from var(--inner-bg-color) calc(l * 0.9) c h);
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --font-color: #fff;

        --kbd-background: #2a2a2a;
        --kbd-border-color: #555;
        --kbd-font-color: #ddd;

        --link-color: #88a3e8;
        --link-visited-color: #b47ee7;
        --link-hover-color: #ff6666;

        --outer-bg-color: #000;
        --inner-bg-color: #151510;

        --code-bg-color: oklch(from var(--inner-bg-color) calc(l + 0.15) c h);
        --bg-box-shadow-color: oklch(from var(--inner-bg-color) calc(l - 0.05) c h);
    }
}


@media (prefers-color-scheme: light) and (not (prefers-contrast: more)) {
/* Background */ .bg { background-color: #f8f8f8; }
/* PreWrapper */ .chroma { background-color: #f8f8f8; -webkit-text-size-adjust: none; }
/* Other */ .chroma .x { color: #000000 }
/* Error */ .chroma .err { color: #a40000 }
/* LineLink */ .chroma .lnlinks { outline: none; text-decoration: none; color: inherit }
/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; }
/* LineHighlight */ .chroma .hl { background-color: #dfdfdf }
/* LineNumbersTable */ .chroma .lnt { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
/* LineNumbers */ .chroma .ln { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
/* Line */ .chroma .line { display: flex; }
/* Keyword */ .chroma .k { color: #204a87; font-weight: bold }
/* KeywordConstant */ .chroma .kc { color: #204a87; font-weight: bold }
/* KeywordDeclaration */ .chroma .kd { color: #204a87; font-weight: bold }
/* KeywordNamespace */ .chroma .kn { color: #204a87; font-weight: bold }
/* KeywordPseudo */ .chroma .kp { color: #204a87; font-weight: bold }
/* KeywordReserved */ .chroma .kr { color: #204a87; font-weight: bold }
/* KeywordType */ .chroma .kt { color: #204a87; font-weight: bold }
/* Name */ .chroma .n { color: #000000 }
/* NameAttribute */ .chroma .na { color: #c4a000 }
/* NameClass */ .chroma .nc { color: #000000 }
/* NameConstant */ .chroma .no { color: #000000 }
/* NameDecorator */ .chroma .nd { color: #5c35cc; font-weight: bold }
/* NameEntity */ .chroma .ni { color: #ce5c00 }
/* NameException */ .chroma .ne { color: #cc0000; font-weight: bold }
/* NameLabel */ .chroma .nl { color: #f57900 }
/* NameNamespace */ .chroma .nn { color: #000000 }
/* NameOther */ .chroma .nx { color: #000000 }
/* NameProperty */ .chroma .py { color: #000000 }
/* NameTag */ .chroma .nt { color: #204a87; font-weight: bold }
/* NameBuiltin */ .chroma .nb { color: #204a87 }
/* NameBuiltinPseudo */ .chroma .bp { color: #3465a4 }
/* NameVariable */ .chroma .nv { color: #000000 }
/* NameVariableClass */ .chroma .vc { color: #000000 }
/* NameVariableGlobal */ .chroma .vg { color: #000000 }
/* NameVariableInstance */ .chroma .vi { color: #000000 }
/* NameVariableMagic */ .chroma .vm { color: #000000 }
/* NameFunction */ .chroma .nf { color: #000000 }
/* NameFunctionMagic */ .chroma .fm { color: #000000 }
/* Literal */ .chroma .l { color: #000000 }
/* LiteralDate */ .chroma .ld { color: #000000 }
/* LiteralString */ .chroma .s { color: #4e9a06 }
/* LiteralStringAffix */ .chroma .sa { color: #4e9a06 }
/* LiteralStringBacktick */ .chroma .sb { color: #4e9a06 }
/* LiteralStringChar */ .chroma .sc { color: #4e9a06 }
/* LiteralStringDelimiter */ .chroma .dl { color: #4e9a06 }
/* LiteralStringDoc */ .chroma .sd { color: #8f5902; font-style: italic }
/* LiteralStringDouble */ .chroma .s2 { color: #4e9a06 }
/* LiteralStringEscape */ .chroma .se { color: #4e9a06 }
/* LiteralStringHeredoc */ .chroma .sh { color: #4e9a06 }
/* LiteralStringInterpol */ .chroma .si { color: #4e9a06 }
/* LiteralStringOther */ .chroma .sx { color: #4e9a06 }
/* LiteralStringRegex */ .chroma .sr { color: #4e9a06 }
/* LiteralStringSingle */ .chroma .s1 { color: #4e9a06 }
/* LiteralStringSymbol */ .chroma .ss { color: #4e9a06 }
/* LiteralNumber */ .chroma .m { color: #0000cf; font-weight: bold }
/* LiteralNumberBin */ .chroma .mb { color: #0000cf; font-weight: bold }
/* LiteralNumberFloat */ .chroma .mf { color: #0000cf; font-weight: bold }
/* LiteralNumberHex */ .chroma .mh { color: #0000cf; font-weight: bold }
/* LiteralNumberInteger */ .chroma .mi { color: #0000cf; font-weight: bold }
/* LiteralNumberIntegerLong */ .chroma .il { color: #0000cf; font-weight: bold }
/* LiteralNumberOct */ .chroma .mo { color: #0000cf; font-weight: bold }
/* Operator */ .chroma .o { color: #ce5c00; font-weight: bold }
/* OperatorWord */ .chroma .ow { color: #204a87; font-weight: bold }
/* Punctuation */ .chroma .p { color: #000000; font-weight: bold }
/* Comment */ .chroma .c { color: #8f5902; font-style: italic }
/* CommentHashbang */ .chroma .ch { color: #8f5902; font-style: italic }
/* CommentMultiline */ .chroma .cm { color: #8f5902; font-style: italic }
/* CommentSingle */ .chroma .c1 { color: #8f5902; font-style: italic }
/* CommentSpecial */ .chroma .cs { color: #8f5902; font-style: italic }
/* CommentPreproc */ .chroma .cp { color: #8f5902; font-style: italic }
/* CommentPreprocFile */ .chroma .cpf { color: #8f5902; font-style: italic }
/* Generic */ .chroma .g { color: #000000 }
/* GenericDeleted */ .chroma .gd { color: #a40000 }
/* GenericEmph */ .chroma .ge { color: #000000; font-style: italic }
/* GenericError */ .chroma .gr { color: #ef2929 }
/* GenericHeading */ .chroma .gh { color: #000080; font-weight: bold }
/* GenericInserted */ .chroma .gi { color: #00a000 }
/* GenericOutput */ .chroma .go { color: #000000; font-style: italic }
/* GenericPrompt */ .chroma .gp { color: #8f5902 }
/* GenericStrong */ .chroma .gs { color: #000000; font-weight: bold }
/* GenericSubheading */ .chroma .gu { color: #800080; font-weight: bold }
/* GenericTraceback */ .chroma .gt { color: #a40000; font-weight: bold }
/* GenericUnderline */ .chroma .gl { color: #000000; text-decoration: underline }
/* TextWhitespace */ .chroma .w { color: #f8f8f8 }
}

@media (prefers-color-scheme: dark) and (not (prefers-contrast: more)) {
/* Background */ .bg { color: #ebdbb2; background-color: #282828; }
/* PreWrapper */ .chroma { color: #ebdbb2; background-color: #282828; -webkit-text-size-adjust: none; }
/* LineLink */ .chroma .lnlinks { outline: none; text-decoration: none; color: inherit }
/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; }
/* LineHighlight */ .chroma .hl { background-color: #3d3d3d }
/* LineNumbersTable */ .chroma .lnt { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #756d59 }
/* LineNumbers */ .chroma .ln { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #756d59 }
/* Line */ .chroma .line { display: flex; }
/* Keyword */ .chroma .k { color: #fe8019 }
/* KeywordConstant */ .chroma .kc { color: #fe8019 }
/* KeywordDeclaration */ .chroma .kd { color: #fe8019 }
/* KeywordNamespace */ .chroma .kn { color: #fe8019 }
/* KeywordPseudo */ .chroma .kp { color: #fe8019 }
/* KeywordReserved */ .chroma .kr { color: #fe8019 }
/* KeywordType */ .chroma .kt { color: #fabd2f }
/* NameAttribute */ .chroma .na { color: #b8bb26; font-weight: bold }
/* NameConstant */ .chroma .no { color: #d3869b }
/* NameEntity */ .chroma .ni { color: #fabd2f }
/* NameException */ .chroma .ne { color: #fb4934 }
/* NameLabel */ .chroma .nl { color: #fb4934 }
/* NameTag */ .chroma .nt { color: #fb4934 }
/* NameBuiltin */ .chroma .nb { color: #fabd2f }
/* NameBuiltinPseudo */ .chroma .bp { color: #fabd2f }
/* NameFunction */ .chroma .nf { color: #fabd2f }
/* NameFunctionMagic */ .chroma .fm { color: #fabd2f }
/* LiteralString */ .chroma .s { color: #b8bb26 }
/* LiteralStringAffix */ .chroma .sa { color: #b8bb26 }
/* LiteralStringBacktick */ .chroma .sb { color: #b8bb26 }
/* LiteralStringChar */ .chroma .sc { color: #b8bb26 }
/* LiteralStringDelimiter */ .chroma .dl { color: #b8bb26 }
/* LiteralStringDoc */ .chroma .sd { color: #b8bb26 }
/* LiteralStringDouble */ .chroma .s2 { color: #b8bb26 }
/* LiteralStringEscape */ .chroma .se { color: #b8bb26 }
/* LiteralStringHeredoc */ .chroma .sh { color: #b8bb26 }
/* LiteralStringInterpol */ .chroma .si { color: #b8bb26 }
/* LiteralStringOther */ .chroma .sx { color: #b8bb26 }
/* LiteralStringRegex */ .chroma .sr { color: #b8bb26 }
/* LiteralStringSingle */ .chroma .s1 { color: #b8bb26 }
/* LiteralStringSymbol */ .chroma .ss { color: #83a598 }
/* LiteralNumber */ .chroma .m { color: #d3869b }
/* LiteralNumberBin */ .chroma .mb { color: #d3869b }
/* LiteralNumberFloat */ .chroma .mf { color: #d3869b }
/* LiteralNumberHex */ .chroma .mh { color: #d3869b }
/* LiteralNumberInteger */ .chroma .mi { color: #d3869b }
/* LiteralNumberIntegerLong */ .chroma .il { color: #d3869b }
/* LiteralNumberOct */ .chroma .mo { color: #d3869b }
/* Operator */ .chroma .o { color: #fe8019 }
/* OperatorWord */ .chroma .ow { color: #fe8019 }
/* Comment */ .chroma .c { color: #928374; font-style: italic }
/* CommentHashbang */ .chroma .ch { color: #928374; font-style: italic }
/* CommentMultiline */ .chroma .cm { color: #928374; font-style: italic }
/* CommentSingle */ .chroma .c1 { color: #928374; font-style: italic }
/* CommentSpecial */ .chroma .cs { color: #928374; font-style: italic }
/* CommentPreproc */ .chroma .cp { color: #8ec07c }
/* CommentPreprocFile */ .chroma .cpf { color: #8ec07c; font-style: italic }
/* GenericDeleted */ .chroma .gd { color: #282828; background-color: #fb4934 }
/* GenericEmph */ .chroma .ge { color: #83a598; text-decoration: underline }
/* GenericError */ .chroma .gr { background-color: #fb4934; font-weight: bold }
/* GenericHeading */ .chroma .gh { color: #b8bb26; font-weight: bold }
/* GenericInserted */ .chroma .gi { color: #282828; background-color: #b8bb26 }
/* GenericOutput */ .chroma .go { color: #504945 }
/* GenericSubheading */ .chroma .gu { color: #b8bb26; font-weight: bold }
/* GenericTraceback */ .chroma .gt { background-color: #fb4934; font-weight: bold }
}

@media (prefers-color-scheme: light) and (prefers-contrast: more) {
/* Background */ .bg { background-color: #f8f8f8; }
/* PreWrapper */ .chroma { background-color: #f8f8f8; -webkit-text-size-adjust: none; }
/* LineLink */ .chroma .lnlinks { outline: none; text-decoration: none; color: inherit }
/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; }
/* LineHighlight */ .chroma .hl { background-color: #dfdfdf }
/* LineNumbersTable */ .chroma .lnt { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em; }
/* LineNumbers */ .chroma .ln { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;}
/* Line */ .chroma .line { display: flex; }
}

@media (prefers-color-scheme: dark) and (prefers-contrast: more) {
/* Background */ .bg { background-color: #282828; }
/* PreWrapper */ .chroma { background-color: #282828; -webkit-text-size-adjust: none; }
/* LineLink */ .chroma .lnlinks { outline: none; text-decoration: none; color: inherit }
/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; }
/* LineHighlight */ .chroma .hl { background-color: #dfdfdf }
/* LineNumbersTable */ .chroma .lnt { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em; }
/* LineNumbers */ .chroma .ln { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;}
/* Line */ .chroma .line { display: flex; }
}


:root {
    font-size: clamp(1.15rem, calc(100vw / 29), 1.482rem);
}

body {
    font-family: 'Heliotrope', serif;
    line-height: 1.35;
}

/* TODO: Try out Fira Mono, see how it fares */
code, kbd, samp {
    font-family: 'Source Code VF';
    font-size: 0.8em;
}

pre {
    font-family: 'Source Code VF';
    font-size: 0.85em;
}

h1 {
    font-size: 1.5em;
}

h1#logo {
    font-family: 'Alegreya SC-hypirion-min';
}

h1, h2, h3, h4, h5, h6 {
   text-wrap: balance;
}

/* font justification */

code, kbd {
    hyphens: none;
    text-justify: none;
}

p {
    /* justification looks ugly on small screens, so skip it there */
    @media (600px <= width) {
        text-align: justify;
        text-justify: inter-word;
    }

   hyphens: auto;
   text-wrap: pretty;
}

blockquote {
  font-size: 0.9em;
  line-height: 1.2;
}

.footnote-list {
    font-size: 0.9em;
}


/* Global elements that are redesigned */

a {
    @media (not (prefers-contrast: more)) {
        text-decoration: none;
    }
    color: var(--link-color);
    &:visited {
        color: var(--link-visited-color);
    }
    &:hover {
        text-decoration: underline;
        color: var(--link-hover-color);
    }
}

/* Styling, layout and basic components, roughly in order of
   appearance */

body {
    background: var(--outer-bg-color);
    margin: 0;
    color: var(--font-color);
}

paper-page {
    display: block;
    width: fit-content;
    max-width: 100%;
    background: var(--inner-bg-color);
    margin: 0 auto;
    padding: 0;
    box-shadow: 0 0.5rem 2rem light-dark(rgb(0 0 0 / 0.08), rgb(255 255 255 / 0.08));
    @media (width <= 670px) {
        width: 100%;
    }
}

paper-page > * {
    /* This shenanigans is basically: Keep it 900px wide, where 640px is
       the usable space. If less than 640px, use entire width and 1em
       padding on the sides. Can't really use border-box for this (or
       rather, it doesn't matter), as the computation for the padding
       is the hard part. */
    @media (670px < width) {
        --width-with-padding: min(900px, 100vw);
        --max-width: 640px;
        padding: 0 calc((var(--width-with-padding) - var(--max-width))/2);
        width: var(--max-width);
        margin: 0 auto;
    }
    @media (width <= 670px) {
        padding: 0 1em;
    }
}

/* header */

paper-page > header {
    container-type: inline-size;
    display: flex;
    flex-flow: row wrap;
    align-items: center;

   /* I don't like this: What I want is space-between iff there are
      multiple elements on the same row, otherwise I want the element
      to be centered. This is the closest I could get, but only
      because I know the size of the elements :( */
    @media (670px < width) {
        justify-content: space-between;
    }
    @media (width <= 670px) {
        justify-content: space-evenly;
    }
}

nav > ul {
    display: flex;
    flex-flow: row wrap;
    justify-content: space-evenly;
    padding-left: 0;
    padding-right: 0;
    margin: 0;

    li {
        display: inline;
        padding-left: 0.5em;
        padding-right: 0.5em;
        font-variant: small-caps;
    }

    a:visited {
        color: var(--link-color);
    }
}


/* article contents */


article > header {
    container-type: inline-size;
    display: flex;
    flex-flow: row wrap;
    align-items: baseline;
    justify-content: space-around;
    column-gap: 1em;
}

/* (this includes the logo, btw) */

h1, h2, h3 {
    font-weight: normal;
    margin: 0.3em 0;
    & > a {
      text-decoration: none;
      color: var(--font-color);
      &:visited {
          color: var(--font-color);
      }
      &:hover {
          color: light-dark(oklch(from var(--font-color) calc(l + 0.3) c h),
                            oklch(from var(--font-color) calc(l - 0.15) c h));
          text-decoration: underline;
      }
      & > .anchor {
          @media (prefers-contrast: more) or (hover: none) {
              text-decoration: underline;
          }
          color: light-dark(oklch(from var(--font-color) calc(l + 0.5) c h),
                            oklch(from var(--font-color) calc(l - 0.5) c h));
      }
    }
}

h1, h2, h3, h4 {
    font-variant: small-caps;
    code {
        font-variant: normal;
    }
}
h1#logo {
    font-variant: normal;
}


blockquote {
  margin-left: 0.5em;
  padding-left: 0.5em;

  border-left: 1px var(--font-color) solid;
  @media (width <= 670px) {
      margin-right: 0;
  }
  @media (670px < width) {
      margin-right: 1em;
  }
  p.signature {
      text-align: right;
      font-variant: small-caps;
      &::before {
        content: "—";
      }
  }
}

pre {
    overflow: auto;
    padding: 0.5em 1em;
    @media (not (prefers-contrast: more)) {
        box-shadow: 0 0 0.5rem var(--bg-box-shadow-color);
    }
    @media (width <= 670px) {
        margin: 0 -1em;
    }
    @media (670px < width) and (not (prefers-color-scheme: dark)) and (not (prefers-contrast: more)) {
        border-radius: 1em;
    }
}

/* Rule for inline code snippets */
:not(pre) > code {
    background: var(--code-bg-color);
    border-radius: 0.4em;
    padding: 0 0.3em;
}

/* Rule for code blocks not rendered by chroma */
pre:not(.chroma):has(> code) {
    background: var(--code-bg-color);
}

/* small-caps */
f-sc {
    display: inline;
    font-variant: small-caps;
}

/* inspired by https://developer.mozilla.org/en-US/docs/Web/HTML/Element/kbd */

kbd {
    color: var(--kbd-font-color);
    background-color: var(--kbd-background);
    border-radius: 3px;
    border: 1px solid var(--kbd-border-color);
    @media (not (prefers-contrast: more)) {
        box-shadow: 0 1px 1px rgba(0, 0, 0, .2),
                    0 2px 0 0 light-dark(rgba(255, 255, 255, .7), rgba(255, 255, 255, .12)) inset;
    }
    display: inline-block;
    line-height: 1;
    padding: 4px;
    white-space: nowrap;
}


.footnote-list ol {
    list-style: symbols(fixed "*" "†" "‡" "Δ" "◊");
}

hr {
    border: none;
    border-top: 1px var(--font-color) solid;
}

footer {
    border-top: 1px var(--font-color) solid;
    display: flow-root;

    & > p {
        font-size: 0.8em;
        text-align: center;
    }
}

.pull-right {
    margin-left: auto;
}
