:root {
    color-scheme: light;
    --background: #fff;
    --text: #030303;
    --link: #1558a6;
    --muted: #555;
    --border: #dedede;
    --code: #333;
    --code-background: #e8e8e8;
    --syntax-comment: #59636e;
    --syntax-keyword: #bd202e;
    --syntax-function: #6f42c1;
    --syntax-string: #032f62;
    --syntax-number: #005cc5;
    --syntax-name: #a04100;
    --mark-background: #ff0;
    --outside-background: #f2f2f2;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --background: #171717;
    --text: #e8e8e8;
    --link: #8ab4f8;
    --muted: #bbb;
    --border: #555;
    --code: #f7f7f7;
    --code-background: #333;
    --syntax-comment: #8b949e;
    --syntax-keyword: #ff7b72;
    --syntax-function: #d2a8ff;
    --syntax-string: #a5d6ff;
    --syntax-number: #79c0ff;
    --syntax-name: #ffa657;
    --mark-background: #715f00;
    --outside-background: #101010;
    --note-accent: #8ab4f8;
    --note-background: #202c3b;
    --tip-accent: #81c995;
    --tip-background: #1d3024;
    --important-accent: #f28b82;
    --important-background: #382323;
    --caution-accent: #fdd663;
    --caution-background: #382f1b;
    --warning-accent: #ff9e64;
    --warning-background: #3a281d;
}

:root {
    --note-accent: #1769aa;
    --note-background: #edf5fc;
    --tip-accent: #188038;
    --tip-background: #edf7ee;
    --important-accent: #b3261e;
    --important-background: #fceeee;
    --caution-accent: #8a6100;
    --caution-background: #fff7e0;
    --warning-accent: #b54708;
    --warning-background: #fff1e6;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;
        --background: #171717;
        --text: #e8e8e8;
        --link: #8ab4f8;
        --muted: #bbb;
        --border: #555;
        --code: #f7f7f7;
        --code-background: #333;
        --syntax-comment: #8b949e;
        --syntax-keyword: #ff7b72;
        --syntax-function: #d2a8ff;
        --syntax-string: #a5d6ff;
        --syntax-number: #79c0ff;
        --syntax-name: #ffa657;
        --mark-background: #715f00;
        --outside-background: #101010;
        --note-accent: #8ab4f8;
        --note-background: #202c3b;
        --tip-accent: #81c995;
        --tip-background: #1d3024;
        --important-accent: #f28b82;
        --important-background: #382323;
        --caution-accent: #fdd663;
        --caution-background: #382f1b;
        --warning-accent: #ff9e64;
        --warning-background: #3a281d;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--outside-background);
    color: var(--text);
    font-family: "Atkinson Hyperlegible", sans-serif;
    font-weight: 400;
}

a {
    color: var(--link);
    font-weight: 400;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 3px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: "Atkinson Hyperlegible", sans-serif;
}

img,
video,
iframe {
    max-width: 100%;
}

img {
    height: auto;
}

iframe {
    display: block;
    margin: 2em auto;
}

figure,
figcaption {
    text-align: center;
}

pre {
    overflow-x: auto;
    padding: 1rem;
    background: var(--code-background);
    line-height: 1.5;
}

code,
kbd,
samp {
    font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
    font-size: 0.85em;
    line-height: 1.3;
}

.post-content code {
    color: var(--code);
    background: var(--code-background);
}

.post-content :not(pre) > code {
    padding: 0 0.2em;
}

.post-content pre {
    font-size: 0.85em;
}

.post-content .rouge code {
    color: var(--text);
}

.post-content .rouge .c,
.post-content .rouge .cm,
.post-content .rouge .cp,
.post-content .rouge .c1,
.post-content .rouge .cs {
    color: var(--syntax-comment);
}

