:root {
    --primary-gap: 1rem;
    --secondary-gap: 0.6rem;
    --tertiary-gap: 0.3em;
    --content-gap: 1.5rem;
    --regular-font: Nunito, sans-serif;
    --regular-font-size: 16px;
    --h1-font-size: 25px;
    --content-h1-font-size: 20px;
    --content-h2-font-size: 18px;
    --content-h3-font-size: 16px;
    --subtle-font-size: 0.8rem;
    --header-font-size: 1.1rem;
    --header-height: 2.5rem;
    --monospace-font: JetBrains Mono, monospace;
    --monospace-font-size: 13px;
    --max-width: 80ch;
    --inline-code-block-padding-primary: 4px;
    --inline-code-block-padding-secondary: 2px;
}

/*:root {
    --primary-fg-colour: #444;
    --primary-bg-colour: #fff;
    --primary-fg-link-colour: #0000b3;
    --subtle-fg-colour: #777;
    --subtle-bg-colour: #eef7fc;
    --subtle-border-colour: #ddd;
    --anchor-fg-colour: #ffb36c;
}*/

/*@media (prefers-color-scheme: dark) {*/
    :root {
        --primary-fg-colour: #d4d4d4;
        --primary-bg-colour: #1e1e1e;
        --primary-fg-link-colour: #6cb8ff;
        --subtle-fg-colour: #b4b4b4;
        --subtle-bg-colour: #2b2b2b;
        --subtle-border-colour: #5a5a5a;
        --anchor-fg-colour: #ffb36c;
    }
/*}*/

/*:root {
    --code-keyword-colour: #8a2be2;
    --code-string-colour: #a52a2a;
    --code-comment-colour: #888;
}*/

/*@media (prefers-color-scheme: dark) {*/
    :root {
        --code-keyword-colour: #dda0dd;
        --code-string-colour: #d2d875;
        --code-comment-colour: #969896;
    }
/*}*/

* {
    box-sizing: border-box;
}

body {
    font-family: var(--regular-font);
    font-size: var(--regular-font-size);
}

body {
    color: var(--primary-fg-colour);
    background-color: var(--primary-bg-colour);
}

a {
    text-decoration: none;
    color: var(--primary-fg-link-colour);
}

a:hover {
    text-decoration: underline;
}

h1 {
    font-size: var(--h1-font-size);
    margin: var(--primary-gap) 0;
}

h1, h2, h3 {
    font-weight: normal;
}

hr {
    border: 1px solid var(--subtle-border-colour);
    width: 100%;
    border-bottom: 0;
    margin: 1rem 0;
}

img {
    max-width: 100%;
}

/* Top Bar */

.top {
    display: grid;
    grid-template-columns: min-content 1fr;
    grid-gap: var(--primary-gap);
    max-width: var(--max-width);
    margin: 0 auto;
}

@media (max-width: 35rem) {
    .top {
        grid-template-columns: none;
        grid-template-rows: min-content max-content;
        grid-gap: 0;
        border-bottom: 1px solid var(--subtle-border-colour);
    }

    nav {
        padding-left: 1rem;
    }
}

/* Header */

header {
    line-height: var(--header-height);
    white-space: nowrap;
    user-select: none;
    display: inline-block;
}

header a {
    font-family: var(--monospace-font);
    font-size: var(--header-font-size);
    display: block;
    height: var(--header-height);
    padding: 0 var(--primary-gap);
    border-bottom-right-radius: 10px;
    border-bottom-left-radius: 10px;
}
/*
header a {
    background-color: var(--primary-fg-colour);
    color: var(--primary-bg-colour);
}
*/

/*@media (prefers-color-scheme: dark) {*/
    header a {
        background-color: var(--subtle-bg-colour);
        color: var(--subtle-fg-colour);
    }
/*}*/

header a:hover {
    text-decoration: none;
}

/* Navigation */

nav {
    user-select: none;
}

nav a {
    line-height: var(--header-height);
    color: var(--primary-fg-colour);
}

nav span:not(:last-child):after {
    content: " ⫽ ";
}

/* Content */

main {
    max-width: var(--max-width);
    padding: var(--secondary-gap);
    margin: 0 auto;
}

