/* Blog show details page styling */

/* Override main layout constraints for full-width blog layout */
main {
    max-width: 1200px;
    padding: 40px 0 !important;
}

.blog-detail-container {
    width: 100%;
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

/* Section 1: Featured Image */
.blog-featured-img-container {
    width: 100%;
    margin-bottom: 40px;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.blog-featured-img {
    width: 100%;
    height: auto;
    display: block;
}

.blog-featured-img-placeholder {
    width: 100%;
    height: 350px;
    background-color: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
}

/* Section 2: Two Column Layout */
.blog-main-layout {
    display: grid;
    grid-template-columns: 7fr 3fr;
    gap: 40px;
    align-items: start;
    margin-bottom: 50px;
}

@media (max-width: 992px) {
    .blog-main-layout {
        grid-template-columns: 6.5fr 3.5fr;
        gap: 30px;
    }
}

@media (max-width: 768px) {
    .blog-detail-container {
        margin: 24px auto;
    }

    .blog-featured-img-container {
        margin-bottom: 24px;
        border-radius: 12px;
    }

    .blog-featured-img-placeholder {
        height: 220px;
        font-size: 44px;
    }

    .blog-main-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 30px;
    }

    .blog-main-title {
        font-size: 24px;
        line-height: 1.35;
        margin-bottom: 12px;
    }

    .blog-meta-info {
        gap: 6px 12px;
        font-size: 13px;
        margin-bottom: 24px;
        padding-bottom: 12px;
    }

    .blog-content-wrapper {
        font-size: 15px;
        line-height: 1.75;
    }

    .blog-content-wrapper h2 {
        font-size: 20px;
        margin-top: 28px;
        margin-bottom: 12px;
        scroll-margin-top: 100px;
    }

    .blog-content-wrapper h3 {
        font-size: 17px;
        margin-top: 22px;
        margin-bottom: 10px;
        scroll-margin-top: 100px;
    }

    .blog-content-wrapper h4 {
        font-size: 15px;
        margin-top: 18px;
        margin-bottom: 8px;
        scroll-margin-top: 100px;
    }

    .blog-content-wrapper img {
        margin: 20px 0;
        border-radius: 8px;
    }

    .editor-image {
        margin: 20px 0;
    }

    .editor-image img {
        border-radius: 8px;
    }

    /* Article Content Tables Responsive Behavior */
    .blog-content-wrapper .table-responsive {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        margin: 20px 0;
        border-radius: 8px;
        scrollbar-width: thin;
    }

    /* Fallback if a table has no .table-responsive wrapper */
    .blog-content-wrapper > table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        margin: 20px 0;
        scrollbar-width: thin;
    }

    .blog-content-wrapper table {
        width: 100%;
        min-width: 100%;
        border-collapse: collapse;
        font-size: 13px;
    }

    .blog-content-wrapper th,
    .blog-content-wrapper td {
        min-width: 130px;
        max-width: 320px;
        padding: 9px 12px;
        line-height: 1.5;
        vertical-align: top;
        word-break: normal;
    }
}

/* Left Column Content */
.blog-main-column {
    min-width: 0;
    max-width: 800px;
    width: 100%;
}

.blog-main-title {
    font-size: 32px;
    color: var(--primary);
    font-weight: 800;
    line-height: 1.3;
    margin-top: 0;
    margin-bottom: 15px;
    overflow-wrap: break-word;
    word-break: break-word;
}

.blog-meta-info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    color: #64748b;
    font-size: 14px;
    margin-bottom: 30px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 15px;
}

.meta-date-label {
    font-weight: 600;
    color: #475569;
}

.meta-date-value {
    color: #64748b;
}

.meta-separator {
    color: #cbd5e1;
    font-weight: 300;
}

.meta-written-by {
    font-weight: 600;
    color: #475569;
}

.meta-author-name {
    color: var(--accent);
    font-weight: 700;
}

.category-badge-inline {
    background-color: #fff2eb;
    color: var(--accent);
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 4px;
    text-transform: uppercase;
}

.blog-content-wrapper {
    min-width: 0;
    max-width: 100%;
    color: #334155;
    font-size: 16px;
    line-height: 1.8;
    overflow-wrap: break-word;
    word-break: break-word;
}

.blog-content-wrapper h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    margin-top: 35px;
    margin-bottom: 15px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 8px;
    scroll-margin-top: 160px;
}

.blog-content-wrapper h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    margin-top: 25px;
    margin-bottom: 12px;
    scroll-margin-top: 160px;
}

.blog-content-wrapper h4 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
    margin-top: 20px;
    margin-bottom: 10px;
    scroll-margin-top: 160px;
}

