/* Nocturne — dark-only Ghost theme */

/* ---------- Tokens ---------- */
:root {
    color-scheme: dark;
    --accent: #8b9cff;
    --bg: #121316;
    --bg-raised: #1a1b20;
    --bg-sunken: #0d0e10;
    --border: #2a2c33;
    --text: #e6e6e9;
    --text-muted: #9a9ca5;
    --text-faint: #6b6d76;
    --radius: 12px;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
    --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
    --heading-font: var(--gh-font-heading, var(--font-sans));
    --body-font: var(--gh-font-body, var(--font-sans));
    --w-narrow: 720px;
    --w-wide: 1040px;
    --w-container: 1200px;
}
.shade-midnight {
    --bg: #0e1220;
    --bg-raised: #161b2e;
    --bg-sunken: #0a0d18;
    --border: #252c45;
    --text-muted: #98a0b8;
}
.shade-black {
    --bg: #000;
    --bg-raised: #0e0e10;
    --bg-sunken: #000;
    --border: #222226;
}
.has-serif-body { --body-font: var(--gh-font-body, var(--font-serif)); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 1.0625rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent); color: #000; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

#particles { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
#particles canvas { display: block; }
.site { position: relative; z-index: 1; display: flex; flex-direction: column; min-height: 100vh; }
.site-main { flex: 1; }
.container { width: 100%; max-width: var(--w-container); margin: 0 auto; padding: 0 24px; }
.container.narrow { max-width: calc(var(--w-narrow) + 48px); }
.container.wide { max-width: calc(var(--w-wide) + 48px); }
.dot { color: var(--text-faint); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    height: 38px; padding: 0 16px;
    border-radius: 999px; border: 1px solid transparent;
    font: 600 0.9rem/1 var(--font-sans);
    cursor: pointer; white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.btn-accent { background: var(--accent); color: #0b0b0d; }
.btn-accent:hover { filter: brightness(1.1); }
.btn-ghost { border-color: var(--border); color: var(--text); background: transparent; }
.btn-ghost:hover { border-color: var(--text-muted); }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; padding: 0;
    border: 0; border-radius: 999px; background: transparent;
    color: var(--text-muted); cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--bg-raised); }

