/* vietnamese */
@font-face {
    font-family: "Hepta Slab";
    font-style: normal;
    font-weight: 1 900;
    src: url("/static/fonts/HeptaSlab-VariableFont_wght.ttf") format("truetype");
    unicode-range:
        U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1,
        U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329,
        U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
    font-family: "Hepta Slab";
    font-style: normal;
    font-weight: 1 900;
    src: url("/static/fonts/HeptaSlab-VariableFont_wght.ttf") format("truetype");
}
/* latin */
@font-face {
    font-family: "Hepta Slab";
    font-style: normal;
    font-weight: 1 900;
    src: url("/static/fonts/HeptaSlab-VariableFont_wght.ttf") format("truetype");
}
@font-face {
    font-family: "DM Sans";
    src:
        local("DM Sans"),
        url("/static/fonts/DMSans-VariableFont_opsz,wght.ttf")
            format("truetype");
}

@font-face {
    font-family: "DM Sans Italic";
    src:
        local("DM Sans Italic"),
        url("/static/fonts/DMSans-Italic-VariableFont_opsz,wght.ttf")
            format("truetype");
}

@font-face {
    font-family: "Maple Mono";
    src:
        local("Maple Mono Italic"),
        url("/static/fonts/MapleMono-Italic.ttf") format("truetype");
    font-style: italic;
}

@font-face {
    font-family: "Maple Mono";
    src:
        local("Maple Mono"),
        url("/static/fonts/MapleMono.ttf") format("truetype");
    font-style: normal;
}

@font-face {
    font-family: "Nishiki teki";
    src:
        local("Nishiki-teki"),
        url("/static/fonts/NishikiTeki.ttf") format("truetype");
}

:root {
    /* Color palette */
    --primary-50: 247 244 254;
    --primary-100: 239 235 252;
    --primary-200: 227 218 250;
    --primary-300: 206 189 245;
    --primary-400: 180 151 238;
    --primary-500: 155 109 229;
    --primary-600: 140 77 218;
    --primary-700: 124 59 198;
    --primary-800: 104 49 166;
    --primary-900: 87 42 136;
    --primary-950: 54 25 92;
    --secondary-50: 243 243 250;
    --secondary-100: 233 234 246;
    --secondary-200: 214 214 239;
    --secondary-300: 189 189 228;
    --secondary-400: 167 162 215;
    --secondary-500: 148 138 202;
    --secondary-600: 131 114 185;
    --secondary-700: 113 96 162;
    --secondary-800: 93 80 131;
    --secondary-900: 77 69 106;
    --secondary-925: 55 49 76;
    --secondary-950: 34 30 46;
    --secondary-975: 17 15 23;
    --accent: rgb(var(--primary-400));

    color-scheme: light dark;

    --max-width: 48rem;
    --bg-header: var(--accent);
    --fg-header: rgb(var(--secondary-950));
    --border-header: rgb(var(--secondary-700));
    --plain-bg: light-dark(rgb(var(--primary-50)), rgb(var(--secondary-975)));
    --bg: light-dark(rgb(var(--primary-200)), rgb(var(--secondary-950)));
    --bg-depth: light-dark(var(--bg), rgb(var(--secondary-925)));
    --bg-surface0: light-dark(
        rgb(var(--primary-100)),
        rgb(var(--secondary-900))
    );
    --bg-surface1: light-dark(
        rgb(var(--primary-50)),
        rgb(var(--secondary-975))
    );
    --text-hard: light-dark(rgb(var(--secondary-900)), rgb(var(--primary-100)));
    --text: light-dark(rgb(var(--secondary-900)), rgb(var(--primary-200)));
    --subtext: light-dark(rgb(var(--secondary-700)), rgb(var(--primary-300)));
    --anchor: light-dark(
        hsl(from rgb(var(--secondary-700)) calc(h - 10) calc(s + 10) l),
        hsl(from rgb(var(--secondary-400)) calc(h - 10) calc(s + 10) l)
    );
    --anchor-visited: light-dark(
        hsl(from rgb(var(--primary-700)) calc(h + 10) s l),
        hsl(from rgb(var(--primary-400)) calc(h + 10) s l)
    );
    --anchor-active: light-dark(
        rgb(var(--primary-950)),
        rgb(var(--primary-100))
    );
    --border: light-dark(rgb(var(--primary-800)), rgb(var(--secondary-600)));
    --border-surface0: light-dark(
        rgb(var(--primary-800)),
        rgb(var(--secondary-600))
    );
    --preview: light-dark(rgb(var(--secondary-200)), rgb(var(--secondary-950)));
    --font-mono: "Maple Mono", monospace;
    --font-body: "DM Sans", sans-serif;
    --font-serif: "Hepta Slab", serif;
}

