/* Python Learning — academy */
:root {
  --paper: #f5f7fa;
  --surface: #ffffff;
  --ink: #16202c;
  --muted: #5b6878;
  --line: #dbe2ea;
  --blue: #3776ab;
  --blue-ink: #245a88;
  --blue-soft: #e8f0f8;
  --yellow: #ffd43b;
  --yellow-soft: #fff6cf;
  --green: #2f7d4f;
  --green-soft: #e5f4ea;
  --red: #b83a2e;
  --red-soft: #fbe9e6;
  --code-bg: #f3f6fa;
  --code-ink: #1d2733;
  --k: #8a3ffc; --s: #0f7b5f; --m: #b35c00; --c: #6b7a8a; --nf: #245a88; --nb: #7a4b00;
  --shadow: 0 1px 2px rgb(22 32 44 / .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12171e; --surface: #1a212b; --ink: #e3e8ee; --muted: #9aa7b6; --line: #2c3643;
    --blue: #6ea8dc; --blue-ink: #9cc6ee; --blue-soft: #1e2d3e; --yellow: #ffd43b; --yellow-soft: #3a3418;
    --green: #6cc28f; --green-soft: #1b3326; --red: #ef7f72; --red-soft: #3c2220;
    --code-bg: #141b24; --code-ink: #dfe6ee;
    --k: #c4a1ff; --s: #7fd6b5; --m: #ffb066; --c: #8696a8; --nf: #9cc6ee; --nb: #e8c27a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #12171e; --surface: #1a212b; --ink: #e3e8ee; --muted: #9aa7b6; --line: #2c3643;
  --blue: #6ea8dc; --blue-ink: #9cc6ee; --blue-soft: #1e2d3e; --yellow: #ffd43b; --yellow-soft: #3a3418;
  --green: #6cc28f; --green-soft: #1b3326; --red: #ef7f72; --red-soft: #3c2220;
  --code-bg: #141b24; --code-ink: #dfe6ee;
  --k: #c4a1ff; --s: #7fd6b5; --m: #ffb066; --c: #8696a8; --nf: #9cc6ee; --nb: #e8c27a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16.5px/1.95 "Vazirmatn", Tahoma, sans-serif;
}
a { color: var(--blue-ink); }
a:hover { color: var(--blue); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
code, pre, textarea, .mono { font-family: "JetBrains Mono", Consolas, Menlo, "Vazirmatn", monospace; font-variant-ligatures: none; }
h1, h2, h3 { line-height: 1.45; font-weight: 700; }
p, li { max-width: 72ch; }
.skip { position: absolute; top: 8px; inset-inline-start: 8px; z-index: 20; background: var(--surface); padding: 4px 10px; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }
.skip:focus { clip-path: none; width: auto; height: auto; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--blue) 0 50%, var(--yellow) 50% 100%);
  color: #fff; font: 700 12px/1 "JetBrains Mono", monospace; direction: ltr;
}
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; line-height: 1.2; }
.top nav { display: flex; gap: 18px; margin-inline-start: auto; font-size: 14.5px; align-items: center; }
.top nav a { text-decoration: none; color: var(--muted); }
.top nav a:hover, .top nav a[aria-current] { color: var(--ink); }
.top select { font: inherit; font-size: 13px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; }

