/* ── Theme variables ─────────────────────────────────────── */
:root {
    --bg: #ffffff;
    --bg-subtle: #f5f5f5;
    --bg-hover: #f9f9f9;
    --text: #303633;
    --text-muted: #666666;
    --text-subtle: #999999;
    --heading: #070d4a;
    --link: #3546e5;
    --link-hover: #ef5ba1;
    --border: #e0e0e0;
    --border-faint: #f0f0f0;
    --tag-bg: #e8f4f8;
    --tag-border: #d0e8f0;
}

[data-theme="dark"] {
    --bg: #0d1117;
    --bg-subtle: #161b22;
    --bg-hover: #1c2128;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --text-subtle: #6e7681;
    --heading: #f0f6fc;
    --link: #58a6ff;
    --link-hover: #f07ab5;
    --border: #30363d;
    --border-faint: #21262d;
    --tag-bg: #1a3048;
    --tag-border: #2a5278;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family:
        "Open Sans",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        "Helvetica Neue",
        Arial,
        sans-serif;
    line-height: 1.6;
    background: var(--bg);
    color: var(--text);
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Headings: one serif type scale across the site */
h1,
h2,
h3,
h4 {
    font-family: Lora, Georgia, serif;
    line-height: 1.3;
    color: var(--heading);
}

/* Header & Navigation */
header {
    border-bottom: 2px solid var(--border);
    margin-bottom: 40px;
    padding-bottom: 20px;
}

nav h1 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

nav h1 a {
    color: var(--heading);
    text-decoration: none;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 20px;
    align-items: center;
}

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

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

/* Theme toggle */
.nav-theme {
    margin-left: auto;
    position: relative;
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    line-height: 1;
}

.theme-toggle:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.theme-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 50;
    min-width: 110px;
    padding: 4px;
}

[data-theme="dark"] .theme-menu {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.theme-menu button {
    display: block;
    width: 100%;
    padding: 6px 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    font-size: 0.875em;
    font-family: inherit;
    text-align: left;
    border-radius: 4px;
}

.theme-menu button:hover {
    background: var(--bg-hover);
}

.theme-menu button[aria-checked="true"] {
    color: var(--link);
    font-weight: 500;
}

/* Main Content */
main {
    min-height: 60vh;
}

h2 {
    font-size: 1.375rem;
    margin-bottom: 20px;
}

/* Post List */
.post-list {
    list-style: none;
}

.post-item {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-faint);
}

.post-item:last-child {
    border-bottom: none;
}

.post-item time {
    color: var(--text-muted);
    font-size: 0.9em;
    font-family: Inconsolata, monospace;
}

.post-item h3 {
    margin: 5px 0 10px 0;
}

.post-item h3 a {
    color: var(--link);
    text-decoration: none;
}

.post-item h3 a:hover {
    text-decoration: underline;
}

/* Compact Post List */
.post-list-compact {
    list-style: none;
    line-height: 1.8;
}

.post-list-compact li {
    display: flex;
    align-items: baseline;
    gap: 15px;
    padding: 6px 0;
    flex-wrap: wrap;
}

.post-list-compact li:hover {
    background: var(--bg-hover);
}

.post-list-compact time {
    color: var(--text-muted);
    font-family: Inconsolata, monospace;
    font-size: 1em;
    flex-shrink: 0;
}

.post-list-compact > li > a {
    color: var(--link);
    text-decoration: none;
}

.post-list-compact > li > a:hover {
    text-decoration: underline;
}

.post-list-compact .tags {
    margin-top: 0;
    display: inline-flex;
    gap: 6px;
}

.post-list-compact .tag {
    padding: 2px 8px;
    font-size: 0.75em;
}

/* Tags */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.tag {
    background: var(--tag-bg);
    color: var(--link);
    padding: 2px 8px;
    border-radius: 3px;
    text-decoration: none;
    font-size: 0.75em;
    border: 1px solid var(--tag-border);
}

.tag:hover {
    background: var(--tag-border);
}

.tag .count {
    color: var(--text-muted);
    font-weight: normal;
}

