/* ============================================================
   Design tokens
   ============================================================ */
:root {
    /* Colors — light */
    --color-bg:           #ffffff;
    --color-surface:      #f9f9f9;
    --color-border:       #e8e8e8;
    --color-text:         #1a1a1a;
    --color-text-muted:   #6b6b6b;
    --color-link:         #0f7ae5;
    --color-link-hover:   #0a5cb8;
    --color-accent:       var(--ghost-accent-color, #0f7ae5);
    --color-code-bg:      #f4f4f4;
    --color-code-text:    #c7254e;

    /* Typography */
    --font-sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    --font-mono:  "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

    --text-xs:   0.8125rem;   /* 13px */
    --text-sm:   0.9375rem;   /* 15px */
    --text-base: 1.125rem;    /* 18px */
    --text-lg:   1.25rem;     /* 20px */
    --text-xl:   1.5rem;      /* 24px */
    --text-2xl:  2rem;        /* 32px */
    --text-3xl:  2.5rem;      /* 40px */

    --leading-body:    1.75;
    --leading-heading: 1.25;

    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2.5rem;
    --space-xl: 4rem;

    /* Layout */
    --reading-width: 680px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg:         #111111;
        --color-surface:    #1c1c1c;
        --color-border:     #2e2e2e;
        --color-text:       #e8e8e8;
        --color-text-muted: #8a8a8a;
        --color-link:       #5aabff;
        --color-link-hover: #82c0ff;
        --color-code-bg:    #1e1e1e;
        --color-code-text:  #f8a5b8;
    }
}

/* ============================================================
   Reset & base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 100%; }

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-body);
    -webkit-font-smoothing: antialiased;
}

img, video { max-width: 100%; height: auto; display: block; }

a { color: var(--color-link); text-decoration: none; }
a:hover { color: var(--color-link-hover); text-decoration: underline; }

/* ============================================================
   Layout
   ============================================================ */
.container {
    max-width: var(--reading-width);
    margin: 0 auto;
    padding: 0 var(--space-md);
}

.site-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.site-main {
    flex: 1;
    padding: var(--space-xl) 0;
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-md) 0;
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}

.site-title {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

.site-title:hover { color: var(--color-text); text-decoration: none; }

.site-branding {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.site-description {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin: 0;
}

/* Navigation */
.site-nav {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: var(--space-md);
}

.nav-item a {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    font-weight: 500;
}

.nav-item a:hover,
.nav-item.nav-current a {
    color: var(--color-text);
    text-decoration: none;
}

.search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--color-text-muted);
    line-height: 0;
}

.search-btn:hover { color: var(--color-text); }

.member-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--color-text-muted);
    line-height: 0;
}

.member-btn:hover { color: var(--color-text); }

/* ============================================================
   Post list (index)
   ============================================================ */
.post-feed {
    display: flex;
    flex-direction: column;
}

.post-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-lg) 0;
    border-bottom: 1px solid var(--color-border);
}

.post-card:first-child { padding-top: 0; }

.post-card-image-link {
    flex: 0 0 120px;
    display: block;
}

.post-card-image {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 4px;
}

.post-card-content {
    flex: 1;
    min-width: 0;
}

.post-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.post-card-link:hover { text-decoration: none; }

.post-card-link:hover .post-card-title { color: var(--color-link); }

.post-card-title {
    margin: 0 0 var(--space-xs);
    font-size: var(--text-xl);
    font-weight: 700;
    line-height: var(--leading-heading);
    letter-spacing: -0.02em;
    color: var(--color-text);
    transition: color 0.1s;
}

