/* ==========================================
 * 🎨 Professional EdTech Documentation Theme
 * Redesigned for Maximum Legibility & Clean UX
 * ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* 🎨 Clean Light Palette */
    --bg-body: #FAFAFA;
    --bg-surface: #FFFFFF;
    --bg-surface-hover: #F3F4F6;
    --bg-subtle: #F9FAFB;
    
    --text-primary: #111827;
    --text-secondary: #4B5563;
    --text-tertiary: #9CA3AF;
    
    --border-subtle: #F3F4F6;
    --border-default: #E5E7EB;
    --border-hover: #D1D5DB;

    /* Primary Accent (A refined, energetic Red for the "Wuxia" theme) */
    --primary: #DC2626;
    --primary-hover: #B91C1C;
    --primary-bg: #FEF2F2;
    --primary-border: #FCA5A5;

    /* Secondary / Badges */
    --color-green: #059669;
    --color-green-bg: #D1FAE5;
    --color-orange: #D97706;
    --color-orange-bg: #FEF3C7;
    --color-blue: #2563EB;
    --color-blue-bg: #DBEAFE;

    /* Scratch Block Colors */
    --sb-motion: #4C97FF;
    --sb-looks: #9966FF;
    --sb-sound: #D65CD6;
    --sb-events: #FFBF00;
    --sb-control: #FFAB19;
    --sb-sensing: #4CBFE6;
    --sb-operators: #59C059;
    --sb-variables: #FF8C1A;
    --sb-list: #FF661A;
    --sb-myblocks: #FF6680;

    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    
    /* Metrics */
    --max-width-content: 760px; /* Optimal reading measure (~65-75 chars) */
    --max-width-container: 1100px;
    --sidebar-width: 260px;
    --header-height: 64px;

    /* Shadows & Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    
    /* Code Palette (Deep Night Premium Dark) */
    --code-bg: #111827;            /* Deep dark blue/gray */
    --code-border: #374151;        /* Subtle border for contrast */
    --code-text: #E5E7EB;          /* Light gray for plain text */
}

/* =========================================
 * 🌍 Base & Reset
 * ========================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.7; /* High legibility */
    background-color: var(--bg-body);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    scroll-padding-top: calc(var(--header-height) + 24px); /* For anchor links */
}
body { min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary-hover); }

/* Layout Containers */
.container {
    max-width: var(--max-width-container);
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}
.page-wrapper { flex: 1; display: flex; flex-direction: column; }

/* =========================================
 * 🌟 Header (Clean Stripe-style)
 * ========================================= */
.site-header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-default);
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--header-height);
    display: flex;
    align-items: center;
}
.header-inner {
    max-width: var(--max-width-container);
    width: 100%;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.nav-brand:hover { color: var(--text-primary); }
.brand-icon { font-size: 1.4rem; }

.nav-links { display: flex; gap: 1rem; }
.nav-links a {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}
.nav-links a:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.hamburger { display: none; } /* Handled in media queries */

/* =========================================
 * 🏠 Premium Homepage Redesign
 * ========================================= */
.home-main { padding-bottom: 4rem; position: relative; overflow: hidden; }

/* Dynamic Background Animations */
.hero-bg-anim {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 100%; min-height: 800px;
    background: radial-gradient(circle at top left, #fdfbfb 0%, #ebedee 100%);
    z-index: -1;
    overflow: hidden;
}
.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.6;
    animation: floatAnim 10s infinite ease-in-out alternate;
}
.blob.shape-1 { width: 400px; height: 400px; background: rgba(220, 38, 38, 0.15); top: -100px; left: -100px; }
.blob.shape-2 { width: 500px; height: 500px; background: rgba(37, 99, 235, 0.1); top: 20%; right: -200px; animation-delay: -3s; }
.blob.shape-3 { width: 300px; height: 300px; background: rgba(5, 150, 105, 0.1); bottom: -100px; left: 30%; animation-duration: 12s;}

@keyframes floatAnim {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(-50px) scale(1.1); }
}

