:root {
    --bg-dark: #09090b;
    --bg-card: #141417;
    /* Zinc 900 */
    --bg-sidebar: #0c0c0e;
    --primary: #6366f1;
    /* Indigo 500 */
    --primary-hover: #4f46e5;
    --text-main: #e4e4e7;
    --text-muted: #a1a1aa;
    --border: #27272a;
    --success: #10b981;

    --font-sans: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    height: 100vh;
    overflow: hidden;
}

/* Layout */
.app-container {
    display: flex;
    height: 100%;
}

/* Map View */
.map-view {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at 50% 50%, #1a1a2e 0%, #09090b 100%);
    position: relative;
    z-index: 1;
}

.map-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10;
}

.brand {
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    display: flex;
    gap: 10px;
    align-items: center;
}

.brand i {
    color: var(--primary);
}

.glossary-btn-icon {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background 0.2s;
}

.glossary-btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

.map-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 100px 20px 150px 20px;
    /* Padding for header/footer space */
    display: flex;
    flex-direction: column;
    align-items: center;
    scrollbar-width: none;
    /* Hide scrollbar */
}

.map-scroll-area::-webkit-scrollbar {
    display: none;
}

/* Unit/Block Section */
.unit-section {
    width: 100%;
    max-width: 600px;
    margin-bottom: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.unit-header {
    background: var(--primary);
    color: #fff;
    padding: 15px 30px;
    border-radius: 20px;
    font-weight: 700;
    margin-bottom: 40px;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 10px 30px -10px var(--primary);
    z-index: 2;
    text-align: center;
}

/* Zig Zig Path Logic */
.nodes-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
}

.node-wrapper {
    position: relative;
    margin-bottom: 60px;
    z-index: 2;
}

/* Offsets for Zig Zag */
.node-wrapper:nth-child(4n+1) {
    transform: translateX(0);
}

.node-wrapper:nth-child(4n+2) {
    transform: translateX(-60px);
}

.node-wrapper:nth-child(4n+3) {
    transform: translateX(0);
}

.node-wrapper:nth-child(4n+4) {
    transform: translateX(60px);
}

/* Node wrapper animation - keep in global since it's applied by JS */
.node-wrapper {
    position: relative;
    margin-bottom: 60px;
    z-index: 2;
    animation: popIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(20px);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes unlockPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(99, 102, 241, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
    }
}

.map-node.unlock-anim {
    animation: unlockPulse 1.5s infinite;
}


/* SVG Connector (Background Line) */
.path-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.path-line {
    fill: none;
    stroke: var(--border);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 20 10;
}

/* Learning Overlay */
.learning-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.86, 0, 0.07, 1);
}

.learning-overlay.open {
    transform: translateY(0);
}

.overlay-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 20px;
    background: rgba(9, 9, 11, 0.95);
}

.close-overlay {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
}

.close-overlay:hover {
    color: #fff;
}

.overlay-info {
    flex: 1;
}

.overlay-info h1 {
    font-size: 1.1rem;
    color: #fff;
    margin: 0;
}

.overlay-info .breadcrumb {
    font-size: 0.8rem;
}

.overlay-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}


/* Tabs */
.tabs-header {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    position: relative;
}

.tab-btn.active {
    color: var(--primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

    to {
        opacity: 1;
    }
}

/* Theory Content */
.theory-content {
    font-size: 1rem;
    line-height: 1.8;
    max-width: 800px;
}

.theory-content h1,
.theory-content h2,
.theory-content h3 {
    color: #fff;
    margin-top: 1.5em;
}

.theory-content pre {
    border: 1px solid var(--border);
    border-radius: 8px !important;
}

/* Practice Content */
.code-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

.code-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.run-btn {
    background: var(--success);
    color: #fff;
    border: none;
    padding: 5px 15px;
    border-radius: 4px;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Quiz */
.quiz-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 25px;
    max-width: 600px;
}

.quiz-option {
    display: block;
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: left;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
}

.quiz-option:hover {
    border-color: var(--primary);
}

.quiz-option.correct {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--success);
}

.quiz-option.wrong {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay.open {
    display: flex;
}

.modal-card {
    background: #18181b;
    width: 90%;
    max-width: 600px;
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #fff;
    cursor: pointer;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.glossary-item {
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.glossary-term {
    color: var(--primary);
    font-weight: 700;
    display: block;
    margin-bottom: 5px;
}

/* Mobile */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.2rem;
}

@media(max-width: 768px) {
    .sidebar {
        position: absolute;
        height: 100%;
        transform: translateX(-100%);
        z-index: 50;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .menu-toggle {
        display: block;
    }
}



/* Practice UI (Local Execution) */
.practice-instructions {
    margin-bottom: 1.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.req-section {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.req-badge {
    background: #1f6feb;
    color: #fff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
}

.copy-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.copy-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.copy-btn.copied {
    border-color: var(--success);
    color: var(--success);
}

/* User Stats */
.user-stats {
    display: flex;
    gap: 15px;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 5px 15px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--text-main);
}

.stat-icon {
    font-size: 1.1rem;
}

.stat-icon-gold {
    color: #ffd700;
}

.stat-icon-xp {
    color: #a855f7;
}

@media(max-width: 600px) {
    .user-stats {
        display: none;
        /* Hide on small screens for now or adapt */
    }
}