/* ============================================
   MAESTRO Style — "The Orchestrator's Score"
   Dark theme, warm gold accents, chalk aesthetic
   ============================================ */

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

:root {
    --transition-speed: 300ms;

    /* MAESTRO palette */
    --bg: #1E1E1E;
    --bg-sidebar: #252526;
    --bg-surface: #2D2D2D;
    --bg-hover: #37373D;
    --bg-active: #2D2D2D;
    --text: #D4D4D4;
    --text-muted: #808080;
    --text-bright: #E8E8E8;
    --border: #2A2520;
    --accent-gold: #D4A855;
    --accent-red: #CC0000;
    --accent-green: #6A9955;
    --accent-warm-yellow: #DCDCAA;
    --line-num: #5A5248;
    --tab-active-bg: #1E1E1E;
    --tab-inactive-bg: #252526;
    --tab-border: #252526;
    --terminal-bg: #1A1A1A;
    --terminal-header: #333333;
    --scrollbar-thumb: #3A3530;
    --banner-shadow: rgba(0,0,0,0.5);
    --code-bg: #151210;
}

@media (prefers-reduced-motion: reduce) {
    :root { --transition-speed: 0ms; }
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Paragraphs ── */
p {
    margin-bottom: 16px;
}

p:last-child {
    margin-bottom: 0;
}

/* ── Links ── */
a {
    color: var(--accent-gold);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition-speed);
}

a:hover {
    border-bottom-color: var(--accent-gold);
}

/* ── Tab bar ── */
.tab-bar {
    display: flex;
    align-items: stretch;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    height: 36px;
    flex-shrink: 0;
    overflow-x: auto;
}

.tab-bar-spacer {
    flex: 1;
    background: var(--tab-inactive-bg);
    border-bottom: 1px solid var(--border);
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    background: var(--tab-inactive-bg);
    border: none;
    border-left: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    transition: background var(--transition-speed), color var(--transition-speed);
}
.theme-toggle .theme-icon {
    font-size: 18px;
}
.theme-toggle:hover {
    color: var(--accent-gold);
    background: var(--bg-hover);
}

/* ── Layout ── */
.layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 12px 0;
    transition: transform var(--transition-speed), width var(--transition-speed);
    flex-shrink: 0;
    position: relative;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border-right: none;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }

.sidebar-home {
    display: block;
    margin: 12px 14px;
    padding: 8px 14px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-gold);
    border: 1px solid rgba(212, 168, 85, 0.4);
    border-radius: 6px;
    text-decoration: none;
    text-align: center;
    transition: background 200ms, border-color 200ms;
}

.sidebar-home:hover {
    background: rgba(212, 168, 85, 0.1);
    border-color: var(--accent-gold);
}

.sidebar-section {
    margin-bottom: 4px;
}

/* Accordion: items hidden by default */
.sidebar-section .sidebar-item {
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
    margin: 0;
    opacity: 0;
    transition: max-height 250ms ease, opacity 200ms ease, padding 200ms ease;
}

/* Accordion: items visible when open */
.sidebar-section.open .sidebar-item {
    max-height: 60px;
    opacity: 1;
    padding: 10px 18px 10px 36px;
}

.sidebar-chevron {
    float: right;
    font-size: 12px;
    transition: transform 250ms ease;
}

.sidebar-section.open .sidebar-chevron {
    transform: rotate(180deg);
}

.sidebar-header {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent-gold);
    padding: 10px 16px;
    user-select: none;
    cursor: pointer;
    transition: background 200ms;
}

.sidebar-header:hover {
    background: var(--bg-hover);
}

.sidebar-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 4px 16px 4px 24px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    transition: background var(--transition-speed);
    user-select: none;
    text-decoration: none;
    border-left: 3px solid transparent;
    position: relative;
}

.sidebar-item:hover { background: var(--bg-hover); }

.sidebar-item.active {
    background: var(--bg-active);
    color: var(--text-bright);
    border-left-color: var(--accent-gold);
}

.sidebar-item .num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-muted);
    min-width: 16px;
}

.sidebar-item.active .num { color: var(--accent-gold); }

.sidebar-item .arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-gold);
    text-shadow: 0 0 6px rgba(212, 168, 85, 0.4);
}

/* ── Sidebar collapse button ── */
.sidebar-collapse-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg-sidebar);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    transition: background var(--transition-speed), color var(--transition-speed);
    z-index: 10;
}
.sidebar-collapse-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.sidebar-expand-btn {
    position: fixed;
    top: 44px;
    left: 6px;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg-sidebar);
    color: var(--text-muted);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    z-index: 110;
    transition: background var(--transition-speed), color var(--transition-speed);
    box-shadow: 2px 2px 8px rgba(0,0,0,0.4);
}
.sidebar-expand-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.sidebar-expand-btn.visible {
    display: flex;
}

/* ── Mobile sidebar toggle ── */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    cursor: pointer;
}

/* ── Main content ── */
.main {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    border-left: 1px solid var(--border);
}

.main::-webkit-scrollbar { width: 8px; }
.main::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }

.content {
    max-width: 780px;
    margin: 0 auto;
    padding: 24px 40px 60px;
}

/* ── Breadcrumb ── */
.breadcrumb {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 20px;
}
.breadcrumb span { color: var(--accent-gold); }

/* ── Banner ── */
.banner-frame {
    position: relative;
    margin-bottom: 28px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-surface);
}

.banner-titlebar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--terminal-header);
}