/* Base Common */
.section-header { margin-bottom: 2.5rem; }
.section-header.center { text-align: center; }
.section-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.title-sparkle { color: var(--color-orange); font-size: 1.5rem; }
.section-desc {
    color: var(--text-secondary);
    font-size: 1.125rem;
    margin-top: 0.5rem;
}

/* Hero Section */
.hero-section {
    padding: 6rem 0 4rem;
    position: relative;
}
.hero-container {
    display: flex;
    align-items: center;
    gap: 4rem;
}
.hero-content { flex: 1; min-width: 0; }
.hero-visual {
    flex: 1;
    display: none;
}
@media (min-width: 900px) {
    .hero-visual { display: block; perspective: 1000px; }
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 1rem;
    background: white;
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.1);
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 700;
    border-radius: 9999px;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(220, 38, 38, 0.15);
}

.hero-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 900;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    line-height: 1.1;
}
.text-gradient {
    background: linear-gradient(135deg, var(--primary) 0%, #ff6b6b 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 500px;
    margin-bottom: 2rem;
    line-height: 1.7;
}

/* Buttons */
.hero-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.btn-primary-glow, .btn-secondary-glow {
    padding: 0.875rem 1.75rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-primary-glow {
    background: var(--primary);
    color: white;
    box-shadow: 0 10px 25px -5px rgba(220, 38, 38, 0.4);
}
.btn-primary-glow:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px -5px rgba(220, 38, 38, 0.5);
    color: white;
}
.btn-secondary-glow {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}
.btn-secondary-glow:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05);
}

/* Crystal Card (Hero visual) */
.crystal-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
    transform: rotateY(-5deg) rotateX(5deg);
    transition: transform 0.5s ease;
}
.crystal-card:hover { transform: rotateY(0) rotateX(0); }
.code-preview {
    background: #1e1e1e;
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    text-align: left;
}
.code-preview code { color: #d4d4d4; font-family: var(--font-mono); font-size: 0.9rem; }
.code-preview .kw { color: #569cd6; } /* keyword */
.code-preview .fn { color: #dcdcaa; } /* function */
.code-preview .str { color: #ce9178; } /* string */
.code-preview .num { color: #b5cea8; } /* number */

/* Progress Section */
.progress-section { position: relative; z-index: 10; padding-bottom: 2rem; margin-top: -3rem; }
.glass-panel {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 1);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px -5px rgba(0,0,0,0.05);
    padding: 2rem;
    max-width: 700px;
    margin: 0 auto;
}
.progress-header { display: flex; justify-content: space-between; margin-bottom: 1.25rem; align-items: center; }
.progress-title-wrap { display: flex; align-items: center; gap: 0.5rem; }
.progress-icon { font-size: 1.25rem; }
.progress-title { font-weight: 700; font-size: 1.125rem; color: var(--text-primary); }
.progress-text { font-size: 1rem; font-weight: 700; color: var(--primary); background: var(--primary-bg); padding: 0.25rem 0.75rem; border-radius: 9999px; }
.progress-bar-container { position: relative; }
.progress-bar { height: 12px; background: rgba(0,0,0,0.05); border-radius: 6px; overflow: hidden; position: relative; z-index: 2; box-shadow: inset 0 1px 3px rgba(0,0,0,0.05); }
.progress-fill { height: 100%; background: linear-gradient(90deg, #ff6b6b, var(--primary)); border-radius: 6px; transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1); position: relative; }
.progress-fill::after { content: ''; position: absolute; top:0; left:0; right:0; bottom:0; background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.4) 50%, rgba(255,255,255,0) 100%); animation: shimmer 2s infinite; }
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* Course List */
.course-list-section { padding: 4rem 0; }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 2rem; }
.lesson-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-lg);
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    z-index: 1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}
.lesson-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    padding: 2px;
    background: linear-gradient(135deg, transparent, transparent);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    transition: background 0.4s;
    pointer-events: none;
}
.lesson-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px -15px rgba(220, 38, 38, 0.15);
}
.lesson-card:hover::after {
    background: linear-gradient(135deg, var(--primary) 0%, #ff6b6b 100%);
}

.card-bg-icon {
    position: absolute;
    bottom: -15%;
    right: -10%;
    font-size: 15rem;
    opacity: 0.04;
    transform: rotate(-15deg);
    transition: all 0.5s ease;
    z-index: -1;
    pointer-events: none;
}
.lesson-card:hover .card-bg-icon {
    transform: rotate(0) scale(1.1);
    opacity: 0.08;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.75rem 0.5rem;
}
.lesson-number {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--primary);
    background: var(--primary-bg);
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    letter-spacing: 0.05em;
    border: 1px solid rgba(220, 38, 38, 0.1);
}
.lesson-status {
    font-size: 1.25rem;
    transition: transform 0.3s;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}
