/* --- General & Variables --- */
/* Matches the homepage: light = newsprint editorial, dark = amber terminal. */
:root {
    /* newsprint */
    --bg-color: #ecebe1;
    --card-bg-color: #f3f2ea;
    --text-color: #16140f;
    --text-muted: #5c574b;
    --link-color: #a01818;
    --border-color: #d8d3c4;
    --social-bg: #e5e3d8;
    --panel-bg: #f3f2ea;
    --panel-strong: #e9e6db;
    --accent-warm: #9a6a12;
    --accent-cool: #a01818;
    --accent-rose: #8b2f47;
    /* type tokens (shared with the homepage) */
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
    --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, "Cascadia Code", Consolas, monospace;
    --font-family: var(--sans);
    --paper-dot: rgba(120, 100, 70, .045);
}

/* Dark mode — warm "amber terminal" editorial */
[data-theme="dark"] {
    --bg-color: #0f0d09;
    --card-bg-color: #16130d;
    --text-color: #ece3d2;
    --text-muted: #b58a4a;
    --link-color: #ffb000;
    --border-color: #2a2418;
    --social-bg: #1b1710;
    --panel-bg: #16130d;
    --panel-strong: #1c180f;
    --accent-warm: #ffb000;
    --accent-cool: #ffb000;
    --accent-rose: #e0857a;
    --paper-dot: rgba(255, 176, 0, .03);
}

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(var(--paper-dot) 1px, transparent 1px);
    background-size: 3px 3px;
    color: var(--text-color);
    font-family: var(--font-family);
    line-height: 1.6;
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

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

a:hover {
    text-decoration: underline;
}

/* --- Homepage: simple research homepage --- */
.home-page {
    min-height: 100vh;
    padding: 0;
    background: var(--bg-color);
}

.home-page .container {
    max-width: 920px;
    padding: 0 24px;
}

.home-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 26px 0;
}

.wordmark {
    display: inline-block;
    color: var(--text-color);
    font-size: 0.95rem;
    font-weight: 700;
    text-decoration: none;
}

.wordmark:hover {
    color: var(--link-color);
    text-decoration: none;
}

.home-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.home-links a,
.home-links .theme-toggle {
    position: static;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--text-muted);
}

.home-links a:hover,
.home-links .theme-toggle:hover {
    color: var(--link-color);
    background: var(--social-bg);
    text-decoration: none;
}

.home-links svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.home-links .theme-toggle svg {
    stroke: currentColor;
    fill: none;
}

.home-links .theme-toggle .moon-icon {
    fill: currentColor;
    stroke: none;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 148px;
    gap: 36px;
    align-items: start;
    padding: 54px 0 56px;
}

.hero-copy {
    min-width: 0;
}

.hero h1 {
    margin: 0;
    color: var(--text-color);
    font-size: clamp(2.4rem, 6vw, 4.1rem);
    font-weight: 750;
    line-height: 1.05;
    letter-spacing: 0;
}

.hero .tagline {
    margin: 12px 0 0;
    color: var(--text-muted);
    font-size: 1rem;
}

.hero-lede {
    max-width: 700px;
    margin: 24px 0 0;
    color: var(--text-color);
    font-size: 1.08rem;
    line-height: 1.75;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-top: 22px;
}

.hero-actions a {
    color: var(--link-color);
    font-size: 0.96rem;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.hero-photo {
    width: 148px;
    height: 148px;
    border-radius: 50%;
    object-fit: cover;
}

.section-block {
    padding: 32px 0;
    border-top: 1px solid var(--border-color);
}

.section-heading {
    margin-bottom: 12px;
}

.home-page .section-heading h2 {
    margin: 0;
    padding: 0;
    border: 0;
    color: var(--text-color);
    font-size: 1.35rem;
    font-weight: 720;
    line-height: 1.25;
}

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

.timeline li {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 24px;
    padding: 18px 0;
    border-top: 1px solid var(--border-color);
}

.timeline span {
    display: block;
    padding-top: 2px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 650;
}

.timeline h3 {
    margin: 0 0 4px;
    color: var(--text-color);
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.35;
}

.timeline p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.98rem;
    line-height: 1.55;
}

.writing-section {
    padding-bottom: 10px;
}

.essay-list {
    margin-top: 2px;
}


/* --- Generic Card --- */
.card {
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 30px;
}

/* --- Theme Toggle Button --- */
.theme-toggle {
    position: absolute;
    top: 15px;
    left: 15px;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: color 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
    color: var(--link-color);
    border-color: var(--link-color);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.theme-toggle .moon-icon {
    fill: currentColor;
    stroke: none;
}

/* Show sun in light mode, moon in dark mode */
.theme-toggle .moon-icon {
    display: none;
}

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

[data-theme="dark"] .theme-toggle .moon-icon {
    display: block;
}

/* Blog post: header with back link and theme toggle */
.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.post-header .back-link {
    margin-bottom: 0;
}

.post-header .theme-toggle {
    position: static;
}

/* --- Homepage Specific: Profile & About --- */
.profile {
    position: relative;
    display: flex;
    align-items: center;
    gap: 25px;
}

.profile-photo {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
}

.profile-info .name-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.profile-info h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 600;
}

