/* Python od zera — Thonny course */
:root {
  --bg: #f3efe6;
  --bg-2: #eae4d6;
  --surface: #fffcf6;
  --surface-2: #f7f3ea;
  --text: #1c1915;
  --muted: #5c564c;
  --faint: #8a8376;
  --line: #e0d8c8;
  --accent: #0f766e;
  --accent-2: #0b5c56;
  --accent-soft: #d8efe9;
  --warm: #c2410c;
  --warm-soft: #fde8d8;
  --indigo: #4338ca;
  --indigo-soft: #e7e5ff;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --code-bg: #1b1916;
  --code-text: #f3efe6;
  --code-muted: #b8b0a2;
  --code-kw: #7dd3c0;
  --code-str: #f2c078;
  --code-num: #f0a0a0;
  --code-com: #8f887a;
  --code-fn: #c4b5fd;
  --shadow: 0 1px 2px rgba(28, 25, 21, 0.05), 0 10px 28px rgba(28, 25, 21, 0.06);
  --radius: 16px;
  --sidebar-w: 280px;
  --topbar-h: 64px;
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #121110;
  --bg-2: #1a1816;
  --surface: #1c1a17;
  --surface-2: #24211d;
  --text: #f4f0e6;
  --muted: #b4ada0;
  --faint: #8a8378;
  --line: #2e2b26;
  --accent: #2dd4bf;
  --accent-2: #99f6e4;
  --accent-soft: #13332f;
  --warm: #fb923c;
  --warm-soft: #3a2414;
  --indigo: #a5b4fc;
  --indigo-soft: #222048;
  --ok: #4ade80;
  --ok-soft: #14532d;
  --bad: #f87171;
  --bad-soft: #3f1d1d;
  --code-bg: #0c0b0a;
  --code-text: #f3efe6;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 10% -10%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 50%),
    var(--bg);
}

[data-theme="dark"] body {
  background:
    radial-gradient(1000px 480px at 8% -8%, rgba(45, 212, 191, 0.08), transparent 50%),
    var(--bg);
}

img { max-width: 100%; }

button, input { font: inherit; }

a { color: var(--accent-2); }

