/* ============================================================
   DSA Masterclass — Claymorphism + Minimalist Light Theme
   ============================================================ */

/* Import Shiki-compatible font for code */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── Design Tokens — Nordish Muted Claymorphism ── */
:root {
    /* Core Palette — Muted off-whites with sage/cyan/cream tints */
    --bg-body: #eceae5;
    /* warm grey-cream base */
    --bg-surface: #f0ede8;
    /* slightly lighter cream-sage */
    --bg-sidebar: #e8e6e0;
    /* muted sage-stone sidebar */
    --bg-elevated: #f4f2ed;
    /* soft parchment, NOT pure white */
    --bg-code: #f1efea;
    /* code block background */
    --bg-code-gutter: #e9e7e1;
    /* line number gutter */

    /* Text */
    --text-primary: #2b2f2e;
    /* dark nord-green tinted black */
    --text-secondary: #6b7370;
    /* muted teal-grey */
    --text-tertiary: #969e99;
    /* faded sage */

    /* Accents — Muted, nordic earthy tones */
    --accent: #7a9a6d;
    /* muted sage green */
    --accent-warm: #b08d6e;
    /* warm nordic brown */
    --accent-soft: #c5d4b8;
    /* pale sage */
    --accent-bg: rgba(122, 154, 109, 0.1);
    --accent-border: rgba(122, 154, 109, 0.25);

    /* Claymorphism Shadows — muted, nordic, NO pure white highlights */
    --clay-shadow:
        6px 6px 14px rgba(160, 155, 145, 0.35),
        -4px -4px 10px rgba(245, 243, 238, 0.65);
    --clay-shadow-sm:
        3px 3px 7px rgba(160, 155, 145, 0.25),
        -2px -2px 5px rgba(245, 243, 238, 0.55);
    --clay-shadow-hover:
        5px 5px 10px rgba(160, 155, 145, 0.4),
        -3px -3px 8px rgba(245, 243, 238, 0.7);
    --clay-inset:
        inset 2px 2px 5px rgba(160, 155, 145, 0.2),
        inset -2px -2px 5px rgba(245, 243, 238, 0.5);
    --clay-pressed:
        inset 3px 3px 6px rgba(150, 145, 135, 0.3),
        inset -2px -2px 4px rgba(245, 243, 238, 0.4);

    /* Borders */
    --border-color: rgba(172, 168, 158, 0.3);
    --border-strong: rgba(172, 168, 158, 0.5);

    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;

    /* Typography */
    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-code: 'JetBrains Mono', 'Fira Code', monospace;

    /* Radius — Rounded, soft, clay-like */
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 20px;
    --radius-xl: 24px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.7;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

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

/* ══════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════ */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 100;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 24px 20px 8px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.02em;
}

.close-btn {
    display: none;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    box-shadow: var(--clay-shadow-sm);
}

.close-btn:hover {
    color: var(--text-primary);
    box-shadow: var(--clay-shadow-hover);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.nav-category {
    margin-bottom: 20px;
}

.category-title {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-tertiary);
    margin-bottom: 6px;
    padding: 0 12px;
    font-weight: 600;
}

.nav-item {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-family: var(--font-main);
    transition: var(--transition);
    margin-bottom: 4px;
    font-weight: 400;
    line-height: 1.45;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
    display: block;
}

.nav-item:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    box-shadow: var(--clay-shadow-sm);
    transform: translateX(2px);
}

.nav-item.active {
    background: var(--bg-elevated);
    color: var(--accent);
    font-weight: 600;
    box-shadow: var(--clay-shadow-sm);
    transform: translateX(4px);
    padding-left: 12px;
}

/* ══════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════ */
.main-content {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-body);
}

/* ── Topbar ── */
.topbar {
    padding: 0;
    display: none;
    /* Hidden entirely on desktop since badge was removed */
    align-items: center;
    border-bottom: none;
    background: transparent;
    z-index: 10;
}

.menu-btn {
    display: none;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    box-shadow: var(--clay-shadow-sm);
    transition: var(--transition-fast);
    align-items: center;
    justify-content: center;
}