.lesson-card:hover .lesson-status { transform: scale(1.15); }

.card-body {
    padding: 1rem 1.75rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}
.lesson-emoji-wrap {
    margin-bottom: 1rem;
    height: 3.5rem;
    display: flex;
    align-items: center;
}
.lesson-emoji {
    font-size: 3rem;
    filter: drop-shadow(0 8px 12px rgba(0,0,0,0.15));
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: inline-block;
}
.lesson-card:hover .lesson-emoji {
    transform: translateY(-4px) scale(1.15) rotate(5deg);
}

.lesson-card h3 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    letter-spacing: -0.01em;
    line-height: 1.3;
}
.lesson-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    flex-grow: 1;
}

.card-footer {
    padding: 1.25rem 1.75rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.5);
}
.explore-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
    transition: color 0.3s;
}
.lesson-card:hover .explore-btn { color: var(--primary); }
.explore-btn .arrow {
    display: inline-block;
    transition: transform 0.3s ease;
}
.lesson-card:hover .explore-btn .arrow {
    transform: translateX(6px);
}

/* Appendix Links */
.appendix-section { padding: 4rem 0 6rem; background: var(--bg-surface-hover); border-top: 1px solid var(--border-default); margin-top: 2rem; }
.appendix-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.5rem; }
.appendix-card {
    display: flex; align-items: center; gap: 1rem;
    background: white; border: 1px solid var(--border-default);
    padding: 1.25rem 1.5rem; border-radius: var(--radius-md);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}
.appendix-card:hover { border-color: var(--primary-border); box-shadow: 0 10px 15px -3px rgba(220, 38, 38, 0.1); transform: translateY(-2px); }
.appendix-card .appendix-emoji { font-size: 1.5rem; }
.appendix-card .appendix-title { font-weight: 600; font-size: 1.0625rem; }

/* Subtle Intro Animations */
[data-animate="fade-up"] { opacity: 0; transform: translateY(20px); animation: fadeUp 0.8s forwards cubic-bezier(0.4, 0, 0.2, 1); }
[data-animate="zoom-in"] { opacity: 0; transform: scale(0.95); animation: zoomIn 0.8s forwards cubic-bezier(0.4, 0, 0.2, 1); animation-delay: 0.2s; }
@keyframes fadeUp { to { opacity: 1; transform: translateY(0); } }
@keyframes zoomIn { to { opacity: 1; transform: scale(1); } }

/* =========================================
 * 📘 Lesson Page (Dual Column Layout)
 * ========================================= */
.lesson-container {
    display: flex;
    gap: 4rem;
    padding: 3rem 1.5rem;
    align-items: flex-start;
}

.lesson-main {
    flex: 1;
    min-width: 0;
    max-width: var(--max-width-content);
    margin: 0 auto; /* Center main content if no sidebar */
}

/* Sidebar TOC (Desktop) */
.lesson-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    display: none; /* hidden on mobile, block on lg */
}
@media (min-width: 1024px) {
    .lesson-sidebar { display: block; }
    .lesson-main { margin: 0; } /* Left align when sidebar is present */
}

