/* LearnPlatform — "Nocturne" aesthetic
   Dracula-inspired · deep near-black + signature purple · JetBrains Mono for chrome */

:root, [data-theme="dark"] {
  /* Inspired by Dracula — but deeper. Near-black with a cold violet undertone,
     not literal #282a36. Think "Linear at night, wearing a Dracula hoodie." */
  --bg-0: #08080c;          /* page root — effectively black */
  --bg-1: #0c0c12;          /* sidebar / topbar */
  --bg-2: #101018;          /* cards, primary surface */
  --bg-3: #161622;          /* hover / elevated surface */
  --bg-4: #1e1e2c;          /* input, selection, chips */
  --border-1: #18182230;    /* faint dividers */
  --border-2: #242432;      /* standard borders */
  --border-3: #35354a;      /* strong borders, focus rings */

  --fg-0: #f2f2f7;          /* primary text — soft white with cold undertone */
  --fg-1: #cfcfdb;
  --fg-2: #8a8aa0;          /* muted */
  --fg-3: #585870;          /* very muted / hint */
  --fg-4: #3a3a52;

  --code-bg: #05050a;       /* deeper than bg-0 to stand out */
  --code-border: #2a2a42;   /* visible but not harsh */
  --code-kw: #ff79c6;       /* Dracula pink for keywords */
  --code-str: #f1fa8c;      /* Dracula yellow for strings */
  --code-num: #bd93f9;      /* Dracula purple for numbers */

  /* Primary accent — Dracula purple, the one signature color */
  --accent: #bd93f9;
  --accent-hi: #d6b5ff;
  --accent-lo: #9d6ff0;
  --accent-dim: rgba(189, 147, 249, 0.10);
  --accent-border: rgba(189, 147, 249, 0.28);
  --accent-glow: rgba(189, 147, 249, 0.22);
  --accent-ink: #140a28;    /* deep ink for text on purple bg */

  /* Secondary — Dracula cyan (used sparingly, e.g. links, info) */
  --teal: #8be9fd;
  --teal-dim: rgba(139, 233, 253, 0.10);
  --teal-border: rgba(139, 233, 253, 0.28);

  /* Semantic — Dracula palette */
  --green: #50fa7b;
  --blue: #8be9fd;
  --red: #ff5555;
  --purple: #bd93f9;
  --orange: #ffb86c;
  --pink: #ff79c6;
  --yellow: #f1fa8c;

  --green-dim: rgba(80, 250, 123, 0.10);
  --blue-dim: rgba(139, 233, 253, 0.10);
  --yellow-dim: rgba(241, 250, 140, 0.10);
  --red-dim: rgba(255, 85, 85, 0.10);
  --purple-dim: rgba(189, 147, 249, 0.10);
  --pink-dim: rgba(255, 121, 198, 0.10);
  --orange-dim: rgba(255, 184, 108, 0.10);

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --font-display: 'Geist', -apple-system, sans-serif;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 0 1px var(--accent-border), 0 8px 24px var(--accent-glow);
}

