
/* Mobile Typography Optimization */

/* Improved font loading for mobile */
@font-face {
    font-family: 'Georgia';
    font-display: swap;
    src: local('Georgia'), local('Georgia-Regular');
}

/* Mobile-optimized text styles */
body {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 18px; /* Larger base font for mobile readability */
    line-height: 1.7; /* Improved line spacing */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Responsive headings */
h1 {
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    line-height: 1.2;
    margin: 0.5em 0;
    font-weight: 400;
    letter-spacing: -0.02em;
}

h2 {
    font-size: clamp(1.4rem, 3vw, 2.5rem);
    line-height: 1.3;
    margin: 1em 0 0.5em 0;
    font-weight: 500;
}

h3 {
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    line-height: 1.4;
    margin: 0.8em 0 0.4em 0;
    font-weight: 500;
}

/* Improved paragraph spacing */
p {
    margin: 0 0 1.4em 0;
    max-width: 75ch; /* Optimal reading width */
    hyphens: auto;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
}

/* Mobile-friendly lists */
ul, ol {
    padding-left: 1.5em;
    margin: 1em 0;
}

li {
    margin: 0.5em 0;
    line-height: 1.6;
}

/* Code and pre blocks for mobile */
code {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.9em;
    background: rgba(0, 0, 0, 0.05);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    word-break: break-all;
    -webkit-font-smoothing: auto;
}

pre {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.85em;
    line-height: 1.5;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
    white-space: pre;
    -webkit-overflow-scrolling: touch;
}

pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    word-break: normal;
}

/* Blockquotes */
blockquote {
    border-left: 4px solid #0066cc;
    margin: 1.5em 0;
    padding: 0.5em 0 0.5em 1em;
    font-style: italic;
    color: #555;
    background: rgba(0, 102, 204, 0.05);
}

/* Tables optimized for mobile */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1em 0;
    border: 1px solid #dee2e6;
    border-radius: 6px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    white-space: nowrap;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    vertical-align: top;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    position: sticky;
    top: 0;
}

/* Mobile reading enhancements */
.text-highlight {
    background: linear-gradient(120deg, #a8e6cf 0%, #dcedc8 100%);
    padding: 0.1em 0.2em;
    border-radius: 3px;
}

.reading-time {
    color: #666;
    font-size: 0.9em;
    font-style: italic;
    margin-bottom: 1em;
}

/* Dark mode typography */
@media (prefers-color-scheme: dark) {
    body {
        color: #e0e0e0;
        -webkit-font-smoothing: antialiased;
    }
    
    code {
        background: rgba(255, 255, 255, 0.1);
        color: #ff6b6b;
    }
    
    pre {
        background: #2a2a2a;
        border-color: #404040;
        color: #e0e0e0;
    }
    
    blockquote {
        border-color: #66b3ff;
        color: #ccc;
        background: rgba(102, 179, 255, 0.05);
    }
    
    th {
        background: #333;
        color: #e0e0e0;
    }
    
    td {
        border-color: #404040;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    body {
        color: #000;
        background: #fff;
    }
    
    a {
        color: #0000ff;
        text-decoration: underline;
    }
    
    .chapter-card {
        border: 2px solid #000;
        background: #fff;
    }
}

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
