/* ============================================
   JS Fundamentals Guide — Design System
   ============================================ */

:root {
  --bg: #0d1117;
  --bg-alt: #161b22;
  --bg-raised: #1c2129;
  --border: #2d333b;
  --text: #e6edf3;
  --text-muted: #9198a1;
  --accent: #f7df1e;          /* JS yellow */
  --accent-dim: rgba(247, 223, 30, 0.12);
  --link: #58a6ff;
  --green: #3fb950;
  --red: #f85149;
  --orange: #d29922;
  --purple: #bc8cff;
  --code-bg: #161b22;
  --sidebar-w: 280px;
  --content-max: 860px;
  --radius: 10px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-alt: #f6f8fa;
  --bg-raised: #ffffff;
  --border: #d1d9e0;
  --text: #1f2328;
  --text-muted: #59636e;
  --accent-dim: rgba(191, 168, 0, 0.12);
  --link: #0969da;
  --green: #1a7f37;
  --red: #d1242f;
  --orange: #9a6700;
  --purple: #8250df;
  --code-bg: #f6f8fa;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 16px;
  transition: background 0.2s ease, color 0.2s ease;
}

/* ---------- Layout ---------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 20px 14px 40px;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 40px 48px 100px;
}

.content-inner { max-width: var(--content-max); margin: 0 auto; }

/* ---------- Sidebar ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  padding: 6px 10px 18px;
}

.brand-logo {
  width: 36px; height: 36px;
  background: var(--accent);
  color: #000;
  font-weight: 800;
  font-family: var(--font-mono);
  font-size: 15px;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 3px 1px 0;
  border-radius: 6px;
  flex-shrink: 0;
}

.brand-name { font-weight: 700; font-size: 15px; line-height: 1.25; }
.brand-name small { display: block; font-weight: 400; color: var(--text-muted); font-size: 11.5px; }

.nav-section { margin-top: 18px; }

.nav-heading {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 10px;
  margin-bottom: 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 1px;
}

.nav-item:hover { background: var(--bg-raised); }
.nav-item.active { background: var(--accent-dim); color: var(--text); font-weight: 600; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-icon { width: 18px; text-align: center; opacity: 0.75; flex-shrink: 0; }
.nav-label { flex: 1; }

.nav-check {
  appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  background: transparent;
  margin: 0;
}
.nav-check:checked { background: var(--green); border-color: var(--green); }
.nav-check:checked::after {
  content: "✓";
  color: #fff;
  font-size: 11px;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -52%);
  font-weight: 700;
}

.progress-wrap { padding: 14px 10px 4px; }
.progress-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; display: flex; justify-content: space-between; }
.progress-bar { height: 6px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); border-radius: 99px; width: 0%; transition: width 0.3s ease; }

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  gap: 12px;
}

.breadcrumb { color: var(--text-muted); font-size: 13.5px; }
.breadcrumb strong { color: var(--text); }

.topbar-actions { display: flex; gap: 8px; }

.icon-btn {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--text-muted); }

.menu-btn { display: none; }

/* ---------- Typography ---------- */

h1 { font-size: 2.1rem; line-height: 1.2; margin: 0 0 10px; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; margin: 2.6em 0 0.6em; padding-bottom: 8px; border-bottom: 1px solid var(--border); letter-spacing: -0.01em; }
h3 { font-size: 1.17rem; margin: 2em 0 0.5em; }
h4 { font-size: 1rem; margin: 1.6em 0 0.4em; }

.lead { font-size: 1.12rem; color: var(--text-muted); margin: 0 0 30px; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

p, li { color: var(--text); }
ul, ol { padding-left: 24px; }
li { margin-bottom: 5px; }

hr { border: none; border-top: 1px solid var(--border); margin: 40px 0; }

blockquote {
  margin: 16px 0;
  padding: 2px 18px;
  border-left: 3px solid var(--accent);
  background: var(--bg-alt);
  border-radius: 0 8px 8px 0;
  color: var(--text-muted);
}

/* ---------- Code ---------- */

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 5px;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  position: relative;
  margin: 14px 0;
  line-height: 1.55;
}

pre code { background: none; border: none; padding: 0; font-size: 13.5px; display: block; }

.copy-btn {
  position: absolute;
  top: 8px; right: 8px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  font-family: var(--font-sans);
}
pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--text); }