.profile .social-links {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--social-bg);
}

.profile .social-links a {
    color: var(--text-muted);
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.profile .social-links a:hover {
    color: var(--link-color);
}

.profile .social-links svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.profile-info .tagline {
    margin: 0 0 8px 0;
    font-size: 1rem;
    color: var(--text-muted);
}

.profile-info .intro {
    margin: 0;
    font-size: 1rem;
    color: var(--text-muted);
}

.profile-info p {
    margin: 4px 0;
    font-size: 1rem;
    color: var(--text-muted);
}

h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-top: 0;
}

/* --- Homepage: Post Cards --- */
.post-card {
    display: block;
    background-color: transparent;
    border: 0;
    border-top: 1px solid var(--border-color);
    border-radius: 0;
    padding: 16px 0;
    margin-bottom: 0;
    text-decoration: none;
    transition: border-color 0.2s;
}

.post-card:hover {
    border-top-color: var(--link-color);
    text-decoration: none;
}

.post-card:hover .post-excerpt {
    color: var(--text-color);
}

.post-card h2 {
    margin: 0 0 5px 0;
    font-size: 1.05rem;
    line-height: 1.25;
    font-weight: 700;
    color: var(--text-color);
    border-bottom: none;
    padding-bottom: 0;
}

.post-card .post-excerpt {
    max-width: 760px;
    margin: 0 0 6px 0;
    font-size: 0.96rem;
    color: var(--text-muted);
    line-height: 1.55;
    transition: color 0.2s;
}

.post-card .post-meta {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-muted);
}

/* --- Blog Page: Post List --- */
.blog-post {
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 30px;
}

.blog-post h2 {
    margin-top: 0;
    margin-bottom: 5px;
    border-bottom: none;
}

.blog-post h2 a {
    color: var(--text-color);
}

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

.blog-post p {
    margin-top: 0;
}

/* --- Single Post Page: Content --- */
.post-content {
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 35px;
    line-height: 1.7;
}

.post-content h1 {
    margin-top: 0;
    margin-bottom: 5px;
    font-size: 2.2rem;
    line-height: 1.3;
}

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

.post-content p {
    font-size: 1.1rem;
    margin-bottom: 1.5em;
}

.post-content blockquote {
    border-left: 4px solid var(--link-color);
    margin: 1.5em 0;
    padding: 0.5em 1em;
    color: var(--text-muted);
    background: var(--social-bg);
}

.post-content code {
    background-color: var(--social-bg);
    padding: .2em .4em;
    margin: 0;
    font-size: 85%;
    border-radius: 6px;
}

.post-content {
    position: relative;
}

.post-content h2 {
    font-size: 1.4rem;
    margin-top: 2em;
    margin-bottom: 0.8em;
    border-bottom: none;
    padding-bottom: 0;
}

.post-content ul {
    margin: 1em 0 1.5em 0;
    padding-left: 1.5em;
}

.post-content li {
    font-size: 1.1rem;
    margin-bottom: 0.5em;
}

.post-content strong {
    color: var(--text-color);
}

.back-link {
    display: inline-block;
    margin-bottom: 25px;
    font-size: 0.95rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

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

/* --- Blog Page Layout (sidebar fixed, topbar scrolls) --- */
.blog-sidebar {
    position: fixed;
    left: max(20px, calc(50% - 360px - 220px));
    top: 20px;
    width: 190px;
    max-width: 190px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    z-index: 100;
    overflow: hidden;
}

.blog-sidebar .title-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.blog-sidebar .blog-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
    text-decoration: none;
    flex-shrink: 0;
}

.blog-sidebar .blog-title:hover {
    text-decoration: none;
    color: var(--link-color);
}

.blog-sidebar .theme-toggle {
    position: static;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: color 0.2s;
    flex-shrink: 0;
}

.blog-sidebar .theme-toggle:hover {
    color: var(--link-color);
}

.blog-sidebar .theme-toggle svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.blog-sidebar .theme-toggle .moon-icon {
    fill: currentColor;
    stroke: none;
}

.blog-sidebar .sidebar-home {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-muted);
    text-decoration: none;
}

.blog-sidebar .sidebar-home:hover {
    color: var(--link-color);
    text-decoration: none;
}

/* --- Table of Contents --- */
.toc {
    display: flex;
    flex-direction: column;
    margin-top: 12px;
    padding: 12px;
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    width: 100%;
    box-sizing: border-box;
}

.toc a {
    display: block;
    font-size: 0.72rem;
    line-height: 1.4;
    color: var(--text-muted);
    text-decoration: none !important;
    padding: 3px 0 3px 10px;
    border-left: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.toc a:hover {
    color: var(--link-color);
    text-decoration: none;
}

.toc a.active {
    color: var(--link-color);
    border-left-color: var(--link-color);
    font-weight: 600;
}

.toc a.toc-h3 {
    padding-left: 22px;
    font-size: 0.68rem;
}

.blog-topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    max-width: 720px;
    margin: 0 auto;
    padding: 20px;
}

.blog-nav a {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
    text-decoration: none;
}

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

.blog-layout {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 20px 20px 20px;
}

.blog-layout .site-footer {
    margin-top: 50px;
}

.blog-article {
    line-height: 1.7;
    font-family: var(--serif);
}

.blog-article h1 {
    font-size: 2.3rem;
    font-weight: 800;
    margin: 0 0 10px 0;
    line-height: 1.2;
    letter-spacing: -0.01em;
    font-family: var(--serif);
}

.blog-article .post-meta {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-bottom: 30px;
    font-family: var(--mono);
}

.blog-article p {
    font-size: 1.05rem;
    margin-bottom: 1.4em;
}

.blog-article h2 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-top: 1.5em;
    margin-bottom: 0.8em;
    padding-top: 0.2em;
    padding-bottom: 0.2em;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    font-family: var(--serif);
}

.blog-article p + ul {
    margin-top: -1em;
}

.blog-article ul {
    margin: 0 0 1.5em 0;
    padding-left: 1.5em;
}

.blog-article li {
    font-size: 1.05rem;
    margin-bottom: 0.5em;
}

.blog-article strong {
    color: var(--text-color);
}

.blog-article blockquote {
    border-left: 4px solid var(--link-color);
    margin: 1.5em 0;
    padding: 0.5em 1em;
    color: var(--text-muted);
    background: var(--social-bg);
}

.blog-article code {
    background-color: var(--social-bg);
    padding: .2em .4em;
    font-family: var(--mono);
    font-size: 85%;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* --- Share Bar --- */
.share-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    padding: 20px;
    margin-top: 40px;
    background-color: var(--social-bg);
    border-radius: 8px;
}

.share-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background-color: var(--text-color);
    color: var(--card-bg-color);
    transition: transform 0.2s, opacity 0.2s;
}

.share-btn:hover {
    transform: scale(1.1);
    opacity: 0.85;
    text-decoration: none;
}

.share-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

/* CSS Tooltips for instant display */
.share-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    margin-bottom: 8px;
    background-color: var(--text-color);
    color: var(--card-bg-color);
    font-family: var(--font-family);
    font-size: 0.75rem;
    white-space: nowrap;
    border-radius: 4px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
}

.share-btn:hover::after {
    opacity: 1;
    visibility: visible;
}

/* --- Site Footer --- */
.site-footer {
    text-align: center;
    padding: 30px 20px;
    margin-top: 60px;
}

.site-footer p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* --- Responsive Design --- */
@media (max-width: 1200px) {
    .blog-sidebar {
        position: static;
        max-width: 720px;
        margin: 0 auto;
        padding: 20px 20px 0 20px;
    }
    .toc {
        display: none;
    }
    .blog-topbar {
        padding-top: 10px;
    }
}

@media (max-width: 900px) {
    .hero {
        grid-template-columns: minmax(0, 1fr) 124px;
        gap: 28px;
        padding-top: 34px;
    }
    .hero-photo {
        width: 124px;
        height: 124px;
    }
}

@media (max-width: 600px) {
    .home-page .container {
        padding: 0 18px;
    }
    .home-header {
        align-items: center;
        padding-top: 18px;
    }
    .home-links {
        gap: 3px;
    }
    .hero {
        grid-template-columns: 1fr;
        padding-top: 26px;
        padding-bottom: 38px;
    }
    .hero h1 {
        font-size: clamp(2.4rem, 14vw, 3.4rem);
    }
    .hero-lede {
        margin-top: 20px;
        font-size: 1rem;
        line-height: 1.65;
    }
    .hero-photo {
        width: 118px;
        height: 118px;
        order: -1;
    }
    .timeline li {
        grid-template-columns: 1fr;
        gap: 5px;
        padding: 16px 0;
    }
    .timeline span {
        padding-top: 0;
    }
    .profile {
        flex-direction: column;
        text-align: center;
    }
    header {
        flex-direction: column;
        gap: 15px;
    }
    .post-content {
        padding: 20px;
    }
    .blog-article h1 {
        font-size: 1.6rem;
    }
    .blog-sidebar {
        padding: 15px 15px 0 15px;
    }
    .blog-sidebar .blog-title,
    .blog-nav a {
        font-size: 1.1rem;
    }
    .blog-topbar {
        padding: 10px 15px;
    }
}
