/* ==========================================================================
   Blog CSS — clean, readable typography inspired by leaflet.pub
   ========================================================================== */

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

html {
    font-size: 17px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--body-font, system-ui, sans-serif);
    color: var(--fg, #272727);
    background-color: var(--bg, #fdfcfa);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Site layout */
.site {
    max-width: var(--page-width, 680px);
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.site-header {
    text-align: center;
    padding: 2.5rem 0 2rem;
}

.site-title {
    font-family: var(--heading-font, system-ui, sans-serif);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.site-title a {
    color: var(--accent, #578230);
    text-decoration: none;
}

.site-title a:hover {
    opacity: 0.8;
}

.site-name {
    font-family: var(--heading-font, system-ui, sans-serif);
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0;
}

.site-name a {
    color: var(--accent, #578230);
    text-decoration: none;
}

.site-name a:hover {
    opacity: 0.8;
}

.site-author {
    font-size: 0.9rem;
    color: color-mix(in srgb, var(--fg) 60%, transparent);
    margin-top: 0.25rem;
}

.site-author a {
    color: var(--accent, #578230);
    text-decoration: none;
    font-weight: 500;
}

.site-author a:hover {
    text-decoration: underline;
}

/* Post list */
.post-list {
    flex: 1;
}

.post-item {
    border-bottom: 1px solid color-mix(in srgb, var(--fg) 8%, transparent);
}

.post-item:last-child {
    border-bottom: none;
}

.post-link {
    display: block;
    padding: 1.5rem 0;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.15s;
}

.post-link:hover {
    opacity: 0.75;
}

.post-date {
    display: block;
    font-size: 0.8rem;
    color: color-mix(in srgb, var(--fg) 50%, transparent);
    font-variant-numeric: tabular-nums;
    margin-bottom: 0.35rem;
}

.post-title {
    font-family: var(--heading-font, system-ui, sans-serif);
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.01em;
    margin-bottom: 0.2rem;
}

.post-description {
    font-size: 0.95rem;
    color: color-mix(in srgb, var(--fg) 65%, transparent);
    line-height: 1.5;
    margin-top: 0.25rem;
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.tag {
    font-size: 0.75rem;
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--accent, #578230);
    padding: 0.15rem 0.55rem;
    border-radius: 100px;
    font-weight: 500;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: color-mix(in srgb, var(--fg) 40%, transparent);
    font-size: 1.1rem;
}

/* Post page */
.post-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid color-mix(in srgb, var(--fg) 8%, transparent);
}

.post .post-title {
    font-family: var(--heading-font, system-ui, sans-serif);
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
}

.post-subtitle {
    font-size: 1.15rem;
    color: color-mix(in srgb, var(--fg) 60%, transparent);
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.post-meta {
    font-size: 0.85rem;
    color: color-mix(in srgb, var(--fg) 50%, transparent);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.post-meta a {
    color: var(--accent, #578230);
    text-decoration: none;
    font-weight: 500;
}

.post-meta a:hover {
    text-decoration: underline;
}

.sep {
    color: color-mix(in srgb, var(--fg) 25%, transparent);
}

.cover-image {
    margin: 0 calc(-1 * max(0px, (100vw - var(--page-width, 680px)) / 2 - 1.25rem));
    margin-bottom: 2rem;
}

.cover-image img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

/* Post content */
.post-content {
    font-size: 1rem;
    line-height: 1.75;
}

.post-content > * + * {
    margin-top: 1.25rem;
}

.post-content p {
    margin: 0;
}

.post-content p + p {
    margin-top: 1.25rem;
}

.post-content p:empty,
.post-content p br:only-child {
    margin-top: 0.5rem;
}

.post-content .text-small {
    font-size: 0.875rem;
}

.post-content .text-large {
    font-size: 1.2rem;
}

/* Headings */
.post-content h1, .post-content h2, .post-content h3,
.post-content h4, .post-content h5, .post-content h6 {
    font-family: var(--heading-font, system-ui, sans-serif);
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.02em;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
}

.post-content h1 { font-size: 1.8rem; }
.post-content h2 { font-size: 1.5rem; }
.post-content h3 { font-size: 1.25rem; }
.post-content h4 { font-size: 1.1rem; }
.post-content h5 { font-size: 1rem; }
.post-content h6 { font-size: 0.9rem; }

/* Links */
.post-content a {
    color: var(--accent, #578230);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}

.post-content a:hover {
    text-decoration-thickness: 2px;
}

/* Inline code */
.post-content code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.875em;
    background: color-mix(in srgb, var(--fg) 6%, transparent);
    padding: 0.15em 0.35em;
    border-radius: 4px;
}

/* Code blocks */
.post-content pre {
    background: color-mix(in srgb, var(--fg) 4%, transparent);
    border: 1px solid color-mix(in srgb, var(--fg) 8%, transparent);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    line-height: 1.5;
}

.post-content pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: 0.85rem;
}

/* Blockquote */
.post-content blockquote {
    border-left: 3px solid var(--accent, #578230);
    padding-left: 1.25rem;
    margin: 1.5rem 0;
    color: color-mix(in srgb, var(--fg) 70%, transparent);
    font-style: italic;
}

.post-content blockquote p {
    margin: 0;
}

/* Lists */
.post-content ul,
.post-content ol {
    padding-left: 1.5rem;
    margin: 1rem 0;
}

.post-content li {
    margin: 0.35rem 0;
    line-height: 1.65;
}

.post-content li > ul,
.post-content li > ol {
    margin: 0.25rem 0;
}

.post-content li.checklist {
    list-style: none;
    position: relative;
    padding-left: 0.25rem;
}

.post-content li.checklist::before {
    content: '☐';
    position: absolute;
    left: -1.25rem;
}

.post-content li.checklist.checked::before {
    content: '☑';
    color: var(--accent, #578230);
}

/* Horizontal rule */
.post-content hr {
    border: none;
    border-top: 1px solid color-mix(in srgb, var(--fg) 12%, transparent);
    margin: 2rem 0;
}

/* Images */
.post-content figure {
    margin: 1.75rem 0;
}

.post-content figure.full-bleed {
    margin-left: calc(-1 * max(0px, (100vw - var(--page-width, 680px)) / 2 - 1.25rem));
    margin-right: calc(-1 * max(0px, (100vw - var(--page-width, 680px)) / 2 - 1.25rem));
}

.post-content figure img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
}

.post-content figure.full-bleed img {
    border-radius: 0;
}

.post-content figcaption {
    font-size: 0.8rem;
    color: color-mix(in srgb, var(--fg) 50%, transparent);
    text-align: center;
    margin-top: 0.5rem;
    line-height: 1.4;
}

/* Website embeds */
.website-embed {
    display: flex;
    border: 1px solid color-mix(in srgb, var(--fg) 12%, transparent);
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none !important;
    color: inherit;
    margin: 1.5rem 0;
    transition: border-color 0.15s;
}

.website-embed:hover {
    border-color: color-mix(in srgb, var(--fg) 25%, transparent);
}

.website-embed img {
    width: 120px;
    min-height: 80px;
    object-fit: cover;
    flex-shrink: 0;
}

.website-embed-text {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.website-embed-text strong {
    font-size: 0.9rem;
    line-height: 1.3;
}

.website-embed-text span {
    font-size: 0.8rem;
    color: color-mix(in srgb, var(--fg) 60%, transparent);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.website-embed-url {
    font-size: 0.75rem !important;
    color: color-mix(in srgb, var(--fg) 40%, transparent) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Bluesky embed */
.bsky-embed {
    border: 1px solid color-mix(in srgb, var(--fg) 12%, transparent);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
}

.bsky-embed a {
    color: var(--accent, #578230);
    text-decoration: none;
    font-weight: 500;
}

.bsky-embed a:hover {
    text-decoration: underline;
}

/* Button block */
.button-block {
    margin: 1.5rem 0;
    text-align: center;
}

.button-block .btn {
    display: inline-block;
    background: var(--accent, #578230);
    color: #fff;
    padding: 0.6rem 1.5rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: opacity 0.15s;
}

.button-block .btn:hover {
    opacity: 0.85;
}

/* iFrame */
.iframe-wrapper {
    position: relative;
    width: 100%;
    margin: 1.5rem 0;
    border-radius: 8px;
    overflow: hidden;
}

.iframe-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Math */
.math-block {
    margin: 1.5rem 0;
    overflow-x: auto;
    text-align: center;
}

/* Rich text formatting */
strong { font-weight: 700; }
em { font-style: italic; }
s { text-decoration: line-through; }
u { text-decoration: underline; }
mark {
    background: color-mix(in srgb, var(--accent) 20%, transparent);
    padding: 0.1em 0.2em;
    border-radius: 2px;
}

/* Footnotes */
.footnote a {
    color: var(--accent, #578230);
    text-decoration: none;
    font-size: 0.8em;
}

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

.footnotes {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid color-mix(in srgb, var(--fg) 10%, transparent);
    font-size: 0.85rem;
    color: color-mix(in srgb, var(--fg) 70%, transparent);
}

.footnotes ol {
    padding-left: 1.25rem;
}

.footnotes li {
    margin: 0.5rem 0;
}

.footnote-back {
    text-decoration: none;
    margin-left: 0.25rem;
}

/* Footer */
.site-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid color-mix(in srgb, var(--fg) 8%, transparent);
    font-size: 0.8rem;
    color: color-mix(in srgb, var(--fg) 45%, transparent);
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.site-footer a {
    color: var(--accent, #578230);
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

.rss-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.back-link {
    font-weight: 500;
}

/* 404 page */
.error-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 1rem;
}

.error-page h2 {
    font-family: var(--heading-font, system-ui, sans-serif);
    font-size: 4rem;
    font-weight: 700;
    color: color-mix(in srgb, var(--fg) 15%, transparent);
    margin-bottom: 0.5rem;
}

.error-page p {
    color: color-mix(in srgb, var(--fg) 50%, transparent);
    margin-bottom: 1.5rem;
}

.error-page .back-link {
    color: var(--accent, #578230);
    text-decoration: none;
    font-weight: 500;
}

.error-page .back-link:hover {
    text-decoration: underline;
}

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

    .site {
        padding: 1rem 1rem 2rem;
    }

    .site-header {
        padding: 1.5rem 0 1.25rem;
    }

    .site-title {
        font-size: 1.4rem;
    }

    .post .post-title {
        font-size: 1.65rem;
    }

    .post-content pre {
        border-radius: 0;
        margin-left: -1rem;
        margin-right: -1rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .website-embed {
        flex-direction: column;
    }

    .website-embed img {
        width: 100%;
        height: 140px;
    }
}
