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

/* Variables */
:root {
    --text: #e8e4df;
    --text-secondary: #9a9590;
    --border: #333130;
    --bg: #1a1917;
    --bg-hover: #232220;
    --max-width: 640px;
    --font-heading: 'Space Grotesk', -apple-system, sans-serif;
    --font-body: 'Space Grotesk', -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
}

a {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--border);
    transition: text-decoration-color 0.15s;
}

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

h1, h2, h3 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

p {
    color: var(--text-secondary);
    line-height: 1.7;
}

/* Layout */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Nav */
nav {
    padding: 2rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav .site-name {
    font-family: var(--font-heading);
    font-size: 1.125rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text);
}

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

nav .nav-links a {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s;
}

nav .nav-links a:hover,
nav .nav-links a.active {
    color: var(--text);
}

/* Main */
main {
    padding: 2rem 0 4rem;
}

/* Section headings */
.section-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 1rem;
}

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

.intro p {
    font-size: 1.0625rem;
    line-height: 1.8;
}

/* Home - recent posts list */
.post-list {
    list-style: none;
}

.post-list li {
    border-bottom: 1px solid var(--border);
}

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

.post-list a {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.75rem 0;
    text-decoration: none;
    gap: 1rem;
}

.post-list .post-title {
    font-size: 0.9375rem;
    color: var(--text);
}

.post-list .post-date {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

/* View all link */
.view-all {
    display: inline-block;
    margin-top: 1.5rem;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s;
}

.view-all:hover {
    color: var(--text);
}

/* Writing page - year groups */
.year-group {
    margin-bottom: 2.5rem;
}

.year-group h2 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.writing-header {
    margin-bottom: 2rem;
}

.writing-header p {
    font-size: 0.9375rem;
}

/* Projects page */
.project {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border);
}

.writing-header + .project {
    padding-top: 0;
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
    gap: 1rem;
}

.project h3 {
    font-size: 1.1rem;
}

.project .project-date {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.project h3 a {
    text-decoration-color: var(--border);
}

.project h3 a:hover {
    text-decoration-color: var(--text);
}

.project p {
    font-size: 0.9375rem;
    line-height: 1.6;
}

/* About page */
.bio {
    margin-bottom: 3rem;
}

.bio p {
    font-size: 1rem;
    line-height: 1.8;
    margin-bottom: 1rem;
}

.bio p:last-child {
    margin-bottom: 0;
}

.elsewhere-list {
    list-style: none;
}

.elsewhere-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

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

.elsewhere-list .label {
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.elsewhere-list a {
    font-size: 0.9375rem;
}

/* 404 page */
.not-found {
    text-align: center;
    padding: 6rem 0;
}

.not-found h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.not-found p {
    margin-bottom: 1.5rem;
}

/* Article (single post view) */
.article {
    padding-bottom: 2rem;
}

.back-link {
    display: inline-block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 2rem;
    transition: color 0.15s;
}

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

.article-title {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.article-date {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.article-body {
    line-height: 1.8;
    font-size: 1rem;
}

.article-body p {
    margin-bottom: 1.25rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.article-body a {
    color: var(--text);
    text-decoration-color: var(--border);
}

.article-body a:hover {
    text-decoration-color: var(--text);
}

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

.article-body em {
    font-style: italic;
}

.article-body ul, .article-body ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.article-body li {
    margin-bottom: 0.5rem;
    line-height: 1.8;
}

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

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

.article-body h2, .article-body h3 {
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.article-source {
    display: inline-block;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s;
    width: 100%;
}

.article-source:hover {
    color: var(--text);
}

/* Loading / fallback states */
.loading {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    padding: 1rem 0;
}


/* Responsive */
@media (max-width: 600px) {
    nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    nav .nav-links {
        gap: 1.25rem;
    }

    .post-list a {
        flex-direction: column;
        gap: 0.125rem;
    }

    .post-list .post-date {
        font-size: 0.75rem;
    }

    .project-header {
        flex-direction: column;
        gap: 0.125rem;
    }

    .elsewhere-list li {
        flex-direction: column;
        gap: 0.125rem;
    }

}
