/* =============================================
   1tsprune — Blog Article Styles
   Dark navy/gold theme, Maland-inspired layout
   ============================================= */

:root {
    --bg: #0f1117;
    --surface: #1a1d28;
    --surface2: #222636;
    --line: #2a3040;
    --accent: #d8b57a;
    --accent-soft: rgba(216, 181, 122, 0.12);
    --accent-line: rgba(216, 181, 122, 0.25);
    --white: #eaedf4;
    --muted: #8b93a7;
    --muted2: #5e6680;
    --font: "Montserrat", sans-serif;
    --mono: "JetBrains Mono", monospace;
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--white);
    line-height: 1.7;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

::selection {
    background: var(--accent);
    color: #1a1206;
}

/* ── Article Container ─────────────────────── */
.article-wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 48px;
}

/* ── Top Bar ───────────────────────────────── */
.article-topbar {
    max-width: 960px;
    margin: 0 auto;
    padding: 14px 48px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.back-link {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: color 0.2s;
}
.back-link:hover {
    color: var(--accent);
    text-decoration: none;
}

/* ── Article Header ────────────────────────── */
.article-header {
    padding: 48px 0 32px;
}

.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.article-tag {
    font-family: var(--mono);
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid var(--accent-line);
    padding: 4px 14px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition:
        background 0.2s,
        border-color 0.2s;
}
.article-tag:hover {
    background: rgba(216, 181, 122, 0.2);
    border-color: var(--accent);
    text-decoration: none;
}

.article-title {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-bottom: 16px;
    color: var(--white);
}

.article-meta {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--muted2);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.article-meta .author {
    color: var(--accent);
    font-weight: 500;
}

.article-meta .sep {
    color: var(--line);
}

/* ── Cover Image ───────────────────────────── */
.article-cover {
    margin: 0 -24px 36px;
    border-radius: 0;
    overflow: hidden;
    border-bottom: 1px solid var(--line);
}

.article-cover img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 420px;
    object-fit: cover;
}

/* ── Prose Content ─────────────────────────── */
.prose {
    font-size: 1.125rem;
    line-height: 1.78;
    color: #c8cdd8;
}

.prose h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--white);
    margin: 44px 0 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
    letter-spacing: -0.01em;
}

.prose h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--white);
    margin: 36px 0 12px;
    letter-spacing: -0.01em;
}

.prose h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent);
    margin: 28px 0 10px;
}

.prose p {
    margin: 0 0 18px;
}

.prose strong {
    color: var(--white);
    font-weight: 600;
}

.prose em {
    color: var(--muted);
}

.prose a {
    color: var(--accent);
    border-bottom: 1px solid var(--accent-line);
    transition: border-color 0.2s;
}
.prose a:hover {
    border-color: var(--accent);
    text-decoration: none;
}

.prose ul,
.prose ol {
    margin: 0 0 18px 24px;
}

.prose li {
    margin-bottom: 6px;
}

.prose li::marker {
    color: var(--accent);
}

/* ── Blockquote ────────────────────────────── */
.prose blockquote {
    border-left: 3px solid var(--accent);
    background: var(--surface);
    padding: 16px 22px;
    margin: 24px 0;
    border-radius: 0 8px 8px 0;
    color: var(--muted);
    font-style: italic;
}

.prose blockquote p {
    margin: 0;
}

.prose blockquote strong {
    color: var(--accent);
    font-style: normal;
}

/* ── Code Inline ───────────────────────────── */
.prose code {
    font-family: var(--mono);
    font-size: 0.82rem;
    background: var(--surface2);
    color: var(--accent);
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid var(--line);
}

/* ── Code Block ────────────────────────────── */
.code-block {
    position: relative;
    margin: 28px 0;
    border-radius: 10px;
    overflow-x: auto;
    border: 1px solid var(--line);
    background: #0d1117;
}

.code-block__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--surface2);
    border-bottom: 1px solid var(--line);
    font-family: var(--mono);
    font-size: 0.66rem;
}

.code-block__lang {
    color: var(--muted2);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.code-block__copy {
    font-family: var(--mono);
    font-size: 0.64rem;
    font-weight: 600;
    color: var(--muted2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 3px;
    transition:
        color 0.15s,
        background 0.15s;
}
.code-block__copy:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

.code-block pre {
    margin: 0;
    padding: 18px 20px;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 0.8rem;
    line-height: 1.65;
    color: #c9d1d9;
    background: #0d1117;
}

.code-block pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
    color: inherit;
}

/* Syntax token styles */
.code-block .kw {
    color: #ff7b72;
} /* keyword */
.code-block .fn {
    color: #d2a8ff;
} /* function */
.code-block .str {
    color: #a5d6ff;
} /* string */
.code-block .cm {
    color: #8b949e;
    font-style: italic;
} /* comment */
.code-block .var {
    color: #ffa657;
} /* variable */
.code-block .op {
    color: #ff7b72;
} /* operator */
.code-block .num {
    color: #79c0ff;
} /* number */
.code-block .type {
    color: #ffa657;
} /* type */

/* ── Image Wrapper ─────────────────────────── */
.img-wrap {
    margin: 32px 0;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--surface);
}