.post-content .rouge .k,
.post-content .rouge .kc,
.post-content .rouge .kd,
.post-content .rouge .kn,
.post-content .rouge .kp,
.post-content .rouge .kr,
.post-content .rouge .kt,
.post-content .rouge .o,
.post-content .rouge .ow {
    color: var(--syntax-keyword);
}

.post-content .rouge .nf,
.post-content .rouge .fm {
    color: var(--syntax-function);
}

.post-content .rouge .s,
.post-content .rouge .sb,
.post-content .rouge .sc,
.post-content .rouge .sd,
.post-content .rouge .s1,
.post-content .rouge .s2,
.post-content .rouge .se,
.post-content .rouge .sh,
.post-content .rouge .si,
.post-content .rouge .sx,
.post-content .rouge .sr,
.post-content .rouge .ss {
    color: var(--syntax-string);
}

.post-content .rouge .m,
.post-content .rouge .mb,
.post-content .rouge .mf,
.post-content .rouge .mh,
.post-content .rouge .mi,
.post-content .rouge .mo {
    color: var(--syntax-number);
}

.post-content .rouge .na,
.post-content .rouge .nb,
.post-content .rouge .bp,
.post-content .rouge .nc,
.post-content .rouge .nd,
.post-content .rouge .ne,
.post-content .rouge .nn,
.post-content .rouge .nv,
.post-content .rouge .vc,
.post-content .rouge .vg,
.post-content .rouge .vi,
.post-content .rouge .nt {
    color: var(--syntax-name);
}

mark {
    background: var(--mark-background);
}

.site-shell {
    width: min(100% - 2rem, 74rem);
    margin: 2rem auto;
    padding: 2.5rem clamp(1.5rem, 5vw, 4rem);
    border-radius: 0.35rem;
    background: var(--background);
    box-shadow: 0 0 0 1px var(--border);
}

.site-header {
    display: grid;
    grid-template-columns: 1fr auto;
    margin-bottom: 3rem;
}

.site-heading {
    grid-column: 1 / -1;
}

.site-heading h1 {
    margin-bottom: 0;
}

.site-heading h1 a {
    text-decoration: none;
}

.site-heading p {
    margin-top: 0.2rem;
}

.header-controls {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    justify-self: end;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

.site-nav {
    display: flex;
    gap: 1rem;
    font-family: "Atkinson Hyperlegible", sans-serif;
    text-transform: uppercase;
}

.theme-toggle {
    display: inline-flex;
    width: 2.25rem;
    height: 2.25rem;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--background);
    color: var(--text);
    cursor: pointer;
}

