@font-face {
    font-family: "Lexend";
    src: url("/fonts/Lexend.woff2") format("woff2");
    font-display: swap;
    font-weight: 100 900;
    font-style: normal;
}

@font-face {
    font-family: "JetBrains Mono";
    src: url("/fonts/JetBrainsMono.woff2") format("woff2");
    font-display: swap;
    font-weight: 500;
    font-style: normal;
}

:root {
    --color-backdrop: #18181c;
    --color-base: #1e1e23;
    --color-highlight: #32323c;
    --color-subtext: #8c8c8c;
    --color-text: #ffffff;
    --color-red: #f06464;
    --color-orange: #f08c5a;
    --color-yellow: #f0c878;
    --color-green: #a0f082;
    --color-teal: #50c8c8;
    --color-blue: #6496f0;
    --color-purple: #b478f0;

    --font-size-xlarge: 36px;
    --font-size-large: 24px;
    --font-size-medium: 16px;
    --font-size-small: 14px;
    --transition: all 0.15s cubic-bezier(0.65, 0, 0.35, 1);
    --border: 1.5px solid var(--color-highlight);
    --border-radius: 0.3rem;
    --font-family: "Lexend", sans-serif;
    --font-monospace: "JetBrains Mono", monospace;
    --padding: 0.2rem 0.5rem;
    --box-shadow: 0 0 12px 4px var(--color-backdrop);
}

html {
    background-color: var(--color-base);
    box-sizing: border-box;
    color: var(--color-text);
    font-family: var(--font-family);
    font-synthesis: none;
}

html:has(.sidebar.open) {
    overflow: hidden;
}

* {
    box-sizing: border-box;
}

body {
    display: flex;
    flex-direction: row;
    line-height: 1.5;
    margin: 1rem;
}

main {
    display: flex;
    flex-direction: column;
    max-width: 60ch;
    margin: 0 auto;
    padding: 0 1rem;
}

h1 {
    margin: 1rem 0;
    font-size: var(--font-size-xlarge);
    font-weight: 700;
}

h2 {
    margin: 0.75rem 0;
    font-size: var(--font-size-large);
    font-weight: 600;
}

h3 {
    margin: 0.5rem 0;
    font-size: var(--font-size-medium);
    font-weight: 600;
}

p {
    margin: 0.5rem 0;
    font-size: var(--font-size-medium);
}

a {
    color: var(--color-text);
    cursor: pointer;
    font-size: var(--font-size-medium);
    text-decoration: underline;
    font-weight: 500;
    transition: var(--transition);

    &:is(:hover, :focus-visible) {
        color: var(--color-blue);
    }
}

button {
    align-items: center;
    background-color: var(--color-backdrop);
    border: var(--border);
    border-radius: var(--border-radius);
    cursor: pointer;
    color: var(--color-text);
    display: flex;
    justify-content: center;
    padding: 0.2rem 0.5rem;
    transition: var(--transition);

    &:hover {
        border-color: var(--color-blue);
        color: var(--color-blue);
    }
}

ul {
    margin: 0.5rem 0;
    padding-left: 1rem;
    list-style-type: "> ";
}

ol {
    margin: 0;
    padding-left: 1rem;
}

li {
    margin: 0.3rem 0;
}

table {
    display: block;
    background-color: var(--color-backdrop);
    border: var(--border);
    border-collapse: collapse;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin: 1rem auto;
    overflow-x: auto;
}

thead {
    border-bottom: var(--border);
}

th,
td {
    font-size: var(--font-size-medium);
    padding: var(--padding);
}

tr {
    &:last-child > td {
        border-bottom: none;
    }

    &:nth-child(odd) {
        background-color: var(--color-base);
    }

    &:nth-child(even) {
        background-color: var(--color-highlight);
    }
}

img {
    max-width: 100%;
}

pre {
    background-color: var(--color-backdrop);
    border: var(--border);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    overflow-x: auto;
    padding: 1rem;
    margin: 1rem 0;
}

code {
    background-color: var(--color-backdrop);
    border-radius: var(--border-radius);
    border: var(--border);
    font-family: var(--font-monospace);
    font-size: var(--font-size-small);
    padding: 0.05rem 0.1rem;
}

pre > code {
    background-color: transparent;
    border: none;
    padding: 0;
}

.z-code {
    background-color: var(--color-backdrop);
}

aside {
    background-color: var(--color-backdrop);
    border: var(--border);
    border-radius: var(--border-radius);
    bottom: 1rem;
    box-shadow: var(--box-shadow);
    height: fit-content;
    left: 1rem;
    overflow-y: auto;
    padding: 1rem;
    top: 1rem;
    transition: 0.3s ease;
    z-index: 2;
}

.sidebar-open {
    bottom: 1rem;
    display: none;
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}

.sidebar-close {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 3;
}

.icon {
    width: 1.5rem;
    height: 1.5rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (max-width: 80ch) {
    aside {
        height: auto;
        position: fixed;
        transform: translateY(calc(100% + 1rem));
        right: 1rem;
    }

    aside.open {
        display: block;
        position: fixed;
        transform: translateY(0);
    }

    .sidebar-open {
        display: flex;
    }

    .sidebar-close {
        display: flex;
    }
}

aside > a {
    display: block;
    font-size: var(--font-size-large);
    font-weight: 600;
    text-decoration: none;
}

.note-tree {
    list-style: none;
    margin: 0.5rem 0;
    padding: 0;
}

.note-tree ul {
    border-left: 1px solid var(--color-highlight);
    list-style: none;
    margin: 0.2rem 0 0.2rem 0.55rem;
    padding-left: 0.75rem;
}

.note-tree li {
    margin: 0.3rem 0;
}

.note-tree a {
    text-decoration: none;
}

.note-tree a.active {
    color: var(--color-blue);
}

:is(h1, h2, h3) {
    position: relative;
}

:is(h1, h2, h3):hover > .internal-link {
    color: var(--color-subtext);
}

.internal-link {
    color: transparent;
    font-size: inherit;
    text-decoration: none;
    margin-left: 0.5rem;

    &:hover {
        color: var(--color-text) !important;
    }
}

footer {
    margin: 3rem 0;
    padding-top: 2rem;
    text-align: center;
    color: var(--color-subtext);
    border-top: var(--border);
    font-size: var(--font-size-small);
}

details,
blockquote {
    background-color: var(--color-backdrop);
    border: var(--border);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

details {
    padding: 0.5rem 0.75rem;
    margin: 0.5rem 0;
}

summary {
    font-size: var(--font-size-medium);
    font-weight: 600;
    user-select: none;
}

blockquote {
    padding: 1rem;
    margin: 0 2rem;

    &::before {
        display: block;
        font-size: var(--font-size-medium);
        font-weight: 600;
        text-align: center;
    }

    &.markdown-alert-note::before {
        content: "Note";
        color: var(--color-blue);
    }

    &.markdown-alert-tip::before {
        content: "Tip";
        color: var(--color-green);
    }

    &.markdown-alert-important::before {
        content: "Important";
        color: var(--color-purple);
    }

    &.markdown-alert-warning::before {
        content: "Warning";
        color: var(--color-yellow);
    }

    &.markdown-alert-caution::before {
        content: "Caution";
        color: var(--color-red);
    }
}

.audio-player {
    align-items: center;
    border: var(--border);
    border-radius: var(--border-radius);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    margin: 0.5rem 0;
    padding: 0.5rem;
}

.audio-player figcaption {
    flex: 1 1 12rem;
}

.audio-player audio {
    max-width: 100%;
}