/*  https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Box_model#the_alternative_css_box_model */
html {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    font-family: var(--font-body);
    background-color: var(--bg);
    color: var(--text);
}

p,
blockquote,
h1,
h2,
h3 {
    text-wrap: pretty;
}
.wrapper {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

main > :first-child,
article > :first-child {
    margin-top: 0;
    margin-block-start: 0;
}

main > :last-child,
article > :last-child {
    margin-bottom: 0;
    margin-block-end: 0;
}

main,
article {
    padding-top: 0.33rem;
    padding-bottom: 0.33rem;
}

main,
.page,
article {
    flex-grow: 1;
    font-family: var(--font-body);
    margin: 1rem auto;
    background: var(--plain-bg);
    border: 1px solid light-dark(var(--subtext), var(--bg-surface0));
    box-shadow: 0.3rem 0.5rem
        light-dark(
            hsl(
                from rgb(var(--secondary-900)) calc(h - 10) calc(s + 10)
                    calc(l + 10)
            ),
            hsl(
                from rgb(var(--secondary-950)) calc(h + 40) calc(s + 80)
                    calc(l - 10)
            )
        );
    width: var(--max-width);
    padding: 1.5rem 1rem;

    /*
      Needed, otherwise .wrapper grid will use `min-width: min-content`.
      Problematic if an element expands past 100vw,
      where it will cause main to grow massively.

      https://developer.mozilla.org/en-US/docs/Web/CSS/min-width#values
     */
    min-width: 0;

    @media (width <= 48rem) {
        & {
            width: 100%;
            margin: 0 auto;
            border: none;
            box-shadow: none;
        }
    }

    & > * {
        max-width: min(var(--max-width), 100%);
        margin-left: auto;
        margin-right: auto;
    }
}

a {
    color: var(--anchor);

    &:visited {
        color: var(--anchor-visited);
    }

    &:hover,
    &:focus {
        text-decoration: none;
    }

    &:active {
        color: var(--anchor-active);
    }
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-serif);
    /* font-optical-sizing: auto; */
    font-style: normal;
    font-weight: 450;
    margin-block-start: 1.5rem;
    margin-block-end: 0.5rem;
}

/* h1.blog-head,
h1.page-head {
    margin-block-start: 0.33rem;
} */

span.blog-subhead {
    font-family: var(--font-serif);
}

p.blog-publish {
    font-family: var(--font-serif);
    font-style: italic;
}

p,
ul,
ol {
    margin-block-start: 0.5rem;
    margin-block-end: 1rem;
}
p code {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 10pt;
}

samp {
    font-family: var(--font-mono);
    font-weight: 400;
}

body {
    counter-reset: figure 0;
}

figure {
    display: flex;
    flex-direction: column;

    figcaption {
        &::before {
            counter-increment: figure;
            content: "Figure " counter(figure) ": ";
        }
    }
}

