/*
 * Heimdall-family styles for the blog, without a build step.
 * Tokens follow Heimdall's globals.css; the accent is the blog's leaf green
 * (#65a30d, derived with heimdall-style's accent.py). Pages use only these
 * variables, never raw colours, so light and dark stay in step.
 */

:root {
    color-scheme: light;
    --page: #f2f3f5;
    --surface: #ffffff;
    --subtle: #f7f8f9;
    --hover: #f1f5ee;
    --line: #d9dce1;
    --line-subtle: #e9ebee;
    --fg: #1d1f23;
    --muted: #5b616b;
    --faint: #8a9099;
    --primary: #406c00;
    --primary-hover: #305300;
    --primary-soft: #eaf1e5;
    --on-primary: #ffffff;
    --link: #406c00;
    --success: #1b7f42;
    --success-soft: #e5f5eb;
    --warning: #8f5300;
    --warning-soft: #fff3dc;
    --danger: #c4243c;
    --danger-hover: #a01b30;
    --on-danger: #ffffff;
    --danger-soft: #fdebee;
    --info: #1f5fbf;
    --info-soft: #e8f0fc;
    --ring: rgb(64 108 0 / 0.35);
    --shadow: 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.04);
    --shadow-lg: 0 10px 30px rgb(16 24 40 / 0.12);
    --overlay: rgb(17 20 24 / 0.45);
    --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --page: #141518;
    --surface: #1c1e22;
    --subtle: #22252a;
    --hover: #282e23;
    --line: #353941;
    --line-subtle: #2a2d33;
    --fg: #eef0f3;
    --muted: #a9afb8;
    --faint: #7c838d;
    --primary: #4f8200;
    --primary-hover: #5f9717;
    --primary-soft: #203012;
    --on-primary: #ffffff;
    --link: #8cbc62;
    --success: #4cc27a;
    --success-soft: #16301f;
    --warning: #f0b252;
    --warning-soft: #33280f;
    --danger: #f2687c;
    --danger-hover: #ff8596;
    --on-danger: #1a0b0e;
    --danger-soft: #3a1a20;
    --info: #7fadff;
    --info-soft: #1b2a45;
    --ring: rgb(140 188 98 / 0.4);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 30px rgb(0 0 0 / 0.5);
    --overlay: rgb(0 0 0 / 0.6);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --page: #141518;
        --surface: #1c1e22;
        --subtle: #22252a;
        --hover: #282e23;
        --line: #353941;
        --line-subtle: #2a2d33;
        --fg: #eef0f3;
        --muted: #a9afb8;
        --faint: #7c838d;
        --primary: #4f8200;
        --primary-hover: #5f9717;
        --primary-soft: #203012;
        --on-primary: #ffffff;
        --link: #8cbc62;
        --success: #4cc27a;
        --success-soft: #16301f;
        --warning: #f0b252;
        --warning-soft: #33280f;
        --danger: #f2687c;
        --danger-hover: #ff8596;
        --on-danger: #1a0b0e;
        --danger-soft: #3a1a20;
        --info: #7fadff;
        --info-soft: #1b2a45;
        --ring: rgb(140 188 98 / 0.4);
        --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
        --shadow-lg: 0 10px 30px rgb(0 0 0 / 0.5);
        --overlay: rgb(0 0 0 / 0.6);
    }
}

/* Base */

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 14px; background: var(--page); -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100dvh;
    background: var(--page);
    color: var(--fg);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
code, .mono { font-family: var(--font-mono); }
code { background: var(--subtle); border-radius: 4px; padding: 0.1em 0.3em; font-size: 0.9em; }
:focus-visible { outline: 2px solid transparent; box-shadow: 0 0 0 3px var(--ring); border-radius: 4px; }
::selection { background: var(--primary-soft); }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.icon { width: 16px; height: 16px; flex: none; }
.icon-lg { width: 28px; height: 28px; color: var(--faint); }
.logo { flex: none; display: block; }
.stack > * + * { margin-top: 0.75rem; }
.stack-lg > * + * { margin-top: 1.5rem; }

/* Buttons */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 2rem; padding: 0 0.75rem; border-radius: 6px;
    border: 1px solid var(--line); background: var(--surface); color: var(--fg);
    font: 500 0.875rem/1 var(--font-sans); white-space: nowrap; cursor: pointer;
    text-decoration: none; transition: background-color 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--subtle); text-decoration: none; }
