/* ============================================================
   Kazhdan's Log — terminal-dark theme, matched to kazhdan.dev
   ============================================================ */

/* ---- Fonts ---- */
@font-face {
    font-family: 'Cormorant Garamond';
    font-style: normal;
    font-weight: 400 600;
    font-display: swap;
    src: url('../fonts/cormorant-garamond.woff2') format('woff2');
}
@font-face {
    font-family: 'Cormorant Garamond';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/cormorant-garamond-italic.woff') format('woff');
}
@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('../fonts/ibm-plex-mono-300.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/ibm-plex-mono-400.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/ibm-plex-mono-500.woff2') format('woff2');
}

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

:root {
    --bg: #0b0b0b;
    --bg-soft: #111110;
    --fg: #cdc6b8;
    --fg-strong: #e7e2d7;
    --fg-muted: #6b6560;
    --line: rgba(107, 101, 96, 0.18);
    --line-strong: rgba(107, 101, 96, 0.32);
    --accent: #39ff14;
    --accent-hover: #5fff3a;
    --accent-glow: rgba(57, 255, 20, 0.12);
    --serif: "Cormorant Garamond", Georgia, serif;
    --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --content-width: 680px;
    --feed-width: 720px;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--mono);
    font-weight: 300;
    line-height: 1.7;
    min-height: 100dvh;
    position: relative;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

.bg-glow {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(57, 255, 20, 0.04), transparent 70%),
        radial-gradient(ellipse 40% 80% at 85% 15%, rgba(57, 255, 20, 0.02), transparent 70%);
    animation: breathe 8s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 1.7; } }

.bg-noise {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    opacity: 0.9;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.028'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

::selection { background: var(--accent); color: var(--bg); }

a { color: var(--fg); text-decoration: none; transition: color 0.25s ease; }
a:hover { color: var(--accent-hover); }

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

/* ---- Layout shell ---- */
.viewport {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    max-width: var(--feed-width);
    margin: 0 auto;
    padding: 0 1.75rem;
}

/* ---- Header ---- */
.site-head {
    padding: 2.25rem 0 1.75rem;
    border-bottom: 1px solid var(--line);
}
.site-head-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.site-brand { display: flex; align-items: baseline; gap: 0.6rem; }
.site-brand-mark {
    font-family: var(--mono);
    font-weight: 500;
    color: var(--accent);
    font-size: 0.9rem;
    text-shadow: 0 0 10px var(--accent-glow);
}
.site-brand-title {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 1.35rem;
    letter-spacing: -0.01em;
    color: var(--fg-strong);
}
.site-brand:hover .site-brand-title { color: var(--accent-hover); }
.site-nav { display: flex; }
.site-nav ul {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 1.3rem;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.site-nav a { color: var(--fg-muted); font-weight: 400; }
.site-nav a:hover { color: var(--accent); }

/* ---- Main ---- */
.site-main { flex: 1 0 auto; padding: 1.5rem 0 4rem; }

/* ---- Feed ---- */
.feed { display: flex; flex-direction: column; }

.hero-post { padding: 1.5rem 0 0.5rem; }
.hero-link { display: block; }
.hero-cover {
    margin-bottom: 1.6rem;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--line);
    aspect-ratio: 16 / 9;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.hero-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-link:hover .hero-cover { border-color: rgba(57,255,20,0.35); box-shadow: 0 0 24px rgba(57,255,20,0.08); }
.hero-meta, .post-row-meta, .article-meta {
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--fg-muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.9rem;
}
.hero-kicker { color: var(--accent); text-shadow: 0 0 12px var(--accent-glow); }
.hero-sep, .post-row-sep, .article-meta-sep { color: var(--line-strong); }
.hero-title {
    font-family: var(--serif);
    font-weight: 500;
    font-size: clamp(2.3rem, 6vw, 3.4rem);
    line-height: 1.06;
    letter-spacing: -0.02em;
    color: var(--fg-strong);
    margin-bottom: 1rem;
}
.hero-link:hover .hero-title { color: var(--accent-hover); }
.hero-excerpt {
    font-size: 0.92rem;
    line-height: 1.75;
    color: var(--fg);
    max-width: 54ch;
    margin-bottom: 1.2rem;
}
.hero-cta {
    display: inline-block;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    color: var(--accent);
    border: 1px solid rgba(57, 255, 20, 0.3);
    background: rgba(57, 255, 20, 0.04);
    padding: 0.5rem 1rem;
    border-radius: 3px;
    transition: border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}
.hero-link:hover .hero-cta,
a.hero-cta:hover {
    border-color: rgba(57, 255, 20, 0.6);
    background: rgba(57, 255, 20, 0.08);
    box-shadow: 0 0 18px rgba(57, 255, 20, 0.12);
}

/* Feed divider */
.feed-divider {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin: 2.75rem 0 0.5rem;
}
.feed-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}
.feed-divider-label {
    font-size: 0.66rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--fg-muted);
}

