/* === Reset === */
*,
::after,
::before {
    box-sizing: border-box;
}

html {
    -webkit-tap-highlight-color: transparent;
    overflow-y: scroll;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

a,
button,
body,
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--primary);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-size: 18px;
    line-height: 1.6;
    word-break: break-word;
    background: var(--theme);
}

article,
aside,
figcaption,
figure,
header,
hgroup,
main,
nav,
section,
table {
    display: block;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    line-height: 1.2;
}

h1,
h2,
h3,
h4,
h5,
h6,
p {
    margin-top: 0;
    margin-bottom: 0;
}

ul, ol {
    padding: 0;
}

a {
    text-decoration: none;
}

body,
figure,
ul {
    margin: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    overflow-x: auto;
    word-break: keep-all;
}

button,
input,
textarea {
    padding: 0;
    font: inherit;
    background: 0 0;
    border: 0;
}

input,
textarea {
    outline: 0;
}

button,
input[type=button],
input[type=submit] {
    cursor: pointer;
}

input:-webkit-autofill,
textarea:-webkit-autofill {
    box-shadow: 0 0 0 50px var(--theme) inset;
}

img {
    display: block;
    max-width: 100%;
}

/* === Variables === */
:root {
    --main-width: 780px;
    --main-padding: 1.4em;
    --main-padding-bottom: 3rem;

    --caption-padding: calc(.25 * var(--main-padding));

    --header-top-gap: 2rem;
    --header-bottom-gap: 2rem;
    --header-menu-side-gap: .5rem;
    --header-menu-top-gap: 1rem;

    --font-body: 'JetBrains Mono', monospace;
    --font-mono: 'JetBrains Mono', monospace;

    --h1-margin-top: 2rem;
    --h1-margin-bottom: 1.5rem;
    --h2-margin-top: 2rem;
    --h2-margin-bottom: 1.5rem;
    --hx-margin-top: 1.5rem;
    --hx-margin-bottom: 1rem;
    --p-margin-top: 1rem;
    --p-margin-bottom: 1rem;
    --code-margin-top: 2rem;
    --code-margin-bottom: 2rem;

    --h1-font-size: 2em;
    --h2-font-size: 1.8em;
    --hx-font-size: 1.3em;
    --p-font-size: 1em;
    --p-line-height: 1.5em;
    --caption-font-size: .8em;

    --li-indent: 2rem;
    --ul-margin-top: 1rem;
    --ul-margin-bottom: 1rem;
    --li-checkbox-size: 0.8em;

    --toc-margin-top: 2rem;
    --toc-margin-bottom: 3rem;

    --code-padding: 1.5rem;
    --code-border-radius: 10px;
    --copy-code-button-border-radius: 7px;

    --social-icons-bottom-margin: 3rem;

    --footer-height: 3rem;

    --content-height: calc(100vh - var(--footer-height));
    --figure-img-max-height: 800px;

    --table-cell-padding: .5rem;
    --table-margin-top: 2rem;
    --table-margin-bottom: 2rem;
}

@media screen and (max-width: 1024px) {
    :root {
        --main-width: 750px;
        --header-top-gap: 1rem;
        --caption-padding: calc(.25 * var(--main-padding));
    }
}

@media screen and (max-width: 640px) {
    :root {
        --header-top-gap: 1rem;
        --social-icons-bottom-margin: 0rem;
        --caption-padding: calc(2 * var(--main-padding));
        --li-indent: 1rem;
        --main-padding: 1em;
    }
}

/* === Fonts === */
@font-face {
    font-family: 'JetBrains Mono';
    src: url('/fonts/jetbrains-mono/JetBrainsMono-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('/fonts/jetbrains-mono/JetBrainsMono-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('/fonts/jetbrains-mono/JetBrainsMono-Italic.woff2') format('woff2');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('/fonts/jetbrains-mono/JetBrainsMono-BoldItalic.woff2') format('woff2');
    font-weight: 700;
    font-style: italic;
    font-display: swap;
}

/* === Colors (default) === */
:root {
    --content-primary: rgb(36, 36, 36);
    --content-secondary: rgb(117, 117, 117);
    --background: rgb(255, 255, 255);
    --code-background: rgb(249, 249, 249);
    --code-border: rgb(229, 229, 229);
}

.dark {
    --content-primary: rgb(218, 218, 218);
    --content-secondary: rgb(140, 140, 140);
    --background: rgb(20, 20, 20);
    --code-background: rgb(30, 30, 30);
    --code-border: rgb(50, 50, 50);
}

/* === Main === */
html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  margin: auto;
  max-width: var(--main-width);
  padding-left: var(--main-padding);
  padding-right: var(--main-padding);
  color: var(--content-primary);
  background: var(--background);
}