.btn-sm { height: 1.75rem; padding: 0 0.625rem; font-size: 13px; }
.btn-sm .icon { width: 14px; height: 14px; }
.btn-lg { height: 2.5rem; width: 100%; font-size: 15px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--subtle); color: var(--fg); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-danger-outline { color: var(--danger); }
.btn-danger-outline:hover { border-color: var(--danger); background: var(--danger-soft); }
.icon-btn {
    display: inline-flex; padding: 6px; border-radius: 4px; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--subtle); color: var(--fg); }
.icon-btn .icon { width: 18px; height: 18px; }

/* Cards */

.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.card-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line-subtle); }
.card-head h2 { font-size: 15px; font-weight: 600; }
.card-head p { font-size: 13px; margin-top: 2px; }
.card-body { padding: 1rem 1.25rem; }
.card-foot {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.75rem;
    padding: 0.75rem 1.25rem; border-top: 1px solid var(--line-subtle); background: var(--subtle);
    border-radius: 0 0 8px 8px;
}
.card-danger { border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 3rem 1.5rem; }
.empty .muted { font-size: 13px; }

/* Badges, pills, callouts */

.badge {
    display: inline-flex; align-items: center; gap: 4px; border-radius: 4px; padding: 2px 6px;
    font-size: 0.75rem; font-weight: 500; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-neutral { border: 1px solid var(--line); background: var(--subtle); color: var(--muted); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.pill { border-radius: 4px; background: var(--subtle); padding: 0 6px; font-size: 0.75rem; color: var(--muted); }
.count {
    margin-left: auto; border-radius: 4px; background: var(--warning-soft); color: var(--warning);
    padding: 0 6px; font-size: 0.75rem; font-weight: 600;
}
.callout { display: flex; gap: 0.75rem; border-radius: 6px; padding: 0.75rem 0.875rem; font-size: 13px; }
.callout .icon { margin-top: 1px; }
.callout-title { font-weight: 600; }
.callout-success { background: var(--success-soft); } .callout-success .icon { color: var(--success); }
.callout-warning { background: var(--warning-soft); } .callout-warning .icon { color: var(--warning); }
.callout-danger { background: var(--danger-soft); } .callout-danger .icon { color: var(--danger); }
.callout-info { background: var(--info-soft); } .callout-info .icon { color: var(--info); }

/* Forms */

.field { display: flex; flex-direction: column; gap: 0.375rem; }
.field label { font-size: 13px; font-weight: 500; }
.optional { font-weight: 400; color: var(--faint); margin-left: 4px; }
.hint { font-size: 0.75rem; color: var(--muted); }
input:not([type="checkbox"]):not([type="file"]), select, textarea {
    width: 100%; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg);
    font: 0.875rem/1.5 var(--font-sans); padding: 0 0.625rem;
}
input:not([type="checkbox"]):not([type="file"]), select { height: 2rem; }
textarea { padding: 0.375rem 0.625rem; resize: vertical; }
textarea.mono { font-family: var(--font-mono); font-size: 13px; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="file"] { font: 0.875rem var(--font-sans); color: var(--muted); }
.form-grid { display: grid; gap: 1rem; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .span-2 { grid-column: span 2; } }
.form-actions { display: flex; justify-content: flex-end; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.inline-form label { font-size: 13px; }
.inline-form input:not([type="file"]) { width: auto; flex: 1 1 12rem; }
.inline-field { display: flex; align-items: center; gap: 0.5rem; font-size: 13px; color: var(--muted); margin-right: auto; }
.inline-field select { width: auto; }
.prefixed { display: flex; }
.prefixed span {
    display: flex; align-items: center; padding: 0 0.625rem; border: 1px solid var(--line); border-right: 0;
    border-radius: 6px 0 0 6px; background: var(--subtle); color: var(--muted); font-size: 0.875rem;
}
.prefixed input:not([type="checkbox"]) { border-radius: 0 6px 6px 0; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Theme switch */

.theme-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; padding: 2px; background: var(--surface); }
.theme-switch button {
    display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; color: var(--muted);
    border-radius: 4px; padding: 3px 8px; font: 0.75rem var(--font-sans); cursor: pointer;
}
.theme-switch button:hover { color: var(--fg); }
.theme-switch button[aria-pressed="true"] { background: var(--primary-soft); color: var(--link); }
.theme-switch .icon { width: 14px; height: 14px; }

/* Public reading layout */

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 720px; margin: 0 auto; height: 3.5rem; padding: 0 1rem; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); font-size: 15px; font-weight: 600; }
.brand:hover { text-decoration: none; }
.reading { max-width: 720px; margin: 0 auto; padding: 1.5rem 1rem 2rem; }
.reading > * + * { margin-top: 1.5rem; }
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.site-footer {
    max-width: 720px; margin: 0 auto; padding: 1rem 1rem 2rem; display: flex; flex-wrap: wrap; gap: 1rem;
    align-items: center; justify-content: space-between; font-size: 13px;
}
.site-footer nav { display: flex; gap: 1rem; }
.site-footer nav a { color: var(--muted); }