.menu-btn:hover {
    box-shadow: var(--clay-shadow-hover);
}

.badge {
    margin-left: auto;
    background: var(--bg-surface);
    color: var(--accent);
    padding: 6px 16px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid var(--accent-border);
    box-shadow: var(--clay-shadow-sm);
}

/* ── Content Wrapper ── */
.content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
}

.view {
    display: block;
    max-width: 960px;
    margin: 0 auto;
}

.view.hidden {
    display: none;
}

.fade-in {
    animation: fadeIn 0.45s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ══════════════════════════════════════════════
   HOME VIEW
   ══════════════════════════════════════════════ */

/* Hero Section */
.hero-section {
    text-align: left;
    margin-bottom: 48px;
    padding: 20px 0;
    max-width: 800px;
}

.hero-section h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: 12px;
}

.hero-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem !important;
    line-height: 1.6 !important;
    margin: 0 0 48px 0 !important;
}

.overview-section {
    margin-bottom: 40px;
}

.overview-section h3 {
    color: var(--text-primary);
    margin: 0 0 16px 0;
    font-weight: 600;
    font-size: 1.25rem;
}

.overview-section p {
    color: var(--text-secondary);
    line-height: 1.8;
}

.overview-section ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.8;
}

.overview-section li {
    margin-bottom: 12px;
}

.overview-section strong {
    color: var(--text-primary);
    font-weight: 500;
}

/* Chart Card — Clay Style */
.glass-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 28px;
    margin-bottom: 44px;
    box-shadow: var(--clay-shadow);
    transition: var(--transition);
}

.glass-card:hover {
    box-shadow: var(--clay-shadow-hover);
}

.glass-card h3 {
    font-size: 1.15rem;
    margin-bottom: 4px;
    font-weight: 600;
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    margin-bottom: 24px;
}

.chart-container-wrapper {
    position: relative;
    width: 100%;
}

.chart-container {
    height: 280px;
    width: 100%;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.feature-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
    cursor: pointer;
    box-shadow: var(--clay-shadow);
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--clay-shadow-hover);
    border-color: var(--accent-border);
}

.feature-card .icon {
    font-size: 1.75rem;
    margin-bottom: 14px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--clay-shadow-sm);
}

.feature-card h4 {
    margin-bottom: 6px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.6;
}

/* ══════════════════════════════════════════════
   TOPIC VIEW
   ══════════════════════════════════════════════ */

/* Topic Header */
.topic-header {
    margin-bottom: 32px;
}

.category-tag {
    display: inline-block;
    color: var(--accent);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    margin-bottom: 6px;
    background: var(--accent-bg);
    padding: 4px 12px;
    border-radius: 100px;
    border: 1px solid var(--accent-border);
}

.topic-header h2 {
    font-size: 2.2rem;
    margin-bottom: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.problem-statement {
    margin-bottom: 24px;
}

.problem-statement h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-weight: 600;
}

.problem-statement p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.7;
}

/* ── Tabs ── */
.tabs-container {
    margin-top: 36px;
}

.tab-buttons {
    display: flex;
    gap: 16px;
    margin-bottom: 28px;
    padding: 0 0 8px 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.tab-buttons::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 4px;
    font-size: 0.95rem;
    font-family: var(--font-main);
    cursor: pointer;
    border-radius: 0;
    transition: var(--transition);
    white-space: nowrap;
    font-weight: 500;
    position: relative;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: transparent;
}

.tab-btn.active {
    color: var(--accent);
    background: transparent;
    box-shadow: none;
    font-weight: 600;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -9px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--accent);
    border-top-left-radius: 3px;
    border-top-right-radius: 3px;
}

.tab-content {
    display: none;
    animation: fadeIn 0.35s ease;
}

.tab-content.active {
    display: block;
}

/* ══════════════════════════════════════════════
   CODE TAB — Shiki-Style Code Block
   ══════════════════════════════════════════════ */
#tab-code {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--clay-shadow-sm);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
}

