/* Reset and base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #fff;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 2rem;
}

/* On smaller screens, reduce max-width and padding */
@media (max-width: 1024px) {
    body {
        max-width: 900px;
        padding: 2rem 1.5rem;
    }
}

/* Header */
.site-header {
    position: relative;
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid #eee;
}

.site-title {
    font-size: 2rem;
    font-weight: 600;
    color: #2563eb;
    text-decoration: none;
    transition: color 0.2s ease;
}

.site-title:hover {
    color: #1d4ed8;
}

/* Language Switch */
.language-switch {
    position: absolute;
    top: 0;
    right: 0;
}

.lang-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: #f8fafc;
    color: #475569;
    text-decoration: none;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.lang-btn:hover {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

/* Navigation */
.nav {
    margin-top: 1rem;
}

.nav a {
    display: inline-block;
    margin: 0 1rem;
    padding: 0.5rem 1rem;
    color: #666;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.nav a:hover {
    background: #f3f4f6;
    color: #2563eb;
}

/* Main content */
.main-content {
    margin-bottom: 3rem;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    margin: 2rem 0 1rem 0;
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 2.25rem; color: #1f2937; }
h2 { font-size: 1.875rem; color: #374151; }
h3 { font-size: 1.5rem; color: #4b5563; }
h4 { font-size: 1.25rem; color: #6b7280; }

p {
    margin: 1rem 0;
}

a {
    color: #2563eb;
    text-decoration: none;
    word-wrap: break-word;
    word-break: break-all;
    hyphens: auto;
}

a:hover {
    text-decoration: underline;
}

/* Lists */
ul, ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

li {
    margin: 0.5rem 0;
}

/* Code blocks */
code {
    background: #f3f4f6;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', Consolas, Monaco, monospace;
    font-size: 0.9em;
    word-wrap: break-word;
    word-break: break-all;
    hyphens: auto;
    white-space: pre-wrap;
}

pre {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
}

pre code {
    background: none;
    padding: 0;
    white-space: pre;
    word-wrap: normal;
    word-break: normal;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

th, td {
    border: 1px solid #e2e8f0;
    padding: 0.75rem;
    text-align: left;
}

th {
    background: #f8fafc;
    font-weight: 600;
}

/* Blockquotes */
blockquote {
    border-left: 4px solid #2563eb;
    padding-left: 1rem;
    margin: 1rem 0;
    font-style: italic;
    color: #6b7280;
}

/* Footer */
.site-footer {
    text-align: center;
    padding-top: 2rem;
    border-top: 2px solid #eee;
    color: #6b7280;
    font-size: 0.9rem;
}

.footer-links a {
    color: #6b7280;
    margin: 0 0.5rem;
}

/* Table of Contents */
.toc {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
    margin: 2rem 0;
}

.toc-permalink {
    color: #cbd5e1;
    text-decoration: none;
    margin-left: 0.5rem;
}

.toc-permalink:hover {
    color: #2563eb;
}

/* Code highlighting styles */
.highlight {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
}

.highlight pre {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 1rem 0.5rem;
        max-width: 100%;
    }

    .site-header {
        margin-bottom: 2rem;
    }

    .site-title {
        font-size: 1.5rem;
    }

    .language-switch {
        position: static;
        margin-top: 1rem;
        text-align: center;
    }

    .nav {
        margin-top: 1.5rem;
    }

    .nav a {
        display: block;
        margin: 0.5rem 0;
        padding: 0.75rem;
        background: #f8fafc;
        border-radius: 6px;
    }

    h1 { font-size: 1.875rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }

    table {
        font-size: 0.9rem;
        overflow-x: auto;
        display: block;
        white-space: nowrap;
    }

    th, td {
        padding: 0.5rem;
    }

    pre {
        font-size: 0.8rem;
    }

    /* Better text wrapping on mobile */
    p, li {
        word-wrap: break-word;
        hyphens: auto;
    }
    
    /* Long URLs and code should scroll horizontally on mobile when needed */
    code {
        max-width: 100%;
        overflow-x: auto;
        display: inline-block;
    }
}

/* Print styles */
@media print {
    body {
        color: #000;
        background: #fff;
    }

    .site-header,
    .site-footer {
        border: none;
    }

    a {
        color: #000;
        text-decoration: none;
    }

    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}
