/* ═══════════════════════════════════════════════════════
   SHARED COMPONENTS — Learn Django
   Layout, typography, callouts, code blocks, tables,
   pills, steps, flow, compare, quiz
   ═══════════════════════════════════════════════════════ */

/* ══════════════════════════ HEADER ══════════════════════════ */
header {
  border-bottom: 1px solid var(--border);
  padding: 2rem 3rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  background: rgba(13,15,20,0.92);
  backdrop-filter: blur(12px);
  z-index: 100;
}
.logo {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.logo span { color: var(--accent); font-style: italic; }
.header-tag {
  font-size: 0.65rem;
  padding: 2px 8px;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.header-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}
nav {
  margin-left: auto;
  display: flex;
  gap: 0.25rem;
}
nav button {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  letter-spacing: 0.03em;
}
nav button:hover { color: var(--text); border-color: var(--border); }
nav button.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(74,222,128,0.06);
}

/* ══════════════════════════ LAYOUT ══════════════════════════ */
.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 73px);
}

/* ══════════════════════════ SIDEBAR ══════════════════════════ */
aside {
  border-right: 1px solid var(--border);
  padding: 2rem 1.5rem;
  position: sticky;
  top: 73px;
  height: calc(100vh - 73px);
  overflow-y: auto;
}
.sidebar-section {
  margin-bottom: 2rem;
}
.sidebar-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--muted);
  transition: all 0.2s;
  border: 1px solid transparent;
  text-decoration: none;
}
.sidebar-item:hover { color: var(--text); background: var(--surface); }
.sidebar-item.active {
  color: var(--accent);
  background: rgba(74,222,128,0.07);
  border-color: rgba(74,222,128,0.15);
}
.sidebar-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  font-size: 0.75rem;
  text-align: center;
}
.sidebar-item.active .sidebar-dot { background: var(--accent); }
.sidebar-item-sm { font-size: 0.68rem; }

/* ══════════════════════════ MAIN CONTENT ══════════════════════════ */
.layout main {
  padding: 3rem;
  max-width: 860px;
}

/* Sections */
.section { display: none; }
.section.active { display: block; animation: fadeIn 0.3s ease; }

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

/* ══════════════════════════ TYPOGRAPHY ══════════════════════════ */
.layout h1 {
  font-family: 'Fraunces', serif;
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--heading);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
}
.layout h1 em {
  font-style: italic;
  color: var(--accent);
}
.layout h2 {
  font-family: 'Fraunces', serif;
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--heading);
  margin: 2.5rem 0 1rem;
  letter-spacing: -0.02em;
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
}
.layout h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent2);
  margin: 2rem 0 0.75rem;
}
.layout p {
  font-size: 0.82rem;
  color: #94a3b8;
  margin-bottom: 1rem;
  line-height: 1.8;
}
.layout strong { color: var(--text); font-weight: 600; }