figure:has(img) {
    box-shadow: 1px 2px var(--bg-depth);
    background-color: #000;
    border: 1px solid rgb(53 50 68);
    justify-content: flex-end;

    img {
        padding: 0.2rem;
    }
    figcaption {
        padding: 0.2rem 0;
        border-top: 1px solid rgb(53 50 68);
        background: var(--bg);
    }
}

img:not(.raw) {
    max-height: 24rem;
    max-width: 100%;
    height: auto;
    object-fit: contain;

    margin: 0 auto;
    display: block;
}

img:not(.raw) {
}

img:not(.raw).applerounded {
    border-radius: 1.5rem;
}

img:not(.raw).superrounded {
    border-radius: 3rem;
}

img:not(.raw).blackbg {
    background-color: #000000;
}

abbr {
    text-decoration-style: dotted;
    cursor: help;
}

hr {
    width: 100%;
}
hr.frontmatter {
    border: none;
    border-top: 3px double var(--text);
    color: var(--text);
    overflow: visible;
    text-align: center;
    height: 5px;
}

hr.frontmatter::after {
    background: var(--bg-surface1);
    content: "0";
    font-family: var(--font-mono);
    padding: 0 2px;
    position: relative;
    top: -10px;
}

hr.frontmatter.pilcrow::after {
    content: "¶";
}

#title {
    font-size: 2rem;
    margin-bottom: 0.2rem;
}

.pona {
    font-family: "Nishiki teki", "Fairfax HD", sans-serif;
}

.metadata {
    /* make italic */
    font-family: var(--font-mono);
    color: var(--subtext);
    margin-bottom: 1rem;
    display: flex;
    flex-direction: row;
    gap: 1rem;
    font-style: italic;
}

.table-of-contents {
    background-color: var(--bg-surface0);
    list-style: none;
    padding-inline-start: 0;
    padding: 1rem;

    & h3 {
        margin-top: 0;
    }

    & a {
        color: var(--text);
    }
}

footer#page-footer {
    padding: 1rem 0;
    background-color: var(--bg-header);
    color: var(--fg-header);
    border-top: 2px solid var(--border-header);

    div.inner {
        width: min(calc(var(--max-width) - 0.5rem), 100%);
        padding: 0 1rem;
        margin-left: auto;
        margin-right: auto;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    div._88x31s {
        justify-content: end;
    }

    @media (width <= 48rem) {
        & {
            flex-direction: column;
        }
    }

    @media (width <= 27rem) {
        & {
            padding: 0.5em;
        }
    }
}

div._88x31s {
    display: flex;
    flex-flow: row wrap;
    align-items: center;
    gap: 1px;

    & > * {
        width: 88px;
        height: 31px;
        display: block;
    }

    img {
        image-rendering: pixelated;
    }
}

.tablet-show {
    display: none;
}
@media (width <=48rem) {
    .tablet-show {
        display: initial;
    }

    .tablet-hide {
        display: none;
    }
}

.mobile-show {
    display: initial;
}

@media (width >=27rem) {
    .mobile-show {
        display: none;
    }
}

@media (width <=27rem) {
    .mobile-hide {
        display: inherit;
    }
}

.sr-only {
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    width: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
}

main {
    container-type: inline-size;
}
@container (width < 28.5rem) {
    /* Specificity hack */
    /* https://csswizardry.com/2014/07/hacks-for-dealing-with-specificity/ */
    .card-stack.card-stack {
        grid-template-columns: 1fr;
    }
}

.card-stack {
    display: grid;
    gap: 0.5em;
    grid-template-columns: repeat(auto-fill, 14rem);
    justify-content: center;
}

.card:hover > .title {
    color: var(--anchor);
    text-decoration: underline;

    .year {
        color: var(--subtext);
    }
}

.card-stack > a {
    display: flex;
    flex-direction: column;
}

