/* CSS Reset & Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Noto Sans KR', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
}

:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #161b26;
    --bg-sidebar: #0f131c;
    --card-bg: rgba(22, 27, 38, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-inverse: #111827;
    
    --primary-color: #6366f1; /* Indigo */
    --primary-hover: #4f46e5;
    
    --success-color: #10b981; /* Emerald */
    --success-bg: rgba(16, 185, 129, 0.1);
    --error-color: #ef4444; /* Rose */
    --error-bg: rgba(239, 68, 68, 0.1);
    
    --glow-color: rgba(99, 102, 241, 0.15);
    --shadow-premium: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
    
    --sidebar-width: 280px;
}

/* Light Theme Variables (Optional class triggered by toggle) */
body.light-theme {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-sidebar: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.8);
    --border-color: rgba(0, 0, 0, 0.06);
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    
    --primary-color: #4f46e5;
    --primary-hover: #3730a3;
    
    --glow-color: rgba(79, 70, 229, 0.08);
    --shadow-premium: 0 20px 40px -15px rgba(15, 23, 42, 0.08);
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    overflow-x: hidden;
    line-height: 1.6;
}

/* App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 10;
}

.logo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 3rem;
}

.logo-icon {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 10px var(--primary-color));
}

.logo-area h2 {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 0.2rem;
}

.logo-area p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.nav-menu {
    flex-grow: 1;
}

.nav-menu ul {
    list-style: none;
}

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

.nav-menu a {
    display: flex;
    align-items: center;
    padding: 0.8rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
}

.nav-menu li.active a {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
}

.nav-menu li.locked a {
    cursor: not-allowed;
    opacity: 0.6;
}

.nav-menu li.locked a i {
    margin-left: auto;
    font-size: 0.8rem;
}

.nav-menu a:hover:not(.locked a) {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.03);
}

body.light-theme .nav-menu a:hover:not(.locked a) {
    background-color: rgba(0, 0, 0, 0.02);
}

.ch-num {
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    opacity: 0.5;
    margin-right: 0.8rem;
    font-weight: 600;
}

.sidebar-footer {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    padding: 3rem 4rem;
    max-width: 1200px;
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.badge {
    display: inline-block;
    background-color: var(--glow-color);
    color: var(--primary-color);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.main-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -1px;
}

.eng-title {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 0.5rem;
    font-family: 'Outfit', sans-serif;
}

.theme-toggle {
    cursor: pointer;
    font-size: 1.3rem;
    color: var(--text-muted);
    width: 45px;
    height: 45px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.theme-toggle:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: scale(1.05);
}

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

/* Cards (Glassmorphism) */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: var(--shadow-premium);
    position: relative;
    overflow: hidden;
}

/* Introduction Card */
.intro-card {
    display: flex;
    gap: 1.5rem;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(99, 102, 241, 0.05) 100%);
}

.card-icon {
    font-size: 2rem;
    color: var(--primary-color);
    opacity: 0.3;
}

.quote {
    font-size: 1.3rem;
    font-weight: 500;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.summary-text {
    color: var(--text-muted);
    font-size: 1.05rem;
}

/* Concept Cards */
.concept-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.concept-no {
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    color: var(--primary-color);
    font-weight: 700;
    letter-spacing: 1px;
    display: block;
    margin-bottom: 0.3rem;
}

/* Comparison layouts */
.comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .comparison {
        grid-template-columns: 1fr;
    }
}

.comp-box {
    padding: 1.8rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
}

body.light-theme .comp-box {
    background: rgba(0, 0, 0, 0.01);
}

.comp-box.bad h3 {
    color: var(--error-color);
}

.comp-box h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.popper-alternative {
    background: var(--glow-color);
    border: 1px dashed var(--primary-color);
    padding: 1.8rem;
    border-radius: 18px;
}

.popper-alternative h3 {
    color: var(--primary-color);
    font-size: 1.15rem;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Hard to Vary styling */
.highlighted {
    background: linear-gradient(185deg, var(--bg-secondary) 0%, rgba(99, 102, 241, 0.08) 100%);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 20px 40px -15px rgba(99, 102, 241, 0.15);
}

.concept-desc {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.key-feature {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.feature-item {
    display: flex;
    gap: 1.5rem;
}

.feature-icon {
    font-size: 1.5rem;
    color: var(--primary-color);
    background: var(--glow-color);
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.feature-content h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.feature-content p {
    color: var(--text-muted);
    font-size: 0.98rem;
}

/* Interactive Widget Card */
.widget-card {
    background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 100%);
    border-color: rgba(99, 102, 241, 0.2);
}

body.light-theme .widget-card {
    background: linear-gradient(135deg, #e0e7ff 0%, #f8fafc 100%);
}

.widget-card h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.2rem;
}

.quiz-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 2rem;
    margin: 1.5rem 0;
}

body.light-theme .quiz-container {
    background: rgba(0, 0, 0, 0.02);
}

.quiz-question {
    font-size: 1.15rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.quiz-question span {
    color: var(--primary-color);
    font-weight: 700;
}

.quiz-options {
    display: flex;
    gap: 1rem;
}

@media (max-width: 576px) {
    .quiz-options {
        flex-direction: column;
    }
}

.btn {
    padding: 0.8rem 1.8rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    outline: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

body.light-theme .btn-secondary {
    background-color: rgba(0, 0, 0, 0.05);
}

body.light-theme .btn-secondary:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.btn-outline {
    background-color: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

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

.feedback {
    margin-top: 1.5rem;
    padding: 1.2rem;
    border-radius: 12px;
    font-size: 0.95rem;
    display: none;
}

.success-feedback {
    display: block;
    background-color: var(--success-bg);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.error-feedback {
    display: block;
    background-color: var(--error-bg);
    color: var(--error-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.quiz-progress {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Reach diagram mapping */
/* Chapter Sections */
.chapter-section {
    display: none;
    animation: fadeIn 0.5s ease;
}

.chapter-section.active {
    display: block;
}

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

/* Theme Toggle Container */
.theme-toggle-container {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1.5rem;
}

/* Chain of Interpretation Widget (Chapter 2) */
.chain-game {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.chain-pool, .chain-slots {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    min-height: 100px;
    padding: 1rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
}

body.light-theme .chain-pool, body.light-theme .chain-slots {
    background: rgba(0, 0, 0, 0.01);
}

.chain-item {
    padding: 1rem;
    border-radius: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.95rem;
    user-select: none;
}

.chain-item:hover {
    border-color: var(--primary-color);
    transform: translateX(5px);
}

.chain-item .step-num {
    background: var(--glow-color);
    color: var(--primary-color);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.chain-item.placed {
    background: rgba(99, 102, 241, 0.05);
    border-color: var(--primary-color);
}

.chain-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.reach-example {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin: 2rem 0;
}

.example-box {
    width: 100%;
    padding: 1.5rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
}

.example-box h4 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

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

.example-box.success {
    background: rgba(16, 185, 129, 0.03);
    border-color: rgba(16, 185, 129, 0.2);
}

.example-box.success h4 {
    color: var(--success-color);
}

.arrow-down {
    color: var(--primary-color);
    font-size: 1.2rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.highlight-text {
    font-size: 1.1rem;
    font-weight: 500;
    border-left: 4px solid var(--primary-color);
    padding-left: 1.2rem;
    margin-top: 1.5rem;
}

