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

:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --accent-color: #3b82f6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --text-color: #1f2937;
    --text-light: #6b7280;
    --bg-color: #ffffff;
    --bg-alt: #f9fafb;
    --bg-hero: #f0f7ff;
    --border-color: #e5e7eb;
    --code-bg: #1e293b;
    --code-text: #e2e8f0;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --max-width: 1100px;
    --scroll-offset: 80px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.7;
    color: var(--text-color);
    background-color: var(--bg-color);
    padding-top: 70px;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

/* Navigation */
.navbar {
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 24px;
    max-width: var(--max-width);
}

.nav-brand .brand-link {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.nav-brand .brand-link:hover {
    color: var(--secondary-color);
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.nav-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: var(--text-color);
    transition: all 0.3s ease;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    align-items: center;
}

.nav-menu a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: all 0.3s ease;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
}

.nav-menu a:hover {
    color: var(--primary-color);
    background-color: var(--bg-alt);
}

/* Content Area */
.content {
    padding: 0 0 4rem;
    min-height: calc(100vh - 200px);
}

/* Hero Section Styling */
.content .container > h1:first-child {
    font-size: 2.75rem;
    margin: 0 -24px 2rem;
    padding: 4rem 24px 3rem;
    background: linear-gradient(135deg, var(--bg-hero) 0%, var(--bg-alt) 100%);
    border-bottom: 3px solid var(--primary-color);
    text-align: center;
}

.content .container > h1:first-child + p {
    text-align: center;
    margin: 2rem auto;
}

/* Image container centering - note: :has() has limited browser support in older browsers */
.content .container > p:has(> img) {
    text-align: center;
    margin: 2rem 0;
}

/* Fallback for browsers without :has() support - images will still display correctly */
.content p img {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Typography from Markdown */
.content h1 {
    font-size: 2.5rem;
    margin: 3rem 0 1.5rem;
    color: var(--text-color);
    font-weight: 700;
    line-height: 1.2;
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 0.5rem;
}

.content h1:first-child {
    margin-top: 0;
}

.content h2 {
    font-size: 2rem;
    margin: 3.5rem 0 1.5rem;
    color: var(--text-color);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.75rem;
    scroll-margin-top: var(--scroll-offset);
}

.content h3 {
    font-size: 1.5rem;
    margin: 2.5rem 0 1rem;
    color: var(--text-color);
    font-weight: 600;
    scroll-margin-top: var(--scroll-offset);
}

.content h4 {
    font-size: 1.25rem;
    margin: 2rem 0 0.75rem;
    color: var(--text-color);
    font-weight: 600;
    scroll-margin-top: var(--scroll-offset);
}

.content p {
    margin-bottom: 1.25rem;
    line-height: 1.8;
}

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

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

/* Images */
.content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 2rem auto;
    box-shadow: var(--shadow-lg);
    display: block;
}

/* Lists */
.content ul,
.content ol {
    margin: 1rem 0 1.5rem 2rem;
    line-height: 1.8;
}

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

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

.content ul ul,
.content ol ol,
.content ul ol,
.content ol ul {
    margin: 0.5rem 0 0.5rem 1.5rem;
}

/* Code Blocks */
.content pre {
    background-color: var(--code-bg);
    border: none;
    border-radius: 8px;
    padding: 1.25rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.content code {
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 0.875em;
}

.content pre code {
    background-color: transparent;
    border: none;
    padding: 0;
    display: block;
    color: var(--code-text);
    line-height: 1.6;
}

.content p code,
.content li code,
.content td code {
    background-color: #e5e7eb;
    color: #dc2626;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: none;
    font-size: 0.875em;
    font-weight: 500;
}

.copy-button {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    padding: 0.375rem 0.875rem;
    background-color: rgba(255, 255, 255, 0.9);
    color: var(--code-bg);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0.9;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.copy-button:hover {
    opacity: 1;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

/* Tables */
.content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.95rem;
}

.content th {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 1rem 1.25rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.95rem;
}

.content td {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.content tr:last-child td {
    border-bottom: none;
}

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

.content tbody tr:hover {
    background-color: #f0f7ff;
    transition: background-color 0.2s ease;
}

/* Blockquotes */
.content blockquote {
    border-left: 4px solid var(--primary-color);
    padding: 1.25rem 1.75rem;
    margin: 1.5rem 0;
    background-color: var(--bg-alt);
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: var(--text-light);
}

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

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

/* Strong and Em */
.content strong {
    font-weight: 600;
    color: var(--text-color);
}

.content em {
    font-style: italic;
}

/* Footer */
.footer {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    color: white;
    padding: 2.5rem 0;
    margin-top: 5rem;
}

.footer .container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    align-items: center;
    text-align: center;
    max-width: var(--max-width);
}

.footer p {
    opacity: 0.9;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links a {
    color: white;
    text-decoration: none;
    transition: all 0.3s ease;
    padding: 0.5rem 1rem;
    border-radius: 6px;
}

.footer-links a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

/* Responsive Design - Tablet */
@media (max-width: 768px) {
    body {
        padding-top: 60px;
    }

    .container {
        padding: 0 20px;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        flex-direction: column;
        padding: 1rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        display: none;
        gap: 0;
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-menu li {
        width: 100%;
        text-align: center;
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-menu li:last-child {
        border-bottom: none;
    }

    .nav-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .nav-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .nav-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }

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

    .content .container > h1:first-child {
        font-size: 2.25rem;
        padding: 3rem 20px 2.5rem;
        margin: 0 -20px 2rem;
    }

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

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

    .content table {
        font-size: 0.875rem;
    }

    .content th,
    .content td {
        padding: 0.5rem;
    }
}

/* Responsive Design - Mobile */
@media (max-width: 480px) {
    .container {
        padding: 0 16px;
    }

    .nav-brand .brand-link {
        font-size: 1.25rem;
    }

    .content {
        padding: 0 0 3rem;
    }

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

    .content .container > h1:first-child {
        font-size: 1.875rem;
        padding: 2.5rem 16px 2rem;
        margin: 0 -16px 1.5rem;
    }

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

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

    .content h4 {
        font-size: 1.1rem;
    }

    .content pre {
        padding: 0.75rem;
        font-size: 0.85rem;
    }

    .content table {
        font-size: 0.8rem;
        display: block;
        overflow-x: auto;
    }

    .footer-links {
        gap: 1rem;
    }
}

/* Accessibility */
a:focus,
button:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    body {
        padding-top: 0;
    }

    .navbar,
    .footer {
        display: none;
    }

    .content {
        padding: 0;
    }

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

    .copy-button {
        display: none;
    }
}
