/* TODO: closed time, rss, cache fonts */

/* ======================================== */
/* Colors
/* ======================================== */
:root {
    --font: #252525;
    --bg: #fffff7;
    --bg-block: #f9f9f2;
    --link: #458588;
    --accent: #555;
    --highlight: #edbd7766;
    --blend: darken;
    --filter: invert(0%);
    /* --max-width: calc(min(100vw - 60px, 2000px, 145px + 50vw)); */
}

@media (prefers-color-scheme: dark) {
    :root {
        --font: #f0f0f0;
        --bg: #1b1b1b;
        --bg-block: #1f1f24;
        --link: #88c0d0;
        --accent: #f2f5f7;
        --highlight: #617bff66;
        --blend: lighten;
        --filter: invert(100%);
    }
}

html[data-theme=light] {
    --font: #252525;
    --bg: #fffff7;
    --bg-block: #f9f9f2;
    --link: #458588;
    --accent: #555;
    --highlight: #edbd7766;
    --blend: darken;
    --filter: invert(0%);
}

html[data-theme=dark] {
    --font: #f0f0f0;
    --bg: #1b1b1b;
    --bg-block: #1f1f2466;
    --link: #88c0d0;
    --accent: #f2f5f7;
    --highlight: #617bff66;
    --blend: lighten;
    --filter: invert(100%);
}

* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    line-height: 155%;
    @media (max-width: 425px) {
        line-height: 135%;
    }
    box-sizing: border-box;
    -webkit-font-smoothing: subpixel-antialiased;
    transition: background 0.8s ease-in-out, color 0.5s ease;
}