[data-theme="light"] {
  /* Cool off-white — Dracula's "Alucard" cousin but more neutral */
  --bg-0: #f6f6fa;
  --bg-1: #f1f1f6;
  --bg-2: #ffffff;
  --bg-3: #ebebf2;
  --bg-4: #e0e0ea;
  --border-1: #e6e6ee;
  --border-2: #d4d4e0;
  --border-3: #b4b4c6;

  --fg-0: #14141c;
  --fg-1: #28283a;
  --fg-2: #585870;
  --fg-3: #7a7a92;
  --fg-4: #a0a0b4;

  --code-bg: #f0f0f6;
  --code-border: #d4d4e0;
  --code-kw: #c026d3;       /* fuchsia for keywords */
  --code-str: #0891b2;      /* cyan for strings */
  --code-num: #7c3aed;      /* purple for numbers */

  /* Purple accent, deepened for light-mode contrast */
  --accent: #7c3aed;
  --accent-hi: #6d28d9;
  --accent-lo: #5b21b6;
  --accent-dim: rgba(124, 58, 237, 0.08);
  --accent-border: rgba(124, 58, 237, 0.26);
  --accent-glow: rgba(124, 58, 237, 0.14);
  --accent-ink: #ffffff;

  --teal: #0891b2;
  --teal-dim: rgba(8, 145, 178, 0.10);
  --teal-border: rgba(8, 145, 178, 0.28);

  --green: #059669;
  --blue: #0284c7;
  --red: #dc2626;
  --purple: #7c3aed;
  --orange: #ea580c;
  --pink: #db2777;
  --yellow: #ca8a04;

  --green-dim: rgba(5, 150, 105, 0.10);
  --blue-dim: rgba(2, 132, 199, 0.10);
  --yellow-dim: rgba(202, 138, 4, 0.10);
  --red-dim: rgba(220, 38, 38, 0.10);
  --purple-dim: rgba(124, 58, 237, 0.10);
  --pink-dim: rgba(219, 39, 119, 0.10);
  --orange-dim: rgba(234, 88, 12, 0.10);

  --shadow-sm: 0 1px 2px rgba(20, 20, 28, 0.06);
  --shadow-md: 0 4px 14px rgba(20, 20, 28, 0.08);
  --shadow-lg: 0 20px 50px rgba(20, 20, 28, 0.14);
  --shadow-glow: 0 0 0 1px var(--accent-border), 0 6px 20px var(--accent-glow);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg-0);
  color: var(--fg-1);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
  position: relative;
}

/* Subtle grain overlay — very light, skip on light theme */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  opacity: 0.18;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
[data-theme="light"] body::before { display: none; }

/* Keep UI above grain */
#root { position: relative; z-index: 2; }

code, pre, .mono { font-family: var(--font-mono); }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 10px; border: 2px solid var(--bg-0); }
::-webkit-scrollbar-thumb:hover { background: var(--border-3); }

/* App Layout */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 48px 1fr;
  grid-template-areas: "sidebar topbar" "sidebar main";
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.sidebar {
  grid-area: sidebar;
  background: var(--bg-1);
  border-right: 1px solid var(--border-1);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
}

.topbar {
  grid-area: topbar;
  border-bottom: 1px solid var(--border-1);
  background: var(--bg-0);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 12px;
  position: relative;
}

/* Scan line decor under topbar */
.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-border), transparent);
  opacity: 0.6;
}

.main {
  grid-area: main;
  overflow: auto;
  background: var(--bg-0);
  position: relative;
}

/* Sidebar */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  height: 48px;
  border-bottom: 1px solid var(--border-1);
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--fg-0);
  letter-spacing: 0.02em;
  font-size: 13px;
  position: relative;
}
.brand::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, var(--accent) 0, var(--accent) 24px, transparent 24px);
}
.brand-mark {
  position: relative;
  flex-shrink: 0;
  display: inline-block;
  line-height: 0;
}
.brand-mark svg { display: block; border-radius: 6px; }
.nav { padding: 10px; display: flex; flex-direction: column; gap: 1px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  color: var(--fg-2);
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--bg-3); color: var(--fg-1); }
.nav-item.active {
  background: var(--bg-3); color: var(--fg-0);
}
.nav-item.active::before {
  content: "";
  position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px; border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}
.nav-item svg { width: 14px; height: 14px; stroke-width: 1.8; flex-shrink: 0; }
.nav-section-label {
  padding: 14px 10px 4px; color: var(--fg-4);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 500;
  font-family: var(--font-mono);
}
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-1);
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-0);
}
.avatar {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-lo));
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--accent-ink);
  font-family: var(--font-mono);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
}