.post-card-excerpt {
    margin: 0;
    color: var(--color-text-muted);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card-meta {
    margin-top: var(--space-sm);
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

/* ============================================================
   Single post
   ============================================================ */
.post-header { margin-bottom: var(--space-lg); }

.post-title {
    margin: 0 0 var(--space-sm);
    font-size: var(--text-3xl);
    font-weight: 800;
    line-height: var(--leading-heading);
    letter-spacing: -0.03em;
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.post-meta a { color: var(--color-text-muted); font-weight: 500; }
.post-meta a:hover { color: var(--color-text); text-decoration: none; }

.post-image { margin: 0 0 var(--space-lg); }

.post-image img { width: 100%; border-radius: 4px; }

.post-image figcaption {
    margin-top: var(--space-xs);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-align: center;
}

/* ============================================================
   Post content
   ============================================================ */
.gh-content {
    font-size: var(--text-base);
    line-height: var(--leading-body);
}

.gh-content > * + * { margin-top: var(--space-md); }

.gh-content h2,
.gh-content h3,
.gh-content h4,
.gh-content h5,
.gh-content h6 {
    margin-top: var(--space-lg);
    margin-bottom: var(--space-xs);
    font-weight: 700;
    line-height: var(--leading-heading);
    letter-spacing: -0.02em;
    color: var(--color-text);
}

.gh-content h2 { font-size: var(--text-2xl); }
.gh-content h3 { font-size: var(--text-xl); }
.gh-content h4 { font-size: var(--text-lg); }

.gh-content p { margin: 0; }
.gh-content p + p { margin-top: calc(var(--space-lg) / 2); }

.gh-content .code-block + p,
.gh-content pre + p { margin-top: var(--space-lg); }

.gh-content a {
    color: var(--color-link);
    text-decoration: underline;
    text-underline-offset: 2px;
}

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

.gh-content ul,
.gh-content ol { padding-left: 1.5em; margin: 0; }

.gh-content li + li { margin-top: var(--space-xs); }

.gh-content blockquote {
    margin: 0;
    padding: var(--space-sm) var(--space-md);
    border-left: 3px solid var(--color-accent);
    color: var(--color-text-muted);
    font-style: italic;
}

.gh-content hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: var(--space-xl) 0;
}

/* Figures */
.gh-content figure { margin: var(--space-lg) 0; }
.gh-content figure img { width: 100%; border-radius: 4px; }

/* Koenig card widths — break out of the reading column */
.kg-width-wide {
    width: calc(100% + 160px);
    margin-left: -80px;
}

.kg-width-full {
    width: 100vw;
    position: relative;
    left: 50%;
    margin-left: -50vw;
}

@media (max-width: 840px) {
    .kg-width-wide { width: 100%; margin-left: 0; }
    .kg-width-full { width: calc(100% + 2 * var(--space-md)); margin-left: calc(-1 * var(--space-md)); left: 0; }
}

.gh-content figcaption {
    margin-top: var(--space-xs);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-align: center;
}

/* Responsive video embeds */
.kg-embed-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: var(--space-lg) 0;
}

.kg-embed-card iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: none;
}

/* Code — inline */
.gh-content code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--color-code-bg);
    color: var(--color-code-text);
    padding: 0.15em 0.4em;
    border-radius: 3px;
}

/* Code — block */
.code-block {
    position: relative;
}

.gh-content pre {
    background: var(--color-code-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: var(--space-md);
    padding-top: 2.25rem;
    overflow-x: auto;
    font-size: var(--text-sm);
    line-height: 1.6;
    margin: 0;
}

.code-lang {
    position: absolute;
    top: 0;
    right: 0;
    padding: 0.3em 0.7em;
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    border-left: 1px solid var(--color-border);
    border-radius: 0 6px 0 4px;
    pointer-events: none;
    user-select: none;
    letter-spacing: 0.03em;
}

.gh-content pre code {
    background: none;
    color: var(--color-text);
    padding: 0;
    font-size: inherit;
    border-radius: 0;
}

/* ============================================================
   Comments
   ============================================================ */
.read-more {
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
}

.read-more-title {
    font-size: var(--text-lg);
    font-weight: 700;
    margin: 0 0 var(--space-lg);
}

.post-comments {
    margin-top: var(--space-xl);
}

/* ============================================================
   Post footer — tags
   ============================================================ */
.post-footer {
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.post-tag {
    display: inline-block;
    padding: 0.25em 0.75em;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    font-weight: 500;
}

.post-tag:hover {
    color: var(--color-text);
    border-color: var(--color-text-muted);
    text-decoration: none;
}

/* ============================================================
   Page (static)
   ============================================================ */
.page-header { margin-bottom: var(--space-lg); }

.page-title {
    margin: 0;
    font-size: var(--text-3xl);
    font-weight: 800;
    line-height: var(--leading-heading);
    letter-spacing: -0.03em;
}

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
    margin-top: var(--space-xl);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.pagination a { color: var(--color-text-muted); font-weight: 500; }
.pagination a:hover { color: var(--color-text); text-decoration: none; }

/* ============================================================
   Error pages
   ============================================================ */
.error-page {
    text-align: center;
    padding: var(--space-xl) 0;
}

.error-code {
    font-size: 6rem;
    font-weight: 800;
    line-height: 1;
    color: var(--color-border);
    margin: 0 0 var(--space-sm);
    font-family: var(--font-sans);
}

.error-message {
    font-size: var(--text-lg);
    color: var(--color-text-muted);
    margin: 0 0 var(--space-lg);
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
    border-top: 1px solid var(--color-border);
    padding: var(--space-lg) 0;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 720px) {
    :root {
        --text-base: 1rem;
        --text-3xl:  1.875rem;
        --text-2xl:  1.5rem;
        --space-xl:  2.5rem;
        --space-lg:  1.75rem;
    }

    .site-header .container {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .post-card-image-link { flex-basis: 80px; }
    .post-card-image { width: 80px; height: 60px; }
}
