:root {
    --max-width: 42rem;
    --spacing: 1.5rem;
    --text: #1d1d1f;
    --bg: #fafaf8;
    --muted: #6e6e73;
    --border: #d2d2d7;
    --code-bg: #f2f2f0;
    --accent: #1d6b4f;
    --accent-hover: #155840;
    --accent-subtle: color-mix(in srgb, var(--accent) 4%, var(--bg));
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --text: #e5e5e0;
        --bg: #1a1a1e;
        --muted: #9a9a9e;
        --border: #38383c;
        --code-bg: #28282c;
        --accent: #4aba8a;
        --accent-hover: #5ccf9e;
        --accent-subtle: color-mix(in srgb, var(--accent) 4%, var(--bg));
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 1.125rem;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
    padding: var(--spacing);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
}

/* Header — masthead presence */
.container > header {
    padding: calc(var(--spacing) * 2.5) 0 calc(var(--spacing) * 1.25);
    border-bottom: 2px solid var(--text);
    margin-bottom: calc(var(--spacing) * 2.5);
}

.container > header h1 {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.1;
}

.container > header h1 a {
    color: inherit;
    text-decoration: none;
}

.container > header p {
    color: var(--muted);
    font-size: 0.925rem;
    margin-top: 0.625rem;
    letter-spacing: 0.01em;
}

nav {
    margin-top: 1rem;
    display: flex;
    gap: 1.5rem;
}

nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: color 0.15s ease;
}

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

main {
    min-height: 60vh;
}

main > :first-child {
    margin-top: 0;
}

/* "Recent Posts" section label */
main > h1:first-child {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin-bottom: 2rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

footer {
    margin-top: calc(var(--spacing) * 4);
    padding-top: calc(var(--spacing) * 1.5);
    border-top: 2px solid var(--text);
    color: var(--muted);
    font-size: 0.8125rem;
    letter-spacing: 0.01em;
}

/* Links — subtle underline with transitions */
a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent) 30%, transparent);
    text-underline-offset: 0.2em;
    text-decoration-thickness: 1px;
    transition: text-decoration-color 0.2s ease, color 0.2s ease;
}

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

/* Typography — editorial texture */
h1, h2, h3, h4 {
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-top: 2em;
    margin-bottom: 0.5em;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.625rem; }
h3 { font-size: 1.25rem; }

p, ul, ol, pre, blockquote {
    margin-bottom: 1.25em;
}

ul, ol {
    padding-left: 1.5em;
}

/* Code blocks */
pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    padding: 1.5rem;
    overflow-x: auto;
    border-radius: 6px;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.875em;
    line-height: 1.6;
}

code {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.875em;
    background: var(--code-bg);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}

pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    border: none;
    font-size: inherit;
}

/* Blockquote — accent-tinted */
blockquote {
    border-left: 3px solid var(--accent);
    padding: 1rem 1.25rem;
    color: var(--muted);
    font-style: italic;
    background: var(--accent-subtle);
    border-radius: 0 4px 4px 0;
}

del { opacity: 0.65; }

.all-small-caps { font-variant-caps: all-small-caps; }
.star-rating { letter-spacing: 0.05em; }
.star-rating-block { font-size: 2em; text-align: center; margin: 1em 0; display: block; }

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2em 0;
}

img {
    max-width: 100%;
    height: auto;
}