/* ---------- Header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 24px; height: 92px; }
.site-brand { display: flex; align-items: center; flex-shrink: 0; }
.site-logo { height: 68px; width: auto; max-width: none; transition: transform .3s; }
.site-brand:hover .site-logo { transform: rotate(-12deg); }
.site-title { font-weight: 800; font-size: 1.2rem; letter-spacing: -0.01em; }
.site-nav { flex: 1; }
.site-nav .nav { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.site-nav .nav a {
    position: relative; display: block; padding: 8px 14px; border-radius: 999px;
    color: var(--text-muted); font-size: 0.95rem; font-weight: 500;
    transition: color .15s, background .15s;
}
.site-nav .nav a:hover { color: var(--text); background: var(--bg-raised); }
.site-nav .nav-current a {
    color: var(--accent); font-weight: 600;
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}
.site-nav .nav-current a::after {
    content: ""; position: absolute; left: 50%; bottom: -14px;
    width: 18px; height: 3px; border-radius: 3px; transform: translateX(-50%);
    background: var(--accent);
    box-shadow: 0 0 10px 1px var(--accent);
}
.site-nav .nav-current a:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.menu-toggle { display: none; }

@media (max-width: 760px) {
    .header-inner { gap: 12px; height: 72px; }
    .site-logo { height: 52px; }
    .menu-toggle { display: inline-flex; }
    .hide-sm { display: none; }
    .site-nav {
        display: none;
        position: absolute; top: 72px; left: 0; right: 0;
        background: var(--bg); border-bottom: 1px solid var(--border);
        padding: 12px 16px 20px;
    }
    .nav-open .site-nav { display: block; }
    .site-nav .nav { flex-direction: column; }
    .site-nav .nav a { padding: 12px 16px; font-size: 1.05rem; border-radius: 10px; }
    .site-nav .nav-current a::after { left: 0; top: 50%; bottom: auto; width: 3px; height: 18px; transform: translateY(-50%); }
}

/* ---------- Hero / archive headers ---------- */
.hero, .archive-header { padding: 88px 24px 56px; text-align: center; }
.hero { position: relative; }
.hero.has-cover {
    display: flex; align-items: flex-end; justify-content: center;
    padding: 0; margin-bottom: 56px; overflow: hidden;
    min-height: 62vh; isolation: isolate;
}
.hero.cover-medium { min-height: 44vh; }
.hero.cover-full { min-height: calc(100vh - 92px); }
.hero-cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.hero.has-cover::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background:
        linear-gradient(to bottom, rgba(0,0,0,.25) 0%, rgba(0,0,0,.35) 45%, var(--bg) 100%),
        radial-gradient(ellipse at 50% 100%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%);
}
.hero.has-cover .hero-content { padding-top: 120px; padding-bottom: 64px; }
.hero.has-cover .hero-title { text-shadow: 0 2px 24px rgba(0,0,0,.6); }
.hero.has-cover .hero-desc { color: #e2e2e6; text-shadow: 0 1px 12px rgba(0,0,0,.7); }
.hero-title, .article-title, .post-card-title {
    font-family: var(--heading-font);
}
.hero-title {
    margin: 0 auto; max-width: 18ch;
    font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.08;
    font-weight: 800; letter-spacing: -0.025em;
}
.hero-desc { margin: 16px auto 0; max-width: 56ch; color: var(--text-muted); font-size: 1.2rem; }
.archive-header .avatar { margin: 0 auto 20px; }
.author-links { display: flex; gap: 16px; justify-content: center; margin-top: 16px; color: var(--text-muted); font-size: .95rem; }
.author-links a:hover { color: var(--accent); }
.section-label {
    display: block; margin: 0 0 12px;
    font-size: .8rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
    color: var(--accent);
}

/* Subscribe form */
.subscribe-form {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
    max-width: 440px; margin: 32px auto 0;
}
.subscribe-form input {
    flex: 1; min-width: 0; height: 44px; padding: 0 18px;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--bg-raised); color: var(--text); font: inherit; font-size: .95rem;
}
.subscribe-form input::placeholder { color: var(--text-faint); }
.subscribe-form input:focus { outline: none; border-color: var(--accent); }
.subscribe-form .btn { height: 44px; }
.form-msg { display: none; width: 100%; margin: 4px 0 0; font-size: .9rem; }
.subscribe-form.success .form-success { display: block; color: #7ee2a8; }
.subscribe-form.error .form-error { display: block; color: #ff8a8a; }
.subscribe-form.loading .btn { opacity: .6; pointer-events: none; }

/* ---------- Post feed ---------- */
.post-feed {
    display: grid; gap: 28px;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    padding-top: 8px; padding-bottom: 64px;
}
.post-card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color .2s, transform .2s;
}
.post-card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); transform: translateY(-2px); }
.post-card-link { display: flex; flex-direction: column; height: 100%; }
.post-card-image { aspect-ratio: 16 / 9; overflow: hidden; background: var(--bg-sunken); }
.post-card-image img { width: 100%; height: 100%; object-fit: cover; }
.post-card-body { display: flex; flex-direction: column; flex: 1; padding: 20px 22px 22px; }
.post-card-tag { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.post-card-title { margin: 0; font-size: 1.3rem; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
.lock-icon { display: inline-block; vertical-align: -1px; margin-right: 6px; color: var(--text-muted); }
.post-card-excerpt {
    margin: 10px 0 0; color: var(--text-muted); font-size: .95rem;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.post-card-meta { margin-top: auto; padding-top: 16px; font-size: .85rem; color: var(--text-faint); display: flex; gap: 6px; }


/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; padding-bottom: 80px; }
.pagination-info { color: var(--text-faint); font-size: .9rem; }

/* ---------- Article ---------- */
.article-header { padding-top: 72px; padding-bottom: 40px; }
.article-tag { font-size: .8rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.article-title {
    margin: 12px 0 0;
    font-size: clamp(2rem, 4.5vw, 3.1rem); line-height: 1.1;
    font-weight: 800; letter-spacing: -0.025em;
}
.article-excerpt { margin: 16px 0 0; font-size: 1.25rem; color: var(--text-muted); line-height: 1.5; }
.article-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 24px; color: var(--text-muted); font-size: .92rem; }
.article-meta a:hover { color: var(--text); }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--bg-raised); }
.avatar.lg { width: 56px; height: 56px; flex-shrink: 0; }
.avatar.xl { width: 96px; height: 96px; }
.article-image { margin: 0 auto 48px; }
.article-image img { width: 100%; border-radius: var(--radius); }
.article-image figcaption, .gh-content figcaption {
    margin-top: 10px; text-align: center; font-size: .85rem; color: var(--text-faint);
}

