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

:root {
    --bg: #141312;
    --bg-hover: #1e1d1b;
    --text: #d8d3cc;
    --text-dim: #8a8480;
    --text-faint: #5a5550;
    --green: #3d9b7a;
    --green-hover: #4db88e;
    --gold: #c9a84c;
    --border: #262422;
    --max-w: 680px;
    --font: 'IBM Plex Serif', Georgia, serif;
    --font-heading: 'Lora', Georgia, serif;
    --font-ui: 'IBM Plex Sans', -apple-system, sans-serif;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg: #f4f1eb;
        --bg-hover: #eae6de;
        --text: #2a2725;
        --text-dim: #6b6560;
        --text-faint: #9a948e;
        --green: #2a7a5e;
        --green-hover: #1f6b50;
        --gold: #9a8235;
        --border: #ddd8d0;
    }
}

[data-theme="light"] {
    --bg: #f4f1eb;
    --bg-hover: #eae6de;
    --text: #2a2725;
    --text-dim: #6b6560;
    --text-faint: #9a948e;
    --green: #2a7a5e;
    --green-hover: #1f6b50;
    --gold: #9a8235;
    --border: #ddd8d0;
}

body {
    font-family: var(--font);
    font-size: 1.02rem;
    font-weight: 500;
    line-height: 1.8;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background 0.2s, color 0.2s;
}

::selection { background: var(--green); color: white; }

a { color: var(--green); text-decoration: none; font: inherit; }
a:hover { color: var(--green-hover); }

.wrap {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 1.5rem;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 1.75rem 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Header ── */
.site-header {
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.site-name {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}
.site-name:hover { color: var(--text); }

.site-nav {
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

.site-nav a {
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-dim);
    text-decoration: none;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.site-nav a:hover {
    color: var(--text);
    background: var(--bg-hover);
}
.site-nav a.active {
    background: rgba(61, 155, 122, 0.1);
    border-radius: 4px;
    font-weight: 600;
    color: var(--green);
}

a.header-search {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-dim);
    margin-left: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, border-color 0.2s;
}
a.header-search svg {
    width: 16px;
    height: 16px;
}
a.header-search:hover {
    color: var(--text);
    border-color: var(--text-faint);
    background: none;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: none;
    color: var(--text-dim);
    cursor: pointer;
    margin-left: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, border-color 0.2s, transform 0.3s;
}
.theme-toggle svg {
    width: 16px;
    height: 16px;
    display: none;
}
.theme-toggle.active-dark .icon-moon,
.theme-toggle.active-light .icon-sun,
.theme-toggle.active-system .icon-system { display: block; }
.theme-toggle:hover {
    color: var(--text);
    border-color: var(--text-faint);
}
.theme-toggle.rotating {
    transform: rotate(360deg);
}

.nav-toggle {
    display: none;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: none;
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

/* ── Main ── */
.site-main {
    min-height: calc(100vh - 300px);
    margin-bottom: 4rem;
}

/* ── Homepage ── */
.home {
    padding: 0 0 2rem;
}

.home-intro {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 500;
    line-height: 1.55;
    color: var(--text);
    margin-bottom: 0.8rem;
}
.home-intro a {
    color: var(--green);
}

.home-intro-second {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.home-location {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 1.2rem;
}

.home-nav {
    font-family: var(--font-ui);
    font-size: 0.88rem;
    color: var(--text-dim);
    margin-bottom: 0.25rem;
}
.home-nav:last-of-type {
    margin-bottom: 2rem;
}
.home-nav a {
    color: var(--green);
}

.home-label {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 0.75rem;
}

/* ── Section head (reusable) ── */
.section-head {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding: 1.75rem 0 0.75rem;
}

/* ── Post list (homepage + blog) ── */
.post-list {
    list-style: none;
}

.post-item {
    display: block;
    padding: 0.9rem 0;
    border-top: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
}
.post-item:hover { color: inherit; }
.post-item:hover .post-item-title { color: var(--green); }

.post-item-meta {
    font-family: var(--font-ui);
    font-size: 0.78rem;
    color: var(--text-faint);
    margin-bottom: 0.2rem;
}

.post-item-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 500;
    line-height: 1.35;
    color: var(--text);
    transition: color 0.15s;
}

.post-item-excerpt {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-top: 0.25rem;
    line-height: 1.55;
}

.more-link {
    display: inline-block;
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--green);
    padding: 1.25rem 0;
}

/* ── Blog page: year groups ── */
.year-label {
    font-family: var(--font-ui);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gold);
    padding-top: 2rem;
    padding-bottom: 0.5rem;
}

.blog-search {
    margin-bottom: 0.5rem;
}
.blog-search input {
    width: 100%;
    max-width: 320px;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-hover);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 0.88rem;
    transition: border-color 0.2s;
}
.blog-search input:focus {
    outline: none;
    border-color: var(--green);
}
.blog-search input::placeholder {
    color: var(--text-faint);
}

.search-empty-state {
    color: var(--text-dim);
    padding: 1rem 0;
    font-size: 0.9rem;
}

.tag-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.2rem;
}
.tag-pill {
    font-family: var(--font-ui);
    font-size: 0.82rem;
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tag-pill:hover {
    color: var(--text);
    border-color: var(--text-dim);
}
.tag-pill.active {
    color: var(--green);
    border-color: var(--green);
    background: color-mix(in srgb, var(--green) 10%, transparent);
}

.hero {
    padding: 2.5rem 0 0;
}

.hero h1 {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 500;
    line-height: 1.55;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.hero-description {
    font-size: 0.92rem;
    color: var(--text-dim);
    margin-top: 0.25rem;
    line-height: 1.5;
}

/* ── Article page ── */
.article-head {
    padding: 3rem 0 1.75rem;
}
.article-head .article-meta {
    font-family: var(--font-ui);
    font-size: 0.78rem;
    color: var(--text-faint);
    margin-bottom: 0.6rem;
}
.article-head .reading-time {
    color: var(--gold);
}
.article-head h1 {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
}
.article-head .subtitle {
    font-style: italic;
    color: var(--text-dim);
    margin-top: 0.5rem;
    font-size: 1.05rem;
}

.article-body {
    padding-bottom: 2.5rem;
    border-bottom: 1px solid var(--border);
}
.article-body p {
    margin-bottom: 1.4rem;
}

.article-body h1 {
    font-family: var(--font-heading);
    font-size: 1.7rem;
    font-weight: 700;
    margin: 2.5rem 0 0.75rem;
    color: var(--text);
    line-height: 1.3;
}

.article-body h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 2.5rem 0 0.75rem;
    color: var(--text);
    line-height: 1.3;
}

.article-body h3 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    margin: 2rem 0 0.6rem;
    color: var(--text);
    line-height: 1.35;
}

.article-body blockquote {
    border-left: 2px solid var(--green);
    padding-left: 1.25rem;
    margin: 1.75rem 0;
    color: var(--text-dim);
    font-style: italic;
}

.article-body code {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.88em;
    background: var(--bg-hover);
    padding: 0.1em 0.35em;
    border-radius: 3px;
}

.article-body pre {
    background: var(--bg-hover);
    padding: 1.25rem;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 1.4rem;
    border: 1px solid var(--border);
}
.article-body pre code {
    background: transparent;
    padding: 0;
}

.article-body a {
    color: var(--green);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: rgba(61, 155, 122, 0.3);
}
.article-body a:hover {
    text-decoration-color: var(--green);
}

.article-body ul,
.article-body ol {
    margin-bottom: 1.4rem;
    padding-left: 1.75rem;
}
.article-body li {
    margin-bottom: 0.5rem;
    line-height: 1.7;
}

.article-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 1.75rem 0;
}

.article-body strong {
    font-weight: 700;
    color: var(--text);
}

.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9rem;
}
.article-body th,
.article-body td {
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    text-align: left;
}
.article-body th {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-dim);
    background: var(--bg-hover);
}
.article-body td {
    color: var(--text);
}

/* Footnotes (markdown-it-footnote) */
.footnotes-sep {
    margin-top: 2rem;
}
.footnotes {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    font-size: 0.88rem;
    color: var(--text-dim);
}
.footnotes ol {
    padding-left: 1.5rem;
}
.footnotes li {
    margin-bottom: 0.4rem;
}
.footnote-ref a {
    font-family: var(--font-ui);
    font-size: 0.7em;
    color: var(--green);
    text-decoration: none;
}
.footnote-backref {
    text-decoration: none;
    color: var(--green);
    font-size: 0.8em;
}

/* ── Post navigation (prev/next) ── */
.post-nav {
    display: flex;
    justify-content: space-between;
    padding: 1.5rem 0 3rem;
    font-family: var(--font-ui);
    font-size: 0.82rem;
}
.post-nav a {
    color: var(--text-dim);
    text-decoration: none;
}
.post-nav a:hover { color: var(--green); }
.post-nav .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    display: block;
    margin-bottom: 0.15rem;
}
.post-nav .nav-title {
    color: var(--text);
}
.post-nav a:hover .nav-title { color: var(--green); }
.post-nav .next { text-align: right; }

/* ── About page ── */
.about-content {
    padding: 2.5rem 0 3rem;
}
.about-content h1 {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 500;
    line-height: 1.55;
    margin-bottom: 0.5rem;
    color: var(--text);
}
.about-content h2 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text);
}
.about-content p {
    margin-bottom: 1.4rem;
    color: var(--text);
}
.about-content a {
    color: var(--green);
}
.about-content ul, .about-content ol {
    margin-bottom: 1.4rem;
    padding-left: 1.75rem;
}
.about-content li {
    margin-bottom: 0.5rem;
}

.callout {
    border-left: 2px solid var(--green);
    padding-left: 1.25rem;
    margin: 1.75rem 0;
    font-style: italic;
    color: var(--text-dim);
}

.footer-icons {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}
.footer-icons a {
    display: block;
    color: var(--text-faint);
    text-decoration: none;
    transition: color 0.15s;
}
.footer-icons a:hover {
    color: var(--green);
}
.footer-icons svg {
    width: 1rem;
    height: 1rem;
    display: block;
}

/* ── Footer ── */
.site-footer {
    padding: 2rem 0;
    border-top: 1px solid var(--border);
    margin-top: 3rem;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.5rem;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    color: var(--text-faint);
}
.footer-inner a {
    color: var(--text-faint);
    text-decoration: none;
}
.footer-inner a:hover { color: var(--text-dim); }
.footer-inner .footer-icons a:hover { color: var(--green); }

/* ── Responsive ── */
@media (max-width: 600px) {
    .header-inner {
        flex-wrap: wrap;
    }

    .site-nav {
        display: none;
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.25rem;
        padding-top: 0.75rem;
        justify-content: flex-end;
    }
    .site-nav.open {
        display: flex;
    }
    .site-nav a {
        padding: 0.45rem 0.6rem;
        font-size: 0.8rem;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .home-intro { font-size: 1.25rem; }
    .article-head h1 { font-size: 1.6rem; }

    .post-nav { flex-direction: column; gap: 1rem; }
    .post-nav .next { text-align: left; }

    .footer-inner { flex-direction: column; gap: 0.75rem; text-align: center; }

    .blog-search input { max-width: 100%; }
}
