@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;1,300&family=DM+Mono:wght@400;500&display=swap');

:root {
  --bg: #f7f5f0;
  --bg2: #eeeae2;
  --ink: #111010;
  --red: #e8321a;
  --gold: #b8922a;
  --blue: #1a55c8;
  --green: #1a7a4a;
  --muted: #666;
  --border: rgba(0,0,0,0.1);
  --card: #ffffff;
  --sidebar-w: 280px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  font-weight: 300;
  font-size: 1.05rem;
  line-height: 1.85;
}

/* ── PROGRESS BAR ── */
.progress-bar {
  position: fixed; top: 0; left: 0;
  height: 3px; background: var(--red);
  z-index: 200; transition: width 0.1s linear; width: 0%;
}

/* ── TOP BAR ── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--ink); color: var(--bg);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 2rem; height: 52px; gap: 1rem;
}
.topbar-left { display: flex; align-items: center; gap: 1.5rem; }
.topbar-back {
  font-family: 'DM Mono', monospace; font-size: 0.65rem;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: rgba(247,245,240,0.5); text-decoration: none;
  display: flex; align-items: center; gap: 0.4rem;
  transition: color 0.15s;
}
.topbar-back::before { content: '←'; }
.topbar-back:hover { color: var(--bg); }
.topbar-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.3rem; letter-spacing: 0.08em;
}
.topbar-title span { color: var(--red); }
.topbar-chapter {
  font-family: 'DM Mono', monospace; font-size: 0.62rem;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: rgba(247,245,240,0.4);
}

/* ── LAYOUT ── */
.layout { display: flex; min-height: calc(100vh - 52px); }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--ink); color: var(--bg);
  position: sticky; top: 52px;
  height: calc(100vh - 52px);
  overflow-y: auto; padding: 1.5rem 0;
  scrollbar-width: thin; scrollbar-color: #333 transparent;
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: #333; }

.sidebar-section-label {
  font-family: 'DM Mono', monospace; font-size: 0.55rem;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: rgba(247,245,240,0.3); padding: 1.2rem 1.5rem 0.4rem;
}
.sidebar-link {
  display: flex; align-items: center;
  gap: 0.7rem; padding: 0.5rem 1.5rem;
  font-size: 0.82rem; color: rgba(247,245,240,0.55);
  text-decoration: none; transition: color 0.15s, background 0.15s;
  border-left: 2px solid transparent; cursor: pointer;
}
.sidebar-link:hover, .sidebar-link.active {
  color: var(--bg); background: rgba(255,255,255,0.05);
  border-left-color: var(--red);
}
.sidebar-link .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; opacity: 0.4; flex-shrink: 0;
}

/* Chapter nav in sidebar */
.sidebar-chapter-nav { padding: 1rem 1.5rem; border-top: 1px solid rgba(255,255,255,0.07); margin-top: 1rem; }
.sidebar-chapter-nav-label {
  font-family: 'DM Mono', monospace; font-size: 0.55rem;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: rgba(247,245,240,0.3); margin-bottom: 0.6rem;
}
.sidebar-chapter-nav a {
  display: block; font-size: 0.78rem;
  color: rgba(247,245,240,0.4); text-decoration: none;
  padding: 0.2rem 0; transition: color 0.15s;
}
.sidebar-chapter-nav a:hover { color: var(--bg); }

/* ── MAIN ── */
.main { flex: 1; padding: 3rem 3.5rem 6rem; max-width: 880px; }