/* Post rows */
.post-row { border-bottom: 1px solid var(--line); }
.post-row-link {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    padding: 1.6rem 0.6rem;
    margin: 0 -0.6rem;
    position: relative;
    border-radius: 3px;
    transition: background 0.25s ease;
}
.post-row-link:hover { background: var(--accent-glow); }
.post-row-body { flex: 1 1 auto; min-width: 0; }
.post-row-thumb {
    flex: 0 0 auto;
    width: 128px;
    height: 96px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--line);
    transition: border-color 0.25s ease;
}
.post-row-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-row.has-image .post-row-arrow { display: none; }
.post-row.has-image .post-row-link:hover .post-row-thumb { border-color: rgba(57,255,20,0.4); }
.post-row-title {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 1.55rem;
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: var(--fg-strong);
    margin-bottom: 0.6rem;
}
.post-row-link:hover .post-row-title { color: var(--accent-hover); }
.post-row-excerpt {
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--fg-muted);
    max-width: 60ch;
}
.post-row-tag { color: var(--fg-muted); }
.post-row-arrow {
    position: absolute;
    top: 1.6rem;
    right: 0.4rem;
    color: var(--fg-muted);
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.25s ease, transform 0.25s ease, color 0.25s ease;
}
.post-row-link:hover .post-row-arrow { opacity: 1; transform: translateX(0); color: var(--accent); }

/* ---- Pagination ---- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2.5rem;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-muted);
}
.pagination a { color: var(--fg-muted); }
.pagination a:hover { color: var(--accent); }
.pagination .page-number { flex: 1; text-align: center; }

/* ---- Archive (tag/author) ---- */
.archive-head { padding: 1.5rem 0 0.5rem; }
.archive-kicker { font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.archive-title {
    font-family: var(--serif);
    font-weight: 500;
    font-size: clamp(2rem, 5vw, 2.8rem);
    letter-spacing: -0.02em;
    color: var(--fg-strong);
    margin-top: 0.4rem;
}
.archive-desc { font-size: 0.9rem; color: var(--fg-muted); margin-top: 0.6rem; max-width: 54ch; }
.archive-divider { width: 2rem; height: 1px; background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); margin-top: 1.5rem; }

/* ---- Article ---- */
.article { max-width: var(--content-width); margin: 0 auto; padding-top: 1rem; }
.article-back {
    display: inline-block;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-muted);
    margin-bottom: 1.8rem;
    transition: color 0.25s ease;
}
.article-back:hover { color: var(--accent); }
.article-title {
    font-family: var(--serif);
    font-weight: 500;
    font-size: clamp(2.4rem, 6vw, 3.6rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--fg-strong);
    margin-bottom: 1.1rem;
}
.article-subtitle {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--fg-muted);
    max-width: 56ch;
    margin-bottom: 1.5rem;
}
.article-divider { width: 2rem; height: 1px; background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); margin: 1.8rem 0 0; }
.article-image { margin: 2.5rem 0; }
.article-image img { border-radius: 4px; border: 1px solid var(--line); }
.article-image figcaption { font-size: 0.72rem; color: var(--fg-muted); text-align: center; margin-top: 0.7rem; }