@media (max-width: 70ch) { /* should match var(--max-width) */
    main {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Pages */

.page {
    margin-bottom: var(--content-gap);
}

.pages .page:last-child .page__header {
    border-bottom: 0;
}

.page__meta {
    font-family: var(--monospace-font);
    font-size: var(--subtle-font-size);
    color: var(--subtle-fg-colour);
    white-space: nowrap;
}

.page__date {
    display: inline-block;
}

.page--view .page__meta {
    display: block;
}

.tags {
    display: inline-block;
}

.tags__tag {
    font-size: var(--subtle-font-size);
    font-family: var(--monospace-font);
    display: inline-block;
    background-color: #333;
    color: #fff;
    border-radius: 5px;
}

.tags__tag a, .tags__tag div {
    padding: 4px 6px;
    display: inline-block;
    color: var(--primary-fg-colour);
}

.tags__tag a:hover, .tags__tag--selected div {
    border-radius: 5px;
    text-decoration: none;
    background-color: var(--primary-fg-colour);
    color: var(--primary-bg-colour);
}



@media only screen and (max-width: 40rem) {
    .page__meta {
        margin-bottom: var(--primary-gap);
    }
}

/* Content */

.title {
    margin-right: var(--primary-gap);
    margin-bottom: var(--secondary-gap);
}

.title a {
    color: var(--primary-fg-colour);
}

section h1 {
    font-size: var(--content-h1-font-size);
}

section h2 {
    font-size: var(--content-h2-font-size);
}

section h3 {
    font-size: var(--content-h3-font-size);
}

section h1 a.anchor {
    color: var(--anchor-fg-colour);
    user-select: none;
    margin-right: var(--tertiary-gap);
}

section h1 a.anchor:hover {
    text-decoration: none;
}

section,
section h1,
section h2,
section h3,
section p {
    margin: 1rem 0;
}

section h1,
section h2,
section h3 {
    margin: 1.5rem 0;
}

section li,
section p {
    line-height: 1.7rem;
}

section code {
    font-variant-ligatures: none;
    line-height: 1.4rem;
}

section pre,
section pre > code {
    font-variant-ligatures: none;
    white-space: pre;
    padding: 0;
}

section pre {
    font-variant-ligatures: none;
    border-radius: 5px;
    padding: var(--secondary-gap);
    padding-left: var(--primary-gap);
    overflow: auto;
    word-wrap: normal;
}

section pre,
section code {
    background-color: var(--subtle-bg-colour);
    font-family: var(--monospace-font);
    font-size: var(--monospace-font-size);
}

section code {
    color: var(--primary-fg-colour);
    padding: var(--inline-code-block-padding-secondary);
    padding-left: var(--inline-code-block-padding-primary);
    padding-right: var(--inline-code-block-padding-primary);
    white-space: nowrap;
    border-radius: 5px;
}

section blockquote {
    border-radius: 5px;
    overflow-x: auto;
    margin: 0;
    padding: var(--secondary-gap);
    padding-left: var(--primary-gap);
    background-color: var(--subtle-bg-colour);
    border-left: 6px solid var(--subtle-border-colour);
}

section blockquote p:first-child {
    margin-top: 0 !important;
}

section blockquote p:last-child {
    margin-bottom: 0 !important;
}

/* Footer */

@media only screen and (max-width: 70ch) { /* should match var(--max-width) */
    .footnotes ol {
        padding-left: 20px;
    }
}

/* Util */

.row {
    margin-top: var(--secondary-gap);
    margin-bottom: var(--secondary-gap);
}

em {
    transform: skewX(-10deg);
    display: inline-block;
}

/* Media Queries */

@media only screen and (max-width: 70ch) { /* should match var(--max-width) */
    header a {
        border-bottom-left-radius: 0;
    }
}

/*
    https://github.com/rouge-ruby/rouge/wiki/List-of-tokens
*/

/* Highlighting: Keywords */
.highlight .k,
.highlight .kn,
.highlight .kd,
.highlight .kp,
.highlight .kr,
.highlight .kc,
.highlight .kt,
.highlight .kv {
    color: var(--code-keyword-colour);
}

/* Highlighting: Strings */
.highlight .s,
.highlight .sa,
.highlight .se,
.highlight .sb,
.highlight .sc,
.highlight .dl,
.highlight .sd,
.highlight .s2,
.highlight .sh,
.highlight .sx,
.highlight .s1 {
    color: var(--code-string-colour);
}

/* Highlighting: Comments */
.highlight .c,
.highlight .cm,
.highlight .c1,
.highlight .cs {
    color: var(--code-comment-colour);
}

/* Fonts */
@font-face {
    font-family: JetBrains Mono;
    font-display: swap;
    src: url('/assets/fonts/JetBrainsMono-Regular.woff2') format('woff2'),
         url('/assets/fonts/JetBrainsMono-Regular.woff') format('woff');
}

@font-face {
    font-family: JetBrains Mono Bold;
    font-display: swap;
    font-weight: bold;
    src: url('/assets/fonts/JetBrainsMono-Bold.woff2') format('woff2'),
         url('/assets/fonts/JetBrainsMono-Bold.woff') format('woff');
}

@font-face {
    font-family: JetBrains Mono Bold Italic;
    font-display: swap;
    font-weight: bold;
    font-style: italic;
    src: url('/assets/fonts/JetBrainsMono-Bold-Italic.woff2') format('woff2'),
         url('/assets/fonts/JetBrainsMono-Bold-Italic.woff') format('woff');
}

/* Nunito-Regular-Italic-Cyrillic-Ext */
@font-face {
    font-family: Nunito;
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Regular-Italic-Cyrillic-Ext.woff2) format('woff2');
    unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

/* Nunito-Regular-Italic-Cyrillic-Ext */
@font-face {
    font-family: Nunito;
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Regular-Italic-Cyrillic-Ext.woff2) format('woff2');
    unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* Nunito-Regular-Italic-Vietnamese */
@font-face {
    font-family: Nunito;
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Regular-Italic-Vietnamese.woff2) format('woff2');
    unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
}

/* Nunito-Regular-Italic-Latin-Ext */
@font-face {
    font-family: Nunito;
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Regular-Italic-Latin-Ext.woff2) format('woff2');
    unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Nunito-Regular-Italic-Latin */
@font-face {
    font-family: Nunito;
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Regular-Italic-Latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Nunito-Bold-Italic-Cyrillic-Ext */
@font-face {
    font-family: Nunito;
    font-style: italic;
    font-weight: 700;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Bold-Italic-Cyrillic-Ext.woff2) format('woff2');
    unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

/* Nunito-Bold-Italic-Cyrillic */
@font-face {
    font-family: Nunito;
    font-style: italic;
    font-weight: 700;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Bold-Italic-Cyrillic.woff2) format('woff2');
    unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* Nunito-Bold-Italic-Vietnamese */
@font-face {
    font-family: Nunito;
    font-style: italic;
    font-weight: 700;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Bold-Italic-Vietnamese.woff2) format('woff2');
    unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
}

/* Nunito-Bold-Italic-Latin-Ext */
@font-face {
    font-family: Nunito;
    font-style: italic;
    font-weight: 700;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Bold-Italic-Latin-Ext.woff2) format('woff2');
    unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Nunito-Bold-Italic-Latin */
@font-face {
    font-family: Nunito;
    font-style: italic;
    font-weight: 700;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Bold-Italic-Latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Nunito-Regular-Cyrillic-Ext */
@font-face {
    font-family: Nunito;
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Regular-Cyrillic-Ext.woff2) format('woff2');
    unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

/* Nunito-Regular-Cyrillic */
@font-face {
    font-family: Nunito;
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Regular-Cyrillic.woff2) format('woff2');
    unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* Nunito-Regular-Vietnamese */
@font-face {
    font-family: Nunito;
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Regular-Vietnamese.woff2) format('woff2');
    unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
}

/* Nunito-Regular-Latin-Ext */
@font-face {
    font-family: Nunito;
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Regular-Latin-Ext.woff2) format('woff2');
    unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Nunito-Regular-Latin */
@font-face {
    font-family: Nunito;
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Regular-Latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Nunito-Bold-Cyrillic-Ext */
@font-face {
    font-family: Nunito;
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Bold-Cyrillic-Ext.woff2) format('woff2');
    unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

/* Nunito-Bold-Cyrillic */
@font-face {
    font-family: Nunito;
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Bold-Cyrillic.woff2) format('woff2');
    unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* Nunito-Bold-Vietnamese */
@font-face {
    font-family: Nunito;
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Bold-Vietnamese.woff2) format('woff2');
    unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
}

/* Nunito-Bold-Latin-Ext */
@font-face {
    font-family: Nunito;
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Bold-Latin-Ext.woff2) format('woff2');
    unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Nunito-Bold-Latin */
@font-face {
    font-family: Nunito;
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url(/assets/fonts/Nunito-Bold-Latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
