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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #0a0a0a;
    color: #e0e0e0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: #2a9d8f; text-decoration: none; }
a:hover { color: #3dc4b4; }

/* ========== Nav ========== */
.edu-nav {
    background: #111;
    border-bottom: 1px solid #222;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 56px;
}

.nav-brand {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.nav-brand i { color: #2a9d8f; }
.nav-brand:hover { color: #fff; }

.nav-home {
    margin-left: auto;
    color: #666;
    font-size: 1.1rem;
}
.nav-home:hover { color: #2a9d8f; }

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #666;
    overflow-x: auto;
    white-space: nowrap;
}

.breadcrumbs a { color: #888; }
.breadcrumbs a:hover { color: #2a9d8f; }
.breadcrumbs .sep { color: #444; }
.breadcrumbs .current { color: #ccc; }

/* ========== Main ========== */
.edu-main {
    flex: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

/* ========== Landing ========== */
.landing-hero {
    text-align: center;
    padding: 3rem 0 2.5rem;
}

.landing-hero h1 {
    font-size: 2.8rem;
    font-weight: 300;
    color: #fff;
    letter-spacing: 0.02em;
}

.landing-subtitle {
    color: #888;
    font-size: 1.15rem;
    margin-top: 0.75rem;
}

/* ========== Subject Grid ========== */
.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.subject-card {
    background: #111;
    border: 1px solid #222;
    border-radius: 12px;
    padding: 2rem;
    transition: border-color 0.3s, transform 0.2s;
    display: flex;
    flex-direction: column;
    color: #e0e0e0;
}

.subject-card:hover {
    border-color: #2a9d8f;
    transform: translateY(-2px);
    color: #e0e0e0;
}

.subject-icon {
    font-size: 2rem;
    color: #2a9d8f;
    margin-bottom: 1rem;
}

.subject-card h2 {
    font-size: 1.3rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #fff;
}

.subject-card p {
    font-size: 0.9rem;
    color: #888;
    line-height: 1.5;
    flex: 1;
}

.topic-count {
    font-size: 0.8rem;
    color: #2a9d8f;
    margin-top: 1rem;
    font-family: monospace;
}

/* ========== Topic Grid ========== */
.section-header {
    margin-bottom: 2rem;
}

.section-header i {
    font-size: 1.5rem;
    color: #2a9d8f;
    margin-bottom: 0.5rem;
}

.section-header h1 {
    font-size: 2rem;
    font-weight: 400;
    color: #fff;
}

.section-desc {
    color: #888;
    margin-top: 0.5rem;
    font-size: 1rem;
}

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

.topic-card {
    background: #111;
    border: 1px solid #222;
    border-radius: 12px;
    padding: 1.5rem;
    transition: border-color 0.3s, transform 0.2s;
    color: #e0e0e0;
}

.topic-card:hover {
    border-color: #2a9d8f;
    transform: translateY(-2px);
}

.topic-card h2 {
    font-size: 1.15rem;
    font-weight: 500;
    color: #fff;
    margin-bottom: 0.5rem;
}

.topic-card p {
    font-size: 0.9rem;
    color: #888;
    line-height: 1.5;
}

.lesson-count {
    font-size: 0.8rem;
    color: #2a9d8f;
    margin-top: 0.75rem;
    display: block;
    font-family: monospace;
}

/* ========== Lesson List ========== */
.lesson-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.lesson-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #111;
    border: 1px solid #222;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    transition: border-color 0.3s;
    color: #e0e0e0;
}

.lesson-item:hover { border-color: #2a9d8f; }

.lesson-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1a1a2e;
    color: #2a9d8f;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.lesson-item h3 {
    font-size: 1rem;
    font-weight: 500;
    color: #fff;
}

.lesson-date {
    font-size: 0.8rem;
    color: #666;
}

.lesson-item .fa-chevron-right {
    margin-left: auto;
    color: #444;
    font-size: 0.8rem;
}

/* ========== Lesson Content ========== */
.lesson-content {
    max-width: 800px;
    margin: 0 auto;
}

.lesson-header {
    margin-bottom: 2rem;
    border-bottom: 1px solid #222;
    padding-bottom: 1.5rem;
}

.lesson-header h1 {
    font-size: 2rem;
    font-weight: 400;
    color: #fff;
}

.lesson-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.5rem;
    color: #666;
    font-size: 0.85rem;
}

.print-btn {
    background: none;
    border: 1px solid #333;
    color: #888;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}
.print-btn:hover { border-color: #2a9d8f; color: #2a9d8f; }

/* Lesson body typography */
.lesson-body {
    line-height: 1.8;
    font-size: 1.05rem;
}

.lesson-body h1,
.lesson-body h2,
.lesson-body h3 {
    color: #fff;
    margin: 2rem 0 1rem;
    font-weight: 500;
}

.lesson-body h2 { font-size: 1.5rem; border-bottom: 1px solid #222; padding-bottom: 0.5rem; }
.lesson-body h3 { font-size: 1.2rem; }

.lesson-body p { margin-bottom: 1rem; }

.lesson-body ul, .lesson-body ol {
    margin: 0 0 1rem 1.5rem;
}

.lesson-body li { margin-bottom: 0.4rem; }

.lesson-body code {
    background: #1a1a2e;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
    color: #e5c07b;
}

.lesson-body pre {
    background: #111;
    border: 1px solid #222;
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.lesson-body pre code {
    background: none;
    padding: 0;
    color: #e0e0e0;
}

.lesson-body blockquote {
    border-left: 3px solid #2a9d8f;
    padding: 0.5rem 1rem;
    margin: 1rem 0;
    color: #aaa;
    background: #111;
    border-radius: 0 8px 8px 0;
}

.lesson-body img {
    max-width: 100%;
    border-radius: 8px;
    margin: 1rem 0;
}

.lesson-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.lesson-body th, .lesson-body td {
    padding: 0.6rem 1rem;
    border: 1px solid #222;
    text-align: left;
}

.lesson-body th {
    background: #111;
    color: #fff;
    font-weight: 500;
}

/* ========== Callout Boxes ========== */
.callout {
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
    border-left: 4px solid;
}

.callout-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.callout-note {
    background: #0d1b2a;
    border-color: #4a9eff;
}
.callout-note .callout-title { color: #4a9eff; }

.callout-example {
    background: #1a1a0d;
    border-color: #e5c07b;
}
.callout-example .callout-title { color: #e5c07b; }

/* ========== Interactive Equations ========== */
.interactive-equation {
    background: #111;
    border: 1px solid #222;
    border-radius: 10px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    text-align: center;
}

.equation-display {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    min-height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.equation-display .katex { font-size: 1.8rem; }

.equation-terms {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.eq-term {
    background: #1a1a2e;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    border: 1px solid transparent;
}

.eq-term:hover, .eq-term.active {
    background: #2a9d8f22;
    border-color: #2a9d8f;
    color: #2a9d8f;
}

.eq-term strong {
    color: #2a9d8f;
    margin-right: 0.3rem;
}

/* ========== Inline Citations ========== */
sup.cite {
    font-size: 0.75em;
    line-height: 0;
    vertical-align: super;
}

sup.cite a {
    color: #2a9d8f;
    text-decoration: none;
    padding: 0 0.1em;
}

sup.cite a:hover {
    color: #3dc4b4;
    text-decoration: underline;
}

/* ========== Sources Table ========== */
.lesson-sources {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid #222;
}

.lesson-sources h2 {
    font-size: 1.3rem;
    font-weight: 500;
    color: #fff;
    margin-bottom: 1rem;
}

.sources-table {
    width: 100%;
    border-collapse: collapse;
}

.sources-table tr {
    border-bottom: 1px solid #1a1a1a;
}

.sources-table tr:target {
    background: #2a9d8f15;
}

.sources-table td {
    padding: 0.6rem 0.75rem;
    vertical-align: top;
    font-size: 0.9rem;
}

.source-num {
    width: 2.5rem;
    white-space: nowrap;
    color: #2a9d8f;
    font-weight: 600;
}

.source-num a {
    color: #2a9d8f;
}

.source-title {
    color: #ccc;
}

.source-link {
    word-break: break-all;
    font-size: 0.8rem;
}

.source-link a {
    color: #666;
}

.source-link a:hover {
    color: #2a9d8f;
}

/* ========== Three.js Scenes ========== */
.three-scene {
    background: #0a0a0a;
    border: 1px solid #222;
    border-radius: 10px;
    margin: 1.5rem 0;
    min-height: 400px;
    position: relative;
    overflow: hidden;
}

.three-scene canvas {
    border-radius: 10px;
    display: block;
}

.three-loading, .plotly-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 0.9rem;
}

/* ========== Manim Videos ========== */
.manim-embed {
    margin: 1.5rem 0;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #222;
}

.manim-embed video {
    width: 100%;
    display: block;
    background: #000;
}

/* ========== Plotly Charts ========== */
.plotly-chart {
    background: #111;
    border: 1px solid #222;
    border-radius: 10px;
    margin: 1.5rem 0;
    min-height: 350px;
    position: relative;
    overflow: hidden;
}

/* ========== Lesson Nav ========== */
.lesson-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid #222;
    gap: 1rem;
}

.nav-prev, .nav-next {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #888;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border: 1px solid #222;
    border-radius: 8px;
    transition: border-color 0.3s, color 0.3s;
}

.nav-prev:hover, .nav-next:hover {
    border-color: #2a9d8f;
    color: #2a9d8f;
}

.nav-next { margin-left: auto; }

/* ========== Footer ========== */
.edu-footer {
    text-align: center;
    padding: 2rem;
    color: #444;
    font-size: 0.85rem;
    border-top: 1px solid #111;
}

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #666;
}

.empty-state i {
    font-size: 2.5rem;
    color: #2a9d8f;
    margin-bottom: 1rem;
}

/* ========== Print ========== */
@media print {
    body { background: #fff; color: #000; }

    .edu-nav, .edu-footer, .print-btn, .lesson-nav { display: none; }

    .lesson-body { font-size: 11pt; line-height: 1.6; }
    .lesson-header h1 { color: #000; font-size: 18pt; }

    .callout { border-color: #999; background: #f5f5f5; color: #000; page-break-inside: avoid; }
    .callout-title { color: #333; }

    .interactive-equation { background: #f5f5f5; border-color: #ccc; color: #000; }
    .eq-term { background: #eee; color: #000; }

    .three-scene { min-height: auto; border: 1px solid #ccc; }
    .three-scene::after { content: '[3D Interactive Scene]'; display: flex; align-items: center; justify-content: center; padding: 2rem; color: #666; }
    .three-scene canvas { display: none; }

    .lesson-body pre { border-color: #ccc; }
    .lesson-body code { background: #eee; color: #333; }
    .lesson-body a { color: #000; text-decoration: underline; }
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .landing-hero h1 { font-size: 2rem; }
    .subject-grid, .topic-grid { grid-template-columns: 1fr; }
    .lesson-content { padding: 0; }
    .lesson-header h1 { font-size: 1.5rem; }
    .equation-display .katex { font-size: 1.3rem; }
    .breadcrumbs { font-size: 0.75rem; }
    .lesson-nav { flex-direction: column; }
}
