:root {
    --bg-color: #f5f5f3;
    /* ruri-iro */
    --primary-color: #1F4788;
    --text-color: #141414;
    --separator-color: #555555;
    --border-color: #044F67;
    --code-block-bg-color: #dededa;
    --code-inline-bg-color: #f9f9f6;
    --link-color: #1f4788;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1f1f1f;
        --primary-color: #959dc3;
        --text-color: #f5f5f5;
        --separator-color: #aaaaaa;
        --border-color: #959dc3;
        --code-block-bg-color: #333333;
        --code-inline-bg-color: #1f1f1f;
        --link-color: var(--text-color);
    }
}

body {
    max-width: min(40rem, 100%);
    margin-left: auto;
    margin-right: auto;
    font-family: sans-serif;
    color: var(--text-color);
    background-color: var(--bg-color);
}

/* Let the article handle the spacing between itself and the header */
main > :first-child {
    margin-top: 0;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--primary-color);
    margin-bottom: 0;
}

h1 {
    font-size: 2rem;
    margin-top: 1rem;
}

h2 {
    font-size: 1.5rem;
    margin-top: 0.75rem;
}

h3 {
    font-size: 1.25rem;
    margin-top: 0.625rem;
}

h4, h5, h6 {
    font-size: 1.125rem;
    margin-top: 0.5625rem;
}

p {
    margin-top: 1rem;
    margin-bottom: 0;
    font-size: 1rem;
    line-height: 1.6rem;
    font-variant-numeric: oldstyle-nums;
}

header {
    margin-top: 1.5rem;
    margin-bottom: 0rem;
    margin-left: 0.4rem;
    margin-right: 0.4rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid var(--separator-color);
}

header a, header a:visited {
    font-size: 1.5rem;
    color: var(--primary-color);
    text-decoration: none;
}

main {
    margin-top: 1rem;
    margin-left: 0.4rem;
    margin-right: 0.4rem;
}

.note {
    border-width: 2px;
    border-style: solid;
    border-color: var(--border-color);
    border-radius: 0.2rem;
    margin-top: 1rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    padding-bottom: 0.5rem;
}

figure {
    width: 100%;
    margin: 0;
    margin-top: 0.5rem;
}

figure > img {
    max-width: 100%;
    min-width: 60%;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

@media (min-width: 600px) {
    .limit-width {
        margin: auto;
        max-width: 80%;
        display: block;
    }
}

@media (prefers-color-scheme: dark) {
    figure > img {
        filter: brightness(0.8) contrast(1.2);
    }
}

figure > figcaption {
    width: 100%;
    text-align: center;
    font-style: italic;
}

#refs {
    margin-top: 1rem;
}

div.sourceCode {
    padding: 0.05rem 0.5rem;
    margin-top: 0.5rem;
    background-color: var(--code-block-bg-color);
    border-radius: 0.2rem;
    overflow-x: auto;
    font-variant-numeric: normal;
}

code:not(.sourceCode) {
    padding: 0 0.25rem;
    background-color: var(--code-inline-bg-color);
    border-style: solid;
    border-width: 1px;
    border-color: #777;
    font-variant-numeric: normal;
}

@media (max-width: 720px) {
    code:not(.sourceCode) {
        word-break: break-all;
    }
}

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

details {
    margin-top: 0.5rem;
}

li {
    line-height: 1.6rem;
}

/* Merge each citation into a single line */
/* Credits to Tony Zorman */
div.csl-left-margin {
    display: inline;
}

div.csl-right-inline {
    display: inline;
}

.post-list {
    padding-left: 0rem;
}

.post-list-item {
    list-style: none;
    margin-top: 0.6rem;

    /* By default on small viewports,
       show the published dates below each title. */
    flex-direction: column;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

@media (min-width: 600px) {
    .post-list-item {
        /* When the viewport is wide enough,
           show the published dates in the right end,
           on the same lines as each title. */
        flex-direction: row;
    }
}

.post-list-item-published {
    font-variant-numeric: tabular-nums;
}

/* Reset some props to make it look identical to the header>a on the posts */
/* This is required because the h1 on a post page is the title of the post,
   while the h1 on the index page is the title of the site */
#index-header-h1 {
    font: inherit;
    margin: 0;
    display: inline-block;
}

footer {
    padding: 0.5rem 0.5rem;
    margin-top: 2.5rem;
    background-color: var(--code-block-bg-color);
    border-radius: 0.2rem;
    margin-left: 0.4rem;
    margin-right: 0.4rem;
}

footer p {
    text-align: center;
    line-height: 1.2rem;
    font-size: 0.8rem;
    margin-top: 0;
    color: var(--text-color);
}

footer p + p {
    margin-top: 0.5rem;
}

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

/* Make line heights consistent even with inline <sup> elements */
sup {
    vertical-align: top;
    font-size: 0.75rem;
    position: relative;
    top: -0.25rem;
}

blockquote {
    font-style: italic;
    margin: 0;
    margin-top: 1rem;
    padding: 0;
    padding-left: 1rem;
    border-left: 2px solid var(--code-block-bg-color);
}

body > nav {
    margin-top: 0.5rem;
    justify-content: center;
    display: flex;
}

body > nav > ul {
    padding: 0;
    margin: 0;
}

/* Add bottom padding to the last nav on the page,
   otherwise it's too close to the bottom of the screen to my liking. */
body > nav:last-child {
    padding-bottom: 1rem;
}

body > nav > ul > li {
    list-style: none;
    display: inline-block;
    margin: 0 0.25rem;
    margin-top: 0.3rem;
}

/* Enlarge hit target of webring arrows horizontally. */
.enlarge-hit {
    display: inline-block;
    padding-left: 0.2rem;
    padding-right: 0.2rem;
}