.code-header span {
    font-family: var(--font-code);
    font-size: 0.78rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* Removed File indicator dot */

.copy-btn {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 5px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-family: var(--font-main);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: var(--clay-shadow-sm);
}

.copy-btn:hover {
    background: var(--accent);
    color: var(--bg-elevated);
    border-color: var(--accent);
    box-shadow: var(--clay-shadow-hover);
}

/* Highlight.js Base & Line Numbers */
.hljs {
    background: var(--bg-code);
    padding: 24px;
    font-size: 0.82rem;
    line-height: 1.8;
    font-family: var(--font-code);
    color: var(--text-primary);
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    word-break: break-all !important;
    overflow-x: hidden !important;
    border-radius: 0;
    margin: 0;
    display: block;
}

/* The table generated by highlightjs-line-numbers */
.hljs-ln {
    width: 100%;
    border-collapse: collapse;
}

.hljs-ln td {
    padding: 0;
    border: none;
    vertical-align: top;
}

/* Gutter column */
.hljs-ln-numbers {
    width: 44px !important;
    min-width: 44px !important;
    background: transparent !important;
    border-right: 1px solid var(--border-color) !important;
    text-align: right !important;
    padding-right: 12px !important;
    color: var(--text-tertiary) !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

.hljs-ln-n {
    display: inline-block;
    padding-top: 0px;
}

/* Code column */
.hljs-ln-code {
    padding-left: 16px !important;
}

/* Code wrapping inside hljs line numbers */
.hljs-ln-line {
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    word-break: break-all !important;
    overflow-wrap: break-word !important;
    font-size: 0.82rem !important;
    line-height: 1.8 !important;
}

/* token overrides — Nord-inspired palette */
.hljs-comment,
.hljs-quote,
.hljs-meta {
    color: #969e99 !important;
    font-style: italic !important;
}

.hljs-punctuation {
    color: #6b7370 !important;
}

.hljs-number,
.hljs-literal,
.hljs-symbol {
    color: #b08d6e !important;
}

.hljs-string,
.hljs-regexp,
.hljs-addition {
    color: #7a9a6d !important;
}

.hljs-operator,
.hljs-built_in {
    color: #8a7e6e !important;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-type,
.hljs-deletion {
    color: #9b7093 !important;
}

.hljs-function,
.hljs-title,
.hljs-title.class_,
.hljs-title.function_ {
    color: #5e8a9a !important;
}

.hljs-variable,
.hljs-template-variable,
.hljs-attr {
    color: #c08b6a !important;
}

/* ══════════════════════════════════════════════
   THEORY TAB
   ══════════════════════════════════════════════ */
.theory-body {
    background: transparent;
    border: none;
    padding: 0;
    border-radius: 0;
    line-height: 1.8;
    box-shadow: none;
}

.theory-body h3,
.theory-body h4,
.theory-body h5 {
    color: var(--text-primary);
    margin-top: 24px;
    margin-bottom: 12px;
    font-weight: 600;
}

.theory-body h3 {
    font-size: 1.15rem;
}

.theory-body h4 {
    font-size: 1rem;
}

.theory-body h5 {
    font-size: 0.9rem;
}

.theory-body p {
    color: var(--text-secondary);
    margin-bottom: 14px;
    font-size: 0.9rem;
}

.theory-body ul,
.theory-body ol {
    color: var(--text-secondary);
    margin-left: 18px;
    margin-bottom: 14px;
    font-size: 0.9rem;
}

.theory-body li {
    margin-bottom: 6px;
}

.theory-body strong {
    color: var(--text-primary);
    font-weight: 600;
}

.theory-body em {
    color: var(--accent);
    font-style: normal;
    font-weight: 500;
}

.theory-body code {
    font-family: var(--font-code);
    font-size: 0.8rem;
    background: var(--bg-body);
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    color: var(--accent);
}

/* Theory — Advantages/Disadvantages cards that come from data.js */
.theory-body div[class*="bg-green"],
.theory-body div[class*="bg-red"],
.theory-body div[class*="bg-blue"],
.theory-body div[class*="bg-purple"],
.theory-body div[class*="bg-indigo"] {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    box-shadow: none;
    margin-bottom: 24px;
}

.theory-body div[class*="bg-green"] h5,
.theory-body div[class*="bg-red"] h5,
.theory-body div[class*="bg-blue"] h5,
.theory-body div[class*="bg-purple"] h5,
.theory-body div[class*="bg-indigo"] h5 {
    color: var(--text-primary) !important;
    font-weight: 700 !important;
    font-size: 0.85rem !important;
    margin-top: 0 !important;
}

.theory-body div[class*="bg-green"] li,
.theory-body div[class*="bg-red"] li,
.theory-body div[class*="bg-blue"] li,
.theory-body div[class*="bg-purple"] li,
.theory-body div[class*="bg-indigo"] li {
    color: var(--text-secondary) !important;
    font-size: 0.82rem !important;
}

.theory-body div[class*="bg-green"] p,
.theory-body div[class*="bg-red"] p,
.theory-body div[class*="bg-blue"] p,
.theory-body div[class*="bg-purple"] p,
.theory-body div[class*="bg-indigo"] p {
    color: var(--text-secondary) !important;
    font-size: 0.82rem !important;
}

/* Theory grid — override tailwind-like grid classes */
.theory-body div[class*="grid"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 16px !important;
}

/* ══════════════════════════════════════════════
   VIVA TAB
   ══════════════════════════════════════════════ */
.viva-grid {
    display: grid;
    gap: 14px;
}

.viva-card {
    background: transparent;
    border: none;
    border-bottom: 1px dashed var(--border-color);
    border-radius: 0;
    padding: 24px 0;
    transition: var(--transition);
    box-shadow: none;
}

/* Removed hover effect from viva cards */

.viva-card h4 {
    margin-bottom: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.5;
}

.viva-card h4 span {
    color: var(--accent);
    font-weight: 700;
    margin-right: 6px;
}

.viva-card p {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.7;
}

.viva-card p b {
    color: var(--accent);
    font-weight: 600;
    margin-right: 4px;
}

/* ══════════════════════════════════════════════
   RESPONSIVE — Mobile & Tablet
   ══════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .theory-body div[class*="grid"] {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 280px;
        box-shadow: 10px 0 40px rgba(45, 42, 38, 0.15);
        transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 200;
    }

    .sidebar.open {
        left: 0;
    }

    .close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .menu-btn {
        display: flex;
    }

    .topbar {
        display: flex;
        padding: 14px 20px;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .hero-section h1 {
        font-size: 1.75rem;
    }

    .topic-header h2 {
        font-size: 1.65rem;
    }

    .content-wrapper {
        padding: 20px 16px;
    }

    body {
        font-size: 14px;
    }

    .tabs-container {
        margin-top: 20px;
    }

    .tab-btn {
        padding: 8px 14px;
        font-size: 0.82rem;
    }

    .theory-body {
        padding: 0;
    }

    .theory-body div[class*="grid"] {
        grid-template-columns: 1fr !important;
    }

    .viva-card {
        padding: 18px 0;
    }

    .hljs,
    .hljs-ln-line {
        font-size: 0.75rem !important;
    }

    .hljs-ln-numbers {
        width: 34px !important;
        min-width: 34px !important;
        padding-right: 8px !important;
    }

    .hljs-ln-code {
        padding-left: 10px !important;
    }
}

@media (max-width: 480px) {
    .hero-section h1 {
        font-size: 1.5rem;
    }

    .topic-header h2 {
        font-size: 1.4rem;
    }

    .content-wrapper {
        padding: 16px 12px;
    }

    .glass-card {
        padding: 20px;
    }

    .feature-card {
        padding: 20px;
    }

    .chart-container {
        height: 220px;
    }
}

/* ── Mobile sidebar overlay ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(43, 47, 46, 0.18);
    z-index: 150;
    transition: opacity 0.3s ease;
}

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