/* ======================================== */
/* Fonts
/* ======================================== */
@font-face {
    font-family: 'EB Garamond';
    src: url('../assets/EB_Garamond/EBGaramond-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
}

@font-face {
    font-family: 'EB Garamond';
    src: url('../assets/EB_Garamond/EBGaramond-Italic-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: italic;
}

@font-face {
    font-family: 'Playfair Display';
    src: url('../assets/Playfair_Display/PlayfairDisplay-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
}

@font-face {
    font-family: 'Playfair Display';
    src: url('../assets/Playfair_Display/PlayfairDisplay-Italic-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: Italic;
}

@font-face {
    font-family: 'Josefin Sans';
    src: url('../assets/Josefin_Sans/JosefinSans-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
}

@font-face {
    font-family: 'Josefin Sans';
    src: url('../assets/Josefin_Sans/JosefinSans-Italic-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: italic;
}

@font-face {
    font-family: 'Ioskeley Mono';
    src: url('../assets/Ioskeley_Mono/IoskeleyMono-Regular.ttf') format('truetype');
    font-weight: 200;
    font-style: normal;
}

@font-face {
    font-family: 'Ioskeley Mono';
    src: url('../assets/Ioskeley_Mono/IoskeleyMono-Italic.ttf') format('truetype');
    font-weight: 200;
    font-style: italic;
}

/* ======================================== */
/* Base
/* ======================================== */
html {
    color: var(--bg);
    font-family: "EB Garamond", "Helvetica Neue", "Segoe UI", Helvetica, Arial, serif;
    overflow: scroll;
    overflow-y: hidden;
    overflow-x: hidden;
    margin: 0;
    scroll-behavior: smooth;
    font-size: 22px;
    @media (max-width: 625px) {
        font-size: 20px;
    }
}

body {
    margin: 0;
    color: var(--font);
    background: var(--bg);
    overflow-y: auto;
    height: 100vh;
    -webkit-text-size-adjust: 100%;
}

header,
footer,
#nav,
#content,
.content {
    display: block;
    color: var(--font);
    background: var(--bg);
    margin-bottom: 0.8em;
    margin: 0 auto;
    width: 87.5%;
    max-width: 820px;
    font-size: 1.1rem;
    @media (min-width: 1480px) {
        max-width: 1000px;
    }
    @media (min-width: 1480px) {
        font-size: 1.3rem;
    }
    @media (max-width: 625px) {
        font-size: 18px;
    }
    @media (max-width: 425px) {
        font-size: 17.4px;
    }
}

.content {
    border-top: 0.5px solid var(--accent);
}

/* @media (min-width: 1480px) { */
/*   header, */
/*   footer, */
/*   .content { */
/*     /\* padding-right: 20%; *\/ */
/*     width: 60%; */
/*     margin: 0 4rem; */
/*   } */
/* } */

footer {
    border-top: 0.5px solid var(--accent);
    font-size: 0.9rem;
    text-align: center;
    padding: 1.2rem 0;
}

#nav {
    font-family: "Ioskeley Mono", monospace;
    display: flex;
    text-align: center;
    margin: auto;
    padding: 0.5rem;
    @media (max-width: 400px) {
        font-size: 14px;
    }
}

#nav a {
    color: var(--accent);
}

#nav a:hover,
#nav a:focus {
    background-color: var(--bg);
    opacity: 0.6;
}

header {
    margin-left: 0;
    max-width: 100%;
    width: 100%;
}

/* ======================================== */
/* Headings
/* ======================================== */

h1 {
    font-family: "Playfair Display", serif;
    color: var(--accent);
    /* border-bottom: 0.5px solid var(--accent); */
    font-weight: normal;
    text-align: left;
    margin-top: 0;
    margin-bottom: 0.25rem;
    padding: 1.2rem 0;
    font-size: 3.6rem;
}
.title {
    text-align: left;
}

h2 {
    color: var(--accent);
    text-align: center;
    font-size: 2.2rem;
    font-weight: 300;
    font-style: italic;
}

h1,
h2 {
    line-height: 1;
}

h3 {
    font-family: "Playfair Display", serif;
    color: var(--accent);
    /* border-bottom: 0.5px solid var(--accent); */
    font-size: 1.6rem;
    font-weight: 600;
    margin: 0.9rem 0;
}

@media (max-width: 625px) {
    h1 {
        font-size: 1.8rem;
    }
    h2 {
        font-size: 1.6rem;
    }
    h3 {
        font-size: 1.2rem;
    }
}

/* ==== Mini-headings ==== */
h4,
h5,
h6 {
    font-family: "Josefin Sans", sans-serif;
    color: var(--accent);
    letter-spacing: 0.05em;
    font-weight: 300;
    margin-top: 0.9rem;
    margin-bottom: 0.7rem;
}

h4 {
    font-size: 1.3rem;
    text-transform: uppercase;
}

h5,
h6 {
    font-size: 1.1rem;
    /* font-variant: all-small-caps; */
    text-transform: uppercase;
    text-decoration: underline;
    font-weight: 400;
}

h4 + div > p:first-child,
h5 + div > p:first-child,
h6 + div > p:first-child {
    margin-top: 0.2rem;
}

/* ======================================== */
/* Text (+inline code)
/* ======================================== */
p {
    white-space: pre-line;
    font-family: "EB Garamond", serif;
    font-weight: 300;
    letter-spacing: 0.01em;
    margin: auto;
    margin-top: 1em;
    text-align: left;
    hyphens: nil;
    font-size: 1.1rem;
    @media (min-width: 1480px) {
        max-width: 1000px;
    }
    @media (min-width: 1480px) {
        font-size: 1.3rem;
    }
    @media (max-width: 625px) {
        font-size: 18px;
    }
    @media (max-width: 425px) {
        font-size: 17.4px;
    }
}

p:last-child {
    margin-bottom: 1em;
}

p code {
    font-size: 80%;
    letter-spacing: 0em;
}

pre,
code {
    font-family: "Ioskeley Mono", monospace;
    overflow-x: auto;
}

code {
    border-radius: 0px;
    font-size: 90%;
    font-weight: 200;
}

::-moz-selection {
    background: var(--highlight);
}

::selection {
    background: var(--highlight);
}

/* ======================================== */
/* Source Block
/* ======================================== */
pre {
    border-radius: 0px;
    background-color: var(--bg-block);
    border-top: 0.5px solid var(--accent);
    border-bottom: 0.5px solid var(--accent);
    border-left: 0px;
    border-right: 0px;
    font-size: 18px;
    margin-top: 1em;
    margin-bottom: 0.4rem;
    padding: 0.5rem;
    @media (max-width: 650px) {
        font-size: 14px;
    }
    @media (max-width: 450px) {
        font-size: 12px;
    }
}

.font-lock-keyword-face { color: #c678dd; }
.font-lock-function-name-face { color: #61afef; }
.font-lock-variable-name-face { color: #e06c75; }
.font-lock-string-face { color: #98c379; }
.font-lock-comment-face { color: #5c6370; font-style: italic; }
.font-lock-comment-delimiter-face { color: #5c6370; }
.font-lock-type-face { color: #e5c07b; }
.font-lock-constant-face { color: #d19a66; }
.font-lock-builtin-face { color: #56b6c2; }
.font-lock-preprocessor-face { color: #c678dd; }

/* pre.src::before { */
/*     position: sticky; */
/* } */

/* ======================================== */
/* Dark-light toggle
/* ======================================== */
#dark-mode-button input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

#dark-mode-button {
    margin-left: auto;
    cursor: pointer;
    position: relative;
    width: clamp(12px, 4vw, 24px);
    height: clamp(12px, 4vw, 24px);
}

#dark-mode-button::after {
    content: '';
    width: 100%;
    height: 100%;
    background: var(--accent);
    border-radius: 50%;
    position: absolute;
    /* FIXME */
    top: clamp(25%, 30%, 50%);
    left: clamp(25%, 30%, 50%);
    pointer-events: none;
}

/* #dark-mode-button::after { */
/*     content: ''; */
/*     width: 20px; */
/*     height: 20px; */
/*     background: var(--accent); */
/*     border-radius: 50%; */
/*     position: absolute; */
/*     top: 10px; */
/*     left: -20px; */
/*     @media (min-width: 1480px) { */
/*         top: 11px; */
/*         left: -22px; */
/*         width: 22px; */
/*         height: 22px; */
/*     } */
/*     @media (max-width: 625px) { */
/*         top: 8px; */
/*         left: -16px; */
/*         width: 16px; */
/*         height: 16px; */
/*     } */
/*     @media (max-width: 400px) { */
/*         top: 6px; */
/*         left: -12px; */
/*         width: 12px; */
/*         height: 12px; */
/*     } */
/* } */

/* #dark-mode-button:has(input:checked)::after { */
/* } */

/* ======================================== */
/* Miscellaneous
/* ======================================== */
a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    background-color: var(--highlight);
}

blockquote {
    margin: 2rem auto;
    @media (max-width: 625px) {
        margin: 1rem 0;
    }
}

p.verse,
blockquote p {
    white-space: pre-line;
    display: block;
    font-style: italic;
    line-height: 1.35em;
    text-align: left;
    margin: 0.5em auto;
    width: fit-content;
    padding: 0.5rem auto;
    quotes: none;
}

blockquote p:last-child {
    margin-bottom: 0.5em;
}

.note p {
    border-left: 0.25rem solid var(--accent);
    border-radius: 3px 6px 6px 3px;
    display: block;
    padding: 0.5rem;
    background-color: var(--bg-block);
    color: var(--font);
    margin: 0.8rem 0.3rem;
    padding: 0.25rem 1rem;
}

img {
    display: block;
    /* margin: 0 0 1rem; */
    filter: var(--filter);
    mix-blend-mode: var(--blend);
    max-width: 100%;
}
/* img:hover, img:focus { */
/*     transition-duration: 0.5s; */
/*     box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); */
/* } */

figure {
    margin: 0 auto;
    text-align: center;
}

figure img {
    margin: 0 auto;
}

figcaption {
    font-style: italic;
    color: #aaa;
    max-width: 100%;
}

.katex {
    font-size: 1em !important;
}

p > span:has(.katex-display) {
    display: inline-block;
    margin: 0 auto;
    width: 100%;
    overflow: auto;
}

span > .katex-display {
    margin: 0.3em 0 !important;
}

.katex-display {
    text-align: center;
}

.footpara { display: inline; }
.footdef  {
    font-size: 90%;
    margin-bottom: 0.5rem;
}

/* ======================================== */
/* Lists
/* ======================================== */
ol,
ul {
    padding-left: 32px;
    @media (max-width: 625px) {
        padding-left: 16px;
    }
    margin: 0.35em 0;
}

ol li::marker,
ul li::marker {
    margin-left: -2.5rem;
    position: absolute;
}

ol li,
ul li {
    @media (min-width: 625px) {
        font-size: 95%;
    }
    font-weight: 300;
    margin-top: 0.35em;
    margin-bottom: 0.45em;
    line-height: 1.45;
}

ol li p,
ul li p {
    margin-left: 0.25rem;
    margin-top: 0;
}

.entries > .outline-2 > .outline-text-2 > ul,
.entries ~ .outline-2 > .outline-text-2 > ul {
    padding-left: 0.5em;
}
.entries > .outline-2 > .outline-text-2 > ul > li,
.entries ~ .outline-2 > .outline-text-2 > ul > li {
    color: var(--font);
    display: block;
    text-align: left;
    font-size: 1.4rem;
    margin: 0.5rem 0;
}

.entries > .outline-2 > .outline-text-2 > ul > li a,
.entries ~ .outline-2 > .outline-text-2 > ul > li a {
    color: var(--font);
}
    
.content:has(.entries) ~ footer {
    border-top: none;
}

/* ======================================== */
/* TOC
/* ======================================== */
#table-of-contents {
    font-family: "Josefin Sans", sans-serif;
    font-size: 1.15rem;
    border-bottom: 0.5px solid var(--accent);
}

#table-of-contents h2 {
    color: var(--accent);
    font-weight: 400;
    text-align: left;
    display: block;
    font-size: 105%;
    text-transform: uppercase;
    margin: 0.7rem 0;
    font-style: normal;
}

#table-of-contents ul {
    padding: 0;
    font-weight: 400;
    list-style: none;
    counter-reset: list 0;
}

#table-of-contents ul li {
    vertical-align: top;
    font-size: 90%;
    display: inline-block;
    margin-bottom: 0em;
    margin-top: 0em;
    margin-left: 1rem;
    width: 30%;
    @media (max-width: 625px) {
        width: 45%;
    }
    @media (max-width: 450px) {
        width: 80%;
    }
}

/* ======================================== */
/* Table
/* ======================================== */
table {
    font-family: "Josefin Sans";
    border-collapse: collapse;
    width: 95%;
    font-size: 95%;
    margin: 1rem auto;
    display: block;
    overflow: auto;
    white-space: nowrap;
    text-align: center;
}

table::-webkit-scrollbar {
    display: none;
}

thead {
    display: table-header-group;
    vertical-align: middle;
    border-color: inherit;
}

table th {
    font-weight: normal;
    text-transform: uppercase;
    font-size: 90%;
    font-style: bold;
    letter-spacing: 1px;
    padding: 0.3rem 0.5rem;
    line-height: 1.05;
}

tbody {
    display: table-row-group;
    vertical-align: middle;
    border-color: inherit;
}

tr {
    display: table-row;
    vertical-align: inherit;
    border-color: inherit;
}

table td {
    /* font-family: "Source Sans Pro"; */
    font-weight: 300;
    padding: 0.4em;
    text-align: center;
    hyphens: none;
}

table td + td {
    border-left: 1px solid var(--accent);
}

table tr + tr {
    border-top: 1px solid var(--accent);
}

/* .custom-scrollbar { */
/*   overflow: auto; */
/*   height: 100vh; */
/* } */

/* ::-webkit-scrollbar { */
/*   background-color: transparent; */
/*   width: 18px; */
/* } */

/* ::-webkit-scrollbar-track { */
/*   background-color: transparent; */
/* } */

/* ::-webkit-scrollbar-thumb { */
/*   background: var(--accent); */
/*   border-radius: 20px; */
/*   border: 6px solid transparent; */
/*   background-clip: content-box; */
/* } */
/* ::-webkit-scrollbar-thumb:hover { */
/*   opacity: 0.6; */
/* } */

/* ::-webkit-scrollbar-corner { */
/*   background: var(--bg); */
/* } */
