:root {
    --mono-font-stack: SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono",
    "Courier New", monospace;
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Oxygen-Sans, Ubuntu, Cantarell,
    "Helvetica Neue", sans-serif;

    --color-background: #fff;
    --color-background-secondary: rgb(255, 250, 240);
    --color-text: #1e1e1e;
    --color-text-secondary: #7d7d7d;
    --color-link: #2D639E;
    --max-width: 800px;
    --sixteen-nine-h: calc(var(--max-width) * (9 / 16));
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-background: #1D1D1D;
        --color-background-secondary: #3f3f3f;
        --color-text: #D8D8D8;
        --color-text-secondary: #878787;
        --color-link: #367DB4;
    }
}


body {
    max-width: var(--max-width);
    padding: 0 0.5rem;
    margin-right: auto;
    margin-left: auto;
    line-height: 1.5em;
    font-family: sans-serif;
    font-family: var(--font-stack);
    font-size: 1.1em;
    font-weight: 300;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;

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

@media (max-width: 840px) {
    body {
        max-width: 80%;
        font-size: 1em;
        --sixteen-nine-h: calc(100vw * 9 / 16);
    }
    article.post {
        display: flex;
        flex-flow: row;
        flex-wrap: wrap;
        align-items: baseline;
        justify-content: flex-start;
        margin-top: 1em;
    }

    article.post .post-date {
        margin-right: 0.5em;
        min-width: 160px;
        min-width: 100%;
        flex: 1;
    }

    article.post .post-title {
        margin-top: 0.2em;
        min-width: 66%;
    }
}

@media (min-width:840px) {
    article.post {
        display: table-row;
    }

    article.post .post-date {
        display: table-cell;
        padding-right: 1em;
    }

    article.post .post-title {
        display: table-cell;
    }
}

header {
    display: block;
    text-align: center;
}

header > h1 {
    font-size: 2.0em;
    line-height: 1.5em;
    font-weight: 900;
}

header > h3 {
    font-size: 1.7em;
    line-height: 1.5em;
    font-weight: 900;
}

nav {
    font-size: 1.0em;
    line-height: 1.5em;
    font-weight: 400;
}

footer {
    margin-top: 2rem;
    font-size: 11pt;
    text-align: center;
}

footer li {
    display: inline;
    margin: 0.5rem;
}

footer ul {
    display: inline;
}

nav li {
    display: inline;
    margin: 0.5rem;
}

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

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

figure {
    display: block;
    text-align: center;
    margin: auto;
}

p {
    margin-top: 0px;
}


h1 {
    font-size: 1.7em;
    font-weight: 600;
}

article h1 {
    margin-bottom: 1rem;
}

h3 {
    font-size: 1.4em;
    font-weight: 600;
}

sup {
    vertical-align: 0.3em;
    font-size: 0.65em;
}

pre {
    font-family: var(--mono-font-stack);
    font-size: 16px;
    background-color: var(--color-background-secondary);
    padding-left: 2%;
    padding-top: 1ch;
    padding-bottom: 1ch;
    overflow: auto;
}


.org-src-container {
    margin-top: -2em;
}

.org-ul {
    margin-top: -2em;
}


blockquote {
    background-color: var(--color-background-secondary);
    border: 0;
    width: 97.5%;
    font-style: italic;
    text-align: left;
    padding: 2ch 1ch;
    margin: 0 0 2ch;
}

blockquote div {
    text-transform: none;
    text-align: right;
    width: 100%;
}

figcaption {
    color: var(--color-text-secondary);
    text-align: center;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1em;
}

.socials {
    padding-bottom: 2rem;
}

/* Table of Contents
/* ---------------------------------------------------------- */

.toc {
    background: var(--color-background-secondary);
    padding: 0.75em 1em;
    margin: 0 0 1.5em;
    border-radius: 4px;
}

.toc summary {
    cursor: pointer;
    font-weight: 600;
    user-select: none;
    list-style: none;
}

.toc summary::before {
    content: "▶ ";
    font-size: 0.75em;
}

details[open].toc summary::before {
    content: "▼ ";
}

.toc nav ul {
    margin: 0.5em 0 0.25em;
    padding-left: 1.25em;
}

.toc nav li {
    display: list-item;
    margin: 0.2em 0;
    font-size: 0.95em;
}

.toc nav li:has(> ul:only-child) {
    list-style: none;
    margin: 0;
}

/* Post footer (date, reading time, prev/next)
/* ---------------------------------------------------------- */

.post-footer {
    margin-top: 2rem;
    color: var(--color-text-secondary);
    font-size: 0.9em;
}

.post-nav {
    display: flex;
    justify-content: space-between;
    gap: 1em;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-background-secondary);
    font-size: 0.9em;
}

