/* JetBrains Mono Font Import with Performance Optimization */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap');

/* CSS Custom Properties for Typography System */
:root {
    --font-mono: "JetBrains Mono", "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
    --color-bg: #1a1a1a;
    --color-surface: #2d2d2d;
    --color-text-primary: #ffffff;
    --color-text-secondary: #e9ecef;
    --color-text-muted: #f8f9fa;
    --color-border: #4a5568;
    --color-garden-sage: #9ca3af;
    --color-garden-sage-dark: #6b7280;
    --color-garden-accent: #10b981;
    --reading-width: 65ch;
    --focus-ring: 0 0 0 2px #10b981;
    
    /* Syntax Highlighting Colors (Monokai-inspired Dark Theme) */
    --syntax-keyword: #66d9ef;        /* Blue for keywords (def, if, return, function, const) */
    --syntax-string: #e6db74;         /* Yellow for strings and literals */
    --syntax-function: #a6e22e;       /* Green for function names and classes */
    --syntax-comment: #75715e;        /* Gray for comments */
    --syntax-number: #ae81ff;         /* Purple for numbers and escape sequences */
    --syntax-operator: #f92672;       /* Pink/Red for operators and built-ins */
    --syntax-text: #f8f8f2;          /* Light gray for regular text and punctuation */
    --syntax-code-bg: #1f2937;       /* Dark background for code blocks */
}

/* Reset and base styles */
*, ::before, ::after {
    box-sizing: border-box;
    border-width: 0;
    border-style: solid;
    border-color: #e5e7eb;
}