/* ── Lead / Hero ── */
.lead {
  font-family: 'Fraunces', serif;
  font-size: 1rem;
  font-weight: 300;
  font-style: italic;
  color: #94a3b8;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

/* ══════════════════════════ CALLOUTS ══════════════════════════ */
.callout {
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  font-size: 0.78rem;
  line-height: 1.7;
  border-left: 3px solid;
}
.callout strong { font-weight: 700; display: block; margin-bottom: 0.25rem; }
.callout-tip    { background: rgba(74,222,128,0.06);  border-color: var(--accent);  color: #86efac; }
.callout-info   { background: rgba(56,189,248,0.06);  border-color: var(--accent2); color: #7dd3fc; }
.callout-warn   { background: rgba(251,146,60,0.06);  border-color: var(--accent4); color: #fdba74; }
.callout-key    { background: rgba(244,114,182,0.06); border-color: var(--accent3); color: #f9a8d4; }
.callout-danger { background: rgba(248,113,113,0.06); border-color: #f87171;        color: #fca5a5; }

/* ══════════════════════════ CODE BLOCKS ══════════════════════════ */
.code-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 1.25rem 0;
  overflow: hidden;
}
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.code-filename {
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.05em;
}
.code-lang {
  font-size: 0.6rem;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.lang-python { background: rgba(56,189,248,0.12); color: var(--accent2); }
.lang-html   { background: rgba(251,146,60,0.12);  color: var(--accent4); }
.lang-bash   { background: rgba(74,222,128,0.12);  color: var(--accent); }
.lang-url    { background: rgba(244,114,182,0.12); color: var(--accent3); }
.lang-js     { background: rgba(251,191,36,0.12);  color: #fbbf24; }
.lang-txt    { background: rgba(167,139,250,0.12); color: #a78bfa; }

pre {
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  font-size: 0.76rem;
  line-height: 1.8;
  white-space: pre;
  color: #e2e8f0;
}
code {
  font-family: 'JetBrains Mono', monospace;
}

/* ── Syntax highlighting ── */
.kw  { color: #c084fc; }           /* keyword */
.fn  { color: #38bdf8; }           /* function */
.cl  { color: #4ade80; }           /* class */
.st  { color: #f9a8d4; }           /* string */
.cm  { color: #475569; font-style: italic; } /* comment */
.nu  { color: #fb923c; }           /* number */
.dt  { color: #fdba74; }           /* data type */
.op  { color: #94a3b8; }           /* operator */
.dc  { color: #fbbf24; }           /* decorator */
.ht  { color: #fb923c; }           /* html tag */
.ha  { color: #4ade80; }           /* html attr */
.hv  { color: #f9a8d4; }           /* html value */

/* ── Inline code ── */
code.ic {
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.8em;
  color: var(--accent2);
}

/* ══════════════════════════ TABLES ══════════════════════════ */
.crud-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.75rem;
}
.crud-table th {
  text-align: left;
  padding: 0.6rem 1rem;
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border-bottom: 1px solid var(--border);
}
.crud-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid rgba(37,42,56,0.5);
  vertical-align: top;
}
.crud-table tr:last-child td { border-bottom: none; }
.crud-table tr:hover td { background: rgba(255,255,255,0.02); }

/* ══════════════════════════ PILLS ══════════════════════════ */
.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.pill-green  { background: rgba(74,222,128,0.12);  color: var(--accent); }
.pill-blue   { background: rgba(56,189,248,0.12);  color: var(--accent2); }
.pill-pink   { background: rgba(244,114,182,0.12); color: var(--accent3); }
.pill-orange { background: rgba(251,146,60,0.12);  color: var(--accent4); }
.pill-red    { background: rgba(248,113,113,0.12); color: #f87171; }
.pill-teal   { background: rgba(13,110,110,0.12);  color: #5eead4; }

/* ══════════════════════════ FLOW DIAGRAM ══════════════════════════ */
.flow {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 1.5rem 0;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}
.flow-step {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 1rem;
  font-size: 0.7rem;
  text-align: center;
  flex-shrink: 0;
  min-width: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.flow-step span {
  display: block;
  font-size: 0.58rem;
  color: var(--muted);
  margin-top: 2px;
}
.flow-icon  { font-size: 1.1rem; }
.flow-title { font-weight: 600; color: var(--heading); font-size: 0.73rem; }
.flow-sub   { color: var(--muted); font-size: 0.64rem; font-family: 'JetBrains Mono', monospace; }
.flow-arrow {
  color: var(--muted);
  padding: 0 0.5rem;
  font-size: 0.8rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.flow-arrow-label { font-size: 0.58rem; color: var(--muted); font-family: 'JetBrains Mono', monospace; white-space: nowrap; }
.flow-arrow-col { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 0 8px; }

/* ══════════════════════════ COMPARE / TOGGLE ══════════════════════════ */
.compare-toggle {
  display: flex;
  gap: 0.5rem;
  margin: 1.5rem 0 0.5rem;
}
.compare-btn {
  padding: 0.4rem 1rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.2s;
}
.compare-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(74,222,128,0.07); }
.compare-content { display: none; }
.compare-content.active { display: block; }

/* ══════════════════════════ STEPS ══════════════════════════ */
.steps { counter-reset: step; margin: 1rem 0; }
.step {
  counter-increment: step;
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: flex-start;
}
.step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.step-body  { flex: 1; }
.step-title { font-size: 0.8rem; font-weight: 700; color: var(--text); margin-bottom: 0.3rem; }
.step-desc  { font-size: 0.75rem; color: var(--muted); }

/* ══════════════════════════ QUIZ ══════════════════════════ */
.quiz-q {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin: 1rem 0;
}
.quiz-text { font-size: 0.82rem; color: var(--text); margin-bottom: 0.75rem; }
.quiz-options { display: flex; flex-direction: column; gap: 0.4rem; }
.quiz-opt {
  padding: 0.5rem 0.9rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'JetBrains Mono', monospace;
  background: none;
  color: var(--muted);
  text-align: left;
}
.quiz-opt:hover { border-color: var(--accent2); color: var(--text); }
.quiz-opt.correct { border-color: var(--accent); color: var(--accent); background: rgba(74,222,128,0.07); }
.quiz-opt.wrong   { border-color: #f87171; color: #f87171; background: rgba(248,113,113,0.07); }
.quiz-feedback { font-size: 0.72rem; margin-top: 0.6rem; display: none; padding: 0.5rem; border-radius: 4px; }
.quiz-feedback.show { display: block; }
.quiz-feedback.ok  { background: rgba(74,222,128,0.08);  color: #86efac; }
.quiz-feedback.bad { background: rgba(248,113,113,0.08); color: #fca5a5; }

/* ══════════════════════════ MOBILE MENU TOGGLE ══════════════════════════ */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  padding: 6px;
  flex-shrink: 0;
}
.menu-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: all 0.3s;
}
.menu-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.menu-toggle.active span:nth-child(2) { opacity: 0; }
.menu-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 49;
}
.sidebar-overlay.active { display: block; }
