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

:root {
    --primary: #0e1726;
    --secondary: #2a364d;

    --background: #f2f2f2;
    --surface: #e3e6e8fa;
    --surface-secondary: oklch(0.8 0.004 236.501 / 0.98);

    --link: oklch(0.45 0.134 243.439);
    --link-visited: oklch(0.4 0.117 261.841);
    --link-active: #FF0000;
}

:root[data-theme=dark] {
    --primary: #e3e6e8;
    --secondary: #bbbdbf;

    --background: oklch(0.3 0.005 286.198 / 0.96);
    --surface: oklch(0.3 0.005 286.198 / 0.96);
    --surface-secondary: oklch(0.5 0.004 236.501 / 0.96);

    --link: oklch(0.75 0.134 243.439);
    --link-visited: oklch(0.7 0.117 261.841);
    --link-active: #FF0000;
}

/* SETUP */
:root {
    font-family: sans-serif;
    line-height: 1.5;
    color: var(--primary);
    background-color: var(--background);
    scrollbar-gutter: stable;
}

body {
    margin: 0;
    padding: 0;
    min-block-size: 100dvh;
    display: flex;
    flex-direction: column;
}

/* NAV BAR */
#nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;

    font-size: larger;

    background-color: var(--surface);
    border-block-end: 1px solid var(--surface-secondary);
    padding: 0.5em 1em;

    .home-link {
        display: flex;
        align-items: center;
        gap: 0.25em;
    }

    button.theme-toggle {
        background-color: inherit;
        border: none;
        font-size: inherit;
        color: inherit;
        display: flex;

        &:hover {
            background-color: var(--surface-secondary);
            cursor: pointer;
        }
    }

    .icon {
        width: 2ch;
        height: 100%;
        color: inherit;
    }
}

/* PAGE */
#container {
    inline-size: 70ch;
    max-inline-size: 100%;
    margin: 2em auto 5em;
    padding: 0 0.5em;
    flex-grow: 1;
}

/* Page Navigation */
#site-nav, #toc {
    padding: 0.5em;
    margin-block: 1em;
    background-color: var(--surface);
    border: 1px solid var(--surface-secondary);
    border-radius: 0.25em;

    ul {
        margin: 0;
    }

    summary {
        font-size: large;
        cursor: pointer;
    }

    h2 {
        font-size: 1em;
        margin: 0;
        display: inline-block;
    }
}

.sibling-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1em;

    > .link {
        border-radius: 0.25em;
        border: 1px solid var(--surface-secondary);
        padding: 1em 0.5em;
        background-color: var(--surface);

        p {
            margin: 0;
        }
    }
}

/* FOOTER */
footer {
    background-color: var(--surface);
    padding: 0.5em 1em;
    text-align: center;
    border-block-start: 1px solid var(--surface-secondary);
}

@media screen and (max-width: 70ch) {
    #nav-bar {
        padding: 0.5em;
    }

    footer {
        padding: 0.5em;
    }
}

@media screen and (max-width: 40ch) {
    .sibling-links {
        display: block;
        border: 1px solid var(--surface-secondary);
        border-radius: 0.25em;
        background-color: var(--surface);
        padding: 0.5em 1em;

        > .link {
            background-color: initial;
            border: initial;
            padding: 0;
            margin: initial;
        }
    }
}

/* Typography */
code {
    font-size: 1rem;
}

pre > code {
    font-size: 0.8rem;
}

ul {
    line-height: 1.75;
}

a:hover {
    text-decoration: underline;
}

:link[aria-current="page"] {
    font-style: italic;
}

:link {
    color: var(--link);
}

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

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

:is(h1, h2, h3, h4, h5, h6) :link {
    color: inherit;
}

/* UTILS */
.flex-left, .flex-right {
    display: flex;
    align-items: center;
    gap: 1em;
}

.flex-right {
    align-items: end;
}

/* Hidden Content */
/* https://www.a11yproject.com/posts/how-to-hide-content/ */
.visually-hidden:not(:focus):not(:active) {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

/* Skip Links */
#skip-link {
    background: var(--background);
    padding: 0.5rem 1rem;
    border: 1px solid var(--secondary);
}

#skip-link.visually-hidden:focus {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 999;
}