/* Topbar */
.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}
.breadcrumb > * { flex-shrink: 0; }
.breadcrumb .sep { color: var(--fg-4); }
.breadcrumb .current { color: var(--fg-0); font-weight: 500; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  white-space: nowrap;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  color: var(--fg-1);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.003em;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.btn:hover { background: var(--bg-3); border-color: var(--border-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 13px; height: 13px; }
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 0 rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn-ghost:hover { background: var(--bg-3); color: var(--fg-1); }
.btn-icon { padding: 5px; }
.btn-sm { padding: 3px 8px; font-size: 11.5px; }
.btn-lg { padding: 9px 16px; font-size: 13.5px; }
.btn.mono { font-family: var(--font-mono); font-weight: 500; letter-spacing: 0.01em; }

/* Inputs */
.input {
  width: 100%;
  padding: 8px 11px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  color: var(--fg-0);
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.input::placeholder { color: var(--fg-4); }
.label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-3);
  margin-bottom: 7px;
  font-weight: 500;
}

/* Cards */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-lg);
}

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge svg { width: 10px; height: 10px; }
.badge.neutral { background: var(--bg-3); color: var(--fg-2); border-color: var(--border-2); }
.badge.green { background: var(--green-dim); color: var(--green); border-color: rgba(74,222,128,0.25); }
.badge.orange { background: var(--accent-dim); color: var(--accent-hi); border-color: var(--accent-border); }
[data-theme="light"] .badge.orange { color: var(--accent); }

.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

/* Kbd */
kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--fg-2);
  font-weight: 500;
}

/* Headings */
h1, h2, h3, h4 { margin: 0; color: var(--fg-0); font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.muted { color: var(--fg-2); }
.mono-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  letter-spacing: 0.01em;
}

/* Progress bar — legacy .progress / .progress-bar pair (bar-fill style) */
.progress {
  height: 4px;
  background: var(--border-2);
  border-radius: 3px;
  overflow: hidden;
  width: 100%;
  position: relative;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* Tweaks panel */
.tweaks {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 260px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 999;
  font-size: 12px;
  display: none;
  overflow: hidden;
}
.tweaks.active { display: block; }
.tweaks-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-1);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; color: var(--fg-0);
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tweaks-body { padding: 14px; display: flex; flex-direction: column; gap: 13px; }
.tweak-row { display: flex; flex-direction: column; gap: 6px; }
.tweak-options { display: flex; gap: 4px; }
.tweak-options button {
  flex: 1;
  padding: 5px 7px;
  border: 1px solid var(--border-2);
  background: var(--bg-3);
  border-radius: var(--radius-sm);
  color: var(--fg-2);
  font-size: 11px;
  font-family: var(--font-mono);
  transition: all 0.12s;
}
.tweak-options button:hover { color: var(--fg-0); border-color: var(--border-3); }
.tweak-options button.active {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--accent);
}

/* tooltip */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-0);
  color: var(--fg-0);
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 100;
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-md);
}

/* Pulsing dot for "current task" marker on kanban cards */
.current-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-glow);
  animation: currentPulse 2s ease-in-out infinite;
}
@keyframes currentPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(189,147,249,0.6); }
  50%      { box-shadow: 0 0 0 4px rgba(189,147,249,0); }
}
[data-theme="light"] .current-dot {
  animation-name: currentPulseLight;
}
@keyframes currentPulseLight {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124,58,237,0.45); }
  50%      { box-shadow: 0 0 0 4px rgba(124,58,237,0); }
}

/* Mobile */
.mobile-menu-btn { display: none; }
.mobile-backdrop { display: none; }

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 48px 1fr;
    grid-template-areas: "topbar" "main";
  }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    z-index: 200;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu-btn { display: inline-flex; }
  .mobile-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
    display: none;
  }
  .mobile-backdrop.active { display: block; }
  .topbar { padding: 0 12px; }
  .breadcrumb { font-size: 11px; }
  .breadcrumb .crumb-hide-mobile { display: none; }
  .tweaks { right: 10px; bottom: 74px; width: calc(100vw - 20px); max-width: 320px; }
  .hide-mobile { display: none !important; }
}

/* Course page: main + side infra panel */
.course-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
}
@media (max-width: 1280px) {
  .course-layout { grid-template-columns: minmax(0, 1fr) 240px; }
}