/* Tag Cloud */
.tag-cloud {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.tag-cloud li {
    display: inline-block;
}

/* Individual Post */
.post header {
    margin-bottom: 30px;
}

.post h1 {
    font-size: 1.75rem;
    margin-bottom: 10px;
    font-weight: normal;
}

.post-meta {
    color: var(--text-muted);
    font-size: 0.9em;
    margin-bottom: 20px;
}

.post-meta time {
    font-family: Inconsolata, monospace;
}

.post .content {
    font-family: Lora, Georgia, serif;
    font-size: 16px;
    line-height: 1.6;
    max-width: 650px;
}

.post .content h1,
.post .content h2,
.post .content h3 {
    margin-top: 30px;
    margin-bottom: 15px;
}

.post .content h1 {
    font-size: 1.375rem;
}
.post .content h2 {
    font-size: 1.25rem;
}
.post .content h3 {
    font-size: 1.1rem;
}

.post .content p {
    margin-bottom: 15px;
}

.post .content code {
    background: var(--bg-subtle);
    padding: 2px 6px;
    border-radius: 3px;
    font-family:
        Inconsolata, "SFMono-Regular", Consolas, "Liberation Mono", Menlo,
        monospace;
    font-size: 1em;
}

.post .content pre {
    background: var(--bg-subtle);
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 20px 0;
    font-size: 90%;
}

.post .content pre code {
    background: none;
    padding: 0;
}

.post .content ul,
.post .content ol {
    margin-left: 25px;
    margin-bottom: 15px;
}

.post .content blockquote {
    border-left: 4px solid var(--border);
    padding-left: 20px;
    margin: 20px 0;
    color: var(--text-muted);
    font-style: italic;
}

.post .content a {
    color: var(--link);
    text-decoration: none;
    border-bottom: thin solid;
    padding-bottom: 1px;
}

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

.post footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* Post Navigation */
.post-nav {
    display: flex;
    gap: 30px;
    margin-bottom: 20px;
}

.prev-post,
.next-post {
    flex: 1;
}

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

.nav-label {
    display: block;
    font-size: 0.85em;
    color: var(--text-subtle);
    margin-bottom: 5px;
}

.post-nav a {
    display: block;
    color: var(--link);
    text-decoration: none;
    padding: 10px;
    border-radius: 4px;
    transition: background 0.2s;
}

.post-nav a:hover {
    background: var(--bg-subtle);
}

.post-nav time {
    display: inline;
    font-family: Inconsolata, monospace;
    font-size: 0.85em;
    color: var(--text-muted);
    margin-right: 8px;
}

.post-nav span {
    display: inline;
}

.back-link {
    text-align: center;
    padding-top: 15px;
    border-top: 1px solid var(--border-faint);
}

/* Mermaid diagrams */
.mermaid {
    background: var(--bg-hover);
    padding: 20px;
    border-radius: 5px;
    margin: 20px 0;
    overflow-x: auto;
}

/* Footer */
body > footer {
    margin-top: 60px;
    padding-top: 20px;
    border-top: 2px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9em;
}

body > footer a {
    color: var(--link);
}

/* ── Syntax highlighting — dark overrides ────────────────── */
[data-theme="dark"] .bg,
[data-theme="dark"] .chroma {
    background-color: var(--bg-subtle);
    color: var(--text);
}
[data-theme="dark"] .chroma .k,
[data-theme="dark"] .chroma .kc,
[data-theme="dark"] .chroma .kd,
[data-theme="dark"] .chroma .kn,
[data-theme="dark"] .chroma .kp,
[data-theme="dark"] .chroma .kr,
[data-theme="dark"] .chroma .kt {
    color: #ff7b72;
}
[data-theme="dark"] .chroma .na,
[data-theme="dark"] .chroma .nc,
[data-theme="dark"] .chroma .nx {
    color: var(--text);
}
[data-theme="dark"] .chroma .no,
[data-theme="dark"] .chroma .nd,
[data-theme="dark"] .chroma .nt {
    color: #79c0ff;
}
[data-theme="dark"] .chroma .ni,
[data-theme="dark"] .chroma .nb,
[data-theme="dark"] .chroma .nf,
[data-theme="dark"] .chroma .fm {
    color: #d2a8ff;
}
[data-theme="dark"] .chroma .nv,
[data-theme="dark"] .chroma .vc,
[data-theme="dark"] .chroma .vg,
[data-theme="dark"] .chroma .vi,
[data-theme="dark"] .chroma .vm {
    color: #ffa657;
}
[data-theme="dark"] .chroma .s,
[data-theme="dark"] .chroma .sa,
[data-theme="dark"] .chroma .sb,
[data-theme="dark"] .chroma .sc,
[data-theme="dark"] .chroma .dl,
[data-theme="dark"] .chroma .sd,
[data-theme="dark"] .chroma .s2,
[data-theme="dark"] .chroma .se,
[data-theme="dark"] .chroma .sh,
[data-theme="dark"] .chroma .si,
[data-theme="dark"] .chroma .sx,
[data-theme="dark"] .chroma .sr,
[data-theme="dark"] .chroma .s1,
[data-theme="dark"] .chroma .ss {
    color: #a5d6ff;
}
[data-theme="dark"] .chroma .m,
[data-theme="dark"] .chroma .mb,
[data-theme="dark"] .chroma .mf,
[data-theme="dark"] .chroma .mh,
[data-theme="dark"] .chroma .mi,
[data-theme="dark"] .chroma .il,
[data-theme="dark"] .chroma .mo,
[data-theme="dark"] .chroma .o,
[data-theme="dark"] .chroma .ow,
[data-theme="dark"] .chroma .or {
    color: #79c0ff;
}
[data-theme="dark"] .chroma .p {
    color: var(--text);
}
[data-theme="dark"] .chroma .c,
[data-theme="dark"] .chroma .ch,
[data-theme="dark"] .chroma .cm,
[data-theme="dark"] .chroma .c1,
[data-theme="dark"] .chroma .cs,
[data-theme="dark"] .chroma .cp,
[data-theme="dark"] .chroma .cpf {
    color: #8b949e;
}
[data-theme="dark"] .chroma .gd {
    color: #ffa198;
    background-color: #490202;
}
[data-theme="dark"] .chroma .gi {
    color: #56d364;
    background-color: #0f5323;
}
[data-theme="dark"] .chroma .bp {
    color: #8b949e;
}
[data-theme="dark"] .chroma .hl {
    background-color: #2d3139;
}

/* Responsive */
@media (max-width: 600px) {
    body {
        padding: 15px;
    }

    nav ul {
        flex-direction: column;
        gap: 10px;
    }
}
