/* ═══════════════════════════════════════════════════════
   EngineerThe(AI)Wave — Global Stylesheet
   ═══════════════════════════════════════════════════════ */

:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --card: #334155;
    --accent: #38bdf8;
    --accent2: #818cf8;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #475569;
    --highlight: #fbbf24;
    --danger: #f87171;
    --success: #4ade80;
    --topnav-h: 56px;
    --sidebar-w: 320px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

/* ── Top Navigation ─────────────────────────────────── */

.topnav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topnav-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    z-index: 1000;
    gap: 1rem;
}

.topnav .logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    flex-shrink: 0;
}

.topnav .logo-symbol {
    width: 36px;
    height: 36px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topnav .logo-symbol svg {
    width: 36px;
    height: 36px;
}

.topnav .logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.topnav .logo-text .ai {
    color: var(--accent);
    font-weight: 800;
}

.topnav .nav-courses {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 2rem;
    overflow-x: auto;
    flex: 1;
}

.topnav .nav-courses a {
    padding: 0.35rem 0.85rem;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s;
    border: 1px solid transparent;
}

.topnav .nav-courses a:hover {
    background: var(--card);
    color: var(--text);
}

.topnav .nav-courses a.active {
    background: var(--accent);
    color: var(--bg);
    font-weight: 600;
    border-color: var(--accent);
}

.topnav .nav-courses a .badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background: var(--card);
    color: var(--highlight);
    margin-left: 0.35rem;
    vertical-align: middle;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.topnav .nav-courses a.active .badge {
    background: rgba(0,0,0,0.2);
    color: #fff;
}

/* Sidebar toggle for mobile */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

/* ── Sidebar ────────────────────────────────────────── */

.sidebar {
    position: fixed;
    top: var(--topnav-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 1rem 0;
    z-index: 900;
    transition: transform 0.25s ease;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar .course-title {
    padding: 0.5rem 1.25rem 1rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

.sidebar .week-group {
    padding: 0.6rem 1.25rem 0.25rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--highlight);
    font-weight: 700;
    margin-top: 0.5rem;
}

.sidebar .chapter-link {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.45rem 1.25rem;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.84rem;
    line-height: 1.4;
    transition: all 0.12s;
    border-left: 3px solid transparent;
}

.sidebar .chapter-link:hover {
    background: var(--card);
    color: var(--text);
}

.sidebar .chapter-link.active {
    background: rgba(56, 189, 248, 0.08);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 600;
}

.sidebar .chapter-link .ch-num {
    flex-shrink: 0;
    width: 1.6rem;
    text-align: right;
    font-weight: 600;
    color: var(--border);
    font-size: 0.78rem;
}

.sidebar .chapter-link.active .ch-num {
    color: var(--accent);
}

/* ── Main Content ────────────────────────────────────── */

.main-content {
    margin-top: var(--topnav-h);
    margin-left: var(--sidebar-w);
    padding: 2rem 3rem;
    min-height: calc(100vh - var(--topnav-h));
}

/* When sidebar is hidden (home page, coming soon) */
.main-content.full-width {
    margin-left: 0;
}

/* ── Content Styles (shared across pages) ────────────── */

h1 { font-size: 2.2rem; color: var(--accent); margin-bottom: 0.5rem; border-bottom: 2px solid var(--accent); padding-bottom: 0.5rem; }
h2 { font-size: 1.6rem; color: var(--accent2); margin-top: 2.5rem; margin-bottom: 1rem; border-left: 4px solid var(--accent2); padding-left: 0.75rem; }
h3 { font-size: 1.3rem; color: var(--highlight); margin-top: 2rem; margin-bottom: 0.75rem; }
h4 { font-size: 1.1rem; color: var(--accent); margin-top: 1.5rem; margin-bottom: 0.5rem; }
p { margin-bottom: 1rem; }

blockquote {
    border-left: 4px solid var(--accent);
    background: var(--surface);
    padding: 1rem 1.25rem;
    margin: 1rem 0;
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: var(--text-muted);
}
blockquote strong { color: var(--text); font-style: normal; }

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.92rem;
}
th, td {
    border: 1px solid var(--border);
    padding: 0.6rem 0.8rem;
    text-align: left;
}
th { background: var(--card); color: var(--accent); font-weight: 600; }
td { background: var(--surface); }
tr:hover td { background: var(--card); }

code {
    background: var(--card);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.9em;
    color: var(--highlight);
}
pre {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    margin: 1rem 0;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text);
}
pre code { background: none; padding: 0; color: inherit; }

ul, ol { margin: 0.5rem 0 1rem 1.5rem; }
li { margin-bottom: 0.3rem; }
strong { color: var(--text); }
em { color: var(--text-muted); }
hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Diagram Zoom ────────────────────────────────────── */

.diagram-wrapper {
    position: relative;
    background: #1a1a2e;
    border-radius: 12px;
    margin: 1.5rem 0;
    overflow: hidden;
    border: 1px solid var(--border);
}
.diagram-viewport {
    overflow: hidden;
    cursor: grab;
    min-height: 200px;
}
.diagram-viewport:active { cursor: grabbing; }
.diagram-viewport .mermaid {
    background: transparent;
    padding: 1.5rem;
    margin: 0;
    text-align: center;
    transform-origin: 0 0;
    transition: transform 0.15s ease;
    display: inline-block;
    min-width: 100%;
}
.zoom-controls {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.25rem;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s;
}
.diagram-wrapper:hover .zoom-controls { opacity: 1; }
.zoom-controls button {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--accent);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.zoom-controls button:hover { background: var(--card); }
.zoom-level {
    font-size: 0.7rem;
    color: var(--text-muted);
    min-width: 36px;
    text-align: center;
    line-height: 32px;
}

/* ── Chapter Navigation (bottom) ─────────────────────── */

.chapter-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}
.chapter-nav a {
    padding: 0.6rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--accent);
    text-decoration: none;
    transition: background 0.15s;
}
.chapter-nav a:hover { background: var(--card); }

