/* ===================================================
   Monochrome Geek Theme — Black & White
   =================================================== */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ===================================================
   CSS Variables — Light (paper) & Dark (terminal)
   =================================================== */
:root {
    --bg-page:       #ffffff;
    --bg-sidebar:    #fafafa;
    --bg-section:    #ffffff;
    --bg-footer:     #fafafa;
    --border:        #000000;
    --border-light:  #cccccc;
    --text-primary:  #000000;
    --text-secondary:#1a1a1a;
    --text-muted:    #444444;
    --text-faint:    #888888;
    --text-inverted: #ffffff;
    --accent:        #000000;
    --accent-hover:  #333333;
    --accent-light:  #f0f0f0;
    --nav-hover-bg:  #e5e5e5;
    --code-bg:       #f5f5f5;
    --code-text:     #000000;
    --scroll-bar:    #999999;
    --tag-bg:        #000000;
    --tag-text:      #ffffff;
}

html.dark {
    --bg-page:       #0a0a0a;
    --bg-sidebar:    #111111;
    --bg-section:    #111111;
    --bg-footer:     #111111;
    --border:        #444444;
    --border-light:  #2a2a2a;
    --text-primary:  #e0e0e0;
    --text-secondary:#cccccc;
    --text-muted:    #999999;
    --text-faint:    #666666;
    --text-inverted: #000000;
    --accent:        #ffffff;
    --accent-hover:  #cccccc;
    --accent-light:  #1a1a1a;
    --nav-hover-bg:  #222222;
    --code-bg:       #1a1a1a;
    --code-text:     #e0e0e0;
    --scroll-bar:    #555555;
    --tag-bg:        #ffffff;
    --tag-text:      #000000;
}

/* ===================================================
   Base Reset & Body
   =================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', Courier, monospace;
    line-height: 1.6;
    color: var(--text-secondary);
    background: var(--bg-page);
    min-height: 100vh;
    font-size: 13px;
    transition: background 0.2s ease, color 0.2s ease;
}

/* ===================================================
   Layout
   =================================================== */
.layout {
    display: flex;
    min-height: calc(100vh - 44px);
}

/* ===================================================
   Sidebar
   =================================================== */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 2px solid var(--border);
    padding: 1.6rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: calc(100vh - 44px);
    transition: width 0.25s ease, background 0.2s ease, border-color 0.2s ease, padding 0.25s ease;
    overflow: hidden;
}

/* ===================================================
   Theme toggle — fixed top-right corner
   =================================================== */
.theme-toggle {
    position: fixed;
    top: 0.7rem;
    right: 0.9rem;
    z-index: 1000;
    background: var(--bg-section);
    border: 2px solid var(--border);
    width: 34px;
    height: 34px;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    color: var(--text-primary);
    line-height: 1;
    padding: 0;
}

.theme-toggle:hover {
    background: var(--text-primary);
    color: var(--text-inverted);
}

/* Sidebar collapse toggle */
.sidebar-toggle {
    position: absolute;
    top: 0.9rem;
    right: 0.9rem;
    background: none;
    border: 2px solid var(--border);
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    color: var(--text-primary);
    line-height: 1;
    padding: 0;
}

.sidebar-toggle:hover {
    background: var(--text-primary);
    color: var(--text-inverted);
}

/* ===================================================
   Sidebar collapsed state
   =================================================== */
.sidebar.collapsed {
    width: 50px;
    padding: 1.6rem 0.4rem 1rem;
}

.sidebar.collapsed .profile,
.sidebar.collapsed nav,
.sidebar.collapsed .contact-links-sidebar {
    display: none;
}

.sidebar.collapsed .sidebar-toggle {
    position: static;
    margin: 0 auto;
}

.sidebar.collapsed + .content {
    margin-left: 50px;
}

/* Profile / Avatar */
.profile {
    text-align: center;
    margin-bottom: 1.6rem;
    padding-top: 0.4rem;
}

.avatar {
    display: inline-block;
    margin-bottom: 0.7rem;
    line-height: 0;
    color: var(--text-primary);
    transition: color 0.2s ease;
}

.avatar svg {
    filter: none;
}

.profile h1 {
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    transition: color 0.2s ease;
}

.profile h1::before {
    content: '> ';
    font-weight: 400;
    color: var(--text-faint);
}

.profile .tagline {
    font-size: 0.75rem;
    color: var(--text-faint);
    font-weight: 400;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: color 0.2s ease;
}

/* Navigation */
nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 0.5rem 0.8rem;
    font-size: 0.82rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
    position: relative;
}