/* ── CHAPTER HEADER ── */
.chapter-header { margin-bottom: 3rem; scroll-margin-top: 70px; }
.chapter-num {
  font-family: 'DM Mono', monospace; font-size: 0.62rem;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--red); margin-bottom: 0.5rem;
}
.chapter-badge {
  display: inline-block; font-family: 'DM Mono', monospace;
  font-size: 0.55rem; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 0.2rem 0.5rem; border-radius: 2px; margin-left: 0.5rem;
  vertical-align: middle; position: relative; top: -2px;
}
.badge-basic { background: #e0f5ea; color: var(--green); }
.badge-mid { background: #e0ecff; color: var(--blue); }
.badge-advanced { background: #fef6e0; color: var(--gold); }
.badge-senior { background: #fde8e4; color: var(--red); }

.chapter-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2.2rem, 4vw, 3.2rem);
  letter-spacing: 0.04em; line-height: 1;
  margin-bottom: 0.6rem;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.8rem;
}
.chapter-desc {
  color: var(--muted); font-size: 0.95rem;
  margin-bottom: 0; max-width: 600px; margin-top: 0.8rem;
}

/* ── SECTION / TOPIC ── */
.section { margin-bottom: 3rem; scroll-margin-top: 70px; }

.section-title {
  font-weight: 600; font-size: 1.1rem;
  color: var(--ink); margin-bottom: 0.3rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.7rem;
}
.section-title .icon { font-size: 1.2rem; }
.section-tag {
  font-family: 'DM Mono', monospace; font-size: 0.5rem;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0.15rem 0.4rem; border-radius: 2px;
  margin-left: auto;
}
.tag-required { background: #fde8e4; color: var(--red); }
.tag-senior { background: #fde8e4; color: var(--red); }
.tag-tip { background: #e0f5ea; color: var(--green); }

.section p {
  color: #333; margin-bottom: 0.9rem; font-size: 0.98rem;
}
.section strong { color: var(--ink); font-weight: 500; }

/* ── LISTS ── */
.def-list { list-style: none; margin: 0.5rem 0 1rem; }
.def-list li {
  padding: 0.7rem 0; border-bottom: 1px solid var(--border);
  font-size: 0.93rem; display: grid;
  grid-template-columns: 190px 1fr; gap: 1rem;
}
.def-list li:last-child { border-bottom: none; }
.def-term {
  font-family: 'DM Mono', monospace; font-size: 0.78rem;
  color: var(--ink); font-weight: 500; padding-top: 0.05rem;
}
.def-body { color: #444; }

.bullet-list { list-style: none; margin: 0.5rem 0 1rem; }
.bullet-list li {
  padding: 0.4rem 0 0.4rem 1.5rem;
  font-size: 0.93rem; color: #333; position: relative;
}
.bullet-list li::before {
  content: '—'; position: absolute; left: 0;
  color: var(--red); font-size: 0.7rem; top: 0.5rem;
}

.step-list { list-style: none; margin: 0.5rem 0 1rem; counter-reset: step; }
.step-list li {
  padding: 0.7rem 0 0.7rem 2.8rem;
  font-size: 0.93rem; color: #333; position: relative;
  border-bottom: 1px dashed var(--border);
  counter-increment: step;
}
.step-list li:last-child { border-bottom: none; }
.step-list li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute; left: 0;
  font-family: 'DM Mono', monospace; font-size: 0.68rem;
  color: var(--red); top: 0.8rem; font-weight: 500;
}

/* ── CALLOUT BOXES ── */
.callout {
  background: var(--card); border: 1px solid var(--border);
  border-left: 3px solid var(--blue); padding: 1.3rem 1.5rem;
  margin: 1rem 0; border-radius: 2px; font-size: 0.9rem; color: #333;
}
.callout.warning { border-left-color: var(--gold); }
.callout.tip { border-left-color: var(--green); }
.callout.senior { border-left-color: var(--red); background: #fffaf9; }
.callout-label {
  font-family: 'DM Mono', monospace; font-size: 0.6rem;
  letter-spacing: 0.15em; text-transform: uppercase;
  margin-bottom: 0.5rem; font-weight: 500;
}
.callout .callout-label { color: var(--blue); }
.callout.tip .callout-label { color: var(--green); }
.callout.warning .callout-label { color: var(--gold); }
.callout.senior .callout-label { color: var(--red); }

/* ── TABLE ── */
.data-table {
  width: 100%; border-collapse: collapse;
  margin: 1rem 0; font-size: 0.9rem;
}
.data-table th {
  background: var(--ink); color: var(--bg);
  padding: 0.75rem 1rem; text-align: left;
  font-weight: 400; font-family: 'DM Mono', monospace;
  font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase;
}
.data-table td {
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--border);
  color: #333; vertical-align: top;
}
.data-table tr:nth-child(even) td { background: rgba(0,0,0,0.02); }
.data-table tr:last-child td { border-bottom: none; }

/* ── CODE ── */
code {
  font-family: 'DM Mono', monospace; font-size: 0.8em;
  background: var(--bg2); padding: 0.1em 0.45em;
  border-radius: 3px; color: var(--red);
}
.code-block {
  background: #1a1a1a; color: #e8e4dc;
  border-radius: 4px; padding: 1.2rem 1.5rem;
  font-family: 'DM Mono', monospace; font-size: 0.82rem;
  line-height: 1.7; margin: 1rem 0; overflow-x: auto;
}
.code-block .comment { color: #666; }
.code-block .keyword { color: #7ec8e3; }
.code-block .string { color: #9ad98a; }
.code-block .number { color: #f0a28a; }

/* ── EXERCISE BOX ── */
.exercise {
  background: #f0f4ff; border: 1px solid #c5d5f5;
  border-left: 3px solid var(--blue);
  padding: 1.5rem; margin: 2rem 0; border-radius: 4px;
}
.exercise-label {
  font-family: 'DM Mono', monospace; font-size: 0.6rem;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--blue); font-weight: 500; margin-bottom: 0.8rem;
}
.exercise p { font-size: 0.93rem; color: #333; margin-bottom: 0.6rem; }
.exercise ol { padding-left: 1.5rem; }
.exercise ol li { font-size: 0.9rem; color: #333; padding: 0.3rem 0; }

/* ── SENIOR INSIGHT BOX ── */
.senior-box {
  background: #fff8f7; border: 1px solid #f5c6be;
  border-left: 3px solid var(--red);
  padding: 1.5rem; margin: 2rem 0; border-radius: 4px;
}
.senior-label {
  font-family: 'DM Mono', monospace; font-size: 0.6rem;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--red); font-weight: 500; margin-bottom: 0.6rem;
}
.senior-box p { font-size: 0.93rem; color: #333; margin-bottom: 0.5rem; }

/* ── INTERVIEW BOX ── */
.interview-q {
  background: var(--bg2); border-radius: 4px;
  padding: 1.2rem 1.5rem; margin: 0.8rem 0;
}
.interview-q .q {
  font-weight: 500; font-size: 0.95rem; margin-bottom: 0.6rem;
  color: var(--ink);
}
.interview-q .q::before { content: 'Q: '; color: var(--red); font-family: 'DM Mono', monospace; font-size: 0.8em; }
.interview-q .a { font-size: 0.9rem; color: #444; }
.interview-q .a::before { content: 'A: '; color: var(--green); font-family: 'DM Mono', monospace; font-size: 0.8em; font-weight: 500; }

/* ── CHAPTER NAV (bottom prev/next) ── */
.chapter-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 4rem; padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.chapter-nav-btn {
  display: flex; align-items: center; gap: 0.5rem;
  font-family: 'DM Mono', monospace; font-size: 0.68rem;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--red); text-decoration: none;
  padding: 0.6rem 1.2rem; border: 1px solid var(--border);
  border-radius: 2px; background: var(--card);
  transition: border-color 0.15s, background 0.15s;
}
.chapter-nav-btn:hover { border-color: var(--red); background: #fff8f7; }
.chapter-nav-btn.prev::before { content: '←'; }
.chapter-nav-btn.next::after { content: '→'; }

/* ── DIVIDER ── */
hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { padding: 2rem 1.5rem 4rem; }
}