/* Post summaries — divider-separated entries */
.post-summary {
    padding-bottom: 2rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.post-summary:last-of-type {
    border-bottom: none;
}

.post-summary header {
    margin-bottom: 1.5rem;
}

.post-summary:not(.post-summary-short) h2 {
    margin-top: 0.75rem;
}

.post-summary h2 {
    margin-top: 0;
    margin-bottom: 0.2rem;
    font-size: clamp(2rem, 5vw, 2.75rem);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.15;
}

.post-summary h2 a {
    color: var(--text);
    text-decoration: none;
    transition: color 0.15s ease;
}

.post-summary h2 a:hover {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
    text-underline-offset: 0.15em;
    text-decoration-thickness: 2px;
}

.post-meta {
    display: block;
    color: var(--muted);
    font-size: 0.8125rem;
    letter-spacing: 0.02em;
}

.post-excerpt {
    margin-top: 0.625rem;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.6;
}

/* Article header — hero treatment with accent rule */
.article-header {
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: none;
    position: relative;
}

.article-header h1 {
    margin-top: 0;
    font-size: clamp(2.25rem, 6vw, 3.25rem);
    line-height: 1.08;
    letter-spacing: -0.035em;
    font-weight: 800;
}

.article-header .post-meta {
    margin-top: 0.75rem;
}

.article-header::after {
    content: "";
    display: block;
    width: 3rem;
    height: 2px;
    background: var(--accent);
    margin-top: 1.5rem;
}

/* Content headings — subordinate to post title, clear descending hierarchy */
.content h1 {
    font-size: clamp(1.5rem, 3.5vw, 1.875rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.content h2 {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.25;
}

.content h3 {
    font-size: 1.1875rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.content h4 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.35;
    color: var(--muted);
}

/* Tags — pill shape */
.tag {
    border: 1px solid var(--border);
    padding: 0.15rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.8125rem;
    margin-left: 0.5rem;
    text-decoration: none;
    transition: border-color 0.15s ease, color 0.15s ease;
    color: var(--muted);
}

/* Post navigation */
.post-nav {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}

.post-nav a {
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

.post-nav a:hover {
    color: var(--accent);
}

.page-content h1 {
    margin-top: 0;
}

@media (max-width: 640px) {
    body { font-size: 1rem; padding: 1rem; }
    h1 { font-size: 1.75rem; }
    .container > header { padding: var(--spacing) 0 calc(var(--spacing) * 0.75); }
}

/* Link card embeds */
.link-card-container {
    margin: 1.5em 0;
}

.link-card {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    background: var(--bg);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.link-card:hover {
    border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
    box-shadow: 0 2px 8px color-mix(in srgb, var(--text) 6%, transparent);
    color: inherit;
    text-decoration: none;
}

.link-card-image {
    width: 10rem;
    min-height: 6.5rem;
    object-fit: cover;
    flex-shrink: 0;
    border-radius: 0;
}

.link-card-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.875rem 1rem;
    min-width: 0;
}

.link-card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.link-card-description {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.link-card-domain {
    font-size: 0.75rem;
    color: var(--muted);
    letter-spacing: 0.02em;
    margin-top: 0.125rem;
}

.link-card-minimal {
    border-left: 3px solid var(--accent);
    border-radius: 0 6px 6px 0;
}

.link-card-minimal .link-card-content {
    padding: 0.75rem 1rem;
}

@media (max-width: 640px) {
    .link-card { flex-direction: column; }
    .link-card-image { width: 100%; min-height: 0; height: 10rem; }
}

/* Short post styles */
.post-standard { /* Standard posts use default styling */ }

/* Card container for quick posts — subtle background, soft border, gentle radius */
.post-short {
    background: color-mix(in srgb, var(--accent) 3%, var(--bg));
    border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
    border-radius: 6px;
    padding: 1.5rem 1.75rem;
    margin-bottom: 2rem;
}

.post-short .article-header {
    margin-bottom: 1rem;
    padding-bottom: 0;
}

/* Hide the accent rule under the header inside cards */
.post-short .article-header::after {
    display: none;
}

.post-short .post-meta,
.post-summary-short .post-meta {
    margin-bottom: 0.75rem;
}

.post-short .article-header h1 {
    font-size: clamp(1.125rem, 2.5vw, 1.375rem);
    font-weight: 700;
    letter-spacing: -0.025em;
}

.post-titleless .content {
    font-size: 1.1875rem;
    line-height: 1.65;
}

.post-title-link {
    color: var(--text);
    text-decoration: none;
    transition: color 0.15s ease;
}

.post-title-link:hover {
    color: var(--accent);
}

.external-arrow {
    font-size: 0.8em;
    opacity: 0.4;
    margin-left: 0.15em;
    transition: opacity 0.15s ease;
}

.post-title-link:hover .external-arrow {
    opacity: 0.7;
}

.permalink {
    text-decoration: none;
    opacity: 0.3;
    font-size: 1em;
    transition: opacity 0.15s ease;
}

.permalink:hover {
    opacity: 0.8;
}

.permalink svg {
    vertical-align: -0.125em;
}

.post-meta .permalink {
    margin-left: 0.5rem;
}

.post-tags {
    margin-top: 0.5rem;
}

/* Card container for quick post summaries on index page */
.post-summary-short {
    background: color-mix(in srgb, var(--accent) 3%, var(--bg));
    border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
    border-radius: 6px;
    padding: 1.25rem 1.5rem;
}

.post-summary-short h2 {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
}

.post-summary-titleless .content {
    font-size: 1.0625rem;
    line-height: 1.65;
}

.post-summary-short .external-arrow {
    font-size: 0.8em;
    opacity: 0.4;
}

/* Pagination */
.pagination {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9375rem;
}

.pagination a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}

.pagination a:hover {
    color: var(--accent-hover);
}