.card {
    border-radius: 0.5rem;
    background-color: var(--bg-surface0);
    color: var(--text);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: clip;

    .preview {
        max-width: 100%;
        aspect-ratio: 16 / 9;
        background: var(--preview);
        display: flex;
        flex-direction: column;
        border-bottom: 1px solid var(--border);
        overflow: clip;

        img {
            margin: auto;
            max-width: 100%;
        }
    }

    .blurb {
        flex-grow: 1;
        padding: 0.5em;

        span {
            display: block;

            &.title {
                font-size: 1.2rem;
            }

            &.year {
                color: var(--anchor);
                display: inline;
                font-size: 0.8em;
            }

            &.description {
                color: var(--subtext);
                font-size: 0.8em;
            }
        }
    }

    .links {
        display: flex;
        flex-flow: row wrap;
        gap: 0.2em;
        justify-content: space-evenly;
        margin: 0.2em;

        a {
            color: var(--text);
            text-decoration: none;
            display: block;
            background-color: var(--bg-surface1);
            flex-grow: 1;
            border-top: var(--border);
            border: 1px solid var(--border);
            padding: 0.5em 0;
            border-radius: 0.3em;
            text-align: center;
        }
    }
}

blockquote {
    color: var(--text-hard);
    border-radius: 1rem;
    border-right: 1px solid light-dark(var(--bg), rgb(var(--secondary-925)));
    border-left: 0.3rem solid var(--border);
    padding: 0.1rem 0.7rem;
    background-color: var(--bg-surface0);
    box-shadow: 0 0.1rem light-dark(var(--bg), rgb(var(--secondary-925)));
    word-break: break-all;
}

blockquote.small {
    border-radius: 0.2rem;
    margin: 0 0.25em;
    padding: 0.25em;
}

bsky-comments {
    --background-color: var(--bg-surface1);
    --text-color: var(--text);
    --link-color: var(--subtext);
    --link-hover-color: var(--anchor-active);
    --comment-meta-color: var(--subtext);
    --reply-border-color: var(--text);
}

figcaption {
    text-align: center;
}

div.code-toolbar {
    color-scheme: dark;

    position: relative;
    margin: 1em 0px;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;

    .toolbar {
        color-scheme: light;

        background-color: var(--bg);
        color: var(--text);

        border-bottom-left-radius: 0.5rem;
        font-family: var(--font-serif);
        border-left: 1px solid var(--border);
        border-bottom: 1px solid var(--border);

        padding: 0.2rem;
        position: absolute;
        right: 0;
        top: 0;
    }

    pre {
        margin: 0;
        border: 0;
        border-radius: 0;
        overflow-x: auto;
    }
}

pre {
    background-color: var(--plain-bg);
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-family: var(--font-mono);
    font-size: 10pt;

    & b {
        font-weight: 500;
    }

    code {
        word-wrap: normal;
        white-space: pre;
    }

    @media (width <= 27rem) {
        & {
            font-size: 9pt;
        }
    }
}

pre[lang="ansi"] {
    --red: rgb(243 139 168);
    --green: rgb(166 227 161);
    --yellow: rgb(249 226 175);
    --blue: rgb(137 180 250);
    --pink: rgb(245 194 231);
    --teal: rgb(148 226 213);
    --black: #6c7086;
}

span.emoji-icon {
    padding-right: 0.20em;
    padding-left: 0.20rem;
    font-style: normal;
}

.subtle {
    background: none;
    border: none;
    font-size: 0.8em;
    padding: 0;
    color: rgba(34, 30, 46, 0.3) !important;
}
.subtle.clickme {
    text-decoration: underline;
    cursor: pointer;

    &:hover {
        text-decoration: none;
    }
}

#editorWrapper {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    height: 100%;
    width: 100%;
}

#editorPreview {
    max-width: 50vw;
    max-height: 90vh;
    overflow: scroll;
    border: 1px solid red;
    padding: 0 0.5rem;
    background-color: var(--bg-surface1);
    width: 100%;
}

#editor {
    width: 100%;
    height: 90vh;
}
