/**
 * Article Typography and Readability Enhancements
 * Requirements: 3.4, 3.5, 3.9, 3.10
 * 
 * This stylesheet provides optimal typography for article content:
 * - Font size: 18-21px for comfortable reading
 * - Line height: 1.6-1.8 for optimal readability
 * - Max width: 65-75 characters (~700px) per line
 * - Enhanced typography (proper quotes, dashes)
 * - Syntax highlighting for code blocks
 */

/* ============================================
   Article Content Typography
   ============================================ */

.article-page__content.prose {
    /* Optimal font size for reading (18-21px range) */
    font-size: 19px;
    
    /* Optimal line height for readability */
    line-height: 1.7;
    
    /* Limit line length to 65-75 characters for optimal readability */
    max-width: 700px;
    
    /* Use modern sans-serif font for better readability */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    
    /* Improve text rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    
    /* Better word spacing */
    word-spacing: 0.05em;
    
    /* Color for better contrast */
    color: var(--color-text, #1a202c);
}

/* ============================================
   Headings
   ============================================ */

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
    font-family: var(--font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
    font-weight: 700;
    line-height: 1.3;
    color: var(--color-text, #1a202c);
    margin-top: 2em;
    margin-bottom: 0.75em;
    scroll-margin-top: 100px; /* For smooth scroll with fixed header */
}

.prose h1 {
    font-size: 2.25em;
    margin-top: 0;
}

.prose h2 {
    font-size: 1.875em;
    border-bottom: 1px solid var(--color-border, #e2e8f0);
    padding-bottom: 0.3em;
}

.prose h3 {
    font-size: 1.5em;
}

.prose h4 {
    font-size: 1.25em;
}

.prose h5 {
    font-size: 1.125em;
}

.prose h6 {
    font-size: 1em;
    color: var(--color-text-secondary, #4a5568);
}

/* ============================================
   Paragraphs and Text
   ============================================ */

.prose p {
    margin-bottom: 1.5em;
    margin-top: 0;
}

.prose p:last-child {
    margin-bottom: 0;
}

/* ============================================
   Links
   ============================================ */

.prose a {
    color: var(--color-primary, #3b82f6);
    text-decoration: underline;
    text-decoration-color: rgba(59, 130, 246, 0.3);
    text-underline-offset: 2px;
    transition: all 0.2s ease;
}

.prose a:hover {
    color: var(--color-primary-dark, #2563eb);
    text-decoration-color: currentColor;
}

/* ============================================
   Lists
   ============================================ */

.prose ul,
.prose ol {
    margin: 1.5em 0;
    padding-left: 1.75em;
}

.prose li {
    margin-bottom: 0.5em;
    line-height: 1.7;
}

.prose li > p {
    margin-bottom: 0.75em;
}

.prose ul {
    list-style-type: disc;
}

.prose ul ul {
    list-style-type: circle;
    margin-top: 0.5em;
}

.prose ol {
    list-style-type: decimal;
}

.prose ol ol {
    list-style-type: lower-alpha;
    margin-top: 0.5em;
}

/* ============================================
   Blockquotes
   ============================================ */

.prose blockquote {
    border-left: 4px solid var(--color-primary, #3b82f6);
    padding: 1em 1.5em;
    margin: 2em 0;
    font-style: italic;
    background: var(--color-bg-secondary, #f7fafc);
    border-radius: 0 4px 4px 0;
    color: var(--color-text-secondary, #4a5568);
}

.prose blockquote p {
    margin-bottom: 0.75em;
}

.prose blockquote p:last-child {
    margin-bottom: 0;
}

.prose blockquote cite {
    display: block;
    margin-top: 1em;
    font-size: 0.9em;
    font-style: normal;
    color: var(--color-text-muted, #718096);
}

.prose blockquote cite::before {
    content: '— ';
}

/* ============================================
   Code Blocks and Inline Code
   ============================================ */

.prose code {
    font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875em;
    background: var(--color-bg-secondary, #f7fafc);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    color: var(--color-code, #e53e3e);
    font-weight: 500;
}

.prose pre {
    background: #2d3748;
    color: #e2e8f0;
    padding: 1.5em;
    border-radius: 8px;
    overflow-x: auto;
    margin: 2em 0;
    line-height: 1.6;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.prose pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: 0.9em;
    border-radius: 0;
    font-weight: 400;
}

/* Syntax Highlighting - Basic Theme */
.prose pre code .keyword {
    color: #f687b3;
    font-weight: 600;
}

.prose pre code .string {
    color: #9ae6b4;
}

.prose pre code .comment {
    color: #a0aec0;
    font-style: italic;
}

.prose pre code .function {
    color: #90cdf4;
}

.prose pre code .number {
    color: #fbd38d;
}

.prose pre code .operator {
    color: #fc8181;
}

/* ============================================
   Images and Figures
   ============================================ */

.prose img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 2em 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.prose figure {
    margin: 2em 0;
}

.prose figure img {
    margin: 0;
}

.prose figcaption {
    text-align: center;
    font-size: 0.875em;
    color: var(--color-text-muted, #718096);
    margin-top: 0.75em;
    font-style: italic;
}

/* ============================================
   Tables
   ============================================ */

.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 2em 0;
    font-size: 0.9em;
}

.prose thead {
    background: var(--color-bg-secondary, #f7fafc);
    border-bottom: 2px solid var(--color-border, #e2e8f0);
}

.prose th {
    padding: 0.75em 1em;
    text-align: left;
    font-weight: 600;
    color: var(--color-text, #1a202c);
}

.prose td {
    padding: 0.75em 1em;
    border-bottom: 1px solid var(--color-border, #e2e8f0);
}

.prose tbody tr:hover {
    background: var(--color-bg-secondary, #f7fafc);
}

/* Table wrapper for horizontal scrolling on mobile */
@media (max-width: 768px) {
    .prose table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
}

/* ============================================
   Horizontal Rules
   ============================================ */

.prose hr {
    border: none;
    border-top: 2px solid var(--color-border, #e2e8f0);
    margin: 3em 0;
}

/* ============================================
   Enhanced Typography - Proper Quotes and Dashes
   ============================================ */

/* Smart quotes rendering */
.prose q::before {
    content: '"';
}

.prose q::after {
    content: '"';
}

/* Em dash spacing */
.prose em-dash::before {
    content: '—';
}

/* En dash for ranges */
.prose en-dash::before {
    content: '–';
}

/* ============================================
   Special Elements
   ============================================ */

.prose mark {
    background: #fef08a;
    padding: 0.1em 0.2em;
    border-radius: 2px;
}

.prose kbd {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.875em;
    background: var(--color-bg-secondary, #f7fafc);
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: 4px;
    padding: 0.2em 0.5em;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.prose abbr {
    text-decoration: underline dotted;
    cursor: help;
}

.prose sup,
.prose sub {
    font-size: 0.75em;
    line-height: 0;
}

/* ============================================
   Responsive Typography
   ============================================ */

@media (max-width: 768px) {
    .article-page__content.prose {
        font-size: 18px;
        line-height: 1.65;
    }
    
    .prose h1 {
        font-size: 2em;
    }
    
    .prose h2 {
        font-size: 1.625em;
    }
    
    .prose h3 {
        font-size: 1.375em;
    }
    
    .prose h4 {
        font-size: 1.125em;
    }
    
    .prose pre {
        padding: 1em;
        font-size: 0.875em;
    }
    
    .prose blockquote {
        padding: 0.75em 1em;
        margin: 1.5em 0;
    }
}

@media (max-width: 480px) {
    .article-page__content.prose {
        font-size: 17px;
    }
    
    .prose table {
        font-size: 0.8em;
    }
    
    .prose th,
    .prose td {
        padding: 0.5em 0.75em;
    }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .article-page__content.prose {
        font-size: 12pt;
        line-height: 1.6;
        color: #000;
    }
    
    .prose a {
        color: #000;
        text-decoration: underline;
    }
    
    .prose a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
    
    .prose pre {
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
    
    .prose img {
        max-width: 100%;
        page-break-inside: avoid;
    }
}
