/* ==============================================
   Blog — Systems Manual Style
   ============================================== */

/* Design Tokens — 0x96f palette */
:root {
    /* Paper & Ink (light) */
    --paper: #FCFCFC;
    --paper-warm: #f0eff0;
    --ink: #262427;
    --ink-muted: #3A363A;
    --ink-faint: #555555;
    --ink-subtle: #757075;

    /* Accent */
    --sig-blue: #49CAE4;

    /* Rules */
    --rule-primary: var(--ink);
    --rule-faint: #d4d4d8;
    --rule-subtle: #e4e4e7;

    /* Code */
    --code-bg: #f0eff0;
    --code-border: var(--rule-faint);

    /* Typography */
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --font-sans: ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

    /* Layout */
    --max-width: 740px;

    /* Spacing (8px base) */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 48px;
    --space-2xl: 80px;

    color-scheme: light dark;
}

/* Dark theme — 0x96f */
[data-theme="dark"] {
    --paper: #262427;
    --paper-warm: #322E32;
    --ink: #FCFCFC;
    --ink-muted: #A6A6A5;
    --ink-faint: #757075;
    --ink-subtle: #555555;
    --rule-primary: var(--ink);
    --rule-faint: #3A363A;
    --rule-subtle: #333032;
    --sig-blue: #49CAE4;
    --code-bg: #1C1B1C;
    --code-border: #3A363A;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #262427;
        --paper-warm: #322E32;
        --ink: #FCFCFC;
        --ink-muted: #A6A6A5;
        --ink-faint: #757075;
        --ink-subtle: #555555;
        --rule-primary: var(--ink);
        --rule-faint: #3A363A;
        --rule-subtle: #333032;
        --sig-blue: #49CAE4;
        --code-bg: #1C1B1C;
        --code-border: #3A363A;
    }
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Base */
html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.75;
    background: var(--paper);
    color: var(--ink);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
}

/* Layout */
.page {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: var(--space-lg);
    margin-bottom: var(--space-xl);
    border-bottom: 2px solid var(--ink);
}

.nav-title {
    font-family: var(--font-sans);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--ink);
    text-decoration: none;
}

.nav-title:hover {
    color: var(--ink-faint);
}

.nav-back {
    font-family: var(--font-sans);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-faint);
    text-decoration: none;
    transition: color 0.12s ease;
}

.nav-back:hover {
    color: var(--ink);
    text-decoration: none;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.nav-links a {
    font-family: var(--font-sans);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-faint);
    text-decoration: none;
    transition: color 0.12s ease;
}

.nav-links a:hover {
    color: var(--ink);
}

/* Theme toggle */
.theme-toggle {
    cursor: pointer;
    padding: 0;
    margin: 0;
    background: none;
    border: none;
    display: inline-flex;
    align-items: center;
}

.theme-toggle .icon {
    width: 1rem;
    height: 1rem;
    color: var(--ink-faint);
    fill: currentColor;
    transition: color 0.12s ease;
}

.theme-toggle:hover .icon {
    color: var(--ink);
}

.theme-transition {
    transition: color 0.3s ease, background-color 0.3s ease;
}

/* Typography */
h1 {
    font-family: var(--font-sans);
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.025em;
    line-height: 1.25;
    margin-bottom: var(--space-md);
}

h2 {
    font-family: var(--font-sans);
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.02em;
    line-height: 1.3;
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--rule-subtle);
}

h3 {
    font-family: var(--font-sans);
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.015em;
    line-height: 1.4;
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
}

p {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.8;
    color: var(--ink-muted);
    margin-bottom: var(--space-md);
}

strong {
    color: var(--ink);
    font-weight: 600;
}

a {
    color: var(--sig-blue);
    text-decoration: none;
    transition: color 0.12s ease;
}

a:hover {
    text-decoration: underline;
}

/* Lists */
ul, ol {
    margin: var(--space-md) 0;
    padding-left: var(--space-lg);
    color: var(--ink-muted);
}

li {
    margin-bottom: var(--space-xs);
    line-height: 1.8;
}

li strong {
    color: var(--ink);
}

/* Code */
code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    padding: 0.1em 0.4em;
    border-radius: 2px;
}

pre {
    margin: var(--space-md) 0;
    padding: var(--space-lg);
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-top: 2px solid var(--ink);
    overflow-x: auto;
    line-height: 1.6;
}

pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.8125rem;
    border-radius: 0;
}

/* Blockquotes */
blockquote {
    border-left: 2px solid var(--ink);
    margin: var(--space-lg) 0;
    padding: var(--space-sm) var(--space-lg);
    color: var(--ink-faint);
    font-style: italic;
}

/* Horizontal rules */
hr {
    border: none;
    height: 1px;
    background: var(--rule-faint);
    margin: var(--space-xl) 0;
}

/* Post article */
.post-meta {
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--rule-subtle);
}

.post-date {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--ink-subtle);
    letter-spacing: 0.05em;
    margin-bottom: var(--space-sm);
}

.post-title {
    font-family: var(--font-sans);
    font-size: 2rem;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.post-content {
    margin-top: var(--space-lg);
}

/* Index / Post listing */
.posts-heading {
    font-family: var(--font-sans);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--ink-faint);
    margin-bottom: var(--space-lg);
}

.post-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.post-list li {
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--rule-subtle);
    margin: 0;
}

.post-list li:first-child {
    border-top: 1px solid var(--rule-subtle);
}

.post-list a {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
}

.post-list a:hover {
    color: var(--sig-blue);
}

.post-list .date {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--ink-subtle);
    letter-spacing: 0.03em;
    display: block;
    margin-top: 2px;
}

/* Footer */
footer {
    margin-top: auto;
    padding-top: var(--space-lg);
    border-top: 1px solid var(--rule-subtle);
    display: flex;
    justify-content: center;
    gap: var(--space-md);
}

footer a {
    font-family: var(--font-sans);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-faint);
    text-decoration: none;
    transition: color 0.12s ease;
}

footer a:hover {
    color: var(--ink);
    text-decoration: none;
}

/* Vim command indicator */
.vim-cmd {
    position: fixed;
    bottom: var(--space-md);
    left: var(--space-md);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--ink-faint);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

/* Vim cursor */
.vim-cursor {
    position: absolute;
    width: 0.5em;
    height: 1.15em;
    background: var(--ink);
    opacity: 0;
    pointer-events: none;
    z-index: 999;
    animation: blink 1s step-end infinite;
    transition: top 0.05s ease, left 0.05s ease;
}

@keyframes blink {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0; }
}

/* Responsive */
@media (max-width: 640px) {
    .page {
        padding: var(--space-lg) var(--space-md);
    }

    h1, .post-title {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.125rem;
    }

    pre {
        padding: var(--space-md);
        font-size: 0.75rem;
    }

    nav {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }
}
