/* Single Post Layout */
.single-post {
    padding-bottom: var(--space-shell-bottom);
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    min-width: 0;
}

.back-link {
    display: inline-block;
    color: var(--primary);
    text-decoration: none;
    margin-bottom: 2rem;
    font-weight: 500;
}

.back-link:hover { color: var(--primary-hover); }

.post-header {
    margin-bottom: 3rem;
    text-align: left;
    min-width: 0;
}

.post-hero-image {
    width: 100%;
    height: clamp(240px, 42vw, 450px);
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-bottom: 2.5rem;
    box-shadow: var(--shadow);
}

.post-header h1 { 
    font-size: clamp(2.1rem, 4.5vw, 3rem);
    margin: 1rem 0; 
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.post-meta {
    font-size: 0.9rem;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.meta-left {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 1rem;
    min-width: 0;
}

.post-meta-item {
    display: inline-flex;
    align-items: center;
    min-width: 0;
}

.post-updated {
    color: var(--muted);
}

.post-tags-container {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 3rem;
}

/* Post Content */
.post-content {
    font-size: 1.15rem;
    line-height: 1.8;
    color: var(--text);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: break-word;
}

.post-content > * {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.post-content > p,
.post-content > ul,
.post-content > ol,
.post-content > blockquote,
.post-content > h2,
.post-content > h3,
.post-content > h4,
.post-content > h5,
.post-content > h6 {
    max-width: none;
}

.post-content h2,
.post-content h3 {
    margin: 2rem 0 1rem;
    overflow-wrap: anywhere;
    scroll-margin-top: 6rem;
}

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

.post-content a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 0.16em;
    overflow-wrap: anywhere;
}

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

.post-content li + li {
    margin-top: 0.45rem;
}

.post-content li,
.post-content blockquote,
.post-content th,
.post-content td {
    overflow-wrap: anywhere;
}

.post-content blockquote {
    border-left: 4px solid var(--primary);
    padding: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    background: var(--bg-secondary);
    border-radius: 0 12px 12px 0;
    color: var(--muted);
}

.post-content img,
.post-content video {
    width: 100%;
    height: auto;
    border-radius: var(--radius-md);
}

.post-image {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 1.75rem 0;
}

.post-image figcaption {
    margin-top: 0.65rem;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.5;
    text-align: center;
}

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

.post-embed {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 1.75rem 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-secondary);
}

.post-embed iframe {
    display: block;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    border: none;
}

.post-table-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    margin: 1.5rem 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--card);
    -webkit-overflow-scrolling: touch;
}

.post-content table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.post-content th,
.post-content td {
    padding: 0.85rem 1rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

.post-content tr:last-child td {
    border-bottom: none;
}

.post-content th {
    font-weight: 700;
    background: var(--bg-secondary);
}

/* Code Blocks */
pre {
    background: #1e293b;
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 3.5rem 1.5rem 1.5rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 1.5rem 0;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
    scrollbar-gutter: stable;
}

code {
    font-family: 'Consolas', 'Monaco', monospace;
    background: rgba(128, 128, 128, 0.15);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--primary);
    overflow-wrap: anywhere;
    word-break: break-word;
}

pre code {
    display: block;
    min-width: max-content;
    max-width: none;
    background: transparent;
    padding: 0;
    color: #f8fafc;
    overflow-wrap: normal;
    word-break: normal;
}

.copy-code-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    min-height: 36px;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(248, 250, 252, 0.18);
    background: rgba(15, 23, 42, 0.82);
    color: #f8fafc;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    z-index: 2;
}

.copy-code-btn:hover,
.copy-code-btn:focus-visible {
    background: rgba(30, 41, 59, 0.96);
}

/* Interactions Group */
.interaction-group {
    display: flex;
    gap: 1.2rem;
    align-items: center;
    background: var(--bg-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
}

.stat { display: flex; align-items: center; gap: 0.5rem; }

.interaction-btn {
    background: transparent;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

.interaction-btn:hover { transform: scale(1.2); }
.interaction-btn.active { color: var(--primary); text-shadow: 0 0 10px rgba(99, 102, 241, 0.4); }
.interaction-count { font-weight: 700; font-size: 1.1rem; color: var(--muted); min-width: 1rem; text-align: center; }

@media (max-width: 760px) {
    .post-header {
        margin-bottom: 2.25rem;
    }

    .post-hero-image {
        height: clamp(200px, 54vw, 320px);
        margin-bottom: 1.75rem;
    }

    .post-meta {
        gap: 1rem;
        padding: 0.9rem 0 1rem;
    }

    .interaction-group {
        width: 100%;
        justify-content: center;
    }

    .post-tags-container {
        margin-bottom: 2.25rem;
    }

    .post-content {
        font-size: 1rem;
        line-height: 1.75;
    }

    .post-content h2 {
        font-size: 1.55rem;
    }

    .post-content h3 {
        font-size: 1.25rem;
    }

    .post-content blockquote {
        padding: 1rem 1rem 1rem 1.1rem;
    }

    .post-content img,
    .post-content video,
    .post-embed {
        margin: 1.25rem 0;
    }

    .post-table-scroll {
        margin: 1.25rem 0;
    }

    .post-content th,
    .post-content td {
        padding: 0.75rem 0.85rem;
        font-size: 0.95rem;
    }

    pre {
        margin: 1.25rem 0;
        padding: 3.1rem 1rem 1rem;
        border-radius: 16px;
    }

    pre code {
        font-size: 0.875rem;
    }

    .copy-code-btn {
        top: 0.65rem;
        right: 0.65rem;
        min-height: 34px;
        padding: 0.32rem 0.68rem;
    }
}

@media (max-width: 480px) {
    .back-link {
        margin-bottom: 1.4rem;
    }

    .post-header h1 {
        font-size: 1.95rem;
    }

    .post-meta {
        align-items: stretch;
    }

    .meta-left {
        gap: 0.35rem 0.8rem;
    }

    .interaction-group {
        padding: 0.5rem 0.75rem;
    }

    .stat {
        flex: 1;
        justify-content: center;
    }

    .post-content ul,
    .post-content ol {
        padding-left: 1.15rem;
    }

    code {
        font-size: 0.86em;
    }

    pre {
        padding-top: 2.95rem;
    }

}