html, body {
    margin: 0;
    line-height: inherit;
    font-family: var(--font-mono);
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

body {
    margin: 0;
    line-height: inherit;
    font-family: var(--font-mono);
}

/* Container */
.container {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

@media (min-width: 640px) {
    .container { max-width: 640px; }
}

@media (min-width: 768px) {
    .container { max-width: 768px; }
}

@media (min-width: 1024px) {
    .container { max-width: 1024px; }
}

@media (min-width: 1280px) {
    .container { max-width: 1280px; }
}

@media (min-width: 1536px) {
    .container { max-width: 1536px; }
}

/* Layout */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-grow { flex-grow: 1; }
.flex-1 { flex: 1 1 0%; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.block { display: block; }
.inline-block { display: inline-block; }
.hidden { display: none; }

/* Spacing */
.mx-auto { margin-left: auto; margin-right: auto; }
.mt-auto { margin-top: auto; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mt-12 { margin-top: 3rem; }
.mt-16 { margin-top: 4rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mb-12 { margin-bottom: 3rem; }
.mr-1 { margin-right: 0.25rem; }
.mr-2 { margin-right: 0.5rem; }
.mr-3 { margin-right: 0.75rem; }
.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }

/* Padding */
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.py-12 { padding-top: 3rem; padding-bottom: 3rem; }
.py-0\.5 { padding-top: 0.125rem; padding-bottom: 0.125rem; }
.pt-4 { padding-top: 1rem; }

/* Sizing */
.w-auto { width: auto; }
.w-full { width: 100%; }
.w-4 { width: 1rem; }
.w-5 { width: 1.25rem; }
.w-8 { width: 2rem; }
.h-1 { height: 0.25rem; }
.h-4 { height: 1rem; }
.h-5 { height: 1.25rem; }
.h-8 { height: 2rem; }
.h-12 { height: 3rem; }
.h-32 { height: 8rem; }
.min-h-screen { min-height: 100vh; }
.max-w-none { max-width: none; }
.max-w-2xl { max-width: 42rem; }
.max-w-4xl { max-width: 56rem; }
.max-w-7xl { max-width: 80rem; }

/* Text */
.text-center { text-align: center; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.text-4xl { font-size: 2.25rem; line-height: 2.5rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.leading-relaxed { line-height: 1.625; }

/* Colors */
.bg-white { background-color: #ffffff; }
.bg-gray-50 { background-color: #f9fafb; }
.bg-gray-100 { background-color: #f3f4f6; }
.bg-gray-200 { background-color: #e5e7eb; }
.bg-green-200 { background-color: #bbf7d0; }
.bg-yellow-200 { background-color: #fef08a; }
.bg-blue-200 { background-color: #dbeafe; }
.bg-emerald-500 { background-color: #10b981; }

.text-gray-600 { color: #4b5563; }
.text-gray-700 { color: #374151; }
.text-gray-800 { color: #1f2937; }
.text-gray-900 { color: #111827; }
.text-green-800 { color: #166534; }
.text-yellow-800 { color: #9a3412; }
.text-blue-800 { color: #1e40af; }
.text-emerald-500 { color: #10b981; }

/* Garden theme colors - Dark Theme */
.bg-garden-bg { background-color: var(--color-bg); }
.bg-garden-surface { background-color: var(--color-surface); }
.bg-garden-surface-alt { background-color: #353535; }
.text-garden-text-primary { color: var(--color-text-primary); }
.text-garden-text-secondary { color: var(--color-text-secondary); }
.text-garden-text-muted { color: var(--color-text-muted); }
.text-white { color: #ffffff; }

/* Garden sage and accent colors with opacity variants */
.bg-garden-sage { background-color: var(--color-garden-sage); }
.bg-garden-sage-dark { background-color: var(--color-garden-sage-dark); }
.bg-garden-accent { background-color: var(--color-garden-accent); }
.text-garden-sage { color: var(--color-garden-sage); }
.text-garden-sage-dark { color: var(--color-garden-sage-dark); }
.text-garden-accent { color: var(--color-garden-accent); }

/* Opacity variants for garden colors */
.bg-garden-sage\/10 { background-color: rgb(156 163 175 / 0.1); }
.bg-garden-sage\/20 { background-color: rgb(156 163 175 / 0.2); }
.bg-garden-accent\/10 { background-color: rgb(16 185 129 / 0.1); }
.bg-garden-accent\/20 { background-color: rgb(16 185 129 / 0.2); }

/* Borders */
.border { border-width: 1px; }
.border-b { border-bottom-width: 1px; }
.border-t { border-top-width: 1px; }
.border-garden-border { border-color: var(--color-border); }
.rounded { border-radius: 0.25rem; }
.rounded-full { border-radius: 9999px; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-2xl { border-radius: 1rem; }

/* Flexbox & Grid */
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.space-x-2 > :not([hidden]) ~ :not([hidden]) { margin-right: 0; margin-left: 0.5rem; }
.space-x-4 > :not([hidden]) ~ :not([hidden]) { margin-right: 0; margin-left: 1rem; }
.space-x-6 > :not([hidden]) ~ :not([hidden]) { margin-right: 0; margin-left: 1.5rem; }
.space-y-4 > :not([hidden]) ~ :not([hidden]) { margin-top: 1rem; margin-bottom: 0; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Position */
.fixed { position: fixed; }
.sticky { position: sticky; }
.relative { position: relative; }
.absolute { position: absolute; }
.top-0 { top: 0; }
.left-0 { left: 0; }
.z-50 { z-index: 50; }

/* Effects */
.shadow-sm { box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); }
.shadow-md { box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); }
.transform { transform: translateX(0) translateY(0) rotate(0) skewX(0) skewY(0) scaleX(1) scaleY(1); }
.scale-x-0 { transform: scaleX(0); }

/* Animations */
@keyframes spin {
    to { transform: rotate(360deg); }
}
.animate-spin { animation: spin 1s linear infinite; }
.transition-colors { transition-property: color, background-color, border-color, text-decoration-color, fill, stroke; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.transition-transform { transition-property: transform; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.transition-all { transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.transition-shadow { transition-property: box-shadow; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.duration-200 { transition-duration: 200ms; }
.duration-300 { transition-duration: 300ms; }

/* Hover states */
.hover\:text-garden-accent:hover { color: var(--color-garden-accent); }
.hover\:text-white:hover { color: #ffffff; }
.hover\:underline:hover { text-decoration-line: underline; }
.hover\:bg-garden-accent:hover { background-color: var(--color-garden-accent); }
.hover\:shadow-lg:hover { box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); }

/* Touch Target Classes - 44px minimum for mobile accessibility */
.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.touch-44 {
    min-height: 44px;
    min-width: 44px;
}

.min-touch {
    min-height: 44px;
    min-width: 44px;
}

.mobile-touch {
    min-height: 44px;
    min-width: 44px;
    padding: 0.75rem 1rem;
}

/* Ensure buttons and interactive elements meet touch requirements */
button, .btn {
    min-height: 44px;
    min-width: 44px;
}

/* Navigation link touch targets */
nav a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
}

@media (max-width: 768px) {
    nav a {
        padding: 0.75rem 1rem;
        min-height: 44px;
    }
}

/* Responsive */
@media (min-width: 640px) {
    .sm\:px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
    .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 768px) {
    .md\:hidden { display: none !important; }
    .md\:flex { display: flex; }
    .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .md\:px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
    .md\:text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
    
    /* Hide mobile menu button on desktop screens - multiple selectors for higher specificity */
    .mobile-menu-toggle.md\:hidden,
    button.mobile-menu-toggle,
    .mobile-menu-toggle { display: none !important; }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .lg\:px-8 { padding-left: 2rem; padding-right: 2rem; }
}

@media (min-width: 1280px) {
    .xl\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Mobile Menu Button Visibility Fix */
.mobile-menu-toggle {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--color-text-primary);
    transition: all 0.2s ease;
}

.mobile-menu-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: var(--color-garden-accent);
    color: var(--color-garden-accent);
    transform: scale(1.05);
}

.mobile-menu-toggle:focus {
    outline: none;
    box-shadow: var(--focus-ring);
    border-color: var(--color-garden-accent);
}

.mobile-menu-toggle svg {
    stroke-width: 2.5;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}


/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .mobile-stack {
        flex-direction: column;
    }
    
    .mobile-hidden {
        display: none;
    }
    
    .mobile-full-width {
        width: 100%;
    }
}

/* Prose styling for content - Dark Theme with CSS Variables */
.prose {
    color: var(--color-text-secondary);
    max-width: var(--reading-width);
}

.prose p {
    margin-top: 1.25em;
    margin-bottom: 1.25em;
}

.prose h1, .prose h2, .prose h3 {
    color: var(--color-text-primary);
}

.prose h1 {
    font-weight: 800;
    font-size: 2.25em;
    margin-top: 0;
    margin-bottom: 0.8888889em;
    line-height: 1.1111111;
}

.prose h2 {
    font-weight: 700;
    font-size: 1.5em;
    margin-top: 2em;
    margin-bottom: 1em;
    line-height: 1.3333333;
}

.prose h3 {
    font-weight: 600;
    font-size: 1.25em;
    margin-top: 1.6em;
    margin-bottom: 0.6em;
    line-height: 1.6;
}

.prose a {
    color: var(--color-text-primary);
    text-decoration: underline;
    font-weight: 500;
}

.prose a:focus {
    outline: none;
    box-shadow: var(--focus-ring);
}

.prose ul {
    list-style-type: disc;
    margin-top: 1.25em;
    margin-bottom: 1.25em;
    padding-left: 1.625em;
}

.prose ol {
    list-style-type: decimal;
    margin-top: 1.25em;
    margin-bottom: 1.25em;
    padding-left: 1.625em;
}

.prose code {
    color: var(--color-text-primary);
    font-weight: 600;
    font-size: 0.875em;
}

.prose pre {
    color: #e5e7eb;
    background-color: #1f2937;
    overflow-x: auto;
    overflow-wrap: break-word;
    word-wrap: break-word;
    white-space: pre-wrap;
    font-weight: 400;
    font-size: 0.875em;
    line-height: 1.7142857;
    margin-top: 1.7142857em;
    margin-bottom: 1.7142857em;
    border-radius: 0.375rem;
    padding: 0.8571429em 1.1428571em;
}

.prose blockquote {
    font-weight: 500;
    font-style: italic;
    color: var(--color-text-primary);
    border-left-width: 0.25rem;
    border-left-color: var(--color-border);
    margin-top: 1.6em;
    margin-bottom: 1.6em;
    padding-left: 1em;
}

/* Pygments Syntax Highlighting Styles - Dark Theme (Monokai-inspired) */
.codehilite {
    /* Inherit base code block styles from .prose pre */
    background-color: var(--syntax-code-bg);
    border-radius: 0.375rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.875em;
    line-height: 1.7142857;
    padding: 0.8571429em 1.1428571em;
    margin: 1.7142857em 0;
}

/* Keywords - Blue theme for language keywords */
.codehilite .k,
.codehilite .kd,
.codehilite .kp,
.codehilite .kr,
.codehilite .kt {
    color: var(--syntax-keyword);
}

/* Keyword namespaces - Pink/red for imports and special keywords */
.codehilite .kn {
    color: var(--syntax-operator);
}

/* Function and class names - Green for callables and types */
.codehilite .nf,
.codehilite .nc,
.codehilite .na {
    color: var(--syntax-function);
}

/* Built-in functions and operators - Pink/red for system functions */
.codehilite .nb,
.codehilite .o,
.codehilite .ow,
.codehilite .nt {
    color: var(--syntax-operator);
}

/* Regular names and variables - Light gray for general text */
.codehilite .nx,
.codehilite .nn,
.codehilite .nv,
.codehilite .p {
    color: var(--syntax-text);
}

/* Strings and literals - Yellow for all string types */
.codehilite .s,
.codehilite .s1,
.codehilite .s2,
.codehilite .sd,
.codehilite .sh,
.codehilite .si,
.codehilite .sx {
    color: var(--syntax-string);
}

/* String escape sequences - Purple for special characters */
.codehilite .se {
    color: var(--syntax-number);
}

/* Comments - Gray for all comment types */
.codehilite .c,
.codehilite .c1,
.codehilite .cm,
.codehilite .cs {
    color: var(--syntax-comment);
}

/* Numbers - Purple for all numeric literals */
.codehilite .m,
.codehilite .mi,
.codehilite .mf,
.codehilite .mh,
.codehilite .mo {
    color: var(--syntax-number);
}

/* Generic diff markers - Green for additions, red for deletions */
.codehilite .gi {
    color: var(--syntax-function);
}

.codehilite .gd {
    color: var(--syntax-operator);
}

/* Generic headings - Blue with bold for structure */
.codehilite .gh {
    color: var(--syntax-keyword);
    font-weight: bold;
}

.codehilite .gu {
    color: var(--syntax-comment);
    font-weight: bold;
}

/* Ensure responsive design for code blocks */
@media (max-width: 768px) {
    .codehilite {
        font-size: 0.8rem;
        padding: 0.75em 1em;
        margin: 1.5em 0;
    }
}