.img-wrap img {
    width: 100%;
    height: auto;
    max-height: 520px;
    object-fit: contain;
    display: block;
    cursor: zoom-in;
    transition: transform 0.4s;
}
.img-wrap img:hover {
    transform: scale(1.008);
}

.img-wrap__caption {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--muted2);
    padding: 10px 16px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-top: 1px solid var(--line);
    background: var(--surface2);
}

/* ── Divider ───────────────────────────────── */
.prose hr {
    border: none;
    border-top: 1px solid var(--line);
    margin: 36px 0;
}

/* ── Callout Box ───────────────────────────── */
.callout {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    padding: 18px 22px;
    margin: 28px 0;
}

.callout__title {
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.callout p {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

/* ── Article Footer ────────────────────────── */
.article-footer {
    margin: 56px 0 40px;
    padding: 28px 0 0;
    border-top: 1px solid var(--line);
}

.article-footer__label {
    font-family: var(--mono);
    font-size: 0.64rem;
    color: var(--muted2);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.article-footer__author {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--white);
}

.article-footer__bio {
    font-size: 0.88rem;
    color: var(--muted);
    margin-top: 4px;
}

/* ── More Posts ────────────────────────────── */
.more-posts {
    margin: 48px 0 64px;
}

.more-posts__title {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 18px;
}

.more-posts__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.more-post-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 18px;
    transition:
        border-color 0.2s,
        transform 0.2s;
    text-decoration: none;
    display: block;
}
.more-post-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    text-decoration: none;
}

.more-post-card__date {
    font-family: var(--mono);
    font-size: 0.62rem;
    color: var(--muted2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.more-post-card h4 {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--white);
    line-height: 1.35;
}

/* ── Image Lightbox ────────────────────────── */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.94);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    cursor: zoom-out;
}

.lightbox img {
    max-width: 95vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* ── Responsive ────────────────────────────── */
/* ── Reading Progress Bar ──────────────────── */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #f0c060);
    z-index: 9999;
    width: 0%;
    transition: width 0.15s linear;
    box-shadow: 0 0 8px rgba(216, 181, 122, 0.4);
}

/* ── Table of Contents Toggle ──────────────── */
.toc-toggle {
    position: fixed;
    right: 24px;
    bottom: 32px;
    z-index: 200;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.toc-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: scale(1.05);
}
.toc-toggle svg {
    width: 20px;
    height: 20px;
}

/* ── TOC Sidebar ───────────────────────────── */
.toc-sidebar {
    position: fixed;
    right: -320px;
    top: 0;
    width: 300px;
    height: 100vh;
    z-index: 300;
    background: var(--surface);
    border-left: 1px solid var(--line);
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.4);
    transition: right 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.toc-sidebar.open {
    right: 0;
}

.toc-sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}
.toc-sidebar__title {
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--muted2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.toc-sidebar__close {
    background: none;
    border: none;
    color: var(--muted2);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.15s;
}
.toc-sidebar__close:hover {
    color: var(--accent);
}
.toc-sidebar__close svg {
    width: 18px;
    height: 18px;
}

.toc-sidebar__nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}
.toc-sidebar__nav a {
    display: block;
    padding: 6px 0;
    font-size: 0.82rem;
    color: var(--muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    padding-left: 12px;
    transition: all 0.15s;
    line-height: 1.4;
}
.toc-sidebar__nav a:hover,
.toc-sidebar__nav a.active {
    color: var(--accent);
    border-left-color: var(--accent);
}
.toc-sidebar__nav a.toc-h2 {
    padding-left: 16px;
    font-size: 0.78rem;
}
.toc-sidebar__nav a.toc-h3 {
    padding-left: 28px;
    font-size: 0.73rem;
}

.toc-sidebar__footer {
    border-top: 1px solid var(--line);
    padding: 12px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.toc-sidebar__footer button {
    font-family: var(--mono);
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--surface2);
    border: 1px solid var(--line);
    color: var(--muted);
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s;
}
.toc-sidebar__footer button:hover {
    color: var(--accent);
    border-color: var(--accent);
}
.toc-sidebar__divider {
    width: 100%;
    height: 1px;
    background: var(--line);
    margin: 4px 0;
}

/* ── TOC Overlay ───────────────────────────── */
.toc-overlay {
    position: fixed;
    inset: 0;
    z-index: 250;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.toc-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 640px) {
    .article-wrap {
        max-width: 100%;
        overflow-x: hidden;
        padding: 0 18px;
    }
    .article-title {
        font-size: 1.55rem;
    }
    .article-cover {
        margin: 0 -18px 28px;
    }
    .prose {
        font-size: 0.95rem;
    }
    .prose h1 {
        font-size: 1.35rem;
    }
    .prose h2 {
        font-size: 1.15rem;
    }
    .more-posts__grid {
        grid-template-columns: 1fr;
    }
    .toc-sidebar {
        width: 85vw;
        right: -85vw;
    }
}

/* ── Theme Toggle ──────────────────────────── */
.article-theme-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted2);
    padding: 2px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}