.content {
  min-height: var(--content-height) !important;
}

h1 {
  margin-top: var(--h1-margin-top);
  margin-bottom: var(--h1-margin-bottom);
  font-size: var(--h1-font-size);
}

h2 {
  margin-top: var(--h2-margin-top);
  margin-bottom: var(--h2-margin-bottom);
  font-size: var(--h2-font-size);
}

h3,
h4,
h5,
h6 {
  font-size: var(--hx-font-size);
  margin-top: var(--hx-margin-top);
  margin-bottom: var(--hx-margin-bottom);
}

p {
  margin-top: var(--p-margin-top);
  margin-bottom: var(--p-margin-bottom);
  font-size: var(--p-font-size);
  line-height: var(--p-line-height);
}

li {
  margin-left: var(--li-indent);
}

li:has(> input[type="checkbox"]) {
  list-style-type: none;
}

li > input[type="checkbox"] {
  width: var(--li-checkbox-size);
  height: var(--li-checkbox-size);
  margin: 0 0.2em 0.15em -1.25em;
  vertical-align: middle;
}

a {
  text-decoration: underline;
}

.dark input {
  color-scheme: dark;
}

/* Code blocks */
.copy-code-button {
  background-color: var(--background);
  font-family: var(--font-mono);
  padding: 3px 6px;
  font-size: 0.8em;
  border-radius: var(--copy-code-button-border-radius);
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  display: none;
  border: 1px solid var(--code-border);
}

pre:hover .copy-code-button {
  display: block;
}

pre {
  position: relative;
  padding: var(--code-padding);
  border: 1px solid var(--code-border);
  overflow: scroll;
  border-radius: var(--code-border-radius);
  margin-top: var(--code-margin-top);
  margin-bottom: var(--code-margin-bottom);
  background-color: var(--code-background) !important;
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
  line-height: 1.3em;
}

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

code span {
  display: inline !important;
}

code {
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "liga", "dlig";
  font-variant-ligatures: contextual;
  font-family: var(--font-mono);
  font-size: .9em;
}

li code,
table code,
p code {
  background-color: var(--code-background);
  border-radius: 3px;
  padding: 2px;
}

/* Footnotes */
.footnotes {
  margin-top: 3rem;
  border-style: none;
}

hr {
  border: none;
  height: 1px;
  background: var(--content-secondary);
  margin-top: 2rem;
  margin-bottom: 2rem;
}

/* Header */
.header {
  padding-top: var(--header-top-gap);
  margin-bottom: var(--header-bottom-gap);
}

.header p {
  font-size: small;
  font-family: var(--font-mono);
  margin-top: 0;
  margin-right: var(--header-menu-side-gap);
}

.header-menu {
  display: grid;
  grid-template-columns: repeat(3, max-content);
  column-gap: var(--header-menu-side-gap);
  padding-top: var(--header-menu-top-gap);
}

.header-title {
  font-size: 2.6em;
  font-weight: bold;
  margin-bottom: 0;
  margin-top: 0;
}

.header-title a {
  text-decoration: none;
}

.shuffle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: shuffle-pulse 2.5s ease-in-out infinite;
}

@keyframes shuffle-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Footer */
footer {
  font-size: small;
  display: flex;
  justify-content: center;
  align-items: center;
  max-height: var(--footer-height);
}

footer a {
  font-family: var(--font-mono);
  margin-left: .2rem;
  margin-right: .2rem;
}

/* Posts list */
.post-line {
  margin-bottom: .5rem;
  display: flex;
  align-items: baseline;
}

.post-line p {
  margin-top: 0rem;
  margin-bottom: 0rem;
}

.line-date {
  font-size: small;
  font-family: inherit;
  min-width: 120px;
  max-width: 120px;
  text-align: right;
  padding-right: 1rem;
  margin-top: 0rem;
  margin-bottom: 0rem;
}

.line-title {
  margin: 0;
}

.line-summary {
  font-size: small;
  margin-top: .2rem !important;
  color: var(--content-secondary);
}

.list-container {
  padding-bottom: 3rem;
}

.pagination {
  display: flex;
  align-items: center;
  margin-top: 1rem;
  margin-bottom: 0rem;
  justify-content: center;
}

.pagination-control {
  min-width: 3rem;
  margin-left: .5rem;
  margin-right: .5rem;
  text-align: center;
  align-items: center;
}