/* Syntax highlighting tokens */
.tok-kw  { color: #ff7b72; }
.tok-str { color: #a5d6ff; }
.tok-com { color: #8b949e; font-style: italic; }
.tok-num { color: #79c0ff; }
.tok-fn  { color: #d2a8ff; }
.tok-cls { color: #ffa657; }

[data-theme="light"] .tok-kw  { color: #cf222e; }
[data-theme="light"] .tok-str { color: #0a3069; }
[data-theme="light"] .tok-com { color: #6e7781; }
[data-theme="light"] .tok-num { color: #0550ae; }
[data-theme="light"] .tok-fn  { color: #8250df; }
[data-theme="light"] .tok-cls { color: #953800; }

/* ---------- Callouts ---------- */

.callout {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 14px 18px;
  margin: 18px 0;
  background: var(--bg-alt);
  font-size: 15px;
}
.callout p:first-child { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }
.callout-title { font-weight: 700; display: block; margin-bottom: 4px; }

.callout.tip     { border-left-color: var(--green); }
.callout.warn    { border-left-color: var(--orange); }
.callout.danger  { border-left-color: var(--red); }
.callout.info    { border-left-color: var(--link); }

/* ---------- Cards ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin: 20px 0;
}

.card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.card-icon { font-size: 24px; margin-bottom: 8px; }
.card h3 { margin: 0 0 6px; font-size: 15.5px; }
.card p { margin: 0; font-size: 13.5px; color: var(--text-muted); }

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14.5px; }
th { text-align: left; background: var(--bg-alt); font-weight: 600; }
th, td { border: 1px solid var(--border); padding: 9px 13px; vertical-align: top; }
td code { white-space: nowrap; }

/* ---------- Details / exercises ---------- */

details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 14px 0;
  background: var(--bg-alt);
  overflow: hidden;
}
details summary {
  cursor: pointer;
  padding: 12px 18px;
  font-weight: 600;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
details summary::before { content: "▸"; color: var(--accent); transition: transform 0.15s; }
details[open] summary::before { transform: rotate(90deg); }
details summary:hover { background: var(--bg-raised); }
.details-body { padding: 4px 18px 16px; border-top: 1px solid var(--border); }

.exercise {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 18px 0;
  overflow: hidden;
}
.exercise-head {
  background: var(--bg-alt);
  padding: 10px 18px;
  font-weight: 600;
  font-size: 14.5px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.exercise-body { padding: 6px 18px 14px; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge.easy   { background: rgba(63,185,80,0.15);  color: var(--green); }
.badge.medium { background: rgba(210,153,34,0.15); color: var(--orange); }
.badge.hard   { background: rgba(248,81,73,0.15);  color: var(--red); }
.badge.project{ background: rgba(188,140,255,0.15);color: var(--purple); }

/* ---------- Hero (landing page) ---------- */

.hero {
  position: relative;
  text-align: center;
  padding: 64px 28px 46px;
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(ellipse 60% 45% at 50% -5%, rgba(247, 223, 30, 0.14), transparent 70%),
    radial-gradient(ellipse 45% 40% at 12% 110%, rgba(188, 140, 255, 0.10), transparent 70%),
    radial-gradient(ellipse 45% 40% at 88% 110%, rgba(88, 166, 255, 0.10), transparent 70%),
    var(--bg-alt);
}

/* subtle dot grid overlay */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: 0.5;
  z-index: -1;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 30%, transparent 95%);
          mask-image: linear-gradient(to bottom, transparent, #000 30%, transparent 95%);
}

.hero > * { animation: hero-rise 0.6s ease both; }
.hero .hero-badge { animation-delay: 0.05s; }
.hero h1          { animation-delay: 0.12s; }
.hero .lead       { animation-delay: 0.2s; }
.hero .hero-actions { animation-delay: 0.28s; }
.hero .hero-code  { animation-delay: 0.38s; }

@keyframes hero-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 6px 16px;
  border-radius: 99px;
  margin-bottom: 20px;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.12);
}

.hero h1 { font-size: 2.7rem; margin-top: 0; }
.hero h1 .accent {
  color: var(--accent);
  position: relative;
  text-shadow: 0 0 34px rgba(247, 223, 30, 0.45);
}
[data-theme="light"] .hero h1 .accent {
  color: #b59a00;
  text-shadow: none;
}

.hero .lead { max-width: 640px; margin: 14px auto 28px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.hero-actions .btn.primary {
  box-shadow: 0 4px 22px rgba(247, 223, 30, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hero-actions .btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(247, 223, 30, 0.45);
}
.hero-actions .btn { transition: transform 0.15s ease, border-color 0.15s ease; }
.hero-actions .btn:hover { transform: translateY(-2px); }
.btn-arrow { display: inline-block; transition: transform 0.15s ease; }
.btn.primary:hover .btn-arrow { transform: translateX(4px); }

/* mock code window */
.hero-code {
  max-width: 560px;
  margin: 36px auto 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  text-align: left;
  background: var(--code-bg);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}
[data-theme="light"] .hero-code { box-shadow: 0 14px 34px rgba(31, 35, 40, 0.12); }

.hero-code-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.hero-code .dot { width: 11px; height: 11px; border-radius: 50%; }
.dot-r { background: #ff5f57; }
.dot-y { background: #febc2e; }
.dot-g { background: #28c840; }
.hero-code-title {
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}
.hero-code pre { margin: 0; border: none; border-radius: 0; padding: 16px 18px; }
.hero-code pre code { font-size: 13px; }
.hero-code .copy-btn { display: none; }

/* floating topic chips */
.hero-chip {
  position: absolute;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 7px 14px;
  border-radius: 99px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  animation: chip-float 5.5s ease-in-out infinite;
  pointer-events: none;
}
.chip-1 { top: 88px; left: 4%;  animation-delay: 0s;    transform: rotate(-6deg); }
.chip-2 { top: 64px; right: 5%; animation-delay: 1.6s;  transform: rotate(5deg); }
.chip-3 { bottom: 200px; right: 3%; animation-delay: 3.1s; transform: rotate(-4deg); }

@keyframes chip-float {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -10px; }
}

@media (prefers-reduced-motion: reduce) {
  .hero > *, .hero-chip { animation: none; }
}

.btn {
  display: inline-block;
  padding: 11px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--bg-alt);
  cursor: pointer;
}
.btn:hover { text-decoration: none; border-color: var(--text-muted); }
.btn.primary { background: var(--accent); color: #000; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }

.stat-row {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin: 40px 0;
  flex-wrap: wrap;
}
.stat { text-align: center; }
.stat-num { font-size: 2rem; font-weight: 800; color: var(--accent); font-family: var(--font-mono); }
[data-theme="light"] .stat-num { color: #b59a00; }
.stat-label { font-size: 13px; color: var(--text-muted); }

/* ---------- Page footer nav ---------- */

.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.page-nav a {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  text-decoration: none;
  color: var(--text);
}
.page-nav a:hover { border-color: var(--accent); }
.page-nav .dir { font-size: 12px; color: var(--text-muted); display: block; }
.page-nav .next { text-align: right; }

/* ---------- Playground ---------- */

.playground {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 20px 0;
}

.pg-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--code-bg);
  display: flex;
  flex-direction: column;
}

.pg-head {
  background: var(--bg-alt);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#pg-editor {
  width: 100%;
  min-height: 420px;
  background: transparent;
  color: var(--text);
  border: none;
  resize: vertical;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
  outline: none;
  flex: 1;
  tab-size: 2;
}

#pg-output {
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  min-height: 420px;
  margin: 0;
  border: none;
  border-radius: 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  flex: 1;
}

.pg-log { padding: 2px 0; border-bottom: 1px dashed var(--border); }
.pg-log.err { color: var(--red); }
.pg-log.warn { color: var(--orange); }
.pg-log.ret { color: var(--text-muted); }

.pg-toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.pg-toolbar .btn { padding: 8px 16px; font-size: 13.5px; }

.snippet-select {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-family: var(--font-sans);
  cursor: pointer;
}

/* ---------- Roadmap ---------- */

.week {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 22px 0;
  overflow: hidden;
}
.week-head {
  background: var(--bg-alt);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
}
.week-num {
  background: var(--accent);
  color: #000;
  font-weight: 800;
  font-family: var(--font-mono);
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 14px;
  flex-shrink: 0;
}
.week-head h3 { margin: 0; font-size: 16px; }
.week-head .goal { font-size: 12.5px; color: var(--text-muted); display: block; font-weight: 400; }
.week-body { padding: 6px 20px 16px; }

.day-row { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.day-row:last-child { border-bottom: none; }
.day-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  width: 74px;
  padding-top: 2px;
}
.day-desc { font-size: 14.5px; }
.day-desc strong { display: block; }
.day-desc span { color: var(--text-muted); font-size: 13.5px; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: flex; }
  .content { padding: 24px 20px 80px; }
  .playground { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2rem; }
  .hero { padding: 44px 18px 34px; }
  .hero-chip { display: none; }
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
  }
  .sidebar-overlay.show { display: block; }
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }
