:root {
    /* Theme: GitHub (Default) */
    --primary: #0969da;
    --primary-hover: #0550ae;
    --success: #1f883d;
    --success-hover: #1a7f37;
    --danger: #cf222e;

    --bg: #ffffff;
    --bg-subtle: #f6f8fa;
    --surface: #ffffff;

    --border: #d0d7de;
    --border-muted: #d8dee4;

    --text: #24292f;
    --text-muted: #57606a;
    --text-on-primary: #ffffff;

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    --font-heading: var(--font-sans);

    --radius: 6px;
    --shadow-sm: 0 1px 0 rgba(27, 31, 35, 0.04);
    --shadow-md: 0 3px 6px rgba(140, 149, 159, 0.15);
    --shadow-lg: 0 8px 24px rgba(140, 149, 159, 0.2);

    /* Mapping old variables to new theme for compatibility */
    --primary-alt: #1f883d;
    /* Green */
    --secondary-glow: rgba(31, 136, 61, 0.1);
    --primary-glow: rgba(9, 105, 218, 0.1);
}

/* Theme: Academic (Ivy League) */
[data-theme="academic"] {
    --primary: #a71d2a;
    /* Harvard Red */
    --primary-hover: #7a151f;
    --success: #2e5902;
    --success-hover: #1e3a01;
    --danger: #8b0000;

    --bg: #fdfbf7;
    /* Warm paper */
    --bg-subtle: #f4f0e6;
    --surface: #ffffff;

    --border: #dcd6cc;
    --border-muted: #e6e0d5;

    --text: #1a1a1a;
    --text-muted: #555555;

    --font-sans: "Georgia", "Times New Roman", serif;
    /* Serif for everything */
    --font-heading: "Georgia", "Times New Roman", serif;
    --font-mono: "Courier New", Courier, monospace;

    --radius: 2px;
    /* Sharper corners */
    --shadow-sm: none;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

    --primary-alt: #003366;
    /* Oxford Blue */
}

/* Theme: Swiss (International Style) */
[data-theme="swiss"] {
    --primary: #000000;
    --primary-hover: #333333;
    --success: #000000;
    --success-hover: #333333;
    --danger: #ff3b30;
    /* Swiss Red */

    --bg: #ffffff;
    --bg-subtle: #f5f5f5;
    --surface: #ffffff;

    --border: #000000;
    --border-muted: #e5e5e5;

    --text: #000000;
    --text-muted: #666666;

    --font-sans: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-heading: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;

    --radius: 0px;
    /* No radius */
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;

    --primary-alt: #0055ff;
    /* International Blue */
}



* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    line-height: 1.6;
    /* Slightly increased for readability */
    width: 100%;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}







/* Swiss theme specific adjustments */
[data-theme="swiss"] .container {
    /* Removed max-width: 100% to respect global container width */
}

[data-theme="swiss"] .hero {
    padding-top: 10rem;
}

[data-theme="swiss"] .card,
[data-theme="swiss"] .terminal,
[data-theme="swiss"] .btn,
[data-theme="swiss"] nav {
    border-width: 2px;
}

[data-theme="swiss"] .section-title h2 {
    font-size: 4rem;
    letter-spacing: -0.05em;
    text-transform: uppercase;
}

