/* ============================================================
   writeup — a code-first Ghost theme
   ============================================================ */

:root {
    --bg:        #0d1117;
    --bg-alt:    #161b22;
    --bg-code:   #1a1f29;
    --border:    #21262d;
    --border-hi: #30363d;
    --fg:        #e6edf3;
    --fg-dim:    #8b949e;
    --fg-dimmer: #6e7681;
    --accent:    #00ff88;
    --accent-dim:#00cc6a;
    --danger:    #ff6b6b;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Menlo, Consolas, monospace;

    --maxw: 1080px;
    --maxw-wide: 1320px;
}

[data-accent="Amber"]   { --accent: #ffb86c; --accent-dim: #d99853; }
[data-accent="Cyan"]    { --accent: #00d9ff; --accent-dim: #00a8cc; }
[data-accent="Magenta"] { --accent: #ff79c6; --accent-dim: #cc5fa0; }

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.site-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s;
}
a:hover { border-bottom-color: var(--accent); }

/* ============ HEADER ============ */
.site-header {
    border-bottom: 1px solid var(--border);
    padding: 2rem 1.5rem 1.5rem;
    max-width: var(--maxw-wide);
    margin: 0 auto;
    width: 100%;
}

.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.site-brand {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--fg);
    border: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.site-brand:hover { border: none; }
.brand-prompt { color: var(--accent); }
.brand-cursor {
    color: var(--accent);
    animation: blink 1.1s steps(1) infinite;
}
@keyframes blink {
    50% { opacity: 0; }
}

.site-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 1.5rem;
}
.site-nav a {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--fg-dim);
}
.site-nav a:hover { color: var(--accent); }

.site-tagline {
    font-family: var(--font-mono);
    color: var(--fg-dimmer);
    font-size: 0.875rem;
    margin: 0.75rem 0 0;
}

/* ============ MAIN ============ */
.site-main {
    flex: 1;
    padding: 3rem 0;
}

/* ============ POST FEED ============ */
.post-feed {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.post-card {
    border-bottom: 1px solid var(--border);
    padding: 1.75rem 0;
}
.post-card:first-child { padding-top: 0; }
.post-card:last-child { border-bottom: none; }

.post-card-link {
    display: block;
    color: inherit;
    border: none;
}
.post-card-link:hover { border: none; }
.post-card-link:hover .post-card-title { color: var(--accent); }

.post-card-tag {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.post-card-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0.4rem 0 0.6rem;
    line-height: 1.3;
    color: var(--fg);
    transition: color 0.15s;
}

.post-card-excerpt {
    color: var(--fg-dim);
    font-size: 0.95rem;
    margin: 0 0 0.75rem;
    line-height: 1.55;
}

.post-card-meta {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--fg-dimmer);
}
.meta-sep { margin: 0 0.5rem; opacity: 0.5; }
.post-card-tags { color: var(--fg-dimmer); }

/* ============ POST ============ */
.post-header {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.post-tag {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
}

.post-title {
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1.2;
    margin: 0.5rem 0 1rem;
    color: var(--fg);
}

.post-meta {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--fg-dimmer);
}

.post-feature {
    margin: 2rem 0 0;
}
.post-feature img {
    width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
}
.post-feature figcaption {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--fg-dimmer);
    text-align: center;
    margin-top: 0.5rem;
}

/* ============ POST CONTENT ============ */
.post-content {
    font-size: 1.05rem;
    line-height: 1.75;
}

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

.post-content h2,
.post-content h3,
.post-content h4 {
    color: var(--fg);
    line-height: 1.3;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
}
.post-content h2 {
    font-size: 1.65rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.4rem;
}
.post-content h2::before { content: '## '; color: var(--accent-dim); font-family: var(--font-mono); }
.post-content h3 { font-size: 1.3rem; }
.post-content h3::before { content: '### '; color: var(--accent-dim); font-family: var(--font-mono); }
.post-content h4 { font-size: 1.1rem; }
.post-content h4::before { content: '#### '; color: var(--accent-dim); font-family: var(--font-mono); }

.post-content p {
    color: var(--fg);
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.post-content a {
    color: var(--accent);
    border-bottom: 1px solid var(--border-hi);
}
.post-content a:hover { border-bottom-color: var(--accent); }

.post-content img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    display: block;
    margin: 1.5rem auto;
}

