/* ============================================================================
   VirtualMachine.space - Main Styles
   ============================================================================ */

:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1e40af;
    --color-primary-light: #3b82f6;
    --color-secondary: #64748b;
    --color-border: #e2e8f0;
    --color-border-dark: #1e293b;
    --color-bg: #ffffff;
    --color-bg-dark: #0f172a;
    --color-text: #0f172a;
    --color-text-light: #64748b;
}

/* Typography */
:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
}

/* Dark Mode */
:root.dark {
    --color-bg: #0f172a;
    --color-text: #f1f5f9;
    --color-text-light: #cbd5e1;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.5em;
    margin-top: 1em;
}

h1 {
    font-size: clamp(2rem, 5vw, 3rem);
}

h2 {
    font-size: clamp(1.5rem, 4vw, 2.25rem);
    border-bottom: 1px solid rgba(100, 116, 139, 0.1);
    padding-bottom: 0.5em;
    margin-top: 1.5em;
}

h3 {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
}

h4, h5, h6 {
    font-size: 1.125rem;
}

/* Links */
a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

:root.dark a {
    color: #3b82f6;
}

:root.dark a:hover {
    color: #60a5fa;
}

/* Code */
code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    padding: 0.2em 0.4em;
    background-color: #f1f5f9;
    border-radius: 0.25rem;
    color: #1e293b;
}

:root.dark code {
    background-color: #1e293b;
    color: #e2e8f0;
}

pre {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1rem 0;
    font-size: 0.875rem;
    line-height: 1.5;
}

pre code {
    background: none;
    color: inherit;
    padding: 0;
    border-radius: 0;
}

/* Blockquote */
blockquote {
    border-left: 4px solid var(--color-primary);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--color-text-light);
    font-style: italic;
}

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

li {
    margin: 0.5rem 0;
}

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

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

:root.dark th,
:root.dark td {
    border-bottom-color: var(--color-border-dark);
}

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

:root.dark th {
    background-color: #1e293b;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-primary {
    background-color: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--color-primary-dark);
}

.btn-secondary {
    border: 2px solid var(--color-border);
    color: var(--color-text);
    background-color: transparent;
}

:root.dark .btn-secondary {
    border-color: var(--color-border-dark);
    color: var(--color-text);
}

.btn-secondary:hover {
    background-color: #f8fafc;
}

:root.dark .btn-secondary:hover {
    background-color: #1e293b;
}

/* Cards */
.card {
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 1.5rem;
    transition: all 0.2s ease;
}

:root.dark .card {
    background-color: #1e293b;
    border-color: var(--color-border-dark);
}

.card:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

:root.dark .card:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-primary {
    background-color: #dbeafe;
    color: #0c4a6e;
}

:root.dark .badge-primary {
    background-color: #1e3a8a;
    color: #93c5fd;
}

.badge-secondary {
    background-color: #f1f5f9;
    color: #334155;
}

:root.dark .badge-secondary {
    background-color: #1e293b;
    color: #cbd5e1;
}

/* Prose Styling */
.prose {
    max-width: 65ch;
}

.prose p {
    margin-bottom: 1rem;
    line-height: 1.75;
}

.prose img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
}

/* Premium table system */
.table-wrapper {
    margin: 1.25rem 0;
    overflow-x: auto;
    border: 1px solid #dbe4f0;
    border-radius: 1rem;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 30%);
}

:root.dark .table-wrapper {
    border-color: #23314a;
    background: linear-gradient(180deg, #0f172a 0%, #0b1220 30%);
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.5);
}

.tech-table {
    margin: 0;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 720px;
    font-size: 0.92rem;
}

.tech-table caption {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #334155;
}

:root.dark .tech-table caption {
    color: #cbd5e1;
}

.tech-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #0f172a;
    background: #eaf2ff;
    border-bottom: 1px solid #c8d9f3;
}

:root.dark .tech-table thead th {
    color: #e2e8f0;
    background: #13233b;
    border-bottom-color: #2b3d5b;
}

.tech-table tbody tr:nth-child(odd) {
    background-color: rgba(241, 245, 249, 0.55);
}

:root.dark .tech-table tbody tr:nth-child(odd) {
    background-color: rgba(15, 23, 42, 0.55);
}

.tech-table tbody tr:hover {
    background-color: rgba(191, 219, 254, 0.35);
}

:root.dark .tech-table tbody tr:hover {
    background-color: rgba(30, 64, 175, 0.28);
}

.tech-table th,
.tech-table td {
    padding: 0.85rem 0.95rem;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
}

:root.dark .tech-table th,
:root.dark .tech-table td {
    border-bottom-color: #1e293b;
}

.tech-table thead th.sortable {
    cursor: pointer;
}

.tech-table thead th.sortable:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
}

/* Figure system for markdown images */
.article-figure {
    margin: 1.5rem 0;
}

.article-figure__frame {
    overflow: hidden;
    border-radius: 1rem;
    border: 1px solid #dbe4f0;
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 40%);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

:root.dark .article-figure__frame {
    border-color: #23314a;
    background: linear-gradient(180deg, #0f172a 0%, #0b1220 40%);
    box-shadow: 0 10px 30px rgba(2, 6, 23, 0.55);
}

.article-figure__frame img {
    display: block;
    width: 100%;
    height: auto;
}

.article-figure__caption {
    margin-top: 0.75rem;
    font-size: 0.88rem;
    line-height: 1.6;
    color: #475569;
}

:root.dark .article-figure__caption {
    color: #94a3b8;
}

/* Utility Classes */
.container {
    max-width: 1280px;
    margin: 0 auto;
}

.no-select {
    user-select: none;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Responsive */
@media (max-width: 640px) {
    h1 {
        font-size: 1.875rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
}

/* Print Styles */
@media print {
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    h1, h2, h3 {
        page-break-after: avoid;
    }
    
    code {
        background-color: transparent;
        border: 1px solid #ccc;
    }
    
    pre {
        page-break-inside: avoid;
    }
}
