/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --text-color: #1f2937;
    --text-secondary: #6b7280;
    --bg-color: #ffffff;
    --bg-secondary: #f9fafb;
    --border-color: #e5e7eb;
    --code-bg: #f3f4f6;
    --code-text: #e11d48;
    --header-bg: #ffffff;
    --header-shadow: rgba(0, 0, 0, 0.05);
    --footer-bg: #111827;
    --footer-text: #d1d5db;
    --link-color: #2563eb;
    --link-hover: #1d4ed8;
}

/* Dark mode colors */
[data-theme="dark"] {
    --primary-color: #3b82f6;
    --primary-hover: #60a5fa;
    --text-color: #e5e7eb;
    --text-secondary: #9ca3af;
    --bg-color: #0f172a;
    --bg-secondary: #1e293b;
    --border-color: #334155;
    --code-bg: #1e293b;
    --code-text: #fb7185;
    --header-bg: #1e293b;
    --header-shadow: rgba(0, 0, 0, 0.3);
    --footer-bg: #020617;
    --footer-text: #cbd5e1;
    --link-color: #60a5fa;
    --link-hover: #93c5fd;
}

/* System preference dark mode */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --primary-color: #3b82f6;
        --primary-hover: #60a5fa;
        --text-color: #e5e7eb;
        --text-secondary: #9ca3af;
        --bg-color: #0f172a;
        --bg-secondary: #1e293b;
        --border-color: #334155;
        --code-bg: #1e293b;
        --code-text: #fb7185;
        --header-bg: #1e293b;
        --header-shadow: rgba(0, 0, 0, 0.3);
        --footer-bg: #020617;
        --footer-text: #cbd5e1;
        --link-color: #60a5fa;
        --link-hover: #93c5fd;
    }
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Header */
header {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px var(--header-shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

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

.site-title a {
    color: var(--primary-color);
    text-decoration: none;
}

.main-nav {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.main-nav a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.main-nav a:hover {
    color: var(--primary-color);
}

/* Main Content */
main {
    min-height: calc(100vh - 200px);
    padding: 3rem 0;
}

.content {
    max-width: 900px;
    margin: 0 auto;
}

/* Typography */
.content h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    line-height: 1.2;
    color: var(--text-color);
}

.content h2 {
    font-size: 2rem;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    line-height: 1.3;
    color: var(--text-color);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.content h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--text-color);
}

.content h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.content h5,
.content h6 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.content p {
    margin-bottom: 1.25rem;
    color: var(--text-color);
}

.content a {
    color: var(--link-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.content a:hover {
    color: var(--link-hover);
    border-bottom-color: var(--link-hover);
}

/* Lists */
.content ul,
.content ol {
    margin-bottom: 1.25rem;
    padding-left: 2rem;
}

.content li {
    margin-bottom: 0.5rem;
}

.content li > ul,
.content li > ol {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Code */
.content code {
    background-color: var(--code-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
    font-size: 0.875em;
    color: var(--code-text);
}

.content pre {
    background-color: var(--code-bg);
    padding: 1.25rem;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 1.25rem;
    border: 1px solid var(--border-color);
}

.content pre code {
    background-color: transparent;
    padding: 0;
    color: var(--text-color);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Blockquotes */
.content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1.25rem;
    margin: 1.5rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

.content blockquote strong {
    color: var(--primary-color);
    font-style: normal;
    font-weight: 600;
}

/* Tables */
.content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    display: block;
}

.content th,
.content td {
    padding: 0.75rem;
    text-align: left;
    border: 1px solid var(--border-color);
}

.content th {
    background-color: var(--bg-secondary);
    font-weight: 600;
}

.content tr:nth-child(even) {
    background-color: var(--bg-secondary);
}

/* Horizontal Rule */
.content hr {
    border: none;
    border-top: 2px solid var(--border-color);
    margin: 2rem 0;
}

/* Images */
.content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 1.5rem 0;
}

/* Footer */
footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    padding: 3rem 0 1.5rem;
    margin-top: 4rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3 {
    color: #ffffff;
    font-size: 1.125rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.footer-section p {
    color: var(--footer-text);
    line-height: 1.6;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: var(--footer-text);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-section a:hover {
    color: #ffffff;
}

.footer-bottom {
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    color: var(--footer-text);
}

.footer-bottom a {
    color: var(--footer-text);
    text-decoration: underline;
}

.footer-bottom a:hover {
    color: #ffffff;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .main-nav {
        flex-wrap: wrap;
        gap: 1rem;
        justify-content: center;
    }

    .content h1 {
        font-size: 2rem;
    }

    .content h2 {
        font-size: 1.5rem;
    }

    .content h3 {
        font-size: 1.25rem;
    }

    .content pre {
        padding: 1rem;
        font-size: 0.8rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
    }
}

/* Print Styles */
@media print {
    header,
    footer {
        display: none;
    }

    .content a {
        color: var(--text-color);
        text-decoration: underline;
    }

    .content pre {
        border: 1px solid #000;
        page-break-inside: avoid;
    }
}

/* Theme Toggle Button */
.theme-toggle {
    background: none;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-color);
}

.theme-toggle:hover {
    background-color: var(--bg-secondary);
    border-color: var(--primary-color);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-icon {
    width: 20px;
    height: 20px;
}
