/* ===== Курс «LangGraph для вайб-кодера» - общая дизайн-система ===== */

:root {
  --bg: #0e1420;
  --surface: #171f2e;
  --surface-2: #1e2839;
  --border: #2a3648;
  --text: #e8edf5;
  --muted: #9aa7ba;
  --accent: #2dd4a7;
  --accent-soft: rgba(45, 212, 167, 0.12);
  --accent-2: #8b9cf9;
  --accent-2-soft: rgba(139, 156, 249, 0.12);
  --warn: #f5b04d;
  --warn-soft: rgba(245, 176, 77, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --code-bg: #121a28;
  --radius: 14px;
  --content-width: 46rem;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fa;
    --surface: #ffffff;
    --surface-2: #eef2f6;
    --border: #dde4ec;
    --text: #1a2332;
    --muted: #5b6a7e;
    --accent: #0d9470;
    --accent-soft: rgba(13, 148, 112, 0.1);
    --accent-2: #5865d6;
    --accent-2-soft: rgba(88, 101, 214, 0.1);
    --warn: #b97a17;
    --warn-soft: rgba(185, 122, 23, 0.1);
    --danger: #d64545;
    --danger-soft: rgba(214, 69, 69, 0.08);
    --code-bg: #f0f3f7;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ===== Шапка ===== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.2rem;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.topbar a { color: var(--muted); text-decoration: none; }
.topbar a:hover { color: var(--accent); }
.topbar .brand { color: var(--text); font-weight: 650; }
.topbar .brand b { color: var(--accent); font-weight: 650; }
.topbar .spacer { flex: 1; }

/* ===== Контент ===== */

main {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 2.5rem 1.3rem 5rem;
}

h1 { font-size: 2rem; line-height: 1.25; letter-spacing: -0.02em; margin: 0.5rem 0 0.8rem; }
h2 { font-size: 1.4rem; letter-spacing: -0.01em; margin: 2.4rem 0 0.7rem; }
h3 { font-size: 1.12rem; margin: 1.8rem 0 0.5rem; }
p, ul, ol { margin: 0.7rem 0; }
li { margin: 0.35rem 0; }
a { color: var(--accent); }
strong { font-weight: 650; }
hr { border: none; border-top: 1px solid var(--border); margin: 2.5rem 0; }

.kicker {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0;
}

.lead { font-size: 1.12rem; color: var(--muted); }

/* ===== Карточки-блоки ===== */

.callout {
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin: 1.4rem 0;
}
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.callout .callout-title {
  display: block;
  font-weight: 650;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin-bottom: 0.4rem;
}
.callout.analogy { border-left-color: var(--accent-2); background: var(--accent-2-soft); }
.callout.analogy .callout-title { color: var(--accent-2); }
.callout.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.callout.warn .callout-title { color: var(--warn); }
.callout.ask { border-left-color: var(--accent); background: var(--accent-soft); }

/* ===== Код ===== */

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.55;
}
code {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}
p code, li code, td code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1em 0.4em;
  font-size: 0.85em;
}
pre .cm { color: var(--muted); }       /* комментарий в коде */
pre .hl { color: var(--accent); }      /* акцент в коде */

details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.8rem 1.2rem;
  margin: 1.4rem 0;
}
details summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--accent);
}
details[open] summary { margin-bottom: 0.6rem; }
details pre { margin: 0.6rem -0.2rem; }

/* ===== Таблицы ===== */

.table-wrap { overflow-x: auto; margin: 1.4rem 0; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
}
th, td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* ===== Схемы (диаграммы графов) ===== */

.diagram {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  margin: 1.4rem 0;
  overflow-x: auto;
}
.diagram svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.diagram figcaption {
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 0.8rem;
}
.dg-node { fill: var(--surface-2); stroke: var(--accent); stroke-width: 1.5; }
.dg-node-alt { fill: var(--surface-2); stroke: var(--accent-2); stroke-width: 1.5; }
.dg-node-dim { fill: var(--surface-2); stroke: var(--border); stroke-width: 1.5; }
.dg-text { fill: var(--text); font-size: 13px; font-weight: 600; }
.dg-label { fill: var(--muted); font-size: 11.5px; }
.dg-edge { stroke: var(--muted); stroke-width: 1.5; fill: none; }
.dg-edge-accent { stroke: var(--accent); stroke-width: 1.8; fill: none; }
.dg-arrow { fill: var(--muted); }
.dg-arrow-accent { fill: var(--accent); }
.dg-state { fill: var(--accent-soft); stroke: var(--accent); stroke-dasharray: 5 4; stroke-width: 1.3; }

/* ===== Квиз ===== */

.quiz {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.4rem;
  margin: 2.5rem 0;
}
.quiz > h2 { margin-top: 0; }
.qz { margin: 1.4rem 0; }
.qz-q { font-weight: 650; margin-bottom: 0.6rem; }
.qz-opts { display: grid; gap: 0.55rem; }
.qz-opt {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.qz-opt:hover:not(:disabled) { border-color: var(--accent); }
.qz-opt:disabled { cursor: default; opacity: 0.85; }
.qz-opt.is-right { border-color: var(--accent); background: var(--accent-soft); opacity: 1; }
.qz-opt.is-wrong { border-color: var(--danger); background: var(--danger-soft); opacity: 1; }
.qz-why {
  display: none;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
  font-size: 0.88rem;
  color: var(--muted);
}
.qz-opt.show-why .qz-why { display: block; }
.qz-result {
  margin-top: 1.2rem;
  padding: 0.9rem 1.1rem;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  font-weight: 650;
}

/* ===== Навигация по урокам ===== */

.lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
}
.lesson-nav a {
  flex: 1;
  max-width: 48%;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.9rem 1.1rem;
  color: var(--text);
  transition: border-color 0.15s;
}
.lesson-nav a:hover { border-color: var(--accent); }
.lesson-nav a.next { text-align: right; margin-left: auto; }
.lesson-nav .dir { display: block; font-size: 0.8rem; color: var(--muted); }

/* ===== Оглавление (index) ===== */

.hero { text-align: center; padding: 2.5rem 0 1.5rem; }
.hero h1 { font-size: 2.5rem; }
.hero .lead { max-width: 34rem; margin: 0.8rem auto; }

.lesson-list { display: grid; gap: 0.8rem; margin: 1.6rem 0; }
.lesson-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  transition: border-color 0.15s, transform 0.15s;
}
.lesson-card:hover { border-color: var(--accent); transform: translateX(4px); }
.lesson-card .num {
  flex-shrink: 0;
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}
.lesson-card.is-done .num { background: var(--accent); color: var(--bg); }
.lesson-card .t { font-weight: 650; }
.lesson-card .d { font-size: 0.88rem; color: var(--muted); margin-top: 0.15rem; }
.lesson-card .badge {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.lesson-card.is-done .badge { color: var(--accent); font-weight: 650; }

.ref-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.8rem; margin: 1.6rem 0; }
.ref-card {
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  transition: border-color 0.15s;
}
.ref-card:hover { border-color: var(--accent-2); }
.ref-card .t { font-weight: 650; display: block; }
.ref-card .d { font-size: 0.88rem; color: var(--muted); margin-top: 0.3rem; display: block; }

/* ===== Прочее ===== */

footer.site {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2rem 1rem 3rem;
  border-top: 1px solid var(--border);
}
footer.site a { color: var(--muted); }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .hero h1 { font-size: 1.9rem; }
  .lesson-card .badge { display: none; }
}

@media print {
  .topbar, .lesson-nav, .quiz, footer.site { display: none; }
  body { background: #fff; color: #111; }
  main { max-width: 100%; padding: 0; }
}