.page-number {
  min-width: 3rem;
  margin-left: .5rem;
  margin-right: .5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

/* Social Icons */
.social-icons {
  padding: 12px 0;
  margin-bottom: var(--social-icons-bottom-margin)
}

.social-icons a {
  text-decoration: none;
}

.social-icons a:not(:last-of-type) {
  margin-inline-end: 12px;
}

.social-icons a svg {
  height: 20px;
  width: 20px;
}

/* Single post page */
.single-intro-container {
  margin-top: 1rem;
  margin-bottom: 2rem;
}

.single-title {
  margin-bottom: .5rem;
}

.single-subsummary {
  margin-top: calc(.8 * var(--p-margin-top));
  margin-bottom: var(--p-margin-bottom);
  display: flex;
  align-items: center;
}

.single-subsummary img {
  height: 45px;
  width: 45px;
  margin-right: .7rem;
  border-radius: 50%;
}

.author {
  margin-bottom: 0;
  margin-top: 0;
}

.single-date {
  margin-top: 0;
  margin-bottom: 0;
  color: var(--content-secondary);
}

.single-summary {
  margin-bottom: 0;
  color: var(--content-secondary);
}

.single-content {
  margin-bottom: 5rem;
}

.single-tags {
  margin-top: -1rem;
}

.single-tags span {
  margin-right: .3rem;
}

/* Single pagination */
.single-pagination {
  margin-top: 3rem;
  margin-bottom: 3rem;
}

.single-pagination a {
  margin-left: .4rem;
  margin-right: .4rem;
}

.single-pagination hr {
  margin: 0;
}

.single-pagination-text {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100%;
}

.single-pagination-prev {
  min-width: 50%;
  margin-top: 1rem;
  margin-bottom: 1rem;
  text-align: right;
}

.single-pagination-next {
  min-width: 50%;
  margin-top: 1rem;
  margin-bottom: 1rem;
  text-align: left;
}

.single-pagination-container-next {
  display: flex;
  min-height: 100%;
  padding: .5rem;
}

.single-pagination-container-prev {
  display: flex;
  min-height: 100%;
  padding: .5rem;
  float: right;
}

/* Table of contents */
.toc {
  font-size: var(--p-font-size);
  line-height: calc(.9 * var(--p-line-height));
  margin-top: var(--toc-margin-top);
  margin-bottom: var(--toc-margin-bottom);
}

.toc ul {
  margin-top: .1rem;
  margin-bottom: .1rem;
}

.toc li {
  margin-top: .1rem;
  margin-bottom: .1rem;
}

/* Images */
figure img {
  display: block;
  max-width: 100%;
  height: auto;
}

.caption-container {
  display: flex;
  justify-content: center;
}

figcaption {
  color: var(--content-secondary);
  padding-left: var(--caption-padding);
  padding-right: var(--caption-padding);
  font-size: var(--caption-font-size);
  margin-top: 1rem;
  margin-bottom: 1rem;
}

/* 404 */
.not-found {
  display: flex;
  align-items: center;
  justify-content: center;
}

.not-found div {
  text-align: center;
}

.not-found div h1 {
  font-size: 6rem;
  margin-bottom: 3rem;
}

/* Back to top */
.back-to-top {
  text-align: center;
  font-family: var(--font-mono);
  font-size: small;
  margin-bottom: 2rem;
}

/* Tables */
.table-outer {
  width: 100%;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  margin-top: var(--table-margin-top);
  margin-bottom: var(--table-margin-bottom);
  font-size: var(--p-font-size);
  line-height: var(--p-line-height);
  color: var(--content-primary);
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  border: 1px solid var(--code-border);
  border-radius: var(--code-border-radius);
}

th,
td {
  padding: var(--table-cell-padding);
  text-align: left;
}

th {
  background-color: var(--code-background);
  font-weight: bold;
}

tbody tr {
  border-top: 1px solid var(--code-border);
}

/* Quotes */
blockquote {
  margin: 1.5rem;
  margin-left: 0;
  margin-right: 0;
  border-left: solid 2px;
  color: var(--content-secondary);
}

blockquote p {
  margin-left: 1rem;
  margin-right: 1rem;
}

/* === Utilities === */
.flex {
    display: flex;
    flex-wrap: wrap;
}

.flexnowrap {
    display: flex;
    flex-wrap: nowrap;
}

.bold {
    font-weight: bold;
}

.italic {
    font-style: italic;
}

.small {
    font-size: medium;
}

.monospace {
    font-family: var(--font-mono);
}
