/**
 * Lesson Article Styling
 * Enhanced formatting for lesson article content
 */

/* Article Content Container */
.lesson-article-main {
    max-width: 100%;
}

.article-content {
    /* Ensure proper spacing and readability */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Heading Styles - Enhanced hierarchy */
.article-content h1 {
    margin-top: 48px !important;
    margin-bottom: 32px !important;
    line-height: 1.4 !important;
}

.article-content h2 {
    margin-top: 32px !important;
    margin-bottom: 24px !important;
    line-height: 1.5 !important;
}

.article-content h3 {
    margin-top: 44px !important;
    margin-bottom: 20px !important;
    line-height: 1.5 !important;
}

.article-content h4 {
    margin-top: 40px !important;
    margin-bottom: 18px !important;
    line-height: 1.5 !important;
}

.article-content h5 {
    margin-top: 36px !important;
    margin-bottom: 16px !important;
    line-height: 1.4 !important;
}

.article-content h6 {
    margin-top: 32px !important;
    margin-bottom: 12px !important;
    line-height: 1.4 !important;
}

/* First heading should have less top margin */
.article-content > h1:first-child,
.article-content > h2:first-child,
.article-content > h3:first-child,
.article-content > h4:first-child,
.article-content > h5:first-child,
.article-content > h6:first-child {
    margin-top: 0 !important;
}

/* Remove top margin and padding from first child element (any type) */
.lesson-article-main .article-content > *:first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Code Block Styling - Distinct from article */
.code-block-wrapper {
    margin: 32px 0 !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2) !important;
    background: #0f172a !important;
    border: 2px solid #1e293b !important;
}

.code-block-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%) !important;
    color: #e2e8f0 !important;
    padding: 16px 20px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    border-bottom: 2px solid #475569 !important;
}

.code-block-content {
    background: #0f172a !important;
    color: #e2e8f0 !important;
    padding: 24px !important;
    font-size: 15px !important;
    line-height: 1.75 !important;
}

/* Inline Code Styling */
.inline-code {
    background: #f1f5f9 !important;
    color: #0c4a6e !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
    font-size: 15px !important;
    border: 1px solid #cbd5e1 !important;
    font-weight: 500 !important;
}

/* Paragraph spacing */
.article-content p {
    margin-bottom: 20px;
    line-height: 1.8;
}

/* List styling */
.article-content ul,
.article-content ol {
    margin: 20px 0;
    padding-left: 24px;
}

.article-content li {
    margin: 10px 0;
    line-height: 1.7;
}

/* Blockquote styling */
.article-content blockquote {
    margin: 24px 0 !important;
    padding: 16px 24px !important;
    border-left: 4px solid #0ea5e9 !important;
    background: #f8fafc !important;
    border-radius: 0 8px 8px 0 !important;
}

/* Image styling */
.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 24px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Horizontal rule styling */
.article-content hr {
    margin: 32px 0 !important;
    border: none !important;
    height: 2px !important;
    background: linear-gradient(90deg, transparent, #0ea5e9, transparent) !important;
}

/* Ensure proper spacing between sections */
.article-content > * + * {
    margin-top: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .code-block-wrapper {
        margin: 24px 0 !important;
        border-radius: 8px !important;
    }
    
    .code-block-header {
        padding: 12px 16px !important;
        font-size: 14px !important;
    }
    
    .code-block-content {
        padding: 16px !important;
        font-size: 14px !important;
    }
    
    .article-content h1 {
        font-size: 28px !important;
        margin-top: 40px !important;
        margin-bottom: 24px !important;
    }
    
    .article-content h2 {
        font-size: 22px !important;
        margin-top: 28px !important;
        margin-bottom: 20px !important;
    }
    
    .article-content h3 {
        font-size: 20px !important;
        margin-top: 36px !important;
        margin-bottom: 18px !important;
    }
    
    .article-content h4 {
        font-size: 18px !important;
        margin-top: 32px !important;
        margin-bottom: 16px !important;
    }
}

/* Reduce top spacing/padding from first child elements in all tabs */
.lesson-tabs-content .tab-content > *:first-child {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

/* Reduce vertical padding/margin for h2 elements in lesson-tabs-content */
.lesson-tabs-content h2 {
    margin-top: 16px !important;
    margin-bottom: 12px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* Spacing around tab content container in single lesson page (article-tab and all tabs) */
.lesson-tabs-content .tab-content,
.lesson-tabs-content .tab-content.active {
    padding: 24px !important;
    box-sizing: border-box;
}

/* SVG Diagrams tab uses same outer spacing as other tabs (inherits .lesson-tabs-content .tab-content) */
#diagrams-tab.tab-content.active {
    padding: 24px !important;
}

#diagrams-tab.tab-content.active > div {
    padding: 20px !important;
    padding-top: 0 !important;
}

/* Reduce margin/padding for h2 in Implementation Guide content */
.implementation-content-inner h2 {
    margin-top: 24px !important;
    margin-bottom: 12px !important;
    padding: 0 !important;
}

.implementation-content-inner h2:first-child {
    margin-top: 0 !important;
}

/* Article tab: allow content chain to shrink in grid so code blocks can show horizontal scroll */
#article-tab .lesson-article-main .article-content {
    min-width: 0 !important;
}

/* Constrain code-block-wrapper in Article tab so long code scrolls instead of clipping (match Implementation tab behavior) */
#article-tab .code-block-wrapper {
    max-width: 100% !important;
    min-width: 0 !important;
}

#article-tab .code-block-content {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    box-sizing: border-box !important;
}

/* Constrain code-block-wrapper width in Implementation Guide tab so long code does not stretch layout */
#implementation-tab .code-block-wrapper {
    max-width: 100% !important;
    min-width: 0 !important;
}

#implementation-tab .code-block-content {
    overflow-x: auto !important;
}

/* Embedded Diagram Styling - Prevent Overlap */
.embedded-diagram {
    margin: 24px 0 !important;
    padding: 0 !important;
    width: 100% !important;
    clear: both !important;
    display: block !important;
    position: relative !important;
    box-sizing: border-box !important;
}

.embedded-diagram + .embedded-diagram {
    margin-top: 32px !important;
}

/* Ensure diagrams don't overlap with other content */
.article-content .embedded-diagram {
    margin: 24px 0 !important;
    clear: both !important;
}

.article-content .embedded-diagram:first-child {
    margin-top: 0 !important;
}

.article-content .embedded-diagram:last-child {
    margin-bottom: 0 !important;
}