.sticky-toc {
    position: sticky;
    top: calc(var(--header-height) + 2rem);
    max-height: calc(100vh - var(--header-height) - 4rem);
    overflow-y: auto;
    padding-right: 1rem;
}
.toc-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    margin-bottom: 1rem;
}
.toc-content ul { list-style: none; }
.toc-content ul ul { padding-left: 1rem; margin-top: 0.25rem; }
.toc-content li { margin-bottom: 0.5rem; }
.toc-content a {
    color: var(--text-secondary);
    font-size: 0.875rem;
    display: block;
    line-height: 1.4;
    transition: color 0.15s;
}
.toc-content a:hover { color: var(--primary); }

/* Mobile TOC */
.mobile-toc {
    display: block;
    margin-bottom: 2rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 1rem;
}
@media (min-width: 1024px) { .mobile-toc { display: none; } }
.mobile-toc summary {
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9375rem;
    color: var(--text-primary);
}
.mobile-toc .toc-content { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border-default); }

/* Lesson Header */
.lesson-header { margin-bottom: 2.5rem; }
.lesson-badges {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.badge-green { background: var(--color-green-bg); color: var(--color-green); }
.badge-yellow { background: var(--color-orange-bg); color: var(--color-orange); }
.badge-red { background: var(--primary-bg); color: var(--primary); }
.badge-ai { background: var(--color-blue-bg); color: var(--color-blue); }

.lesson-title {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: var(--text-primary);
}
.lesson-title .lesson-emoji { margin-right: 0.25rem; }

/* Parent Guide Panel */
.parent-guide-panel {
    background: var(--bg-surface);
    border: 1px solid var(--color-blue);
    border-radius: var(--radius-md);
    margin-bottom: 3rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.1);
}
.panel-toggle {
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--color-blue-bg);
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}
.panel-toggle:hover { background: #BFDBFE; }
.toggle-left { display: flex; align-items: center; gap: 0.5rem; }
.toggle-icon { font-size: 1.1rem; }
.toggle-text { font-weight: 600; color: #1E3A8A; font-size: 0.9375rem; }
.toggle-time { font-weight: 400; color: #3B82F6; font-size: 0.875rem; }
.chevron { width: 1.25rem; height: 1.25rem; color: #1E3A8A; transition: transform 0.3s; }
.panel-toggle[aria-expanded="false"] .chevron { transform: rotate(-90deg); }

.panel-content {
    padding: 1.5rem;
    background: var(--bg-surface);
    border-top: 1px solid rgba(37, 99, 235, 0.1);
}
.panel-content.collapsed { display: none; }

/* =========================================
 * 📝 Typography (Prose Class)
 * The highly readable documentation body
 * ========================================= */
.prose {
    color: var(--text-primary);
    font-size: 1.0625rem; /* ~17px, extremely readable */
    line-height: 1.75;
}
/* Hide duplicate h1 from parsed markdown */
.prose > h1:first-child { display: none; }

.prose h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 3.5rem;
    margin-bottom: 1.25rem;
    letter-spacing: -0.01em;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-default);
    color: var(--text-primary);
}
.prose h3 { 
    font-size: 1.25rem; 
    font-weight: 700; 
    margin-top: 2.5rem; 
    margin-bottom: 1rem; 
    letter-spacing: -0.01em;
    color: var(--primary);
    display: flex;
    align-items: center;
}
.prose h3::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 1.2em;
    background: var(--primary);
    margin-right: 0.5rem;
    border-radius: 3px;
}
.prose h4 { font-size: 1.125rem; font-weight: 600; margin-top: 2rem; margin-bottom: 0.75rem; color: var(--text-primary); }

.prose p { margin-bottom: 1.5rem; color: var(--text-secondary); }

/* Significantly improved list indentation and readability */
.prose ul, .prose ol { 
    margin-bottom: 1.5rem; 
    padding-left: 2rem; /* Increased base indentation */
    color: var(--text-secondary); 
}
.prose li { margin-bottom: 0.75rem; padding-left: 0.5rem; line-height: 1.7; }
.prose li > ul, .prose li > ol { 
    margin-top: 0.75rem; 
    margin-bottom: 0; 
    padding-left: 1.5rem; /* Nested indentation */
    border-left: 1px solid var(--border-default); /* Subtle guide line for nested items */
    margin-left: -0.5rem; /* Align borderline */
}
.prose li::marker { color: var(--text-primary); font-weight: 600; }
.prose strong { color: var(--text-primary); font-weight: 700; }

.prose blockquote {
    border-left: 4px solid var(--primary);
    background: var(--primary-bg);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: var(--text-secondary);
    font-size: 1rem;
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose hr {
    border: none;
    border-top: 1px solid var(--border-default);
    margin: 3rem 0;
}

/* Tables */
.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.9375rem;
}
.prose th {
    background: var(--bg-subtle);
    border: 1px solid var(--border-default);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
}
.prose td {
    border: 1px solid var(--border-default);
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
}
.prose tr:nth-child(even) { background: var(--bg-subtle); }

/* Inline Code */
.prose code, .panel-content code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: rgba(17, 24, 39, 0.05); /* Subtle dark background for inline code */
    border: 1px solid var(--border-default);
    padding: 0.15em 0.3em;
    border-radius: 4px;
    color: var(--primary-hover);
    font-weight: 500;
}