.post-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 0.5rem 0 0.5rem 1.25rem;
    margin: 1.5rem 0;
    color: var(--fg-dim);
    font-style: italic;
    background: var(--bg-alt);
}

.post-content ul,
.post-content ol {
    padding-left: 1.5rem;
}
.post-content li { margin: 0.4rem 0; }
.post-content ul li::marker { color: var(--accent); }

/* ============ INLINE & BLOCK CODE ============ */
.post-content :not(pre) > code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--bg-code);
    color: var(--accent);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    border: 1px solid var(--border);
    word-break: break-word;
}

.post-content pre {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    background: var(--bg-code) !important;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    -webkit-overflow-scrolling: touch;
}
.post-content pre code {
    background: transparent !important;
    color: var(--fg);
    padding: 0;
    border: none;
    font-size: inherit;
}

/* prism token override to align with theme */
.post-content pre[class*="language-"] {
    background: var(--bg-code) !important;
}

/* code block with title bar */
.code-block-wrapper {
    margin: 1.5rem 0;
    width: 100%;
}
div.code-toolbar {
    width: 100%;
    display: block;
}
.code-block-title {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: 0.5rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.code-block-title::before {
    content: '';
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 50%;
    opacity: 0.65;
    flex-shrink: 0;
}
.code-block-wrapper > pre,
.code-block-wrapper > div.code-toolbar > pre {
    margin: 0 !important;
    border-radius: 0 0 6px 6px !important;
    border-top: none !important;
}

/* prism line-numbers plugin */
.post-content pre[class*="language-"].line-numbers {
    padding-left: 3.5em;
    position: relative;
}
.line-numbers .line-numbers-rows {
    border-right: 1px solid var(--border) !important;
}
.line-numbers-rows > span::before {
    color: var(--fg-dimmer) !important;
}

/* custom line highlight (replaces buggy prism plugin) */
.post-content pre.line-numbers { position: relative; }
.hl-band {
    position: absolute;
    left: 0;
    right: 0;
    background: rgba(0, 255, 136, 0.10);
    box-shadow: inset 3px 0 0 var(--accent);
    pointer-events: none;
    z-index: 0;
}
.post-content pre.line-numbers > code,
.post-content pre.line-numbers > .line-numbers-rows { position: relative; z-index: 1; }
[data-accent="Amber"]   .hl-band { background: rgba(255, 184, 108, 0.10); }
[data-accent="Cyan"]    .hl-band { background: rgba(0, 217, 255, 0.10); }
[data-accent="Magenta"] .hl-band { background: rgba(255, 121, 198, 0.10); }

/* prism toolbar plugin (language label + copy button) */
div.code-toolbar {
    position: relative;
}
div.code-toolbar > .toolbar {
    opacity: 1 !important;
    top: 0.4em !important;
    right: 0.5em !important;
    display: flex;
    gap: 0.4rem;
}
div.code-toolbar > .toolbar > .toolbar-item > button,
div.code-toolbar > .toolbar > .toolbar-item > span,
div.code-toolbar > .toolbar > .toolbar-item > a {
    background: var(--bg-alt) !important;
    color: var(--fg-dim) !important;
    border: 1px solid var(--border) !important;
    border-radius: 3px !important;
    padding: 0.15rem 0.5rem !important;
    font-family: var(--font-mono) !important;
    font-size: 0.7rem !important;
    box-shadow: none !important;
    text-shadow: none !important;
}
div.code-toolbar > .toolbar > .toolbar-item > button:hover,
div.code-toolbar > .toolbar > .toolbar-item > a:hover {
    color: var(--accent) !important;
    border-color: var(--accent) !important;
}

/* scrollbar */
.post-content pre::-webkit-scrollbar { height: 8px; }
.post-content pre::-webkit-scrollbar-track { background: var(--bg); }
.post-content pre::-webkit-scrollbar-thumb {
    background: var(--border-hi);
    border-radius: 4px;
}

/* ============ TABLES ============ */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    border: 1px solid var(--border);
}
.post-content th,
.post-content td {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    text-align: left;
}
.post-content th {
    background: var(--bg-alt);
    font-weight: 600;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.post-content tr:nth-child(even) td { background: var(--bg-alt); }

/* hr */
.post-content hr {
    border: none;
    border-top: 1px dashed var(--border-hi);
    margin: 2rem 0;
}

/* ============ POST FOOTER ============ */
.post-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}
.post-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.post-tag-link {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--fg-dim);
    background: var(--bg-alt);
    padding: 0.25rem 0.6rem;
    border-radius: 3px;
    border: 1px solid var(--border);
}
.post-tag-link:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* ============ RELATED ============ */
.related {
    border-top: 1px solid var(--border);
    margin-top: 4rem;
    padding: 2.5rem 0;
    background: var(--bg-alt);
}
.related-title {
    font-family: var(--font-mono);
    color: var(--fg-dim);
    font-size: 0.9rem;
    margin: 0 0 1rem;
    font-weight: 500;
}
.related-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.related-item {
    display: flex;
    gap: 1rem;
    color: var(--fg);
    border: none;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    padding: 0.4rem 0;
}
.related-item:hover { color: var(--accent); border: none; }
.related-date { color: var(--fg-dimmer); flex-shrink: 0; }