.theme-toggle svg {
    width: 1.1rem;
    height: 1.1rem;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.theme-toggle .moon-icon,
:root[data-theme="dark"] .theme-toggle .sun-icon {
    display: none;
}

:root[data-theme="dark"] .theme-toggle .moon-icon {
    display: block;
}

.post-list {
    display: grid;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.post-preview {
    display: grid;
    grid-template-columns: 7rem minmax(0, 1fr);
    gap: 1rem;
}

.post-preview time,
.post-date {
    color: var(--muted);
    font-style: italic;
}

.post-preview h2 {
    margin: 0;
    font-size: 1.35rem;
}

.post-summary {
    max-width: 66.667%;
    margin-top: 0.5rem;
}

.post-summary p:first-child {
    margin-top: 0;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 3rem 0;
    text-align: center;
}

.taxonomy-list {
    display: grid;
    gap: 0.6rem;
    padding-left: 1.25rem;
}

.taxonomy-list span,
.taxonomy-back {
    color: var(--muted);
    font-size: 0.8em;
}

.taxonomy-back {
    margin-left: 0.75rem;
    white-space: nowrap;
}

.post {
    font-size: 1.1rem;
}

.post-header {
    margin: 2rem 0;
}

.post-header h1 {
    margin-bottom: 1rem;
    font-size: 2.45rem;
    font-weight: 400;
    line-height: 1.2;
}

.post-date {
    margin-top: 0;
}

.post-content {
    line-height: 1.5rem;
}

.post-content p {
    max-width: 66.667%;
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
}

.post-content ul,
.post-content ol {
    max-width: 66.667%;
}

.post-content li > ul,
.post-content li > ol {
    max-width: none;
}

.post-content h2 {
    margin: 1rem 0 0.4rem;
    font-size: 2.2rem;
    font-style: italic;
    font-weight: 400;
    line-height: 1.2;
}

.post-content h3 {
    font-size: 1.5rem;
    font-weight: 400;
}

.post-content h4 {
    font-size: 1.25rem;
    font-weight: 400;
}

.post-content .quote-block,
.post-content .admonition-block,
.post-content .listing-block,
.post-content .image-block,
.post-content figure,
.post-content .figure {
    max-width: 66.667%;
}

.post-content figure.image-block {
    width: 66.667%;
    margin-right: auto;
    margin-left: 0;
}

.post-content .quote-block blockquote {
    max-width: none;
    margin-right: 0;
    margin-left: 0;
}

.post-content .admonition-block p,
.post-content blockquote p {
    max-width: none;
}

.footnote-context {
    display: grid;
    grid-template-columns: minmax(0, 66.667%) minmax(12rem, 1fr);
    gap: 0 1.5rem;
    align-items: start;
}

.footnote-context > p {
    grid-column: 1;
    max-width: none;
}

.contextual-footnote {
    display: grid;
    grid-column: 2;
    grid-template-columns: 1em minmax(0, 1fr);
    column-gap: 0.2em;
    font-size: 0.8em;
    line-height: 1.55;
}

.footnote-number {
    align-self: start;
    color: var(--link);
    font-size: 0.85em;
    font-weight: 400;
    line-height: 1;
    text-align: right;
    transform: translateY(-0.15em);
}

.contextual-footnote-content {
    overflow-wrap: anywhere;
}

.contextual-footnote-content p {
    max-width: none;
}

.post-content img,
.post-content figure,
.post-content .figure {
    margin: 1.5rem auto;
}

.post-content img.left,
.post-content figure.left,
.post-content .figure.align-left {
    float: left;
    margin: 0 1.5rem 1rem 0;
}

.post-content img.right,
.post-content figure.right,
.post-content .figure.align-right {
    float: right;
    margin: 0 0 1rem 1.5rem;
}

.post-content blockquote,
.post-content .admonition-block {
    padding: 0.75rem 1rem;
}

.post-content blockquote {
    border-left: 5px solid var(--border);
    background: var(--code-background);
    font-style: italic;
}

.post-content blockquote p:first-child {
    margin-top: 0;
}

.post-content .admonition-block {
    display: grid;
    grid-template-columns: 1.5rem minmax(0, 1fr);
    column-gap: 0.75rem;
    align-items: start;
    margin: 1.25rem 0;
    padding: 1rem 1.25rem;
    border-left: 4px solid var(--admonition-accent, var(--border));
    border-radius: 0.25rem;
    background: var(--admonition-background, var(--code-background));
}

.post-content .admonition-block h6 {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

.post-content .admonition-block::before {
    grid-column: 1;
    grid-row: 1;
    margin-top: 0.2em;
    width: 1.5rem;
    height: 1.5rem;
    background: var(--admonition-accent, var(--muted));
    content: "";
    mask: var(--admonition-icon) center / contain no-repeat;
}

.post-content .admonition-block > :not(h6) {
    grid-column: 2;
}

.post-content .admonition-block > p:first-of-type {
    margin-top: 0;
}

.post-content .admonition-block.note {
    --admonition-accent: var(--note-accent);
    --admonition-background: var(--note-background);
    --admonition-icon: url("../icons/info-circle.svg");
}

.post-content .admonition-block.tip {
    --admonition-accent: var(--tip-accent);
    --admonition-background: var(--tip-background);
    --admonition-icon: url("../icons/lightbulb.svg");
}

.post-content .admonition-block.important {
    --admonition-accent: var(--important-accent);
    --admonition-background: var(--important-background);
    --admonition-icon: url("../icons/exclamation-circle.svg");
}

.post-content .admonition-block.caution {
    --admonition-accent: var(--caution-accent);
    --admonition-background: var(--caution-background);
    --admonition-icon: url("../icons/exclamation-triangle.svg");
}

.post-content .admonition-block.warning {
    --admonition-accent: var(--warning-accent);
    --admonition-background: var(--warning-background);
    --admonition-icon: url("../icons/exclamation-octagon.svg");
}

.post-content blockquote p:last-child,
.post-content .admonition-block p:last-child {
    margin-bottom: 0;
}

.post-content .listing-block {
    overflow-x: auto;
}

.post-content pre,
.post-summary pre {
    border: 1px solid var(--border);
}

.post-content .footnote-ref {
    color: var(--link);
    font-size: 0.8em;
    font-weight: 600;
    opacity: 0.7;
    text-decoration: none;
    vertical-align: super;
}

.post-content button.footnote-ref {
    padding: 0;
    border: 0;
    background: none;
    color: var(--link);
    font-family: inherit;
    cursor: pointer;
}

.contextual-footnote[hidden] {
    display: none;
}

.post-footer {
    margin: 2rem 0 3rem;
    font-size: 0.85rem;
}

.post-category {
    text-align: left;
}

.post-tags {
    margin: 0;
}

.article-navigation {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.previous-article,
.next-article {
    display: grid;
    width: 48%;
    gap: 0.25rem;
}

.previous-article > span,
.next-article > span {
    color: var(--muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.next-article {
    text-align: right;
}

.site-footer {
    margin-top: 2rem;
    text-align: center;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1rem;
    padding: 0;
    list-style: none;
}

.site-credit {
    font-size: 0.8rem;
}

:root[data-theme="dark"] #cookiescript_injected_wrapper,
:root[data-theme="dark"] #cookiescript_injected {
    color-scheme: dark !important;
    background-color: var(--background) !important;
}

:root[data-theme="dark"] #cookiescript_injected,
:root[data-theme="dark"] #cookiescript_injected * {
    color: var(--text) !important;
}

:root[data-theme="dark"] #cookiescript_readmore {
    color: var(--link) !important;
}

:root[data-theme="dark"] #cookiescript_accept,
:root[data-theme="dark"] #cookiescript_save {
    background-color: var(--text) !important;
    color: var(--background) !important;
}

:root[data-theme="dark"] #cookiescript_reject {
    border-color: var(--text) !important;
    background: transparent !important;
    color: var(--text) !important;
}

@media (max-width: 640px) {
    .site-shell {
        width: calc(100% - 1rem);
        margin: 0.5rem auto;
        padding: 1rem;
    }

    .site-header {
        margin-bottom: 2rem;
        text-align: center;
    }

    .header-controls {
        grid-column: 2;
    }

    .site-nav {
        justify-content: center;
    }

    .post-preview {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }

    .post {
        font-size: 1rem;
    }

    .post-content p {
        max-width: none;
    }

    .post-content ul,
    .post-content ol {
        max-width: none;
    }

    .post-summary {
        max-width: none;
    }

    .post-content .quote-block,
    .post-content .admonition-block,
    .post-content .listing-block,
    .post-content .image-block,
    .post-content figure,
    .post-content .figure {
        max-width: 100%;
    }

    .post-content figure.image-block {
        width: 100%;
    }

    .footnote-context {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.5rem;
    }

    .footnote-context > p,
    .contextual-footnote {
        grid-column: 1;
    }

    .post-header h1 {
        font-size: 2rem;
    }
}

@media (prefers-reduced-motion: no-preference) {
    a {
        transition: color 120ms ease-in-out;
    }
}
