/* Individual post styles */

/* Override main site overflow hidden */
body {
    overflow: auto !important;
    height: auto !important;
    position: static !important;
}

html {
    overflow: auto !important;
    height: auto !important;
}

.post-container {
    min-height: 100vh;
    background: var(--bg);
    padding: 2rem 1.5rem;
    max-width: 720px;
    margin: 0 auto;
}

/* Post Header */
.post-header {
    margin-bottom: 3rem;
    animation: fadeIn 0.8s ease;
}

.post-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: var(--glass-hover);
    transform: translateX(-2px);
}

.nav-link svg {
    width: 16px;
    height: 16px;
}

.post-nav .theme-toggle {
    width: 40px;
    height: 40px;
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.post-nav .theme-toggle:hover {
    background: var(--glass-hover);
}

.post-nav .theme-toggle svg {
    width: 16px;
    height: 16px;
    color: var(--text);
}

.post-header .post-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-dim);
}

.post-header .post-meta time {
    font-weight: 500;
}

.post-header h1 {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    color: var(--text);
}

.post-header .post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Post Content */
.post-content {
    font-size: 1.0625rem;
    line-height: 1.75;
    color: var(--text);
    margin-bottom: 3rem;
    animation: fadeIn 0.8s ease 0.2s both;
}

.post-content .lead {
    font-size: 1.3125rem;
    font-weight: 500;
    line-height: 1.6;
    margin-bottom: 2rem;
    color: var(--text);
}

.post-content p {
    margin-bottom: 1.5rem;
}

.post-content h2 {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.3;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    color: var(--text);
}

.post-content h3 {
    font-size: 1.375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.4;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.post-content strong {
    font-weight: 600;
    color: var(--text);
}

.post-content a {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: opacity 0.2s ease;
}

.post-content a:hover {
    opacity: 0.7;
}

.post-content blockquote {
    padding-left: 1.5rem;
    border-left: 3px solid var(--border);
    margin: 2rem 0;
    font-style: italic;
    color: var(--text-dim);
}

.post-content code {
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    padding: 0.2em 0.4em;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 4px;
}

.post-content pre {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    overflow-x: auto;
    margin: 2rem 0;
}

.post-content pre code {
    background: none;
    border: none;
    padding: 0;
}

.post-content ul,
.post-content ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.post-content li {
    margin-bottom: 0.5rem;
}

/* Share Section */
.post-share {
    padding: 2rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin-bottom: 3rem;
    animation: fadeIn 0.8s ease 0.4s both;
}

.share-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 1rem;
}

.share-buttons {
    display: flex;
    gap: 0.75rem;
}

.share-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.share-btn:hover {
    background: var(--glass-hover);
    transform: translateY(-2px);
}

.share-btn svg {
    width: 18px;
    height: 18px;
}

/* Post Footer */
.post-footer {
    text-align: center;
    padding: 2rem 0;
    animation: fadeIn 0.8s ease 0.6s both;
}

.back-to-blog {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.back-to-blog:hover {
    background: var(--glass-hover);
    transform: translateY(-2px);
}

/* Desktop */
@media (min-width: 1024px) {
    .post-container {
        padding: 3rem 2rem;
    }
    
    .post-header h1 {
        font-size: 2.75rem;
    }
    
    .post-content {
        font-size: 1.125rem;
    }
    
    .post-content .lead {
        font-size: 1.5rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .post-container {
        padding: 1.5rem 1rem;
    }
    
    .post-header h1 {
        font-size: 1.75rem;
    }
    
    .post-content {
        font-size: 1rem;
    }
    
    .post-content .lead {
        font-size: 1.125rem;
    }
    
    .post-content h2 {
        font-size: 1.5rem;
    }
    
    .post-content h3 {
        font-size: 1.25rem;
    }
    
    .nav-link span {
        display: none;
    }
    
    .nav-link {
        padding: 0.625rem;
    }
}

/* =========================
   Table of Contents + Layout
   ========================= */

/* Desktop: center content in viewport, place TOC on the left (standard) */
@media (min-width: 1280px) {
    .post-container {
        max-width: 720px;
        margin: 0 auto;
        padding-left: 2rem;
        padding-right: 2rem;
    }

    .toc-sidebar {
        position: fixed;
        left: 20px;
        top: 120px;
        width: 240px;
        max-height: calc(100vh - 180px);
        overflow-y: auto;
        padding: 20px;
        background: var(--glass);
        border-radius: 12px;
        border: 1px solid var(--border);
        z-index: 100;
    }

    .toc-header {
        font-weight: 600;
        margin-bottom: 0.5rem;
        color: var(--text);
    }

    .toc-list {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .toc-list .toc-link {
        display: block;
        padding: 0.5rem 0.25rem;
        color: var(--text-dim);
        text-decoration: none;
        border-radius: 6px;
    }

    .toc-list .toc-link:hover {
        color: var(--text);
        background: var(--glass-hover);
    }
    .toc-list .toc-link.active {
        color: var(--text);
        background: var(--glass-hover);
        font-weight: 600;
    }
}

/* Mobile TOC */
.toc-mobile { display: none; margin-bottom: 2rem; }
.toc-mobile-toggle {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding: 1rem 1.25rem; background: var(--glass);
    border: 1px solid var(--border); border-radius: 12px; font-weight: 600;
    color: var(--text); cursor: pointer;
}
.toc-mobile-toggle svg { width: 20px; height: 20px; transition: transform .3s ease; }
.toc-mobile-toggle.active svg { transform: rotate(180deg); }
.toc-mobile-content { max-height: 0; overflow: hidden; transition: max-height .3s ease; margin-top: .5rem; }
.toc-mobile-content.show { max-height: 600px; }
.toc-mobile-list { list-style: none; padding: 1rem; margin: 0; background: var(--glass); border: 1px solid var(--border); border-radius: 12px; }
.toc-mobile-list .toc-link { display: block; padding: .5rem .75rem; color: var(--text-dim); text-decoration: none; border-radius: 8px; }
.toc-mobile-list .toc-link:hover { color: var(--text); background: var(--glass-hover); }
.toc-mobile-list .toc-link.active { color: var(--text); background: var(--glass-hover); font-weight: 600; }

@media (max-width: 1279px) {
    .toc-sidebar { display: none; }
    .toc-mobile { display: block; }
}

/* Image grid for gallery */
.image-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.image-grid figure { margin: 0; }
.image-grid img { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border); background: var(--glass); }

/* Key-value tables */
.kv { width: 100%; border-collapse: collapse; margin: 1rem 0 0.5rem; }
.kv th, .kv td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.kv thead th { font-weight: 600; color: var(--text); }
.table-note { color: var(--text-dim); margin-top: 0.5rem; }

/* Anchor offset for in-page links */
h2[id] { scroll-margin-top: 100px; }

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