/* Base Pre (Markdown blocks without tabs) */
.prose pre, .codehilite pre {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}
.prose pre::before, .codehilite pre::before {
    /* macOS style dots for premium feel */
    content: '';
    display: block;
    width: 54px;
    height: 12px;
    background-image: radial-gradient(circle, #ff5f56 6px, transparent 6px), radial-gradient(circle, #ffbd2e 6px, transparent 6px), radial-gradient(circle, #27c93f 6px, transparent 6px);
    background-size: 16px 16px;
    background-position: left center, center, right center;
    background-repeat: no-repeat;
    margin-bottom: 1rem;
    opacity: 0.5;
}
.prose pre code, .codehilite pre code {
    background: transparent;
    border: none;
    padding: 0;
    color: var(--code-text);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Prose Sm for Panel */
.prose-sm { font-size: 0.9375rem; }
.prose-sm h2 { margin-top: 1.5rem; font-size: 1.125rem; border: none; padding: 0; }
.prose-sm h4 { margin-top: 1.25rem; margin-bottom: 0.5rem; font-size: 0.95rem; }

/* =========================================
 * 💻 Interactive Code Panel (Premium Dark style)
 * ========================================= */
.code-section { margin: 3rem 0; }
.code-section h2 { display: none; } /* Hide duplicate markdown header */

.code-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.code-tabs {
    display: flex;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-default);
    padding: 0 0.5rem;
}
.code-tabs button {
    background: transparent;
    border: none;
    padding: 0.875rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    margin-bottom: -1px;
    font-family: var(--font-mono);
}
.code-tabs button:hover { color: var(--text-primary); }
.code-tabs button[aria-selected="true"] {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.code-content { position: relative; }
.code-content.hidden { display: none; }

.code-content pre {
    margin: 0;
    padding: 1.5rem;
    background: var(--code-bg);
    border: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.3);
}
.code-content pre code { color: var(--code-text); }

/* Elegant custom scrollbar for code blocks */
pre::-webkit-scrollbar { height: 10px; width: 10px; }
pre::-webkit-scrollbar-track { background: transparent; }
pre::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 5px; }
pre::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.4); }

.copy-btn {
    position: absolute;
    top: 0.5rem; right: 0.5rem;
    padding: 0.35rem 0.6rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    z-index: 10;
}
.copy-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}
.copy-btn.copied {
    border-color: var(--color-green);
    color: var(--color-green);
    background: var(--color-green-bg);
}