.banner-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.banner-dot.red { background: #FF605C; }
.banner-dot.yellow { background: #FFBD44; }
.banner-dot.green { background: #00CA4E; }

.banner-titlebar-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--accent-gold);
}

.banner-frame img {
    width: 100%;
    display: block;
    height: auto;
}

/* ── Title ── */
.lesson-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 16px;
    line-height: 1.3;
}

/* ── Summary block ── */
.summary-block {
    border-left: 3px solid var(--accent-gold);
    padding: 14px 20px;
    margin-bottom: 36px;
    background: var(--bg-surface);
    border-radius: 0 6px 6px 0;
    font-size: 15px;
    color: var(--text);
}

/* ── Section headers (h2) ── */
.section-header {
    font-family: 'JetBrains Mono', monospace;
    font-size: 20px;
    font-weight: 600;
    color: var(--accent-gold);
    margin: 40px 0 18px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--accent-gold);
    border-image: linear-gradient(to right, var(--accent-gold), transparent) 1;
}

.section-header .note {
    color: var(--accent-gold);
    font-weight: 400;
    margin-right: 4px;
}

/* ── Subsection headers (h3) ── */
.subsection-header {
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    font-weight: 600;
    color: var(--accent-gold);
    margin: 28px 0 12px;
}

.subsection-header .qnote {
    color: var(--text-muted);
    font-weight: 400;
    margin-right: 4px;
}

/* ── Comparison cards ── */
.comparison-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 20px 0 28px;
}

.comparison-card {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 150ms;
}

.comparison-card:hover { transform: translateY(-2px); }

.comparison-card.highlight {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 1px var(--accent-gold);
}

.comparison-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--terminal-header);
    border-bottom: 1px solid var(--border);
}

.comparison-card-header .title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.comparison-card.highlight .comparison-card-header .title {
    color: var(--accent-gold);
}

.comparison-card-body {
    padding: 16px;
    background: var(--terminal-bg);
    font-size: 14px;
    line-height: 1.6;
}

/* ── Inline list ── */
.inline-list {
    padding-left: 48px;
    margin: 10px 0 20px;
}

.inline-list li {
    font-size: 14px;
    margin-bottom: 6px;
    list-style: none;
    position: relative;
    padding-left: 24px;
}

.inline-list li::before {
    content: "\2022";
    position: absolute;
    left: 0;
    font-size: 14px;
    color: var(--accent-gold);
}

/* ── Warning blocks ── */
.warn-block {
    padding: 14px 18px;
    margin: 12px 0;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.7;
    border-left: 3px solid;
    background: var(--bg-surface);
}

.warn-block .label {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

.warn-block.warn { border-color: var(--accent-gold); }
.warn-block.warn .label { color: var(--accent-gold); }

.warn-block.info { border-color: var(--accent-gold); }
.warn-block.info .label { color: var(--accent-gold); }

.warn-block.danger { border-color: var(--accent-red); }
.warn-block.danger .label { color: var(--accent-red); }

.warn-block.tip { border-color: var(--accent-gold); }
.warn-block.tip .label { color: var(--accent-gold); }

/* ── Checklist ── */
.checklist {
    padding-left: 0;
    margin: 10px 0 20px;
}

.checklist li {
    font-size: 14px;
    margin-bottom: 8px;
    list-style: none;
    position: relative;
    padding-left: 28px;
}

.checklist li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 4px;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--accent-gold);
    border-radius: 3px;
    background: transparent;
}

/* ── Section complete button ── */
.section-complete {
    margin-top: 32px;
    margin-bottom: 8px;
}

.section-complete-btn {
    display: block;
    width: 100%;
    background: transparent;
    color: var(--accent-gold);
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    font-weight: 600;
    padding: 16px 24px;
    border-radius: 6px;
    border: 2px solid var(--accent-gold);
    cursor: pointer;
    text-align: center;
    transition: background 200ms, color 200ms, box-shadow 200ms;
}

.section-complete-btn:hover {
    background: rgba(212, 168, 85, 0.1);
}

.section-complete-btn:focus {
    outline: none;
}

.section-complete-btn.completed {
    background: var(--accent-gold);
    color: #1E1E1E;
    border-color: var(--accent-gold);
}

.section-complete-btn.completed:hover {
    background: rgba(212, 168, 85, 0.8);
}

/* ── Bottom navigation ── */
.bottom-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 48px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.bottom-nav a {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--accent-gold);
    text-decoration: none;
    padding: 8px 16px;
    border: 1px solid var(--accent-gold);
    border-radius: 4px;
    cursor: pointer;
    transition: background var(--transition-speed);
}

.bottom-nav a:hover {
    background: rgba(212, 168, 85, 0.1);
}

/* ── Strong text ── */
strong {
    color: var(--text-bright);
    font-weight: 600;
}

/* ── Mobile ── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 36px;
        left: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform var(--transition-speed);
        box-shadow: 4px 0 20px rgba(0,0,0,0.5);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-menu-btn {
        display: flex;
    }

    .content {
        padding: 20px 18px 60px;
    }

    .comparison-cards {
        grid-template-columns: 1fr;
    }

    .lesson-title {
        font-size: 22px;
    }

    .section-header {
        font-size: 17px;
    }

    .inline-list,
    .checklist {
        padding-left: 0;
    }
}

/* ── Overlay for mobile sidebar ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 99;
}

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

/* ── Subtle depth ── */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(212, 168, 85, 0.015) 0%, transparent 70%),
        radial-gradient(ellipse at 80% 20%, rgba(204, 0, 0, 0.01) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.layout, .tab-bar {
    position: relative;
    z-index: 1;
}

/* ── Selection color ── */
::selection {
    background: rgba(212, 168, 85, 0.3);
    color: var(--text-bright);
}