/* ---- Prose (gh-content) ---- */
.gh-content { margin-top: 2.5rem; font-size: 0.95rem; line-height: 1.85; color: var(--fg); }
/* Posts authored with an embedded title H1: the theme header already renders
   the title, so hide a leading H1 to avoid a duplicate. */
.gh-content > h1:first-child { display: none; }
.gh-content > * + * { margin-top: 1.5rem; }
.gh-content > h2 + *, .gh-content > h3 + * { margin-top: 1rem; }

.gh-content p { max-width: 68ch; }
.gh-content a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid rgba(57, 255, 20, 0.35);
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.gh-content a:hover { color: var(--accent-hover); border-color: var(--accent-hover); background: var(--accent-glow); }

.gh-content h2, .gh-content h3, .gh-content h4 {
    font-family: var(--mono);
    color: var(--fg-strong);
    font-weight: 500;
    letter-spacing: 0;
    line-height: 1.35;
    margin-top: 2.75rem;
}
.gh-content h2 { font-size: 1.4rem; }
.gh-content h3 { font-size: 1.15rem; }
.gh-content h4 { font-size: 1rem; }
.gh-content h2::before { content: "# "; color: var(--accent); }
.gh-content h3::before { content: "## "; color: var(--accent); }

.gh-content strong { color: var(--fg-strong); font-weight: 500; }
.gh-content em { font-style: italic; }

.gh-content ul, .gh-content ol { padding-left: 1.4rem; max-width: 66ch; }
.gh-content li { margin-top: 0.5rem; }
.gh-content li::marker { color: var(--accent); }

.gh-content blockquote {
    border-left: 2px solid var(--accent);
    padding: 0.3rem 0 0.3rem 1.4rem;
    color: var(--fg-muted);
    font-style: italic;
    background: linear-gradient(to right, var(--accent-glow), transparent 60%);
    max-width: 68ch;
}

.gh-content hr {
    border: none;
    height: 1px;
    background: var(--line);
    margin: 3rem 0;
}

/* inline + block code */
.gh-content :not(pre) > code {
    font-family: var(--mono);
    font-size: 0.85em;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 0.12em 0.4em;
    color: var(--accent-hover);
}
.gh-content pre {
    font-family: var(--mono);
    font-size: 0.82rem;
    line-height: 1.6;
    background: var(--bg-soft);
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    padding: 1.1rem 1.2rem;
    overflow-x: auto;
    color: var(--fg);
    max-width: 100%;
}
.gh-content pre code { background: none; border: none; padding: 0; color: inherit; font-size: inherit; }

.gh-content figure { margin: 2.5rem 0; }
.gh-content img { border-radius: 4px; border: 1px solid var(--line); }
.gh-content figcaption { font-size: 0.72rem; color: var(--fg-muted); text-align: center; margin-top: 0.7rem; }

/* Koenig cards */
.kg-width-wide { max-width: min(85vw, 900px); margin-left: 50%; transform: translateX(-50%); }
.kg-width-full { max-width: 100vw; margin-left: 50%; transform: translateX(-50%); }
.kg-card { margin-top: 2rem; }
.kg-embed-card, .kg-gallery-card { display: flex; justify-content: center; }
.kg-callout-card {
    display: flex;
    gap: 0.8rem;
    padding: 1rem 1.2rem;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    background: var(--bg-soft);
    font-size: 0.88rem;
}
.kg-callout-card-green, .kg-callout-card-accent { border-color: rgba(57,255,20,0.3); background: var(--accent-glow); }
.kg-bookmark-card a { border-bottom: none; }
.kg-bookmark-container {
    display: flex;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    overflow: hidden;
    background: var(--bg-soft);
}
.kg-bookmark-content { padding: 1rem 1.2rem; }
.kg-bookmark-title { color: var(--fg-strong); font-weight: 500; }
.kg-bookmark-description { color: var(--fg-muted); font-size: 0.82rem; margin-top: 0.3rem; }
.kg-toggle-card { border: 1px solid var(--line); border-radius: 5px; padding: 1rem 1.2rem; }