.post-nav-next {
    margin-left: auto;
    text-align: right;
}

/* Callouts
/* ---------------------------------------------------------- */

.callout {
    border-left: 4px solid;
    padding: 0.75em 1em 0.75em 1.25em;
    margin: 1.5em 0;
    border-radius: 0 4px 4px 0;
}

.callout-title {
    font-weight: 600;
    margin: 0 0 0.4em;
}

.callout-body > p:last-child {
    margin-bottom: 0;
}

.callout-note {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
}

.callout-tip {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.08);
}

.callout-warning {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.08);
}

.callout-danger {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

/* Cards
/* ---------------------------------------------------------- */

:not(.kg-card):not([id]) + .kg-card {
    margin-top: 2vmin;
}

.kg-card + :not(.kg-card):not([id]) {
    margin-top: 2vmin;
}

.kg-embed-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.kg-embed-card > iframe {
    width: 100%;
    height: var(--sixteen-nine-h);
}

/* Galleries
/* ---------------------------------------------------------- */

.kg-gallery-card + .kg-gallery-card {
    margin-top: 0.75em;
}

.kg-gallery-container {
    position: relative;
}

.kg-gallery-row {
    display: flex;
    flex-direction: row;
    justify-content: center;
}

.kg-gallery-image img {
    display: block;
    margin: 0;
    width: 100%;
    height: 100%;
}

.kg-gallery-row:not(:first-of-type) {
    margin: 0.75em 0 0 0;
}

.kg-gallery-image:not(:first-of-type) {
    margin: 0 0 0 0.75em;
}


/* Bookmark Cards
/* ---------------------------------------------------------- */

.kg-bookmark-card,
.kg-bookmark-publisher {
    position: relative;
    font-size: 1rem;
    width: auto;
}

.kg-bookmark-container,
.kg-bookmark-container:hover {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row-reverse;
    color: currentColor;
    background: var(--color-background-secondary);
    font-family: var(--font-stack);
    text-decoration: none;
    border-radius: 5px;
    box-shadow: 0 2px 6px -2px rgba(0, 0, 0, 0.1), 0 0 1px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.kg-bookmark-content {
    flex-basis: 0;
    flex-grow: 999;
    padding: 20px;
    order: 1;
}

.kg-bookmark-title {
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.3em;
    text-align: start;
}

.kg-bookmark-description {
    display: -webkit-box;
    max-height: 45px;
    margin: 0.5em 0 0 0;
    font-size: 1rem;
    line-height: 1.55em;
    overflow: hidden;
    opacity: 0.8;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-align: start;
}

.kg-bookmark-metadata {
    display: flex;
    align-items: center;
    font-weight: 500;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kg-bookmark-description {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.kg-bookmark-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
}

.kg-bookmark-thumbnail {
    display: flex;
    flex-basis: 24rem;
    flex-grow: 1;
    justify-content: flex-end;
}

.kg-bookmark-thumbnail img {
    max-width: 100%;
    height: auto;
    vertical-align: bottom;
    object-fit: cover;
}

.kg-bookmark-author {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.kg-bookmark-publisher::before {
    content: "•";
    margin: 0 .5em;
}


/* Card captions
/* ---------------------------------------------------------- */

.kg-width-full.kg-card-hascaption {
    display: grid;
    grid-template-columns: inherit;
}

.kg-width-wide.kg-card-hascaption img {
    grid-column: wide-start / wide-end;
}
.kg-width-full.kg-card-hascaption img {
    grid-column: 1 / -1;
}

.kg-width-full.kg-card-hascaption figcaption {
    grid-column: main-start / main-end;
}
