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

:root {
    --color-bg: #fafafa;
    --color-surface: #ffffff;
    --color-text: #1a1a2e;
    --color-text-muted: #6b7280;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-border: #e5e7eb;
    --color-code-bg: #f3f4f6;
    --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
    --max-width: 48rem;
    --radius: 6px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #0f172a;
        --color-surface: #1e293b;
        --color-text: #e2e8f0;
        --color-text-muted: #94a3b8;
        --color-primary: #60a5fa;
        --color-primary-hover: #93bbfc;
        --color-border: #334155;
        --color-code-bg: #1e293b;
    }
}

body {
    font-family: var(--font-sans);
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 1.5rem;
    line-height: 1.7;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

/* ── Typography ──────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 700;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p { margin-bottom: 1rem; }

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

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

/* ── Header ──────────────────────────────────────────────────────────── */
header {
    margin-bottom: 3rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

header nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.site-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
}

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

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    font-weight: 500;
}

.nav-links a:hover {
    color: var(--color-primary);
    text-decoration: none;
}

/* ── Hero ────────────────────────────────────────────────────────────── */
.hero {
    margin-bottom: 3rem;
}

.hero h1 {
    margin-top: 0;
    font-size: 2.25rem;
}

.subtitle {
    color: var(--color-text-muted);
    font-size: 1.1rem;
}

/* ── Post cards ──────────────────────────────────────────────────────── */
.post-list {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.post-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: box-shadow 0.15s ease;
}

.post-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.post-card h2 {
    margin-top: 0;
    margin-bottom: 0.25rem;
    font-size: 1.35rem;
}

.post-card time {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.post-card p {
    margin-top: 0.75rem;
    color: var(--color-text-muted);
}

.read-more {
    display: inline-block;
    margin-top: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

/* ── Post page ───────────────────────────────────────────────────────── */
.post-header {
    margin-bottom: 2rem;
}

.post-header h1 {
    margin-top: 0;
    font-size: 2.25rem;
}

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

.post-content {
    margin-bottom: 2rem;
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin: 1rem 0;
}

.post-footer {
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

/* ── Tags ────────────────────────────────────────────────────────────── */
.tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: var(--color-code-bg);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.tag:hover {
    background: var(--color-primary);
    color: #fff;
    text-decoration: none;
}

/* ── Code ────────────────────────────────────────────────────────────── */
code {
    font-family: var(--font-mono);
    background: var(--color-code-bg);
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    font-size: 0.88em;
}

pre {
    background: var(--color-code-bg);
    padding: 1.25rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 1.25rem 0;
    border: 1px solid var(--color-border);
}

pre code {
    background: none;
    padding: 0;
    font-size: 0.88rem;
    line-height: 1.6;
}

/* ── Blockquote ──────────────────────────────────────────────────────── */
blockquote {
    border-left: 3px solid var(--color-primary);
    margin: 1.25rem 0;
    padding: 0.5rem 1rem;
    color: var(--color-text-muted);
    background: var(--color-surface);
    border-radius: 0 var(--radius) var(--radius) 0;
}

blockquote p:last-child {
    margin-bottom: 0;
}

/* ── Tables ──────────────────────────────────────────────────────────── */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.25rem 0;
}

th, td {
    border: 1px solid var(--color-border);
    padding: 0.6rem 0.8rem;
    text-align: left;
}

th {
    background: var(--color-code-bg);
    font-weight: 600;
}

/* ── Lists ───────────────────────────────────────────────────────────── */
ul, ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

li {
    margin-bottom: 0.25rem;
}

/* ── Archive / Tag pages ─────────────────────────────────────────────── */
.archive-list, .tag-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.archive-entry, .tag-entry {
    display: flex;
    gap: 1rem;
    align-items: baseline;
}

.archive-entry time, .tag-entry time {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    min-width: 6.5rem;
    font-variant-numeric: tabular-nums;
}

/* ── Tags Index ─────────────────────────────────────────────────────── */
.tag-group {
    margin-bottom: 2rem;
}

.tag-group h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--color-border);
}

.tag-group h2 a {
    color: var(--color-heading);
}

.tag-group h2 a:hover {
    color: var(--color-primary);
}

.tag-count {
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.tag-group ul {
    list-style: none;
    padding-left: 0;
}

.tag-group li {
    padding: 0.2rem 0;
}

.tag-group li time {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    min-width: 6.5rem;
    display: inline-block;
    font-variant-numeric: tabular-nums;
}

/* ── Footer ──────────────────────────────────────────────────────────── */
footer {
    margin-top: 4rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

/* ── Horizontal rule ─────────────────────────────────────────────────── */
hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 2rem 0;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    body { padding: 1rem; }
    h1 { font-size: 1.6rem; }
    .hero h1 { font-size: 1.75rem; }
    .post-header h1 { font-size: 1.75rem; }
}