/* ── Home: Course Cards ──────────────────────────────── */

.hero {
    text-align: center;
    padding: 3rem 1rem 2rem;
}

.hero .hero-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.hero .hero-logo svg {
    width: 64px;
    height: 64px;
}

.hero .hero-title {
    font-size: 2.8rem;
    color: var(--text);
    font-weight: 800;
    border: none;
    padding: 0;
    margin: 0;
}

.hero .hero-title .ai { color: var(--accent); }

.hero .hero-subtitle {
    font-size: 1.15rem;
    color: var(--text-muted);
    max-width: 700px;
    margin: 1rem auto 0;
}

.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.5rem;
    margin-top: 2.5rem;
    padding: 0 1rem;
}

.course-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
    transition: transform 0.15s, border-color 0.15s;
    display: flex;
    flex-direction: column;
}

.course-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
}

.course-card .card-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    width: fit-content;
}

.course-card .card-badge.live { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.course-card .card-badge.soon { background: rgba(251, 191, 36, 0.15); color: var(--highlight); }

.course-card .card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.course-card .card-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    flex: 1;
    margin-bottom: 1rem;
}

.course-card .card-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.course-card .card-meta span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.course-card .card-action {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.5rem 1.2rem;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    transition: background 0.15s;
}

.course-card .card-action.primary {
    background: var(--accent);
    color: var(--bg);
}
.course-card .card-action.primary:hover {
    background: #7dd3fc;
    text-decoration: none;
}

.course-card .card-action.disabled {
    background: var(--card);
    color: var(--text-muted);
    cursor: default;
    pointer-events: none;
}

/* ── Coming Soon Page ────────────────────────────────── */

.coming-soon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    padding: 2rem;
}

.coming-soon .cs-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.6;
}

.coming-soon h1 {
    border: none;
    font-size: 2rem;
    margin-bottom: 1rem;
}

.coming-soon .cs-description {
    color: var(--text-muted);
    max-width: 500px;
    margin-bottom: 2rem;
    font-size: 1.05rem;
}

.coming-soon .cs-back {
    padding: 0.6rem 1.4rem;
    border-radius: 8px;
    background: var(--accent);
    color: var(--bg);
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s;
}
.coming-soon .cs-back:hover {
    background: #7dd3fc;
    text-decoration: none;
}

/* ── Course Index (when viewing a course home) ───────── */

.course-home { padding: 1rem 0; }

.course-home .course-header {
    margin-bottom: 2rem;
}

.course-home .course-header h1 {
    border: none;
    margin-bottom: 0.5rem;
}

.course-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0 2rem;
}

.meta-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
}
.meta-card .label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.meta-card .value {
    font-size: 1.25rem;
    color: var(--highlight);
    font-weight: 700;
}

.week-header {
    background: var(--card);
    padding: 0.6rem 1rem;
    border-radius: 6px;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
    color: var(--highlight);
    font-weight: 600;
    font-size: 1rem;
}

/* ── Domain Sections (home page) ─────────────────────── */

.domain-section {
    margin-top: 3rem;
}

.domain-section h2 {
    border-left: none;
    padding-left: 0;
    text-align: center;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.domain-section h2::before,
.domain-section h2::after {
    content: '———';
    margin: 0 0.75rem;
    color: var(--border);
}

/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: block;
    }
    .topnav .nav-courses {
        margin-left: 0.5rem;
    }
}

@media (max-width: 600px) {
    .main-content { padding: 1.5rem 1rem; }
    .hero .hero-title { font-size: 1.8rem; }
    .course-grid { grid-template-columns: 1fr; }
    h1 { font-size: 1.6rem; }
}
