/* ============================================
   Minimal Blog — Inspired by Bear Blog,
   danielgross.com, nat.org
   ============================================ */

:root {
    --bg: #ffffff;
    --fg: #1a1a1a;
    --fg-secondary: #6b6b6b;
    --border: #e0e0e0;
    --link: #1a1a1a;
    --link-hover: #555;
    --code-bg: #f5f5f5;
    --max-width: 640px;
    --font-body: 'Georgia', 'Times New Roman', serif;
    --font-heading: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

[data-theme="dark"] {
    --bg: #0d0d0d;
    --fg: #e0e0e0;
    --fg-secondary: #888;
    --border: #2a2a2a;
    --link: #e0e0e0;
    --link-hover: #aaa;
    --code-bg: #1a1a1a;
}

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

/* --- Base --- */
html {
    font-size: 18px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--fg);
    line-height: 1.7;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 4rem 1.5rem 3rem;
    transition: background 0.3s ease, color 0.3s ease;
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 0.3rem;
}

h2 {
    font-size: 1.3rem;
    margin-top: 2.5rem;
    margin-bottom: 0.8rem;
}

h3 {
    font-size: 1.1rem;
    margin-top: 2rem;
    margin-bottom: 0.6rem;
}

p {
    margin-bottom: 1.4rem;
}

/* --- Links --- */
a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-color: var(--border);
    text-underline-offset: 3px;
    transition: text-decoration-color 0.2s;
}

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

/* --- Header / Nav --- */
header {
    margin-bottom: 3rem;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    letter-spacing: -0.01em;
}

/* --- Theme Toggle --- */
#theme-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--fg);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    line-height: 1;
    transition: border-color 0.2s;
}

#theme-toggle:hover {
    border-color: var(--fg-secondary);
}

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: inline; }

/* --- Intro --- */
.intro {
    margin-bottom: 3rem;
}

.intro p {
    color: var(--fg-secondary);
    font-size: 1rem;
}

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

.post-item {
    margin-bottom: 1.5rem;
}

.post-item a {
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 1.05rem;
    text-decoration: none;
}

.post-item a:hover {
    text-decoration: underline;
    text-decoration-color: var(--border);
    text-underline-offset: 3px;
}

.post-item time {
    display: block;
    font-size: 0.82rem;
    color: var(--fg-secondary);
    margin-top: 0.15rem;
    font-family: var(--font-mono);
}

/* --- Article --- */
article {
    margin-bottom: 3rem;
}

#post-body > p:first-child::first-letter {
    float: left;
    font-family: var(--font-body);
    font-size: 3.4rem;
    line-height: 0.8;
    padding-right: 0.12em;
    padding-top: 0.07em;
    font-weight: 700;
    color: var(--fg);
}

article h1 {
    margin-bottom: 0.4rem;
}

article time {
    display: block;
    font-size: 0.82rem;
    color: var(--fg-secondary);
    font-family: var(--font-mono);
    margin-bottom: 2.5rem;
}

article img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 1.5rem 0;
}

/* --- Blockquote --- */
blockquote {
    border-left: 2px solid var(--border);
    padding-left: 1.2rem;
    margin: 1.5rem 0;
    color: var(--fg-secondary);
    font-style: italic;
}

/* --- Code --- */
code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: var(--code-bg);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

pre {
    background: var(--code-bg);
    padding: 1.2rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 1.5rem 0;
    line-height: 1.5;
}

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

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

li {
    margin-bottom: 0.4rem;
}

/* --- Horizontal Rule --- */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2.5rem 0;
}

/* --- Back Link --- */
.back-link {
    display: inline-block;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    color: var(--fg-secondary);
    text-decoration: none;
}

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

/* --- Footer --- */
footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}

.footer-links a {
    color: var(--fg-secondary);
    text-decoration: none;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.footer-links a:hover {
    color: var(--fg);
}

footer p {
    font-size: 0.8rem;
    color: var(--fg-secondary);
    text-align: center;
}

/* --- Responsive --- */
@media (max-width: 480px) {
    html {
        font-size: 16px;
    }

    body {
        padding: 2rem 1.2rem 2rem;
    }

    header {
        margin-bottom: 2rem;
    }

    h1 {
        font-size: 1.5rem;
    }
}