.hidden-code { display: none; }

/* Pygments Syntax Theme (Premium Deep Night - OneDark/Dracula Inspired) */
.highlight, .codehilite { background: transparent; }

/* Refined Pygments colors for stunning contrast on deep black/blue background */

/* Comments - Brighter vibrant gray/green for extreme legibility */
.highlight .c, .highlight .cm, .highlight .c1, .highlight .cp, .highlight .cs,
.codehilite .c, .codehilite .cm, .codehilite .c1, .codehilite .cp, .codehilite .cs { color: #8B9BB4; font-style: italic; font-weight: 500; } 

/* Keywords - Vibrant purple */
.highlight .k, .highlight .kc, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kt,
.codehilite .k, .codehilite .kc, .codehilite .kd, .codehilite .kn, .codehilite .kp, .codehilite .kr, .codehilite .kt { color: #C678DD; font-weight: 600; } 

/* Operators - Cyan */
.highlight .o, .highlight .ow,
.codehilite .o, .codehilite .ow { color: #56B6C2; } 

/* Strings - Bright green */
.highlight .s, .highlight .s2, .highlight .sa, .highlight .sb, .highlight .sc, .highlight .dl, .highlight .sd, .highlight .se, .highlight .sh, .highlight .si, .highlight .sx, .highlight .sr, .highlight .s1, .highlight .ss,
.codehilite .s, .codehilite .s2, .codehilite .sa, .codehilite .sb, .codehilite .sc, .codehilite .dl, .codehilite .sd, .codehilite .se, .codehilite .sh, .codehilite .si, .codehilite .sx, .codehilite .sr, .codehilite .s1, .codehilite .ss { color: #98C379; } 

/* Functions - Clear blue */
.highlight .nf, .highlight .fm,
.codehilite .nf, .codehilite .fm { color: #61AFEF; font-weight: 600; } 

/* Builtins & Classes - Warm yellow */
.highlight .nb, .highlight .bp, .highlight .nc, .highlight .nn,
.codehilite .nb, .codehilite .bp, .codehilite .nc, .codehilite .nn { color: #E5C07B; font-weight: 600; } 

/* Numbers - Orange */
.highlight .m, .highlight .mb, .highlight .mf, .highlight .mh, .highlight .mi, .highlight .il, .highlight .mo,
.codehilite .m, .codehilite .mb, .codehilite .mf, .codehilite .mh, .codehilite .mi, .codehilite .il, .codehilite .mo { color: #D19A66; } 

/* Variables - Standard Text */
.highlight .nx, .highlight .n,
.codehilite .nx, .codehilite .n { color: #E5E7EB; } 

/* Decorators - Cyan */
.highlight .nd,
.codehilite .nd { color: #56B6C2; } 

.highlight .ni,
.codehilite .ni { color: #D19A66; }

/* Exceptions/Tags - Vibrant red */
.highlight .ne, .highlight .nt,
.codehilite .ne, .codehilite .nt { color: #E06C75; font-weight: 600; }

/* =========================================
 * 🎨 Scratch Block Visuals
 * ========================================= */
.sb-block {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    margin: 0.2rem 0.1rem;
    box-shadow: 0 3px 0 rgba(0,0,0,0.2);
    white-space: nowrap;
    border: 1px solid rgba(0,0,0,0.1);
    background-image: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, transparent 100%);
    position: relative;
    top: -1px;
}
.sb-block:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}

.sb-block i { font-style: normal; margin-right: 0.35rem; font-size: 1.1rem; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.2)); }

.sb-motion { background-color: var(--sb-motion); }
.sb-looks { background-color: var(--sb-looks); }
.sb-sound { background-color: var(--sb-sound); }
.sb-events { background-color: var(--sb-events); }
.sb-control { background-color: var(--sb-control); }
.sb-sensing { background-color: var(--sb-sensing); }
.sb-operators { background-color: var(--sb-operators); }
.sb-variables { background-color: var(--sb-variables); }
.sb-list { background-color: var(--sb-list); }
.sb-myblocks { background-color: var(--sb-myblocks); }

/* Small inline inputs in blocks */
.sb-input {
    background: #fff;
    color: #575E75;
    padding: 0 0.35rem;
    border-radius: 9999px; /* Rounded pill style for inputs */
    margin: 0 0.25rem;
    font-weight: 600;
    min-width: 1.5rem;
    text-align: center;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
    display: inline-block;
    height: 1.4rem;
    line-height: 1.4rem;
}
.sb-var-input {
    background: rgba(0,0,0,0.2);
    color: #fff;
    padding: 0 0.4rem;
    border-radius: 4px;
    margin: 0 0.25rem;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}.lesson-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-default);
}

.lesson-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: all 0.2s;
    font-weight: 500;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
}
.lesson-nav a svg { width: 1.25rem; height: 1.25rem; }
.lesson-nav a:hover:not(.disabled) {
    background: var(--bg-subtle);
    color: var(--text-primary);
    border-color: var(--border-hover);
}
.lesson-nav a.disabled { opacity: 0.5; pointer-events: none; }

.nav-label { font-size: 0.9375rem; display: block; }

.btn-complete {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}
.btn-complete:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.btn-complete.completed {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.btn-icon { font-weight: bold; }

/* =========================================
 * 🧩 Footer & Toast
 * ========================================= */
.site-footer {
    margin-top: auto;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-default);
    padding: 2rem 0;
}
.footer-inner {
    max-width: var(--max-width-container);
    margin: 0 auto;
    padding: 0 1.5rem;
    text-align: center;
}
.footer-brand { font-weight: 600; color: var(--text-secondary); font-size: 0.9375rem; margin-bottom: 0.25rem; }
.footer-copy { font-size: 0.875rem; color: var(--text-tertiary); }

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translate(-50%, 20px);
    background: #1F2937;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-md);
    z-index: 1000;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

/* Back to Top */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 2.75rem; height: 2.75rem;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.2s;
    pointer-events: none;
    z-index: 90;
}
.back-to-top svg { width: 1.25rem; height: 1.25rem; }
.back-to-top.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.back-to-top:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
    background: var(--bg-subtle);
}

/* =========================================
 * 📱 Mobile Responsiveness
 * ========================================= */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: var(--bg-surface);
        flex-direction: column;
        padding: 1rem;
        border-bottom: 1px solid var(--border-default);
        box-shadow: var(--shadow-md);
    }
    .nav-links.open { display: flex; }
    .hamburger {
        display: block;
        border: none;
        background: none;
        width: 1.5rem;
        height: 1.25rem;
        position: relative;
        cursor: pointer;
    }
    .hamburger span {
        display: block; width: 100%; height: 2px;
        background: var(--text-primary);
        position: absolute; transition: 0.2s;
    }
    .hamburger span:nth-child(1) { top: 0; }
    .hamburger span:nth-child(2) { top: 50%; transform: translateY(-50%); }
    .hamburger span:nth-child(3) { bottom: 0; }
    
    .lesson-container { gap: 0; padding-top: 1.5rem; }
    .hero-title { font-size: 2.25rem; }
    .lesson-header h1 { font-size: 2rem; }
    .lesson-nav { flex-direction: column; }
    .lesson-nav a, .btn-complete { width: 100%; justify-content: center; }
}

