/* ==========================================================================
   FONTS
   ========================================================================== */

@font-face {
    font-display: fallback;
    font-family: "B612";
    font-style: normal;
    font-weight: 400;
    src: url("/fonts/b612-v13-latin-regular.woff2") format("woff2");
}

@font-face {
    font-display: fallback;
    font-family: "B612";
    font-style: italic;
    font-weight: 400;
    src: url("/fonts/b612-v13-latin-italic.woff2") format("woff2");
}

@font-face {
    font-display: fallback;
    font-family: "B612";
    font-style: normal;
    font-weight: 700;
    src: url("/fonts/b612-v13-latin-700.woff2") format("woff2");
}

@font-face {
    font-display: fallback;
    font-family: "B612";
    font-style: italic;
    font-weight: 700;
    src: url("/fonts/b612-v13-latin-700italic.woff2") format("woff2");
}

@font-face {
    font-display: fallback;
    font-family: "B612 Mono";
    font-style: normal;
    font-weight: 400;
    src: url("/fonts/b612-mono-v16-latin-regular.woff2") format("woff2");
}

@font-face {
    font-display: fallback;
    font-family: "B612 Mono";
    font-style: italic;
    font-weight: 400;
    src: url("/fonts/b612-mono-v16-latin-italic.woff2") format("woff2");
}

@font-face {
    font-display: fallback;
    font-family: "B612 Mono";
    font-style: normal;
    font-weight: 700;
    src: url("/fonts/b612-mono-v16-latin-700.woff2") format("woff2");
}

@font-face {
    font-display: fallback;
    font-family: "B612 Mono";
    font-style: italic;
    font-weight: 700;
    src: url("/fonts/b612-mono-v16-latin-700italic.woff2") format("woff2");
}

/* ==========================================================================
   CUSTOM PROPERTIES
   ========================================================================== */

:root {
    /* Colors (Light Mode) */
    --color-bg: #fff;
    --color-text: #000;
    --color-text-muted: #666;
    --color-link: #0066cc;
    --color-link-hover: #004499;
    --color-border: #e0e0e0;
    --color-code-bg: #f5f5f5;

    /* Typography */
    --font-body:
        "B612", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
        Ubuntu, sans-serif;
    --font-mono:
        "B612 Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo,
        monospace;
    --font-size-base: 14px;
    --line-height: 1.6;

    /* Layout */
    --max-width: 650px;
    --spacing: 1.2rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #000;
        --color-text: #fff;
        --color-text-muted: #999;
        --color-link: #6699ff;
        --color-link-hover: #99bbff;
        --color-border: #333;
        --color-code-bg: #2a2a2a;
    }
}

/* ==========================================================================
   RESET
   ========================================================================== */

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

/* ==========================================================================
   BASE ELEMENTS
   ========================================================================== */

html {
    font-size: var(--font-size-base);
}

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

a {
    color: var(--color-link);
    text-decoration: none;
    transition: color 0.3s ease-in-out;
}

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

p {
    margin: 1em 0;
}

blockquote {
    margin: 1.5em 0;
    padding-left: 1.5em;
    border-left: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-style: italic;
}

blockquote p {
    margin: 0.5em 0;
}

hr {
    font-family: var(--font-body);
    text-align: center;
    line-height: 1px;
    height: 3px;
    font-size: var(--font-size-base);
    border-width: 1px 0;
    border-style: solid;
    border-color: var(--color-border);
    margin: 4em;
    overflow: visible;
}

hr::after {
    content: "⁂";
    color: var(--color-border);
    display: inline;
    background-color: var(--color-bg);
    padding: 0 0.5em;
}

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

figure {
    margin: 1.5em 0;
}

figcaption {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    text-align: center;
    margin-top: 0.5em;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 0.95rem;
}