.nav-link::before {
    content: '$ ';
    color: var(--text-faint);
    font-weight: 400;
}

.nav-link:hover {
    background: var(--nav-hover-bg);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent);
    color: var(--text-inverted);
}

.nav-link.active::before {
    color: var(--text-inverted);
    opacity: 0.7;
}

/* Sidebar contact links */
.contact-links-sidebar {
    margin-top: auto;
    display: flex;
    gap: 0.4rem;
    justify-content: center;
    padding-top: 1rem;
    border-top: 2px solid var(--border);
    transition: border-color 0.2s ease;
}

.contact-links-sidebar a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 0.3rem 0.65rem;
    border: 2px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.contact-links-sidebar a:hover {
    background: var(--accent);
    color: var(--text-inverted);
    border-color: var(--accent);
}

/* ===================================================
   Main Content
   =================================================== */
.content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    max-width: 800px;
    transition: margin-left 0.25s ease;
}

/* ===================================================
   Sections — sharp border style
   =================================================== */
section {
    background: var(--bg-section);
    padding: 1.5rem;
    margin-bottom: 1.2rem;
    border: 2px solid var(--border);
    transition: background 0.2s ease, border-color 0.2s ease;
}

section h2 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--border);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    transition: color 0.2s ease, border-color 0.2s ease;
}

section h2::before {
    content: '## ';
    color: var(--text-faint);
    font-weight: 400;
}

/* ===================================================
   Fade-in animation (IntersectionObserver)
   =================================================== */
.fade-section {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.fade-section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===================================================
   About section
   =================================================== */
.about-content p {
    margin-bottom: 0.8rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.7;
    transition: color 0.2s ease;
}

/* ===================================================
   Posts list
   =================================================== */
.posts-list article {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px dashed var(--border-light);
    transition: border-color 0.2s ease;
}

.posts-list article:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.posts-list h3 {
    margin-bottom: 0.35rem;
    font-size: 0.92rem;
}

.posts-list h3::before {
    content: '▸ ';
    font-size: 0.7rem;
    color: var(--text-faint);
}

.posts-list a {
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
    transition: color 0.15s ease, background 0.15s ease;
    cursor: pointer;
}

.posts-list a:hover {
    background: var(--accent);
    color: var(--text-inverted);
}

.posts-list p {
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    font-size: 0.8rem;
    transition: color 0.2s ease;
}

.date {
    color: var(--text-faint);
    font-size: 0.72rem;
    transition: color 0.2s ease;
}

.date::before {
    content: '[';
    font-weight: 700;
}
.date::after {
    content: ']';
    font-weight: 700;
}

/* ===================================================
   Contact section
   =================================================== */
#contact .contact-links {
    display: flex;
    gap: 0.8rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

#contact .contact-links a {
    text-decoration: none;
    color: var(--tag-text);
    background: var(--tag-bg);
    padding: 0.45rem 1.1rem;
    border: 2px solid var(--tag-bg);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

#contact .contact-links a:hover {
    background: transparent;
    color: var(--text-primary);
}

#contact > p {
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: color 0.2s ease;
}

/* ===================================================
   Loading / Error states
   =================================================== */
.loading,
.error {
    text-align: center;
    color: var(--text-muted);
    padding: 1.5rem;
    font-size: 0.85rem;
}

