@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;700&display=swap');

:root {
    --primary-color: #ff85a2;
    --secondary-color: #a78bfa;
    --bg-color: #fffafb;
    --text-color: #334155;
    --card-bg: #ffffff;
    --sidebar-bg: #fdf2f8;
    --accent-light: #fce7f3;
}

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

body {
    font-family: 'Noto Sans TC', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: block;
    min-height: 100vh;
}

/* --- Navigation & Sidebar --- */

/* Mobile Top Header */
.nav-header {
    display: none; /* Desktop default */
    background-color: var(--sidebar-bg);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid #f9a8d4;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.nav-header h2 {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin: 0;
}

.menu-toggle {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Sidebar Drawer */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid #f9a8d4;
    padding: 2rem 1.5rem;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000; /* Above overlay */
}

.sidebar h2 {
    color: var(--primary-color);
    margin-bottom: 2rem;
    font-size: 1.5rem;
    text-align: center;
}

/* Sidebar Overlay (Backdrop) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 1500;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Navigation Links */
.nav-links {
    list-style: none;
}

.nav-links li {
    margin-bottom: 0.5rem;
}

.nav-links a {
    text-decoration: none;
    color: #64748b;
    display: block;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-links a:hover, .nav-links a.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 133, 162, 0.3);
}

/* --- Main Content --- */
.main-content {
    margin-left: 280px;
    padding: 2rem;
    max-width: 1100px;
    transition: margin-left 0.3s ease;
}

/* --- Responsive States --- */

@media (max-width: 1024px) {
    .nav-header {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%); /* Hidden by default on mobile */
        box-shadow: 10px 0 25px rgba(0,0,0,0.1);
    }

    .sidebar.active {
        transform: translateX(0); /* Slide in */
    }

    .main-content {
        margin-left: 0;
        padding: 1.5rem;
    }
}

/* --- Content Styling --- */
.chapter-header {
    margin-bottom: 2rem;
    text-align: center;
}

.chapter-header h1 {
    font-size: 2.2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

@media (max-width: 600px) {
    .chapter-header h1 { font-size: 1.6rem; }
}

.chapter-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.03);
    margin-bottom: 1.5rem;
    border: 1px solid #f1f5f9;
}

@media (min-width: 768px) {
    .chapter-card {
        padding: 2.5rem;
        border-radius: 24px;
    }
}

p {
    margin-bottom: 1rem;
    font-size: 1rem;
}

h2 {
    color: var(--secondary-color);
    margin: 1.5rem 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Code Blocks */
pre {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 12px;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    margin: 1.2rem 0;
    font-size: 0.85rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
    pre {
        padding: 1.5rem;
        font-size: 0.95rem;
    }
}

code { font-family: inherit; }

.analogy {
    background-color: var(--accent-light);
    border-left: 5px solid var(--primary-color);
    padding: 1.2rem;
    border-radius: 0 16px 16px 0;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}

.analogy-title {
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.4rem;
    display: block;
}

/* Buttons */
.btn-group {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
}

.btn {
    padding: 0.7rem 1.5rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: bold;
    transition: transform 0.2s, background-color 0.2s;
    font-size: 0.9rem;
    text-align: center;
    flex: 1;
    max-width: 200px;
}

.btn-next { background-color: var(--primary-color); color: white; }
.btn-prev { background-color: #e2e8f0; color: #475569; }
.btn:hover { transform: scale(1.03); }

.icon-box {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}