.blog-content-wrapper p {
    margin-bottom: 20px;
    margin-top: 0;
}

.blog-content-wrapper ul, .blog-content-wrapper ol {
    margin-bottom: 20px;
    padding-left: 24px;
}

.blog-content-wrapper li {
    margin-bottom: 8px;
}

.blog-content-wrapper strong, .blog-content-wrapper b {
    font-weight: 700;
    color: var(--primary);
}

.blog-content-wrapper a {
    color: var(--accent);
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.2s;
    overflow-wrap: break-word;
    word-break: break-word;
}

.blog-content-wrapper a:hover {
    color: var(--accent-hover);
}

.blog-content-wrapper blockquote {
    margin: 25px 0;
    padding: 15px 25px;
    border-left: 4px solid var(--accent);
    background-color: #f8fafc;
    color: #475569;
    font-style: italic;
    border-radius: 0 8px 8px 0;
}

.blog-content-wrapper table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 25px;
    margin-top: 15px;
    font-size: 14px;
}

.blog-content-wrapper th, .blog-content-wrapper td {
    border: 1px solid #cbd5e1;
    padding: 10px 14px;
    text-align: left;
}

.blog-content-wrapper th {
    background-color: #f8fafc;
    font-weight: 700;
    color: var(--primary);
}

.blog-content-wrapper tr:nth-child(even) {
    background-color: #fdfdfd;
}

/* Image styles inside article content */
.blog-content-wrapper img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 30px 0;
}

/* Table Responsive wrapper & Drag-Scroll styles */
.blog-content-wrapper .table-responsive {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    margin: 25px 0;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.blog-content-wrapper .table-responsive.can-drag {
    cursor: grab;
}

.blog-content-wrapper .table-responsive.is-dragging {
    cursor: grabbing;
    user-select: none;
    -webkit-user-select: none;
}

.blog-content-wrapper .table-responsive::-webkit-scrollbar {
    height: 6px;
}

.blog-content-wrapper .table-responsive::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.blog-content-wrapper .table-responsive::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
    transition: background-color 0.2s;
}

.blog-content-wrapper .table-responsive::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Code block styles */
.blog-content-wrapper pre {
    background-color: #0f172a;
    color: #f8fafc;
    padding: 16px 20px;
    border-radius: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    margin: 20px 0;
    font-family: 'Fira Code', 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.5;
}

.blog-content-wrapper code {
    background-color: #f1f5f9;
    color: #e11d48;
    padding: 3px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
}

.blog-content-wrapper :not(pre) > code {
    word-break: break-word;
    overflow-wrap: break-word;
}

.blog-content-wrapper pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}

/* Right Column Sidebar Layout */
.blog-sidebar-wrapper {
    display: flex;
    flex-direction: column;
    gap: 30px;
    align-self: stretch;         /* stretch to full grid row height so sticky has room */
}

@media (max-width: 768px) {
    .blog-sidebar-wrapper {
        min-width: 0;
        width: 100%;
    }

    .blog-detail-container #toc-card {
        position: static;
        top: auto;
        order: -1;
    }

    .blog-sidebar-wrapper .recent-post-info {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .blog-sidebar-wrapper .recent-post-heading {
        display: block;
        overflow: visible;
    }

    .blog-content-wrapper iframe,
    .blog-content-wrapper video,
    .blog-content-wrapper embed {
        max-width: 100%;
    }

    .blog-detail-container .author-info-wrapper {
        min-width: 0;
        max-width: 100%;
        overflow-wrap: anywhere;
    }
}

.sidebar-card {
    background-color: var(--white);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
}

/* Table of Contents Sticky Widget */
#toc-card {
    position: -webkit-sticky;
    position: sticky;
    top: 105px;
    z-index: 10;
    align-self: flex-start;      /* prevents TOC from stretching; sticks naturally */
    width: 100%;
    box-sizing: border-box;
    padding: 22px 18px;
}

@media (min-width: 769px) {
    /* JS reveals a populated TOC with inline display: block. */
    #toc-card[style*="display: block"] {
        display: flex !important;
        flex-direction: column;
        max-height: calc(100vh - 105px - 16px);
    }

    #toc-card > .sidebar-title {
        flex-shrink: 0;
    }

    #toc-card > #toc-list {
        min-height: 0;
        overflow-y: auto;
        scrollbar-width: thin;
    }

    #toc-list > .toc-item-h2,
    #toc-list > .toc-item-h3 {
        flex-shrink: 0;
    }
}

.sidebar-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 10px;
}