.post-list { list-style: none; margin: 0; padding: 0; }
.post-list li + li { border-top: 1px solid var(--line-subtle); }
.post-list a { display: grid; gap: 2px; padding: 1rem 1.25rem; color: inherit; }
.post-list a:hover { background: var(--hover); text-decoration: none; }
.post-list-title { font-size: 16px; font-weight: 600; color: var(--link); }
.post-list-summary { color: var(--fg); }
.post-list time { font-size: 13px; color: var(--muted); }

.post { padding: 1.75rem 1.5rem; }
@media (min-width: 640px) { .post { padding: 2.25rem 2.5rem; } }
.post header { margin-bottom: 1.5rem; }
.post header h1 { font-size: 28px; line-height: 1.25; font-weight: 600; letter-spacing: -0.015em; }
.post header p { margin-top: 0.5rem; font-size: 13px; }

/* Long reading is tiring at 14px, so post text runs at 16px. */
.prose { font-size: 16px; line-height: 1.65; overflow-wrap: break-word; }
.prose > * + * { margin-top: 1em; }
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3 { line-height: 1.3; font-weight: 600; margin-top: 1.75em; }
.prose h1 { font-size: 24px; } .prose h2 { font-size: 20px; } .prose h3 { font-size: 17px; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose li + li { margin-top: 0.25em; }
.prose blockquote { margin-left: 0; padding-left: 1em; border-left: 3px solid var(--line); color: var(--muted); }
.prose pre { background: var(--subtle); border: 1px solid var(--line-subtle); border-radius: 6px; padding: 0.875rem 1rem; overflow-x: auto; font-size: 13.5px; line-height: 1.55; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose img { max-width: 100%; height: auto; border-radius: 6px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line-subtle); padding: 6px 10px; text-align: left; }
.prose th { background: var(--subtle); }

.comments > * + * { margin-top: 1rem; }
.comments h2 { font-size: 17px; font-weight: 600; display: flex; gap: 8px; align-items: baseline; }
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment-list li { padding: 1rem 1.25rem; }
.comment-list li + li { border-top: 1px solid var(--line-subtle); }
.comment-meta { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; font-size: 15px; }
.comment-form { padding: 1.25rem; }
.comment-form > * + * { margin-top: 1rem; }
.comment-form h3 { font-size: 15px; font-weight: 600; }
.cf-turnstile { min-height: 65px; }

/* Sign-in */

.signin main { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3rem 1rem; }
.signin-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 1.5rem; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.signin-card { width: 100%; max-width: 24rem; padding: 1.5rem; }
.signin-card h1 { font-size: 18px; font-weight: 600; }
.signin-card > p { font-size: 13px; margin-top: 4px; }
.signin-card .stack { margin-top: 1.25rem; }

/* Admin console shell */

.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: 15rem; display: flex; flex-direction: column;
    background: var(--surface); border-right: 1px solid var(--line);
    transform: translateX(-100%); transition: transform 0.2s;
}
.nav-toggle:checked ~ .sidebar { transform: none; box-shadow: 0 0 0 100vmax var(--overlay); }
.nav-scrim { display: none; position: fixed; inset: 0; z-index: 30; }
.nav-toggle:checked ~ .nav-scrim { display: block; }
.sidebar-head { height: 3.5rem; display: flex; align-items: center; gap: 10px; padding: 0 1rem; border-bottom: 1px solid var(--line-subtle); }
.sidebar-title { min-width: 0; line-height: 1.25; }
.app-name { font-size: 15px; font-weight: 600; }
.app-context { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-close { margin-left: auto; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem 0.5rem; }
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sidebar-nav ul + ul { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line-subtle); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 6px; font-size: 0.875rem; color: var(--muted); }
.nav-item:hover { background: var(--subtle); color: var(--fg); text-decoration: none; }
.nav-item.active { background: var(--primary-soft); color: var(--link); font-weight: 500; }
.sidebar-foot { border-top: 1px solid var(--line-subtle); padding: 0.75rem 1rem; display: grid; gap: 0.625rem; }
.sidebar-foot .theme-switch { width: 100%; }
.sidebar-foot .theme-switch button { flex: 1; justify-content: center; }
.signout { display: flex; align-items: center; gap: 8px; }
.who { font-size: 13px; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: auto; }
.admin-main { min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; }
.admin-topbar {
    position: sticky; top: 0; z-index: 20; height: 3.5rem; display: flex; align-items: center; padding: 0 1rem;
    background: color-mix(in srgb, var(--surface) 95%, transparent); border-bottom: 1px solid var(--line);
}
.admin-content { width: 100%; max-width: 72rem; margin: 0 auto; padding: 1.5rem 1rem; }
.admin-content > * + * { margin-top: 1.5rem; }
@media (min-width: 1024px) {
    .sidebar { transform: none; }
    .nav-toggle:checked ~ .sidebar { box-shadow: none; }
    .sidebar-close, .nav-scrim, .nav-toggle:checked ~ .nav-scrim { display: none; }
    .admin-main { padding-left: 15rem; }
    .admin-topbar { display: none; }
    .admin-content { padding: 2rem; }
}