/* ---------- Post content (Koenig) ---------- */
.gh-content {
    font-family: var(--body-font);
    font-size: 1.15rem; line-height: 1.75;
    color: #d6d7db;
    padding-bottom: 48px;
}
.shade-black .gh-content { color: #cfd0d4; }
.gh-content > * + * { margin-top: 1.4em; margin-bottom: 0; }
.gh-content > :first-child { margin-top: 0; }
.gh-content h2, .gh-content h3, .gh-content h4 {
    font-family: var(--heading-font); color: var(--text);
    line-height: 1.25; letter-spacing: -0.015em; font-weight: 700;
}
.gh-content h2 { font-size: 1.75rem; margin-top: 2.2em; }
.gh-content h3 { font-size: 1.4rem; margin-top: 1.9em; }
.gh-content h4 { font-size: 1.15rem; margin-top: 1.7em; }
.gh-content a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.gh-content a:hover { text-decoration-thickness: 2px; }
.gh-content strong { color: var(--text); }
.gh-content ul, .gh-content ol { padding-left: 1.3em; }
.gh-content li + li { margin-top: .5em; }
.gh-content li::marker { color: var(--text-faint); }
.gh-content hr { border: 0; height: 1px; background: var(--border); margin: 3em 0; }
.gh-content blockquote:not([class]) {
    margin-left: 0; padding: 4px 0 4px 24px;
    border-left: 3px solid var(--accent);
    color: var(--text); font-style: italic;
}
.gh-content blockquote.kg-blockquote-alt {
    text-align: center; font-size: 1.5rem; line-height: 1.5; font-style: italic;
    color: var(--text); padding: 0 2em; border: 0;
}
.gh-content code {
    font-family: var(--font-mono); font-size: .88em;
    background: var(--bg-raised); border: 1px solid var(--border);
    padding: .12em .4em; border-radius: 6px;
}
.gh-content pre {
    overflow-x: auto; padding: 20px 22px;
    background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 10px;
    font-size: .9rem; line-height: 1.6;
}
.gh-content pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.gh-content table { width: 100%; border-collapse: collapse; font-size: .95rem; display: block; overflow-x: auto; }
.gh-content th, .gh-content td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.gh-content th { color: var(--text); font-family: var(--font-sans); }
.gh-content img, .gh-content video { border-radius: 8px; }
.gh-content figure { margin-left: 0; margin-right: 0; }

/* Card widths required by Ghost */
.kg-width-wide { position: relative; width: min(var(--w-wide), calc(100vw - 48px)); left: 50%; transform: translateX(-50%); }
.kg-width-full { position: relative; width: 100vw; left: 50%; transform: translateX(-50%); }
.kg-width-full img { border-radius: 0; }

/* Dark tweaks for Ghost cards */
.gh-content .kg-callout-card { border-radius: 10px; }
.gh-content .kg-callout-card-grey { background: var(--bg-raised); }
.gh-content .kg-bookmark-container { background: var(--bg-raised); border-color: var(--border); color: var(--text); text-decoration: none; }
.gh-content .kg-bookmark-description, .gh-content .kg-bookmark-metadata { color: var(--text-muted); }
.gh-content .kg-toggle-card, .gh-content .kg-product-card-container, .gh-content .kg-file-card-container {
    background: var(--bg-raised); border-color: var(--border); color: var(--text);
}
.gh-content .kg-header-card.kg-style-dark { background: var(--bg-raised); }
.video-wrap { position: relative; aspect-ratio: 16 / 9; }
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 8px; }

/* Members-only CTA */
.gh-post-upgrade-cta-content { background: var(--bg-raised) !important; border: 1px solid var(--border); border-radius: var(--radius); }

/* Author box / comments / related */
.author-box {
    display: flex; gap: 18px; align-items: flex-start;
    padding-top: 28px; padding-bottom: 28px;
    border-top: 1px solid var(--border);
}
.author-name { font-weight: 700; }
.author-name:hover { color: var(--accent); }
.author-box p { margin: 4px 0 0; color: var(--text-muted); font-size: .95rem; }
.comments { padding-top: 24px; padding-bottom: 48px; }
.related { padding-top: 56px; border-top: 1px solid var(--border); }

/* ---------- Error ---------- */
.error { padding: 120px 24px; text-align: center; }
.error-code { margin: 0 0 8px; font-size: 6rem; font-weight: 800; line-height: 1; color: var(--accent); opacity: .85; }
.error .btn { margin-top: 32px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-sunken); margin-top: 32px; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 32px; padding-top: 32px; padding-bottom: 32px; font-size: .9rem; color: var(--text-faint); }
.footer-nav { flex: 1; }
.footer-nav .nav { display: flex; flex-wrap: wrap; gap: 20px; list-style: none; margin: 0; padding: 0; }
.footer-social { display: flex; gap: 8px; }
.footer-social:empty { display: none; }
.social-link {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 38px; height: 38px; padding: 0 10px; border-radius: 999px;
    border: 1px solid var(--border); color: var(--text-muted);
    transition: color .15s, border-color .15s, box-shadow .15s;
}
.social-link:hover { color: var(--accent); border-color: var(--accent); box-shadow: 0 0 12px -2px var(--accent); }
.social-link svg { width: 18px; height: 18px; }
.social-text { font-size: .85rem; font-weight: 600; }
.footer-nav a, .footer-powered a { color: var(--text-muted); }
.footer-nav a:hover, .footer-powered a:hover { color: var(--text); }

@media (max-width: 600px) {
    body { font-size: 1rem; }
    .container { padding: 0 16px; }
    .hero, .archive-header { padding: 56px 16px 40px; }
    .hero.has-cover { padding: 0; min-height: 56vh; }
    .hero.cover-full { min-height: calc(100vh - 72px); }
    .post-feed { grid-template-columns: 1fr; gap: 20px; }
    .gh-content { font-size: 1.08rem; }
    .kg-width-wide { width: calc(100vw - 32px); }
    .footer-inner { flex-direction: column; align-items: flex-start; }
}