th,
td {
    padding: 0.5em 0.75em;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

th {
    font-weight: 600;
}

/* ==========================================================================
   HEADINGS
   ========================================================================== */

h1,
h2,
h3,
h4,
h5,
h6 {
    font-size: 1rem;
    font-weight: 700;
    margin: 1.5em 0 0.5em;
    text-align: center;
}

h1 {
    font-size: 1.2rem;
    padding-top: calc(var(--spacing) * 1.2);
}

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

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

/* Heading counters (scoped to post body, h2 is top-level) */
.post-body {
    counter-reset: h2counter h3counter h4counter h5counter h6counter;
}

.post-body h2 {
    counter-reset: h3counter h4counter h5counter h6counter;
    counter-increment: h2counter;
}

.post-body h3 {
    counter-reset: h4counter h5counter h6counter;
    counter-increment: h3counter;
}

.post-body h4 {
    counter-reset: h5counter h6counter;
    counter-increment: h4counter;
}

.post-body h5 {
    counter-reset: h6counter;
    counter-increment: h5counter;
}

.post-body h6 {
    counter-increment: h6counter;
}

.post-body h2::before {
    content: "§" counter(h2counter) " ";
    font-weight: 400;
}

.post-body h3::before {
    content: "§" counter(h2counter) "." counter(h3counter) " ";
    font-weight: 400;
}

.post-body h4::before {
    content: "§" counter(h2counter) "." counter(h3counter) "."
        counter(h4counter) " ";
    font-weight: 400;
}

.post-body h5::before {
    content: "§" counter(h2counter) "." counter(h3counter) "."
        counter(h4counter) "." counter(h5counter) " ";
    font-weight: 400;
}

.post-body h6::before {
    content: "§" counter(h2counter) "." counter(h3counter) "."
        counter(h4counter) "." counter(h5counter) "." counter(h6counter) " ";
    font-weight: 400;
}

/* ==========================================================================
   CODE
   ========================================================================== */

code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--color-code-bg);
    padding: 0.15em 0.35em;
    border-radius: 3px;
}

pre {
    font-family: var(--font-mono);
    background: var(--color-code-bg);
    padding: 1em;
    overflow-x: auto;
    border-radius: 4px;
}

pre code {
    background: none;
    padding: 0;
}

/* ==========================================================================
   LAYOUT
   ========================================================================== */

.site-header {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: calc(var(--spacing) * 0.5) 0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 3px double var(--color-border);
}

.site-title {
    font-weight: 700;
    text-decoration: none;
    color: var(--color-text);
}

.site-description {
    color: var(--color-text-muted);
    text-align: right;
    font-size: 0.85rem;
}

@media (max-width: 50rem) {
    .site-description {
        display: none;
    }
}

main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: calc(var(--spacing) * 2) 0;
}

.site-footer {
    max-width: var(--max-width);
    font-size: 0.85rem;
    margin: 0 auto;
    padding: 0 calc(var(--spacing) * 0.5);
    border-top: 3px double var(--color-border);
    color: var(--color-text-muted);
    text-align: center;
}

.site-footer a {
    color: var(--color-text-muted);
}

.site-footer a:hover {
    color: var(--color-link-hover);
}

/* ==========================================================================
   POST METADATA
   ========================================================================== */

.date,
.time,
.location,
.permalink,
.external-link,
.epistemic-status {
    color: var(--color-text-muted);
    padding-left: 0.5rem;
}

/* ==========================================================================
   HOMEPAGE ARTICLES
   ========================================================================== */

main > article {
    margin: 0.5rem 0;
}

main > article > h1,
main > article > h2 {
    margin: 0 0 0.5em;
}

main > article .post-meta {
    text-align: center;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

/* ==========================================================================
   TAGS
   ========================================================================== */

.tags {
    margin: 1em 0;
}

.tag {
    display: inline-block;
    color: var(--color-text-muted);
    text-decoration: none;
    margin-right: 0.5em;
}

.tag:hover {
    color: var(--color-link);
}

.tag-cloud {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em 1em;
}

.tag-cloud li {
    display: inline;
}

.tag-cloud .count {
    color: var(--color-text-muted);
}

/* ==========================================================================
   FOOTNOTES
   ========================================================================== */

.footnotes {
    margin-top: 3em;
    font-size: 0.9rem;
    padding: 1em 0;
    position: relative;
}

.footnotes::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 33%;
    border-top: 1px solid var(--color-border);
}

.footnotes hr {
    display: none;
}

.footnote-ref {
    font-size: 0.75em;
    vertical-align: super;
}

.footnote-backref {
    text-decoration: none;
}
