/* ========================================
   BLOG POST STYLES - Optimized with Enhanced Code Blocks
   ======================================== */

/* Post Container */
.post-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 100px 20px 60px;
}

/* Post Content Wrapper */
.post-content-wrapper {
    min-width: 0;
}

/* Back to Blog Button */
.back-to-blog {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 400;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.3s ease;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
}

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

/* Post Header */
.post-header {
    margin-bottom: 50px;
    text-align: center;
}

/* Header Top */
.post-header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 30px;
}

/* Post Date Badge */
.post-date-badge {
    display: inline-flex;
    align-items: center;
    gap: 0;
    font-size: 16px;
    color: var(--gray);
    font-weight: 500;
    margin: 0;
}

/* Post Title */
.post-title {
    font-size: 42px;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1.2;
    margin-bottom: 30px;
    text-align: center;
}

/* Post Divider */
.post-divider {
    width: 100%;
    height: 1px;
    background: var(--border);
    margin-bottom: 40px;
}

/* Post Featured Image */
.post-featured-image {
    width: 100%;
    height: auto;
    margin: 40px 0;
    display: block;
}

/* Post Content */
.post-content {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-color);
}

.post-content h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-color);
    margin-top: 40px;
    margin-bottom: 16px;
    line-height: 1.3;
}

.post-content h3 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-color);
    margin-top: 32px;
    margin-bottom: 14px;
    line-height: 1.3;
}

.post-content p {
    margin-bottom: 20px;
    color: var(--gray);
    line-height: 1.6;
}

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

.post-content em {
    font-style: italic;
    color: var(--gray);
}

.post-content a {
    color: var(--link);
    text-decoration: underline;
    transition: color 0.3s ease;
}

.post-content a:hover {
    color: var(--link-hover-bg);
}

/* Lists */
.post-content ul,
.post-content ol {
    margin-bottom: 20px;
    padding-left: 24px;
}

.post-content li {
    margin-bottom: 8px;
    color: var(--gray);
    line-height: 1.6;
}


/* Professional Code Blocks */
.code-block {
    position: relative;
    margin: 32px 0;
    border-radius: 8px;
    overflow: hidden;
    background: #1e1e1e;
    border: 1px solid #333;
}

.code-block .copy-button {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #eeeeee;
    border: 1px solid #404040;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    font-size: 13px;
    font-weight: 500;
    min-width: 60px;
    height: 32px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.code-block .copy-button:hover {
    background: #3a3a3a;
    border-color: #505050;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.code-block .copy-button:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.code-block .copy-button.copied {
    background: #22c55e;
    border-color: #16a34a;
    color: #ffffff;
}

.code-block .copy-button.copied:hover {
    background: #16a34a;
    border-color: #15803d;
}

.code-block pre {
    margin: 0;
    padding: 20px;
    padding-right: 100px; /* Make space for copy button */
    background: #1e1e1e;
    border: none;
    border-radius: 0;
    overflow-x: auto;
    font-size: 14px;
    line-height: 1.5;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Consolas', 'Fira Code', monospace;
    user-select: text; /* Enable text selection */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

.code-block code {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    color: #d4d4d4 !important;
    font-family: inherit;
    font-size: 14px;
    white-space: pre;
    user-select: text; /* Enable text selection */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

/* Legacy code styles for inline code */
.post-content code:not(.code-block code) {
    background: var(--box-color);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: var(--link);
}

.post-content pre:not(.code-block pre) {
    background: var(--box-color);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 20px;
}

.post-content pre:not(.code-block pre) code {
    background: transparent;
    border: none;
    padding: 0;
    color: var(--text-color);
    font-size: 13px;
}

/* GitHub Discussion Section */
.post-discussion {
    margin: 0 auto;
    padding: 0;
}

/* Discussion Toggle Button */
.discussion-toggle {
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 20px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--box-color);
    user-select: none;
    max-width: 500px;
    margin: 0 auto;
}

.discussion-toggle:hover {
    border-color: var(--link);
    background: rgba(24, 119, 242, 0.03);
}

.discussion-toggle.active {
    border-color: var(--link);
    background: rgba(24, 119, 242, 0.05);
}

.discussion-toggle-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    line-height: 1.2;
}

.discussion-icon {
    margin-right: 10px;
    font-size: 18px;
}

.toggle-arrow {
    font-size: 14px;
    transition: transform 0.3s ease;
    color: var(--link);
    font-weight: bold;
}

.discussion-toggle-subtitle {
    font-size: 14px;
    color: var(--gray);
    margin: 6px 0 0 28px;
    line-height: 1.4;
}

/* Discussion Content */
.discussion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out, padding 0.3s ease;
    padding: 0;
}