.loading::after {
    content: '_';
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

.error {
    border: 2px solid #000;
    background: #fff;
    color: #000;
    font-weight: 600;
}

html.dark .error {
    border-color: #fff;
    background: #000;
    color: #fff;
}

/* ===================================================
   Footer
   =================================================== */
footer {
    text-align: center;
    padding: 0.7rem;
    color: var(--text-faint);
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    border-top: 2px solid var(--border);
    background: var(--bg-footer);
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

footer p::before {
    content: '[ ';
}
footer p::after {
    content: ' ]';
}

/* ===================================================
   Article View
   =================================================== */
.article-view {
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.article-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 2px solid var(--border);
}

.back-btn {
    background: none;
    border: 2px solid var(--border);
    color: var(--text-secondary);
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.back-btn:hover {
    background: var(--accent);
    color: var(--text-inverted);
    border-color: var(--accent);
}

.article-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    border: none;
    flex: 1;
    transition: color 0.2s ease;
}

.article-body {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.8;
    transition: color 0.2s ease;
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-bar) transparent;
}

.article-body::-webkit-scrollbar {
    width: 4px;
}

.article-body::-webkit-scrollbar-track {
    background: transparent;
}

.article-body::-webkit-scrollbar-thumb {
    background-color: var(--scroll-bar);
}

/* Rendered Markdown styles inside article */
.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 {
    color: var(--text-primary);
    margin-top: 1.4rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.3px;
    transition: color 0.2s ease;
}

.article-body h1 { font-size: 1.35rem; }
.article-body h1::before { content: '# '; color: var(--text-faint); font-weight: 400; }
.article-body h2 { font-size: 1.1rem; padding-bottom: 0.25rem; border-bottom: 2px solid var(--border); }
.article-body h2::before { content: '## '; color: var(--text-faint); font-weight: 400; }
.article-body h3 { font-size: 0.98rem; }
.article-body h3::before { content: '### '; color: var(--text-faint); font-weight: 400; }
.article-body h4 { font-size: 0.9rem; }
.article-body h4::before { content: '#### '; color: var(--text-faint); font-weight: 400; }

.article-body p {
    margin-bottom: 0.85rem;
}

.article-body a {
    color: var(--text-primary);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    transition: color 0.15s ease, background 0.15s ease;
}

.article-body a:hover {
    background: var(--accent);
    color: var(--text-inverted);
}

.article-body ul,
.article-body ol {
    margin: 0.6rem 0 0.8rem 1.4rem;
}

.article-body li {
    margin-bottom: 0.3rem;
}

.article-body li::marker {
    color: var(--text-faint);
}

.article-body blockquote {
    border-left: 4px solid var(--border);
    padding: 0.4rem 0 0.4rem 1rem;
    margin: 0.8rem 0;
    color: var(--text-muted);
    background: var(--accent-light);
    font-style: italic;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* Inline code */
.article-body code {
    background: var(--code-bg);
    color: var(--code-text);
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', Courier, monospace;
    font-size: 0.85em;
    padding: 0.15em 0.4em;
    border: 1px solid var(--border-light);
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Code blocks */
.article-body pre {
    background: var(--code-bg);
    border: 2px solid var(--border);
    padding: 1rem 1.1rem;
    overflow-x: auto;
    margin: 0.8rem 0;
    font-size: 0.8rem;
    line-height: 1.6;
    transition: background 0.2s ease, border-color 0.2s ease;
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-bar) transparent;
}

.article-body pre code {
    background: none;
    padding: 0;
    border: none;
    font-size: inherit;
    color: var(--code-text);
}

.article-body hr {
    border: none;
    border-top: 2px solid var(--border);
    margin: 1.2rem 0;
    transition: border-color 0.2s ease;
}

.article-body img {
    max-width: 100%;
    border: 2px solid var(--border);
}

.article-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.8rem 0;
    font-size: 0.84rem;
}

.article-body th,
.article-body td {
    border: 2px solid var(--border);
    padding: 0.45rem 0.8rem;
    text-align: left;
    transition: border-color 0.2s ease;
}

.article-body th {
    background: var(--accent);
    color: var(--text-inverted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.78rem;
}

/* ===================================================
   Responsive — Mobile
   =================================================== */
@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 2px solid var(--border);
        padding: 0.9rem 1rem;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .sidebar-toggle {
        display: none;
    }

    .sidebar.collapsed {
        width: 100%;
        padding: 0.9rem 1rem;
    }

    .sidebar.collapsed .profile {
        display: flex;
    }

    .sidebar.collapsed nav {
        display: flex;
    }

    .sidebar.collapsed .contact-links-sidebar {
        display: none;
    }

    .sidebar.collapsed + .content {
        margin-left: 0;
    }

    .profile {
        margin-bottom: 0;
        text-align: left;
        display: flex;
        align-items: center;
        gap: 0.6rem;
    }

    .profile h1::before {
        content: '';
    }

    .avatar svg {
        width: 36px;
        height: 36px;
    }

    .profile h1 {
        font-size: 1.05rem;
    }

    .profile .tagline {
        display: none;
    }

    nav {
        flex-direction: row;
        gap: 0.2rem;
        flex-wrap: wrap;
    }

    .nav-link {
        padding: 0.3rem 0.6rem;
        font-size: 0.78rem;
    }

    .nav-link::before {
        content: '';
    }

    .contact-links-sidebar {
        display: none;
    }

    .content {
        margin-left: 0;
        padding: 1rem;
    }

    section {
        padding: 1rem;
    }

    section h2::before {
        content: '';
    }

    .article-body h1::before,
    .article-body h2::before,
    .article-body h3::before,
    .article-body h4::before {
        content: '';
    }
}