.article-theme-btn:hover {
    color: var(--accent);
}
.article-theme-btn svg {
    width: 16px;
    height: 16px;
}
.article-theme-btn .sun {
    display: none;
}
.article-theme-btn .moon {
    display: block;
}
html:not(.dark) .article-theme-btn .sun {
    display: block;
}
html:not(.dark) .article-theme-btn .moon {
    display: none;
}

/* ── Light Mode ────────────────────────────── */
html:not(.dark) {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --surface2: #e8e8e8;
    --line: #d4d4d4;
    --white: #1a1a1a;
    --muted: #555;
    --muted2: #888;
    --accent: #7c5e10;
    --accent-soft: rgba(124, 94, 16, 0.08);
    --accent-line: rgba(124, 94, 16, 0.3);
}
html:not(.dark) body {
    background: var(--bg);
    color: var(--white);
}
html:not(.dark) .article-topbar {
    background: rgba(245, 245, 245, 0.88);
    border-bottom-color: var(--line);
}
html:not(.dark) .back-link {
    color: var(--muted);
}
html:not(.dark) .prose {
    color: #333;
}
html:not(.dark) .prose h1 {
    color: #1a1a1a;
    border-bottom-color: var(--line);
}
html:not(.dark) .prose h2 {
    color: #1a1a1a;
}
html:not(.dark) .prose h3 {
    color: var(--accent);
}
html:not(.dark) .code-block {
    background: #f0f0f0;
    border-color: #d4d4d4;
}
html:not(.dark) .code-block pre {
    background: #f0f0f0;
    color: #333;
}
html:not(.dark) .code-block__header {
    background: #e8e8e8;
    border-bottom-color: #d4d4d4;
}
html:not(.dark) .callout {
    background: #fff;
    border-color: #d4d4d4;
}
html:not(.dark) .callout p {
    color: #555;
}
html:not(.dark) .img-wrap {
    background: #fff;
    border-color: #d4d4d4;
}
html:not(.dark) ::selection {
    background: var(--accent);
    color: #fff;
}
.scroll-btn {
    position: fixed;
    right: 20px;
    z-index: 150;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--muted);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.scroll-btn:hover {
    color: var(--accent);
    border-color: var(--accent-line);
}
.scroll-top {
    bottom: 90px;
}
.scroll-btm {
    bottom: 44px;
}
.article-wrap {
    padding-bottom: 60px;
}
.prose-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--mono);
    font-size: 0.76rem;
    margin: 0;
}
.prose-table thead {
    border-bottom: 2px solid var(--accent);
}
.prose-table th {
    padding: 10px 14px;
    text-align: left;
    color: var(--accent);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.prose-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    vertical-align: top;
}
.prose-table tr:last-child td {
    border-bottom: none;
}
.prose-table td:first-child {
    color: var(--white);
    font-weight: 600;
    white-space: nowrap;
}
@media (max-width: 640px) {
    .prose-table {
        font-size: 0.68rem;
    }
    .prose-table th,
    .prose-table td {
        padding: 8px 10px;
    }
    .code-block {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}
body {
    max-width: 100vw;
    overflow-x: hidden;
}
.prose {
    word-break: break-word;
    overflow-wrap: break-word;
}
.prose pre {
    white-space: pre-wrap;
    word-break: break-all;
    overflow-x: auto;
    max-width: 100%;
}
@media (max-width: 640px) {
    .code-block {
        max-width: 100%;
    }
    .code-block pre {
        white-space: pre;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: calc(100vw - 36px);
    }
    img {
        max-width: 100%;
        height: auto;
    }
}

/* Image Modal (Maland zoom) */
.image-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.92);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 32px;
    cursor: zoom-out;
}
.image-modal.open {
    display: flex;
}
.image-modal__inner {
    position: relative;
    max-width: 90vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.image-modal__inner img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.image-modal__caption {
    margin-top: 12px;
    font-family: var(--mono);
    font-size: 0.62rem;
    color: var(--muted2);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.image-modal__close {
    position: absolute;
    top: -28px;
    right: 0;
    background: none;
    border: none;
    color: var(--muted2);
    font-family: var(--mono);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: color 0.2s;
}
.image-modal__close:hover {
    color: #fff;
}