.discussion-content.open {
    max-height: 2000px;
    padding: 30px 0 0 0;
}

.discussion-content-inner {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 20px;
}

.discussion-subtitle {
    font-size: 16px;
    color: var(--gray);
    margin-bottom: 30px;
    line-height: 1.5;
    text-align: center;
}

.giscus-container {
    max-width: 100%;
    margin: 0 auto;
}

/* Post Footer */
.post-footer {
    margin-top: 50px;
    padding-top: 30px;
    border-top: 1px solid var(--border);
    background: transparent;
}

.post-footer-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 60px;
    width: 100%;
}

/* Author Section */
.post-author {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
    margin-left: 0;
    padding-left: 0;
}

.author-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.author-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.author-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.author-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

.author-email {
    font-size: 14px;
    color: var(--link);
    text-decoration: none;
}

.author-email:hover {
    text-decoration: underline;
}

/* Tags Section */
.post-tags {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 1 1 auto;
    margin: 0;
    padding: 0;
}

.tags-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
}

.tag {
    font-size: 12px;
    font-weight: 500;
    color: var(--link);
    background: transparent;
    border: none;
    padding: 2px 4px;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    border-radius: 4px;
}

.tag:hover {
    background: rgba(24, 119, 242, 0.1);
    color: var(--link);
    transform: translateY(-1px);
    text-decoration: none;
}

/* Dark Mode Adjustments */
.dark-Mode .post-divider {
    background: #333;
}

.dark-Mode .post-footer {
    border-color: #333;
}

.dark-Mode .discussion-toggle {
    background: var(--black-box);
    border-color: #333;
}

.dark-Mode .discussion-toggle:hover {
    border-color: var(--link);
    background: rgba(24, 119, 242, 0.08);
}

.dark-Mode .discussion-toggle.active {
    border-color: var(--link);
    background: rgba(24, 119, 242, 0.12);
}

.dark-Mode .post-content code:not(.code-block code),
.dark-Mode .post-content pre:not(.code-block pre) {
    background: var(--black-box);
    border-color: #333;
}

.dark-Mode .code-block {
    background: #1e1e1e;
    border-color: #333;
}

.dark-Mode .code-block pre {
    background: #1e1e1e;
}

.dark-Mode .code-block .copy-button {
    background: #2d2d2d;
    border-color: #404040;
    color: #e0e0e0;
}

.dark-Mode .code-block .copy-button:hover {
    background: #3a3a3a;
    border-color: #505050;
    color: #ffffff;
}

.dark-Mode .code-block .copy-button.copied {
    background: #22c55e;
    border-color: #16a34a;
    color: #ffffff;
}

.dark-Mode .code-block .copy-button.copied:hover {
    background: #16a34a;
    border-color: #15803d;
}



/* Responsive Design */

/* Tablet */
@media (width <= 1024px) {
    .post-container {
        padding: 90px 30px 50px;
    }

    .post-title {
        font-size: 38px;
    }

    .post-content h2 {
        font-size: 26px;
    }

    .post-content h3 {
        font-size: 20px;
    }

    .post-footer-content {
        gap: 30px;
    }


}