/* ============ ARCHIVE ============ */
.archive-header {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.archive-kind {
    font-family: var(--font-mono);
    color: var(--fg-dimmer);
    font-size: 0.875rem;
}
.archive-title {
    font-family: var(--font-mono);
    font-size: 2rem;
    margin: 0.4rem 0 0.6rem;
    color: var(--accent);
}
.archive-desc { color: var(--fg-dim); margin: 0.5rem 0; }
.archive-count {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--fg-dimmer);
    margin: 0.5rem 0 0;
}

/* ============ PAGINATION ============ */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.875rem;
}
.pagination a {
    color: var(--fg-dim);
    border: 1px solid var(--border);
    padding: 0.4rem 0.8rem;
    border-radius: 3px;
}
.pagination a:hover {
    color: var(--accent);
    border-color: var(--accent);
}
.page-number { color: var(--fg-dimmer); }

/* ============ ERROR ============ */
.error {
    text-align: center;
    padding: 4rem 0;
}
.error-art {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.2;
    display: inline-block;
    text-align: left;
}
.error-title {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    color: var(--fg);
    margin: 1.5rem 0 0.5rem;
}
.error-desc { color: var(--fg-dim); }
.error-link {
    display: inline-block;
    margin-top: 1.5rem;
    font-family: var(--font-mono);
}

/* ============ FOOTER ============ */
.contact-links {
    display: flex;
    gap: 1.2rem;
    justify-content: center;
    padding: 0 0 1.25rem;
    border-bottom: 1px dashed var(--border);
    margin-bottom: 1.5rem;
}
.contact-links a {
    color: var(--fg-dim) !important;
    border: none !important;
    display: inline-flex;
    align-items: center;
    transition: color 0.15s;
}
.contact-links a:hover { color: var(--accent) !important; }
.contact-links svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    display: block;
}

.site-footer {
    border-top: 1px solid var(--border);
    padding: 2rem 1.5rem;
    max-width: var(--maxw-wide);
    margin: 0 auto;
    width: 100%;
}
.site-footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--fg-dimmer);
}
.footer-copy { margin: 0; }
.footer-meta a { color: var(--fg-dim); }
.footer-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 1rem;
}
.footer-nav a { color: var(--fg-dim); }

/* ============ RESPONSIVE ============ */
@media (max-width: 600px) {
    .post-title { font-size: 1.6rem; }
    .post-content { font-size: 1rem; }
    .post-content h2 { font-size: 1.4rem; }
    .post-content h3 { font-size: 1.15rem; }
    .post-content pre { font-size: 0.78rem; padding: 0.85rem 1rem; }
    .site-header { padding: 1.5rem 1rem 1rem; }
    .site-nav ul { gap: 1rem; }
    .container { padding: 0 1rem; }
}

/* ============ KG-CARDS (Ghost editor cards) ============ */
.kg-image-card { margin: 1.5rem 0; }
.kg-image-card figcaption {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--fg-dimmer);
    text-align: center;
    margin-top: 0.4rem;
}
.kg-width-wide { max-width: 100%; }
.kg-width-full { max-width: 100vw; margin-left: calc(-50vw + 50%); }
.kg-bookmark-card {
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-alt);
    padding: 1rem;
    margin: 1.5rem 0;
}
.kg-callout-card {
    background: var(--bg-alt);
    border-left: 3px solid var(--accent);
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    border-radius: 0 4px 4px 0;
}
.kg-toggle-card {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.75rem 1rem;
    margin: 1.5rem 0;
}
.kg-header-card {
    background: var(--bg-alt);
    padding: 2rem;
    border-radius: 4px;
    margin: 1.5rem 0;
}
