/* Global Typography & Layout - Research-Based Minimalist Design */

/* CSS Custom Properties for consistency */
:root {
    /* Typography - System fonts for optimal performance */
    --font-primary: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    
    /* Font sizes - 16px base with optimal scaling */
    --font-size-base: 1rem; /* 16px */
    --font-size-sm: 0.875rem; /* 14px */
    --font-size-lg: 1.125rem; /* 18px */
    --font-size-xl: 1.25rem; /* 20px */
    --font-size-2xl: 1.5rem; /* 24px */
    --font-size-3xl: 1.875rem; /* 30px */
    --font-size-4xl: 2.25rem; /* 36px */
    
    /* Line heights - Research-based 1.5 for body text */
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.625;
    
    /* Letter spacing for optimal readability */
    --letter-spacing-tight: -0.025em;
    --letter-spacing-normal: 0;
    --letter-spacing-wide: 0.025em;
    
    /* Colors - Dark theme with WCAG AAA compliant contrast ratios */
    --color-text: #f7fafc; /* High contrast on dark background */
    --color-text-muted: #cbd5e0; /* Good contrast for secondary text */
    --color-text-light: #a0aec0; /* Subtle text color */
    --color-background: #1a202c; /* Dark background */
    --color-background-subtle: #2d3748; /* Slightly lighter dark */
    --color-background-muted: #4a5568; /* Medium dark for cards/sections */
    
    /* Accent colors */
    --color-primary: #63b3ed; /* Light blue for primary actions */
    --color-primary-hover: #4299e1; /* Darker blue on hover */
    --color-secondary: #4a5568; /* Dark gray for secondary elements */
    --color-border: #4a5568; /* Subtle borders */
    --color-border-subtle: #2d3748; /* Very subtle borders */
    
    /* Semantic colors */
    --color-success: #34d399; /* Green for articles/success states */
    --color-success-hover: #059669; /* Darker green for hover states */
    --color-warning: #fbbf24; /* Yellow/orange for posts/warning states */
    --color-error: #ef4444; /* Red for errors/danger states */
    --color-error-bg: #fef2f2; /* Light red background for errors */
    --color-error-border: #fecaca; /* Light red border for errors */
    --color-info: #3b82f6; /* Blue for info/edit states */
    
    /* Spacing - Modular scale */
    --space-1: 0.25rem; /* 4px */
    --space-2: 0.5rem; /* 8px */
    --space-3: 0.75rem; /* 12px */
    --space-4: 1rem; /* 16px */
    --space-6: 1.5rem; /* 24px */
    --space-8: 2rem; /* 32px */
    --space-12: 3rem; /* 48px */
    --space-16: 4rem; /* 64px */
    --space-20: 5rem; /* 80px */
    
    /* Layout constraints - Simple and consistent */
    --max-width-prose: 65ch; /* Reading width */
    --max-width-content: 1200px; /* Main content container */
    --max-width-wide: 1400px; /* Wide container for admin pages */
    
    /* Border radius for subtle modern feel */
    --radius-sm: 0.125rem;
    --radius: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    
    /* Shadows for subtle depth */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    line-height: var(--line-height-normal);
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    font-family: var(--font-primary);
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    color: var(--color-text);
    background-color: var(--color-background);
    letter-spacing: var(--letter-spacing-normal);
}

/* Typography scale */
h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--space-4) 0;
    font-weight: 600;
    line-height: var(--line-height-tight);
    letter-spacing: var(--letter-spacing-tight);
    color: var(--color-text);
}

h1 {
    font-size: var(--font-size-4xl);
    font-weight: 700;
    margin-bottom: var(--space-6);
}

h2 {
    font-size: var(--font-size-3xl);
    margin-top: var(--space-8);
}

h3 {
    font-size: var(--font-size-2xl);
    margin-top: var(--space-6);
}

h4 {
    font-size: var(--font-size-xl);
}

h5 {
    font-size: var(--font-size-lg);
}

h6 {
    font-size: var(--font-size-base);
    font-weight: 600;
}

p {
    margin: 0 0 var(--space-6) 0;
    max-width: var(--max-width-prose);
}

/* Links with subtle, sophisticated styling */
a {
    color: var(--color-text);
    text-decoration: underline;
    text-decoration-color: var(--color-border);
    text-underline-offset: 0.125em;
    transition: all 0.15s ease;
}

a:hover {
    color: var(--color-primary);
    text-decoration-color: var(--color-primary);
}

a:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Lists with proper spacing */
ul, ol {
    margin: 0 0 var(--space-6) 0;
    padding-left: var(--space-6);
    max-width: var(--max-width-prose);
}

li {
    margin-bottom: var(--space-2);
}

li:last-child {
    margin-bottom: 0;
}

/* Code and preformatted text */
code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background-color: var(--color-background-muted);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius);
    letter-spacing: var(--letter-spacing-normal);
}

pre {
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
    background-color: var(--color-primary);
    color: var(--color-background);
    padding: var(--space-6);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: var(--space-6) 0;
    max-width: 100%;
}

pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

/* Blockquotes */
blockquote {
    margin: var(--space-8) 0;
    padding-left: var(--space-6);
    border-left: 4px solid var(--color-border);
    font-style: italic;
    color: var(--color-text-muted);
    max-width: var(--max-width-prose);
}

/* Images and media */
img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
}

/* Horizontal rules */
hr {
    border: none;
    height: 1px;
    background-color: var(--color-border);
    margin: var(--space-12) 0;
}

/* Selection styling */
::selection {
    background-color: var(--color-background-muted);
    color: var(--color-text);
}

/* Focus styles for accessibility */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Basic utility classes */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Responsive typography adjustments */
@media (max-width: 768px) {
    :root {
        --font-size-4xl: 1.875rem; /* 30px */
        --font-size-3xl: 1.5rem; /* 24px */
        --font-size-2xl: 1.25rem; /* 20px */
    }
    
    body {
        font-size: var(--font-size-base);
        line-height: var(--line-height-relaxed);
    }
    
    h1, h2, h3 {
        line-height: var(--line-height-normal);
    }
}

/* Print styles */
@media print {
    body {
        color: #000;
        background: #fff;
        font-size: 12pt;
        line-height: 1.4;
    }
    
    h1, h2, h3 {
        page-break-after: avoid;
        font-weight: bold;
    }
    
    p, li {
        orphans: 3;
        widows: 3;
    }
    
    a {
        color: #000;
        text-decoration: underline;
    }
}