/* Mobile */
@media (width <= 768px) {
    .post-container {
        padding: 80px 20px 40px;
    }

    .post-header-top {
        gap: 10px;
        margin-bottom: 24px;
    }

    .back-to-blog {
        font-size: 20px;
    }

    .post-date-badge {
        font-size: 14px;
    }

    .post-title {
        font-size: 32px;
        margin-bottom: 24px;
    }

    .post-divider {
        margin-bottom: 32px;
    }

    .post-content {
        font-size: 15px;
    }

    .post-content h2 {
        font-size: 24px;
        margin-top: 32px;
    }

    .post-content h3 {
        font-size: 20px;
        margin-top: 28px;
    }

    .post-featured-image {
        margin: 32px 0;
    }

    .code-block {
        margin: 24px 0;
        border-radius: 6px;
    }

    .code-block .copy-button {
        top: 8px;
        right: 8px;
        padding: 6px 10px;
        font-size: 12px;
        min-width: 50px;
        height: 28px;
    }

    .code-block pre {
        padding: 16px;
        padding-right: 80px; /* Adjust for smaller copy button */
        font-size: 13px;
    }

    .code-block code {
        font-size: 13px;
    }

    /* Discussion Section Mobile */
    .discussion-toggle {
        padding: 16px;
        max-width: 100%;
        margin: 0;
    }

    .discussion-toggle-title {
        font-size: 18px;
    }

    .discussion-icon {
        margin-right: 8px;
        font-size: 16px;
    }

    .discussion-toggle-subtitle {
        font-size: 13px;
        margin-left: 24px;
    }

    .discussion-content-inner {
        padding: 0 10px;
    }

    .discussion-subtitle {
        font-size: 15px;
        margin-bottom: 24px;
        padding: 0 10px;
    }

    /* Stack Author and Tags Vertically on Mobile */
    .post-footer-content {
        flex-direction: column;
        gap: 24px;
        align-items: flex-start;
    }

    .post-author {
        align-self: flex-start;
        margin-left: 0;
        padding-left: 0;
    }

    .post-tags {
        align-items: flex-start;
        align-self: flex-start;
        margin: 0;
        padding: 0;
    }

    .tags-row {
        justify-content: flex-start;
        gap: 10px;
    }
}

@media (width <= 480px) {
    .post-container {
        padding: 80px 16px 30px;
    }

    .post-header-top {
        gap: 8px;
        margin-bottom: 20px;
    }

    .back-to-blog {
        font-size: 18px;
    }

    .post-date-badge {
        font-size: 13px;
    }

    .post-title {
        font-size: 28px;
        margin-bottom: 20px;
    }

    .post-divider {
        margin-bottom: 28px;
    }

    .post-content {
        font-size: 14px;
    }

    .post-content h2 {
        font-size: 22px;
    }

    .post-content h3 {
        font-size: 18px;
    }



    .code-block .copy-button {
        padding: 4px 8px;
        top: 6px;
        right: 6px;
        font-size: 11px;
        min-width: 45px;
        height: 26px;
    }

    .code-block pre {
        padding: 14px;
        padding-right: 70px; /* Adjust for smallest copy button */
        font-size: 12px;
    }

    .code-block code {
        font-size: 12px;
    }

    /* Discussion Section Small Mobile */
    .discussion-toggle {
        padding: 14px;
    }

    .discussion-toggle-title {
        font-size: 17px;
    }

    .discussion-icon {
        margin-right: 6px;
        font-size: 15px;
    }

    .discussion-toggle-subtitle {
        font-size: 12px;
        margin-left: 21px;
    }

    .discussion-content-inner {
        padding: 0 8px;
    }

    .discussion-subtitle {
        font-size: 14px;
        margin-bottom: 20px;
        padding: 0 8px;
    }

    .post-footer-content {
        gap: 20px;
    }

    .author-avatar {
        width: 40px;
        height: 40px;
    }

    .author-name {
        font-size: 15px;
    }

    .author-email {
        font-size: 13px;
    }

    .tag {
        font-size: 11px;
    }
}

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

.post-header,
.post-featured-image,
.post-content,
.post-discussion,
.post-footer {
    animation: fadeInUp 0.6s ease-out;
}

.post-featured-image {
    animation-delay: 0.1s;
}

.post-content {
    animation-delay: 0.2s;
}

.post-discussion {
    animation-delay: 0.3s;
}

.post-footer {
    animation-delay: 0.4s;
}