.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.page-header h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.page-header p { margin-top: 4px; }
.page-header .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.breadcrumbs { display: flex; gap: 6px; font-size: 13px; color: var(--faint); margin-bottom: -1rem; }
.admin-content > .breadcrumbs + * { margin-top: 1.5rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.875rem; }
th {
    background: var(--subtle); border-bottom: 1px solid var(--line); padding: 0.5rem 1rem;
    font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
th:first-child { border-radius: 8px 0 0 0; } th:last-child { border-radius: 0 8px 0 0; }
td { border-bottom: 1px solid var(--line-subtle); padding: 0.75rem 1rem; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--hover); }
.right { text-align: right; }
.row-link { display: grid; color: inherit; }
.row-link:hover { text-decoration: none; }
.row-link:hover .link { text-decoration: underline; }
.link { color: var(--link); }
.sub { font-size: 0.75rem; color: var(--muted); }

.tabs { display: flex; gap: 4px; overflow-x: auto; box-shadow: inset 0 -1px 0 var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: flex; align-items: center; gap: 6px; padding: 0.5rem 0.75rem; border-bottom: 2px solid transparent; font-size: 0.875rem; color: var(--muted); white-space: nowrap; }
.tab:hover { color: var(--fg); text-decoration: none; }
.tab.active { border-color: var(--primary); color: var(--fg); font-weight: 500; }
.admin-content > .tabs + .card { margin-top: 1.25rem; }

.editor { display: grid; }
.editor textarea { border: 0; border-radius: 0; min-height: 28rem; padding: 1rem 1.25rem; }
.editor textarea:focus { box-shadow: inset 0 0 0 2px var(--ring); }
.editor-preview { padding: 1rem 1.25rem; border-top: 1px solid var(--line-subtle); min-height: 6rem; }
.editor-preview:empty::before { content: "Preview"; color: var(--faint); font-size: 14px; }
@media (min-width: 1024px) {
    .editor { grid-template-columns: 1fr 1fr; }
    .editor-preview { border-top: 0; border-left: 1px solid var(--line-subtle); max-height: 40rem; overflow-y: auto; }
}

.moderation { list-style: none; margin: 0; padding: 0; }
.moderation li { padding: 1rem 1.25rem; }
.moderation li + li { border-top: 1px solid var(--line-subtle); }
.moderation-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-size: 13px; }
.moderation .comment-body { font-size: 14px; }
.row-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

.media-grid { list-style: none; margin: 0; padding: 1rem; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
.media-grid li { border: 1px solid var(--line-subtle); border-radius: 6px; overflow: hidden; display: flex; flex-direction: column; }
.media-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--subtle); display: block; }
.snippet { display: block; margin: 0.5rem 0.75rem 0; font-size: 12px; overflow-wrap: anywhere; user-select: all; border-radius: 4px; }
.media-foot { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.75rem 0.75rem; font-size: 0.75rem; margin-top: auto; }