/* Confetti */
.confetti {
    position: fixed;
    animation: fall 3s ease-in forwards;
    z-index: 9999;
}
@keyframes fall {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* =========================================
 * 🌳 Premium Skill Tree Timeline Design
 * ========================================= */
.skill-tree-page {
    position: relative;
    overflow-x: hidden;
}
.tree-bg-anim {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 0; overflow: hidden;
    pointer-events: none;
}
.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
    animation: pulseOrb 8s infinite alternate ease-in-out;
}
.orb-1 { width: 40VW; height: 40VW; background: var(--color-green); top: 10%; right: -10vw; }
.orb-2 { width: 30VW; height: 30VW; background: var(--primary); bottom: 10%; left: -10vw; animation-delay: -4s; }

@keyframes pulseOrb {
    0% { transform: scale(1); opacity: 0.1; }
    100% { transform: scale(1.2); opacity: 0.3; }
}

.skill-tree-content {
    position: relative;
    padding: 2rem 0;
    max-width: 800px;
    margin: 0 auto;
}

/* Central spine line for the timeline */
.skill-tree-content::before {
    content: '';
    position: absolute;
    top: 0; 
    bottom: 0; 
    left: 2rem;
    width: 6px;
    background: linear-gradient(to bottom, var(--border-default) 0%, rgba(229, 231, 235, 0.3) 100%);
    border-radius: 3px;
    z-index: 1;
}
@media (max-width: 768px) {
    .skill-tree-content::before { left: 1rem; }
}