.recent-posts-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.recent-post-item {
    display: flex;
    gap: 12px;
    align-items: center;
}

.recent-post-thumb {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.recent-post-thumb-placeholder {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    background-color: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.recent-post-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.recent-post-heading {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.recent-post-item:hover .recent-post-heading {
    color: var(--accent);
}

.recent-post-date {
    font-size: 11px;
    color: #94a3b8;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.toc-item-h2 {
    font-size: 14px;
    font-weight: 500;
    width: 100%;
    list-style: none;
}

.toc-item-h3 {
    font-size: 13px;
    padding-left: 15px;
    font-weight: 400;
    width: 100%;
    list-style: none;
    box-sizing: border-box;
}

.toc-link {
    color: #475569;
    text-decoration: none;
    display: block;
    padding-left: 8px;
    border-left: 2px solid transparent;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    line-height: 1.5;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
}

#toc-list > .toc-item-h2 > .toc-link,
#toc-list > .toc-item-h3 > .toc-link {
    position: relative;
    padding-left: 24px;
}

#toc-list > .toc-item-h2 > .toc-link::before,
#toc-list > .toc-item-h3 > .toc-link::before {
    position: absolute;
    left: 8px;
    top: 0;
    width: 12px;
    text-align: center;
    font-weight: 400;
}

#toc-list > .toc-item-h2 > .toc-link::before {
    content: '\2022';
    color: var(--accent);
}

#toc-list > .toc-item-h3 > .toc-link::before {
    content: '\25CB';
    color: #94a3b8;
}

.toc-link:hover {
    color: var(--accent);
}

.toc-link.active {
    color: var(--accent) !important;
    border-left-color: var(--accent) !important;
    font-weight: 700 !important;
}

/* Section 3: Author Box */
.author-box-card {
    background-color: var(--white);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
    display: flex;
    gap: 25px;
    align-items: center;
    margin-top: 40px;
    margin-bottom: 40px;
    width: 100%;
}

@media (max-width: 768px) {
    .author-box-card {
        flex-direction: column;
        text-align: center;
        padding: 24px;
        margin-top: 30px;
        margin-bottom: 30px;
    }

    .author-meta-footer {
        flex-direction: column;
        gap: 16px;
        align-items: center;
        justify-content: center;
    }

    .author-socials {
        justify-content: center;
        flex-wrap: wrap;
        gap: 14px;
    }

    .author-profile-btn {
        margin-left: 0;
    }
}

@media (max-width: 480px) {
    .blog-detail-container {
        padding: 0 16px;
    }

    .blog-main-title {
        font-size: 21px;
    }

    .blog-featured-img-placeholder {
        height: 180px;
        font-size: 36px;
    }

    .blog-content-wrapper blockquote {
        padding: 12px 16px;
        margin: 18px 0;
        font-size: 14px;
    }

    .blog-content-wrapper ul,
    .blog-content-wrapper ol {
        padding-left: 20px;
    }

    .blog-content-wrapper pre {
        padding: 12px 14px;
        font-size: 13px;
    }

    .author-box-card {
        padding: 20px 16px;
    }

    .author-photo,
    .author-photo-placeholder {
        width: 76px;
        height: 76px;
        font-size: 30px;
    }

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

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

.author-avatar-wrapper {
    flex-shrink: 0;
}

.author-photo {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #f1f5f9;
}

.author-photo-placeholder {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background-color: var(--accent);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 700;
    border: 3px solid #f1f5f9;
}

.author-info-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.author-written-by {
    font-size: 12px;
    color: var(--accent);
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.author-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 8px 0;
}

.author-bio {
    font-size: 14px;
    color: #475569;
    line-height: 1.6;
    margin: 0 0 15px 0;
}

.author-meta-footer {
    display: flex;
    align-items: center;
    width: 100%;
}

.author-socials {
    display: flex;
    gap: 12px;
}

.author-socials a {
    color: var(--primary);
    font-size: 14px;
    transition: color 0.2s ease;
    text-decoration: none;
}

.author-socials a:hover {
    color: var(--accent);
}

.author-profile-btn {
    margin-left: auto;
    height: 32px;
    padding: 0 15px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.blog-footer-btn-wrapper {
    margin-top: 30px;
    display: flex;
    justify-content: flex-start;
}

/* Custom Editor Image & Figcaption Styles */
.editor-image {
    margin: 24px 0;
    text-align: center;
}

.editor-image img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    border-radius: 10px;
}

.editor-image figcaption {
    margin-top: 8px;
    font-size: 14px;
    font-style: italic;
    color: #64748b;
    line-height: 1.5;
    text-align: center;
}