.container {
    max-width: 1012px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

section[id] {
    scroll-margin-top: 80px;
}

/* Utility for cards */
.glass {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* Navbar */
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 1rem 0;
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    transition: all 0.3s;
}

[data-theme="academic"] nav {
    background: var(--bg);
    border-bottom: 3px double var(--border);
}

[data-theme="swiss"] nav {
    background: var(--bg);
    border-bottom: 2px solid black;
    padding: 1.5rem 0;
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    font-family: var(--font-heading);
}

.logo .char.highlight {
    color: var(--primary);
}

.logo:hover {
    color: var(--primary);
}

/* Win Badge */
.win-badge {
    position: absolute;
    top: 120%;
    left: 50%;
    transform: translateX(-50%) scale(0);
    background: var(--bg);
    color: var(--success);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid var(--success);
    box-shadow: var(--shadow-md);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.logo.game-won .win-badge {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-links a {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    font-family: var(--font-heading);
}

.nav-links a:hover {
    color: var(--text-muted);
}

.lang-toggle,
.theme-select {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    font-family: var(--font-sans);
}

.lang-toggle:hover,
.theme-select:hover {
    background: var(--bg-subtle);
    border-color: var(--border-muted);
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 101;
}

.menu-toggle span {
    display: block;
    width: 25px;
    height: 2px;
    background: var(--text);
    transition: all 0.3s;
}

.menu-toggle.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

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

.menu-toggle.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* Hero Section */
.hero {
    padding-top: 8rem;
    padding-bottom: 4rem;
    text-align: center;
}

.hero h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    letter-spacing: -0.03em;
    color: var(--text);
    font-family: var(--font-heading);
}

.hero p {
    font-size: 1.25rem;
    color: var(--text-muted);
    max-width: 700px;
    margin: 0 auto 2rem;
    line-height: 1.6;
}

.hero-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
}

.btn {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 600;
    text-decoration: none;
    font-size: 1rem;
    transition: all 0.2s;
    display: inline-block;
    font-family: var(--font-heading);
}

.btn-primary {
    background-color: var(--success);
    color: #fff;
    border: 1px solid rgba(27, 31, 35, 0.15);
    box-shadow: var(--shadow-sm);
}

[data-theme="academic"] .btn-primary {
    background-color: var(--primary);
    /* Red */
    border-bottom: 2px solid rgba(0, 0, 0, 0.2);
}

[data-theme="swiss"] .btn-primary {
    background-color: var(--text);
    color: var(--bg);
    border: 2px solid transparent;
}

[data-theme="swiss"] .btn-primary:hover {
    background-color: var(--bg);
    color: var(--text);
    border-color: var(--text);
}

.btn-primary:hover {
    background-color: var(--success-hover);
    text-decoration: none;
}

[data-theme="academic"] .btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--bg-subtle);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background-color: #f3f4f6;
    border-color: var(--border-muted);
}

.terminal {
    max-width: 600px;
    margin: 0 auto;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: left;
    font-family: var(--font-mono);
    color: var(--text);
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.terminal::before {
    content: "$";
    color: var(--text-muted);
    margin-right: 0.75rem;
    -webkit-user-select: none;
    user-select: none;
}

.terminal code {
    color: var(--text);
}

/* Features */
.features {
    padding: 4rem 0;
    background-color: var(--bg);
}

.section-title {
    text-align: center;
    margin-bottom: 3rem;
}

.section-title h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text);
    font-family: var(--font-heading);
}

.section-title p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.card {
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.2s ease;
}

.card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

[data-theme="swiss"] .card:hover {
    transform: translate(-4px, -4px);
    box-shadow: 8px 8px 0 var(--text);
    border-color: var(--text);
}

.card-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-subtle);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    border: 1px solid var(--border);
}

[data-theme="academic"] .card-icon {
    background: transparent;
    border: none;
    font-size: 2rem;
    width: auto;
    height: auto;
    justify-content: flex-start;
    color: var(--primary);
}

.card h3 {
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: var(--font-heading);
}

.card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Primitives Gallery */
.primitives {
    padding: 4rem 0;
    border-top: 1px solid var(--border);
    background-color: var(--bg-subtle);
}

.gallery-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.gallery-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.gallery-item h4 {
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-heading);
}

.gallery-item ul {
    list-style: none;
}

