/**
 * Article Content Styles
 *
 * Comprehensive styling for article content rendered from external CMS
 * (GitHub, WordPress, Contentful, etc.)
 *
 * These styles work within the .article-body container and provide
 * consistent, beautiful rendering for:
 * - Code blocks with syntax highlighting
 * - Tables with proper formatting
 * - Blockquotes and citations
 * - Callout boxes (info, warning, tip, etc.)
 * - Diagrams (ASCII art, Mermaid flowcharts)
 * - Steps and process indicators
 * - Feature grids and cards
 * - Checklists and lists
 * - Keyboard shortcuts
 * - And more...
 */

/* ==========================================================================
   CSS VARIABLES - Theme Integration
   ========================================================================== */
.article-body {
    --article-primary: var(--primary-500, #7c3aed);
    --article-primary-light: var(--primary-100, #ede9fe);
    --article-text: var(--gray-700, #374151);
    --article-text-light: var(--gray-600, #4b5563);
    --article-text-muted: var(--gray-500, #6b7280);
    --article-border: var(--gray-200, #e5e7eb);
    --article-bg: var(--gray-50, #f9fafb);
    --article-bg-alt: var(--gray-100, #f3f4f6);
    --article-success: #22c55e;
    --article-warning: #f59e0b;
    --article-danger: #ef4444;
    --article-info: #3b82f6;
    --article-radius: 8px;
    --article-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

/* ==========================================================================
   LEAD PARAGRAPH
   ========================================================================== */
.article-body .lead {
    font-size: 1.25rem;
    line-height: 1.7;
    color: var(--article-text-light);
    margin-bottom: 2rem;
    font-weight: 400;
}

/* ==========================================================================
   CODE BLOCKS & INLINE CODE
   ========================================================================== */

/* Inline code */
.article-body code {
    background: var(--article-bg-alt);
    color: var(--article-primary);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Fira Code', 'Monaco', 'Consolas', 'Liberation Mono', monospace;
    word-break: break-word;
}

/* Code blocks */
.article-body pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1.25rem 1.5rem;
    border-radius: var(--article-radius);
    overflow-x: auto;
    margin: 1.5rem 0;
    font-size: 0.875rem;
    line-height: 1.7;
    position: relative;
    box-shadow: var(--article-shadow);
}

.article-body pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
    border-radius: 0;
}

/* Code block with language label */
.article-body pre[data-language]::before {
    content: attr(data-language);
    position: absolute;
    top: 0;
    right: 0;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    color: #888;
    background: rgba(255,255,255,0.1);
    border-radius: 0 var(--article-radius) 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Code block line numbers (when wrapped in .line-numbers) */
.article-body .line-numbers pre {
    padding-left: 3.5rem;
    counter-reset: line;
}

.article-body .line-numbers pre code {
    counter-increment: line;
}

.article-body .line-numbers pre code::before {
    content: counter(line);
    display: inline-block;
    width: 2rem;
    margin-left: -3rem;
    margin-right: 1rem;
    text-align: right;
    color: #555;
    user-select: none;
}

/* ==========================================================================
   SYNTAX HIGHLIGHTING - VSCode Dark+ Theme Colors
   ========================================================================== */
.article-body pre .comment { color: #6a9955; }
.article-body pre .keyword { color: #569cd6; }
.article-body pre .string { color: #ce9178; }
.article-body pre .number { color: #b5cea8; }
.article-body pre .function { color: #dcdcaa; }
.article-body pre .class-name { color: #4ec9b0; }
.article-body pre .variable { color: #9cdcfe; }
.article-body pre .operator { color: #d4d4d4; }
.article-body pre .punctuation { color: #d4d4d4; }
.article-body pre .property { color: #9cdcfe; }
.article-body pre .tag { color: #569cd6; }
.article-body pre .attr-name { color: #9cdcfe; }
.article-body pre .attr-value { color: #ce9178; }

/* ==========================================================================
   TABLES
   ========================================================================== */
.article-body table,
.article-body .article-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
    border-radius: var(--article-radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.article-body th,
.article-body td,
.article-body .article-table th,
.article-body .article-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--article-border);
}

.article-body th,
.article-body .article-table th {
    background: var(--article-bg);
    font-weight: 600;
    color: var(--article-text);
    white-space: nowrap;
}

.article-body tr:last-child td {
    border-bottom: none;
}

.article-body tbody tr:hover {
    background: var(--article-bg);
}

/* Responsive table wrapper */
.article-body .table-responsive {
    overflow-x: auto;
    margin: 1.5rem 0;
    border-radius: var(--article-radius);
}

.article-body .table-responsive table {
    margin: 0;
}

/* ==========================================================================
   BLOCKQUOTES
   ========================================================================== */
.article-body blockquote {
    border-left: 4px solid var(--article-primary);
    margin: 1.5rem 0;
    padding: 1.25rem 1.5rem;
    background: var(--article-bg);
    border-radius: 0 var(--article-radius) var(--article-radius) 0;
}

.article-body blockquote p {
    margin: 0;
    font-style: italic;
    color: var(--article-text);
    font-size: 1.05rem;
    line-height: 1.7;
}

.article-body blockquote p + p {
    margin-top: 1rem;
}

.article-body blockquote cite {
    display: block;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--article-text-muted);
    font-style: normal;
}

.article-body blockquote cite::before {
    content: "— ";
}

/* ==========================================================================
   CALLOUT BOXES
   ========================================================================== */
.article-body .callout {
    padding: 1.25rem 1.5rem;
    border-radius: var(--article-radius);
    margin: 1.5rem 0;
    border-left: 4px solid;
}

.article-body .callout-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.article-body .callout p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.6;
}

.article-body .callout ul,
.article-body .callout ol {
    margin: 0.5rem 0 0;
    padding-left: 1.25rem;
}

/* Info Callout */
.article-body .callout-info {
    background: #eff6ff;
    border-color: #3b82f6;
}
.article-body .callout-info .callout-title { color: #1d4ed8; }
.article-body .callout-info .callout-title::before { content: "ℹ️ "; }

/* Tip/Success Callout */
.article-body .callout-tip,
.article-body .callout-success {
    background: #ecfdf5;
    border-color: #10b981;
}
.article-body .callout-tip .callout-title,
.article-body .callout-success .callout-title { color: #047857; }
.article-body .callout-tip .callout-title::before { content: "💡 "; }
.article-body .callout-success .callout-title::before { content: "✅ "; }

/* Warning Callout */
.article-body .callout-warning {
    background: #fffbeb;
    border-color: #f59e0b;
}
.article-body .callout-warning .callout-title { color: #b45309; }
.article-body .callout-warning .callout-title::before { content: "⚠️ "; }

/* Danger/Error Callout */
.article-body .callout-danger,
.article-body .callout-error {
    background: #fef2f2;
    border-color: #ef4444;
}
.article-body .callout-danger .callout-title,
.article-body .callout-error .callout-title { color: #b91c1c; }
.article-body .callout-danger .callout-title::before { content: "🚫 "; }

/* Note Callout */
.article-body .callout-note {
    background: #f5f3ff;
    border-color: #8b5cf6;
}
.article-body .callout-note .callout-title { color: #6d28d9; }
.article-body .callout-note .callout-title::before { content: "📝 "; }

/* ==========================================================================
   DIAGRAMS & ASCII ART
   ========================================================================== */

/* ASCII Art Diagrams */
.article-body .diagram,
.article-body .ascii-art,
.article-body .ascii-diagram {
    background: #1e1e1e;
    color: #00ff00;
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
    padding: 1.5rem;
    border-radius: var(--article-radius);
    overflow-x: auto;
    margin: 1.5rem 0;
    font-size: 0.8rem;
    line-height: 1.4;
    white-space: pre;
    box-shadow: var(--article-shadow);
}

/* Alternative diagram styles */
.article-body .diagram-light {
    background: var(--article-bg);
    color: var(--article-text);
    border: 1px solid var(--article-border);
}

.article-body .diagram-blueprint {
    background: #1e3a5f;
    color: #87ceeb;
}

/* Flowchart container (for Mermaid) */
.article-body .mermaid {
    background: #fff;
    padding: 1.5rem;
    border-radius: var(--article-radius);
    margin: 1.5rem 0;
    text-align: center;
    border: 1px solid var(--article-border);
}

/* Architecture diagram container */
.article-body .architecture-diagram {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 2rem;
    border-radius: var(--article-radius);
    margin: 1.5rem 0;
    border: 1px solid var(--article-border);
    overflow-x: auto;
}

/* ==========================================================================
   STEPS / PROCESS INDICATORS
   ========================================================================== */
.article-body .steps {
    margin: 1.5rem 0;
}

.article-body .step {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: flex-start;
}

.article-body .step-number {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    background: var(--article-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.article-body .step-content {
    flex: 1;
    padding-top: 0.25rem;
}

.article-body .step-content h4 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
    color: var(--article-text);
}

.article-body .step-content p {
    margin: 0;
    color: var(--article-text-light);
}

/* Vertical timeline variant */
.article-body .steps-timeline .step {
    position: relative;
    padding-left: 3rem;
    border-left: 2px solid var(--article-border);
    margin-left: 1.25rem;
}

.article-body .steps-timeline .step-number {
    position: absolute;
    left: -1.25rem;
}

.article-body .steps-timeline .step:last-child {
    border-left-color: transparent;
}

/* ==========================================================================
   FEATURE GRIDS
   ========================================================================== */
.article-body .feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.article-body .feature-item {
    background: var(--article-bg);
    padding: 1.5rem;
    border-radius: var(--article-radius);
    text-align: center;
    border: 1px solid var(--article-border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.article-body .feature-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--article-shadow);
}

.article-body .feature-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.article-body .feature-item h4 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    color: var(--article-text);
}

.article-body .feature-item p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--article-text-muted);
}

/* ==========================================================================
   CHECKLISTS
   ========================================================================== */
.article-body .checklist {
    list-style: none;
    padding-left: 0;
    margin: 1.5rem 0;
}

.article-body .checklist li {
    position: relative;
    padding-left: 2rem;
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.article-body .checklist li::before {
    content: "☐";
    position: absolute;
    left: 0;
    color: var(--article-text-muted);
    font-size: 1.1rem;
}

.article-body .checklist li.checked::before {
    content: "☑";
    color: var(--article-success);
}

/* ==========================================================================
   SUMMARY / HIGHLIGHT BOXES
   ========================================================================== */
.article-body .summary-box,
.article-body .highlight-box {
    background: linear-gradient(135deg, var(--article-primary-light) 0%, #fff 100%);
    border: 1px solid var(--article-primary);
    border-radius: var(--article-radius);
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.article-body .summary-box h4,
.article-body .highlight-box h4 {
    margin: 0 0 1rem;
    color: var(--article-primary);
    font-size: 1.1rem;
}

.article-body .summary-box ul,
.article-body .highlight-box ul {
    margin: 0;
    padding-left: 1.25rem;
}

.article-body .summary-box li,
.article-body .highlight-box li {
    margin-bottom: 0.5rem;
}

/* ==========================================================================
   KEYBOARD SHORTCUTS
   ========================================================================== */
.article-body kbd {
    background: linear-gradient(180deg, #fff 0%, var(--article-bg-alt) 100%);
    border: 1px solid var(--article-border);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
    font-size: 0.85em;
    font-family: inherit;
    box-shadow: 0 1px 0 rgba(0,0,0,0.1);
    white-space: nowrap;
}

/* ==========================================================================
   FIGURES & IMAGES
   ========================================================================== */
.article-body figure,
.article-body .article-figure {
    margin: 2rem 0;
    text-align: center;
}

.article-body figure img,
.article-body .article-figure img {
    max-width: 100%;
    height: auto;
    border-radius: var(--article-radius);
    box-shadow: var(--article-shadow);
}

.article-body figcaption,
.article-body .article-figure .caption {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: var(--article-text-muted);
    font-style: italic;
}

/* ==========================================================================
   CTA BUTTONS
   ========================================================================== */
.article-body .cta-buttons {
    display: flex;
    gap: 1rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.article-body .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--article-radius);
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    border: 2px solid transparent;
}

.article-body .btn-primary {
    background: var(--article-primary);
    color: white;
}

.article-body .btn-primary:hover {
    background: var(--primary-600, #6d28d9);
    transform: translateY(-1px);
}

.article-body .btn-outline {
    background: transparent;
    border-color: var(--article-primary);
    color: var(--article-primary);
}

.article-body .btn-outline:hover {
    background: var(--article-primary);
    color: white;
}

/* ==========================================================================
   HORIZONTAL RULES
   ========================================================================== */
.article-body hr {
    border: none;
    height: 1px;
    background: var(--article-border);
    margin: 2.5rem 0;
}

.article-body hr.decorative {
    height: auto;
    background: none;
    text-align: center;
}

.article-body hr.decorative::before {
    content: "• • •";
    color: var(--article-text-muted);
    font-size: 1.25rem;
    letter-spacing: 0.5rem;
}

/* ==========================================================================
   DEFINITION LISTS
   ========================================================================== */
.article-body dl {
    margin: 1.5rem 0;
}

.article-body dt {
    font-weight: 600;
    color: var(--article-text);
    margin-top: 1rem;
}

.article-body dt:first-child {
    margin-top: 0;
}

.article-body dd {
    margin-left: 1.5rem;
    color: var(--article-text-light);
}

/* ==========================================================================
   ABBREVIATIONS
   ========================================================================== */
.article-body abbr[title] {
    text-decoration: underline dotted;
    cursor: help;
}

/* ==========================================================================
   MARKS / HIGHLIGHTS
   ========================================================================== */
.article-body mark {
    background: #fef08a;
    padding: 0.1rem 0.3rem;
    border-radius: 2px;
}

/* ==========================================================================
   FILE TREES
   ========================================================================== */
.article-body .file-tree {
    background: var(--article-bg);
    border: 1px solid var(--article-border);
    border-radius: var(--article-radius);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
}

.article-body .file-tree ul {
    list-style: none;
    padding-left: 1.25rem;
    margin: 0;
}

.article-body .file-tree > ul {
    padding-left: 0;
}

.article-body .file-tree li {
    position: relative;
    margin: 0.25rem 0;
}

.article-body .file-tree li::before {
    content: "├── ";
    color: var(--article-text-muted);
}

.article-body .file-tree li:last-child::before {
    content: "└── ";
}

.article-body .file-tree .folder {
    color: var(--article-info);
}

.article-body .file-tree .file {
    color: var(--article-text);
}

/* ==========================================================================
   COMPARISON TABLES
   ========================================================================== */
.article-body .comparison-table {
    margin: 1.5rem 0;
}

.article-body .comparison-table th:first-child,
.article-body .comparison-table td:first-child {
    font-weight: 600;
}

.article-body .comparison-table .yes {
    color: var(--article-success);
}

.article-body .comparison-table .no {
    color: var(--article-danger);
}

.article-body .comparison-table .partial {
    color: var(--article-warning);
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */
@media (max-width: 768px) {
    .article-body pre {
        padding: 1rem;
        font-size: 0.8rem;
        border-radius: 0;
        margin-left: -1rem;
        margin-right: -1rem;
    }

    .article-body .feature-grid {
        grid-template-columns: 1fr;
    }

    .article-body .step {
        flex-direction: column;
        align-items: flex-start;
    }

    .article-body .cta-buttons {
        flex-direction: column;
    }

    .article-body .cta-buttons .btn {
        width: 100%;
        justify-content: center;
    }

    .article-body table {
        font-size: 0.85rem;
    }

    .article-body th,
    .article-body td {
        padding: 0.5rem;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */
@media print {
    .article-body pre {
        background: #f5f5f5 !important;
        color: #333 !important;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .article-body .callout {
        border: 1px solid;
        background: #fff !important;
    }

    .article-body .cta-buttons {
        display: none;
    }
}