/* home hero */
.hero { max-width: 1080px; margin: 0 auto; padding: 48px 20px 24px; display: grid; grid-template-columns: 1.3fr 1fr; gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(30px, 4.4vw, 46px); margin: 0 0 12px; letter-spacing: -.01em; }
.hero h1 .code-word { color: var(--blue-ink); background: linear-gradient(transparent 62%, var(--yellow) 62% 92%, transparent 92%); padding: 0 .1em; }
.hero p { color: var(--muted); font-size: 18px; margin: 0 0 22px; }
.progress-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; box-shadow: var(--shadow); }
.progress-card h2 { font-size: 16px; margin: 0 0 12px; }
.bar { height: 12px; border-radius: 99px; background: var(--blue-soft); overflow: hidden; }
.bar i { display: block; height: 100%; width: var(--p, 0%); background: linear-gradient(90deg, var(--blue), var(--yellow)); border-radius: 99px; transition: width .6s; }
#progress-label { display: block; margin: 8px 0 16px; color: var(--muted); font-size: 14px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; cursor: pointer;
  background: var(--blue); color: #fff; border: 0; border-radius: 9px; padding: 9px 18px; font: inherit; font-weight: 700; font-size: 15px;
}
.btn:hover { background: var(--blue-ink); color: #fff; }
.btn.ghost { background: transparent; color: var(--blue-ink); border: 1px solid var(--line); font-weight: 500; }
.btn.ghost:hover { background: var(--blue-soft); }
.btn:disabled { opacity: .6; cursor: progress; }
.linkish { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline; padding: 0; margin-top: 12px; }

/* the learning path (home) */
.path-wrap { max-width: 1080px; margin: 0 auto; padding: 8px 20px 60px; }
.phases { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.phase { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 18px 8px; }
.phase h2 { font-size: 16px; margin: 0 0 2px; }
.phase > p { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; line-height: 1.7; }
.path { list-style: none; margin: 0; padding: 0; }
.path li { position: relative; padding-inline-start: 42px; padding-bottom: 14px; }
.path li::before { /* connecting track */
  content: ""; position: absolute; inset-inline-start: 14px; top: 30px; bottom: -2px; width: 2px; background: var(--line);
}
.path li:last-child::before { display: none; }
.stop { display: block; text-decoration: none; color: var(--ink); line-height: 1.6; }
.stop .dot {
  position: absolute; inset-inline-start: 0; top: 0; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: var(--surface); border: 2px solid var(--blue); color: var(--blue-ink);
}
.stop:hover .t { color: var(--blue); }
.stop .t { font-weight: 500; display: block; padding-top: 2px; }
.stop .m { font-size: 12.5px; color: var(--muted); }
.stop.is-done .dot { background: var(--yellow); border-color: var(--yellow); color: #3b2f00; }
.stop.is-done .dot b { display: none; }
.stop.is-done .dot::after { content: "✓"; }
.exam-card { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; justify-content: space-between;
  background: var(--yellow-soft); border: 1px solid var(--yellow); border-radius: 14px; padding: 16px 20px; }
.exam-card p { margin: 0; }

/* lesson layout */
.layout { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: 270px minmax(0, 1fr); grid-template-areas: "rail main"; gap: 36px; padding: 24px 20px 60px; }
.layout > main { grid-area: main; }
.layout > .rail { grid-area: rail; }
.rail { position: sticky; top: 70px; align-self: start; max-height: calc(100vh - 86px); overflow: auto; font-size: 14px; }
.rail h2 { font-size: 13px; color: var(--muted); font-weight: 500; margin: 14px 0 6px; }
.rail h2:first-child { margin-top: 0; }
.rail .path li { padding-inline-start: 34px; padding-bottom: 6px; }
.rail .path li::before { inset-inline-start: 11px; top: 24px; }
.rail .stop .dot { width: 24px; height: 24px; font-size: 11px; border-width: 1.5px; }
.rail .stop .t { font-weight: 400; padding-top: 0; font-size: 14px; }
.rail .stop[aria-current] .t { font-weight: 700; color: var(--blue-ink); }
.rail .stop[aria-current] .dot { background: var(--blue); color: #fff; }
.rail .stop.is-done[aria-current] .dot { background: var(--yellow); color: #3b2f00; }

main.lesson { min-width: 0; }
.lesson-head { margin-bottom: 8px; }
.kicker { color: var(--blue-ink); font-weight: 700; font-size: 14px; }
.lesson-head h1 { font-size: clamp(26px, 3.4vw, 36px); margin: 2px 0 6px; }
.meta { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.goal { background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--blue); border-radius: 10px; padding: 12px 16px; margin: 18px 0 8px; }
.goal strong { display: block; font-size: 14px; color: var(--blue-ink); }
.goal ul { margin: 4px 0 0; padding-inline-start: 20px; }
main.lesson h2 { font-size: 23px; margin: 40px 0 8px; padding-top: 6px; }
main.lesson h3 { font-size: 18px; margin: 26px 0 6px; }
main.lesson ul, main.lesson ol { padding-inline-start: 22px; }
code.i { background: var(--code-bg); border: 1px solid var(--line); padding: 0 5px; border-radius: 5px; font-size: .85em; direction: ltr; unicode-bidi: isolate; white-space: pre-wrap; overflow-wrap: anywhere; }
.qq legend { max-width: 100%; }
kbd { font-family: "JetBrains Mono", monospace; font-size: .8em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--surface); direction: ltr; unicode-bidi: isolate; }

/* static code */
.codebox { position: relative; margin: 12px 0 16px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; }
.codebox pre { margin: 0; padding: 14px 16px; overflow-x: auto; direction: ltr; text-align: left; font-size: 14px; line-height: 1.7; color: var(--code-ink); }
.codebox .copy-code { font: 12px "Vazirmatn", sans-serif; background: var(--surface); border: 1px solid var(--line); color: var(--muted); border-radius: 6px; padding: 0 8px; cursor: pointer; }
.codebox .cap { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); padding: 5px 12px; border-bottom: 1px solid var(--line); }
.hl .k, .hl .kn, .hl .kc, .hl .ow { color: var(--k); font-weight: 600; }
.hl .s, .hl .s1, .hl .s2, .hl .sa, .hl .se, .hl .sd { color: var(--s); }
.hl .si { color: var(--m); }
.hl .mi, .hl .mf { color: var(--m); }
.hl .c, .hl .c1, .hl .ch { color: var(--c); font-style: italic; }
.hl .nf, .hl .fm { color: var(--nf); }
.hl .nc, .hl .nn { color: var(--nf); font-weight: 600; }
.hl .nb, .hl .bp { color: var(--nb); }
.hl [class^="s"] { unicode-bidi: isolate; }

/* callouts */
.call { border-radius: 10px; padding: 10px 16px; margin: 16px 0; border: 1px solid; }
.call p { margin: 4px 0; }
.call .ct { font-weight: 700; font-size: 14px; display: block; }
.call.tip { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.call.tip .ct { color: var(--green); }
.call.warn { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.call.warn .ct { color: var(--red); }
.call.project { background: var(--yellow-soft); border-color: var(--yellow); }
.call.project .ct { color: color-mix(in srgb, var(--ink) 80%, var(--yellow)); }

/* runner */
.runner, .parsons, .blanks { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin: 18px 0; overflow: hidden; box-shadow: var(--shadow); }
.ex-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.ex-head .badge { font-size: 12px; font-weight: 700; color: var(--blue-ink); background: var(--blue-soft); border-radius: 99px; padding: 0 10px; white-space: nowrap; }
.ex-head h3 { margin: 0; font-size: 16px; }
.passed .ex-head .badge { background: var(--yellow); color: #3b2f00; }
.passed .ex-head .badge::before { content: "✓ "; }
.ex-body { padding: 4px 16px 14px; }
.ex-body > p { margin: 8px 0; }
.runner textarea {
  width: 100%; min-height: 90px; resize: vertical; display: block; margin: 8px 0 0;
  direction: ltr; text-align: left; font-size: 14px; line-height: 1.7; tab-size: 4;
  background: var(--code-bg); color: var(--code-ink); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.runner textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.ex-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.ex-actions .keys { color: var(--muted); font-size: 12.5px; margin-inline-start: auto; }
.out { margin: 10px 0 0; padding: 10px 12px; border-radius: 8px; white-space: pre-wrap; direction: ltr; text-align: left; font: 13.5px/1.7 "JetBrains Mono", monospace; background: var(--code-bg); border: 1px solid var(--line); max-height: 320px; overflow: auto; }
.out.pass { background: var(--green-soft); border-color: var(--green); }
.out.fail, .out.error { background: var(--red-soft); border-color: var(--red); }
.out.loading { color: var(--muted); direction: rtl; text-align: right; font-family: "Vazirmatn", sans-serif; }
details.sol { margin-top: 10px; }
details.sol summary { cursor: pointer; color: var(--muted); font-size: 14px; }

/* parsons */
.parsons ol { list-style: none; margin: 10px 0; padding: 0; counter-reset: p; }
.parsons li {
  display: flex; align-items: center; gap: 8px; margin: 4px 0; padding: 4px 8px; counter-increment: p;
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; cursor: grab;
}
.parsons li code { flex: 1; direction: ltr; text-align: left; white-space: pre; font-size: 13.5px; overflow-x: auto; }
.parsons li::before { content: counter(p); color: var(--muted); font-size: 12px; min-width: 1.5em; }
.parsons li button { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; color: var(--muted); cursor: pointer; width: 28px; height: 26px; }
.parsons.wrong ol { outline: 2px solid var(--red); outline-offset: 4px; border-radius: 8px; }
.p-result, .b-result { margin: 8px 0 0; font-weight: 500; }

/* blanks */
.blanks pre { direction: ltr; text-align: left; background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 8px 0; font-size: 14px; line-height: 2.2; overflow-x: auto; }
.blanks input { font: inherit; font-size: 13.5px; border: 0; border-bottom: 2px solid var(--blue); background: var(--surface); color: var(--ink); padding: 0 4px; border-radius: 4px 4px 0 0; }
.blanks input.right { border-color: var(--green); background: var(--green-soft); }
.blanks input.wrong { border-color: var(--red); background: var(--red-soft); }

/* quiz */
.quiz { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 6px 20px 18px; margin: 30px 0; box-shadow: var(--shadow); }
.quiz > h2 { margin-top: 18px !important; }
.qq { border-top: 1px solid var(--line); padding: 12px 0 6px; }
.qq:first-of-type { border-top: 0; }
.qq .q { font-weight: 500; margin: 0 0 6px; }
.qq label { display: flex; gap: 10px; align-items: baseline; padding: 4px 10px; border-radius: 8px; cursor: pointer; }
.qq label:hover { background: var(--blue-soft); }
.qq.right { box-shadow: inset 4px 0 0 var(--green); }
.qq.wrong { box-shadow: inset 4px 0 0 var(--red); }
[dir="rtl"] .qq.right { box-shadow: inset -4px 0 0 var(--green); padding-inline-start: 10px; }
[dir="rtl"] .qq.wrong { box-shadow: inset -4px 0 0 var(--red); padding-inline-start: 10px; }
.qq .why { font-size: 14.5px; color: var(--muted); margin: 6px 10px 4px; }
.quiz-result { margin: 12px 0 0; padding: 10px 14px; border-radius: 10px; font-weight: 500; }
.quiz-result.pass { background: var(--green-soft); }
.quiz-result.fail, .quiz-result.warn { background: var(--red-soft); }

/* checklist */
.checklist { list-style: none; padding: 0 !important; }
.checklist li { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; }
.checklist input { width: 18px; height: 18px; accent-color: var(--blue); flex: none; transform: translateY(3px); }

/* pager */
.pager { display: flex; justify-content: space-between; gap: 14px; margin-top: 44px; padding-top: 18px; border-top: 1px solid var(--line); }
.pager a { text-decoration: none; display: flex; flex-direction: column; max-width: 48%; }
.pager small { color: var(--muted); }
.pager .next { text-align: end; margin-inline-start: auto; }
table.t { border-collapse: collapse; margin: 12px 0; font-size: 15px; display: block; overflow-x: auto; }
table.t th, table.t td { border: 1px solid var(--line); padding: 6px 12px; text-align: start; vertical-align: top; }
table.t th { background: var(--blue-soft); font-weight: 500; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 20px 16px 30px; }
[hidden] { display: none !important; }

@media (max-width: 980px) {
  .phases { grid-template-columns: repeat(2, 1fr); }
  .hero { grid-template-columns: 1fr; padding-top: 28px; gap: 20px; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; grid-template-areas: "main" "rail"; gap: 0; padding-top: 12px; }
  .rail { position: static; max-height: none; order: 2; border-top: 1px solid var(--line); padding-top: 18px; margin-top: 30px; }
  .top nav .hide-sm { display: none; }
}
@media (max-width: 560px) {
  .phases { grid-template-columns: 1fr; }
  body { font-size: 16px; }
  .top { padding: 8px 14px; gap: 10px; }
  .top nav { gap: 12px; }
  .ex-actions .keys { display: none; }
}
@media (prefers-reduced-motion: reduce) { .bar i { transition: none; } }