/* Group (Lesson Cluster) */
.skill-group {
    position: relative;
    margin-bottom: 4rem;
    padding-left: 5rem;
    z-index: 2;
}
@media (max-width: 768px) {
    .skill-group { padding-left: 3.5rem; }
}

/* Timeline Node / Bullet for Group */
.skill-group::before {
    content: '';
    position: absolute;
    left: 2.3rem;
    top: 2rem;
    width: 20px;
    height: 20px;
    background: var(--bg-surface);
    border: 4px solid var(--primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.1);
    z-index: 3;
    transition: all 0.3s ease;
}
@media (max-width: 768px) {
    .skill-group::before { left: 1.3rem; }
}
.skill-group:hover::before {
    transform: translate(-50%, -50%) scale(1.3);
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.4);
    background: var(--primary);
}

.skill-group h3 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    padding-top: 1rem;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Skill Items Custom Grid */
.skill-group > .skill-item {
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    transform-origin: left center;
}

/* Connecting line from spine to item */
.skill-group > .skill-item::before {
    content: '';
    position: absolute;
    left: -2.7rem;
    top: 50%;
    width: 2rem;
    height: 2px;
    background: var(--border-default);
    z-index: -1;
    transition: background 0.3s;
}
@media (max-width: 768px) {
    .skill-group > .skill-item::before { width: 1.5rem; left: -2rem; }
}

.skill-star { font-size: 1.25rem; display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; transition: all 0.3s; }
.skill-name { font-weight: 700; font-size: 1.0625rem; color: var(--text-primary); min-width: 130px; }
.skill-desc { color: var(--text-secondary); font-size: 0.875rem; flex-grow: 1; line-height: 1.4; }

/* Status: Locked */
.skill-item.locked {
    border: 1px dashed var(--border-hover);
    opacity: 0.65;
    filter: grayscale(80%);
}
.skill-item.locked .skill-star { color: var(--border-hover); border: 1px solid var(--border-hover); }

/* Status: Unlocked */
.skill-item.unlocked {
    border: 1px solid var(--color-green);
    box-shadow: 0 10px 25px -5px rgba(5, 150, 105, 0.1);
    background: #fff;
    opacity: 1;
    filter: none;
    transform: translateX(10px);
}
.skill-item.unlocked::before { background: var(--color-green); box-shadow: 0 0 10px rgba(5, 150, 105, 0.5); }
.skill-item.unlocked .skill-star { 
    color: var(--color-green); 
    background: var(--color-green-bg);
    text-shadow: 0 0 10px rgba(5, 150, 105, 0.5); 
}

/* Hover interations for items */
.skill-item.locked:hover { opacity: 0.9; }
.skill-item.unlocked:hover {
    transform: translateX(15px) scale(1.02);
    box-shadow: 0 15px 35px -5px rgba(5, 150, 105, 0.2);
    border-color: rgba(5, 150, 105, 0.8);
}