.gallery-item li {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.gallery-item li strong {
    color: var(--primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: var(--bg-subtle);
    padding: 0.1em 0.3em;
    border-radius: 4px;
    margin-right: 0.3em;
}

/* Code Showcase */
.showcase {
    padding: 4rem 0;
}

.code-block {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

[data-theme="swiss"] .code-block {
    background: #000;
    color: #fff;
    border: none;
}

pre {
    margin: 0;
}

/* Syntax Highlighting */
.token.comment {
    color: #6e7781;
    font-style: italic;
}

.token.keyword {
    color: #cf222e;
}

.token.string {
    color: #0a3069;
}

.token.function {
    color: #8250df;
}

.token.type {
    color: #953800;
}

.token.number {
    color: #0550ae;
}

/* Swiss Theme Dark Code Override */
[data-theme="swiss"] .token.comment {
    color: #999;
}

[data-theme="swiss"] .token.keyword {
    color: #ff3b30;
    font-weight: bold;
}

[data-theme="swiss"] .token.string {
    color: #4cd964;
}

[data-theme="swiss"] .token.function {
    color: #007aff;
}

[data-theme="swiss"] .token.type {
    color: #5856d6;
    font-weight: bold;
}

[data-theme="swiss"] .token.number {
    color: #ffcc00;
}


/* Performance Section */
.performance-section {
    padding: 4rem 0;
    background-color: var(--bg);
}

.chart-container {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.chart-row {
    margin-bottom: 1.5rem;
}

.chart-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.chart-bar-bg {
    height: 8px;
    background: var(--bg-subtle);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

[data-theme="swiss"] .chart-bar-bg {
    border-radius: 0;
    height: 12px;
    border: 1px solid black;
}

.chart-bar.base {
    background: #e1e4e8;
    width: 100% !important;
}

.chart-bar.cc {
    background: var(--success);
    height: 100%;
    border-radius: 4px;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
}

[data-theme="swiss"] .chart-bar.cc {
    background: var(--text);
    border-radius: 0;
}

.chart-bar.cc.contrast {
    background: var(--primary);
}

/* Knowledge Center */
.knowledge-center {
    padding: 4rem 0;
    border-top: 1px solid var(--border);
}

.doc-nav-wrapper {
    position: sticky;
    top: 60px;
    z-index: 90;
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

[data-theme="academic"] .doc-nav-wrapper {
    background: var(--bg);
}

[data-theme="swiss"] .doc-nav-wrapper {
    background: var(--bg);
    top: 70px;
    /* Adjust for Swiss header */
}



.doc-nav {
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
    padding: 0.75rem 0;
    /* Hide scrollbar but allow scrolling */
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

.doc-nav::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari and Opera */
}

.doc-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}

.doc-btn:hover {
    color: var(--text);
    background: var(--bg-subtle);
}

.doc-btn.active {
    background: var(--bg-subtle);
    color: var(--primary);
    border-color: var(--border);
    font-weight: 600;
}

[data-theme="swiss"] .doc-btn.active {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}



.doc-content {
    display: none;
}

.doc-content.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

.doc-main h3 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    font-family: var(--font-heading);
}

.analogy-box {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin: 1.5rem 0;
}

.analogy-box h4 {
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
}

.analogy-box p {
    font-size: 0.95rem;
    color: var(--text);
}

.principle-sidebar {
    margin-top: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.principle-sidebar h4 {
    grid-column: 1 / -1;
    width: 100%;
}

.principle-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.principle-card h5 {
    color: var(--text);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.principle-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

footer {
    padding: 3rem 0;
    text-align: center;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--bg-subtle);
    font-size: 0.9rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        z-index: 102;
    }

    .logo {
        max-width: calc(100% - 60px);
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        z-index: 102;
        /* Ensure logo is above menu background if needed, though menu covers it usually */
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: 0;
        transform: translateX(100%);
        width: 100%;
        height: 100vh;
        background: var(--bg);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 2.5rem;
        transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0.5s;
        z-index: 100;
        padding: 2rem;
        visibility: hidden;
    }

    .nav-links.active {
        display: flex;
        transform: translateX(0);
        visibility: visible;
        transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0s;
    }

    .nav-links a {
        font-size: 1.5rem;
    }

    .hero h1 {
        font-size: 2.5rem;
    }

    /* Swiss Theme Mobile Adjustments */
    /* [data-theme="swiss"] .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    } */

    [data-theme="swiss"] .section-title h2 {
        font-size: 2.5rem;
    }
}