/* ---- Article footer ---- */
.article-foot { max-width: var(--content-width); margin: 3.5rem auto 0; }
.article-foot-divider { height: 1px; background: var(--line); margin-bottom: 1.5rem; }
.article-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.8rem; }
.article-tag-chip {
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--line-strong);
    border-radius: 3px;
    color: var(--fg);
    transition: border-color 0.25s ease, color 0.25s ease;
}
.article-tag-chip:hover { border-color: rgba(57,255,20,0.4); color: var(--accent); }
.article-back--foot { margin-bottom: 0; }
.article-back-cursor { color: var(--accent); animation: blink 1s step-end infinite; margin-left: 2px; }

/* ---- Subscribe ---- */
.subscribe {
    max-width: var(--content-width);
    margin: 3.5rem auto 0;
    border: 1px solid rgba(57, 255, 20, 0.28);
    background: rgba(57, 255, 20, 0.03);
    border-radius: 5px;
    padding: 1.6rem 1.5rem;
}
.subscribe-prompt { font-size: 0.8rem; color: var(--accent); font-weight: 500; letter-spacing: 0.04em; }
.subscribe-copy { font-size: 0.82rem; color: var(--fg-muted); margin-top: 0.4rem; margin-bottom: 1.1rem; }
.subscribe-form { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.subscribe-input {
    flex: 1;
    min-width: 200px;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 3px;
    color: var(--fg);
    font-family: var(--mono);
    font-size: 0.82rem;
    padding: 0.6rem 0.8rem;
}
.subscribe-input:focus { outline: none; border-color: rgba(57,255,20,0.5); }
.subscribe-input::placeholder { color: var(--fg-muted); }
.subscribe-btn {
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 3px;
    font-family: var(--mono);
    font-weight: 500;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    transition: background 0.2s ease;
}
.subscribe-btn:hover { background: var(--accent-hover); }

/* ---- Error ---- */
.error { max-width: var(--content-width); margin: 4rem auto; text-align: left; }
.error-code { font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.error-title { font-family: var(--serif); font-weight: 500; font-size: clamp(2rem, 6vw, 3rem); color: var(--fg-strong); margin: 0.6rem 0 1rem; }
.error-copy { color: var(--fg-muted); font-size: 0.9rem; margin-bottom: 2rem; }
.error-prompt { color: var(--accent); }

/* ---- Footer ---- */
.site-foot { flex-shrink: 0; padding: 2.5rem 0; border-top: 1px solid var(--line); }
.site-foot-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--fg-muted);
}
.site-foot-sep { color: var(--line-strong); }
.site-foot-link { color: var(--fg-muted); }
.site-foot-link:hover { color: var(--accent); }
.site-foot-cursor { color: var(--accent); animation: blink 1s step-end infinite; }

/* ---- Animations ---- */
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .viewport { padding: 0 1.25rem; }
    .site-head { padding: 1.5rem 0 1rem; }
    .site-nav ul { gap: 0.9rem; }
    .gh-content { font-size: 0.92rem; }
    .post-row-arrow { display: none; }
    .post-row-link { gap: 1rem; }
    .post-row-thumb { width: 84px; height: 84px; }
}

@media (prefers-reduced-motion: reduce) {
    .bg-glow, .article-back-cursor, .site-foot-cursor { animation: none; }
    html { scroll-behavior: auto; }
}