.skip-link {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 80;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
}
.skip-link:focus { top: 12px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px 0 12px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.brand img { border-radius: 8px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05rem;
}
.brand-text span {
  font-size: 0.75rem;
  color: var(--muted);
}

.topbar-progress {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.progress-track {
  width: 140px;
  height: 8px;
  border-radius: 99px;
  background: var(--bg-2);
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 50%, var(--warm)));
  border-radius: inherit;
  transition: width 0.35s ease;
}
.progress-label {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: none;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.menu-icon, .menu-icon::before, .menu-icon::after {
  display: block;
  width: 16px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  position: relative;
}
.menu-icon::before, .menu-icon::after {
  content: "";
  position: absolute;
  left: 0;
}
.menu-icon::before { top: -5px; }
.menu-icon::after { top: 5px; }

.theme-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: inset -4px -2px 0 1px currentColor;
  background: transparent;
}
[data-theme="dark"] .theme-icon {
  box-shadow: none;
  background: currentColor;
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.menu-btn { display: none; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow: auto;
  padding: 20px 14px 32px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}
.sidebar-kicker {
  margin: 0 10px 10px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
}

#nav-list { display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
  font-size: 0.92rem;
  line-height: 1.3;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 600;
}
.nav-num {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--bg-2);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}
.nav-link.active .nav-num { background: var(--accent); color: #fff; }
[data-theme="dark"] .nav-link.active .nav-num { color: #121110; }
.nav-link.done .nav-num {
  background: var(--ok-soft);
  color: var(--ok);
}
.nav-check { color: var(--ok); font-size: 0.85rem; }

.reset-progress {
  margin: 22px 10px 0;
  background: none;
  border: 0;
  color: var(--faint);
  cursor: pointer;
  padding: 0;
  font-size: 0.82rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.reset-progress:hover { color: var(--bad); }

.main {
  padding: 32px 28px 80px;
  max-width: 880px;
  outline: none;
}

.lesson-head { margin-bottom: 28px; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-2);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  margin: 0 0 8px;
}
.lesson h1 {
  font-family: var(--display);
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1.15;
  font-weight: 600;
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}
.summary {
  margin: 0;
  color: var(--muted);
  font-size: 1.12rem;
}

.lesson h2 {
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 600;
  margin: 2.1rem 0 0.7rem;
  letter-spacing: -0.02em;
}

.lesson p { margin: 0 0 1rem; }
.lesson ul, .lesson ol { margin: 0 0 1.1rem; padding-left: 1.3rem; }
.lesson li { margin: 0.3rem 0; }
.lesson li::marker { color: var(--accent); }

.lesson a { text-underline-offset: 3px; }

code, kbd {
  font-family: var(--mono);
  font-size: 0.88em;
}
p code, li code, .callout code, .exercise code {
  background: var(--accent-soft);
  color: var(--accent-2);
  padding: 0.1em 0.35em;
  border-radius: 5px;
}
kbd {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0.05em 0.4em;
  border-radius: 5px;
  box-shadow: 0 1px 0 var(--line);
  font-size: 0.82em;
}

.code-block {
  margin: 0 0 1.25rem;
  border-radius: 14px;
  overflow: hidden;
  background: var(--code-bg);
  color: var(--code-text);
  box-shadow: var(--shadow);
  border: 1px solid color-mix(in srgb, var(--code-bg) 80%, #fff 12%);
}
.code-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  background: color-mix(in srgb, #fff 7%, transparent);
  border-bottom: 1px solid color-mix(in srgb, #fff 8%, transparent);
  color: var(--code-muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}
.code-dots { display: flex; gap: 5px; margin-right: 4px; }
.code-dots i {
  width: 9px; height: 9px; border-radius: 50%; display: block;
  background: #3f3a34;
}
.code-dots i:nth-child(1) { background: #e08a6a; }
.code-dots i:nth-child(2) { background: #d2b16a; }
.code-dots i:nth-child(3) { background: #6aa884; }
.code-bar .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.copy-btn {
  border: 0;
  background: color-mix(in srgb, #fff 10%, transparent);
  color: var(--code-text);
  border-radius: 8px;
  padding: 5px 9px;
  cursor: pointer;
  font-size: 0.75rem;
  font-family: var(--font);
}
.copy-btn:hover { background: color-mix(in srgb, #fff 18%, transparent); }
.copy-btn.copied { color: #86efac; }

.code-block pre {
  margin: 0;
  padding: 16px 18px 18px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.6;
}
.code-block code { font-family: inherit; color: inherit; }

.tok-kw { color: var(--code-kw); font-weight: 500; }
.tok-str { color: var(--code-str); }
.tok-num { color: var(--code-num); }
.tok-com { color: var(--code-com); font-style: italic; }
.tok-fn { color: var(--code-fn); }

.callout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  margin: 0 0 1.25rem;
  border: 1px solid var(--line);
  background: var(--surface);
}
.callout .icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 0.95rem;
  flex: none;
}
.callout p { margin: 0; }
.callout.thonny { background: var(--indigo-soft); border-color: color-mix(in srgb, var(--indigo) 28%, var(--line)); }
.callout.thonny .icon { background: var(--indigo); color: #fff; }
.callout.note { background: var(--warm-soft); border-color: color-mix(in srgb, var(--warm) 30%, var(--line)); }
.callout.note .icon { background: var(--warm); color: #fff; }

.mockup {
  margin: 0 0 1.6rem;
  border-radius: 16px;
  overflow: hidden;
  background: var(--code-bg);
  box-shadow: var(--shadow);
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 0.78rem;
  border: 1px solid color-mix(in srgb, #fff 8%, transparent);
}
.mock-top {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  background: #26221e;
  color: #c9c1b4;
}
.mock-top .code-dots { margin-right: 6px; }
.mock-toolbar {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px;
  background: #211e1b;
  border-top: 1px solid #322e29;
  color: #d7cfc3;
}
.mock-chip {
  background: #33302b;
  border-radius: 6px;
  padding: 2px 8px;
}
.mock-chip.go { background: #0f766e; color: #fff; }
.mock-panes { display: grid; grid-template-rows: 1fr auto; }
.mock-editor, .mock-shell { padding: 12px 14px; }
.mock-shell {
  background: #141210;
  border-top: 1px solid #322e29;
  color: #d7cfc3;
}
.mock-label {
  color: #8f887a;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.mock-cursor { display: inline-block; width: 7px; height: 1em; background: #2dd4bf; vertical-align: text-bottom; }

.exercises, .quiz {
  margin: 1.6rem 0;
  padding: 8px 0 0;
}
.section-label {
  font-family: var(--display);
  font-size: 1.45rem;
  margin: 0 0 12px;
}

.exercise {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 0 0 12px;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--text) 4%, transparent);
}
.exercise h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}
.ex-task { margin: 0 0 12px; }
.ex-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ghost-btn, .primary-btn, .choice, .check-btn {
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid var(--line);
}
.ghost-btn, .check-btn {
  background: var(--surface-2);
  color: var(--text);
  padding: 7px 12px;
  font-size: 0.9rem;
}
.ghost-btn:hover, .check-btn:hover { border-color: var(--accent); }
.primary-btn {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  padding: 11px 16px;
  font-weight: 600;
}
[data-theme="dark"] .primary-btn { color: #121110; }
.primary-btn:hover { filter: brightness(1.05); }
.primary-btn.done {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 30%, var(--line));
}

.reveal {
  display: none;
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px dashed var(--line);
}
.reveal.open { display: block; }
.reveal h4 {
  margin: 0 0 6px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.quiz-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 0 0 12px;
}
.quiz-q { margin: 0 0 12px; font-weight: 600; }
.choices { display: grid; gap: 8px; }
.choice {
  text-align: left;
  padding: 9px 12px;
  background: var(--surface-2);
  color: inherit;
}
.choice:hover { border-color: var(--accent); }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice.correct { border-color: var(--ok); background: var(--ok-soft); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice:disabled { cursor: default; }
.quiz-feedback {
  margin: 10px 0 0;
  font-size: 0.95rem;
  display: none;
}
.quiz-feedback.show { display: block; }

.lesson-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-top: 32px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.pager {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.pager a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  font-size: 0.92rem;
}
.pager a:hover { border-color: var(--accent); }
.pager a[aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
}

.backdrop {
  display: none;
}

.noscript {
  margin: 20px;
  padding: 16px;
  background: var(--warm-soft);
  border-radius: 12px;
}

@media (max-width: 840px) {
  .menu-btn { display: grid; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    z-index: 50;
    top: 0;
    left: 0;
    height: 100vh;
    width: min(86vw, 320px);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  .backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(18, 17, 16, 0.45);
    z-index: 45;
  }
  .backdrop[hidden] { display: none; }
  .main { padding: 22px 16px 72px; }
  .topbar-progress { gap: 6px; }
  .progress-track { width: 72px; }
  .brand-text span { display: none; }
  .progress-label { font-size: 0.72rem; }
}

@media (max-width: 480px) {
  .progress-label { display: none; }
  .lesson-footer { flex-direction: column; align-items: stretch; }
  .pager { flex-direction: column; }
  .pager a, .primary-btn { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .progress-fill, .sidebar { transition: none; }
}
