/* Python Learning — ظاهری نزدیک به مستندات رسمی پایتون (Sphinx / python-docs-theme) */
/* فونت فارسی روی خود سایت است (بدون Google Fonts) — Vazirmatn, SIL Open Font License, fonts/OFL.txt */
@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
:root {
  --bg: #ffffff;
  --text: #222222;
  --heading: #1a1a1a;
  --muted: #5f6368;
  --link: #0072aa;
  --link-visited: #6363bb;
  --link-hover: #00b0e4;
  --bar: #f8f8f8;
  --bar-border: #cccccc;
  --sidebar: #f8f8f8;
  --border: #dddddd;
  --code-bg: #eeffcc;
  --code-border: #aacc99;
  --code-gutter: #e2f2c4;
  --code-no: #8a9a7a;
  --code-head: #dfeec2;
  --literal-bg: #ececec;
  --hl-line: #fff3a8;
  --note-bg: #eeeeee;
  --note-border: #cccccc;
  --warn-bg: #ffe4e4;
  --warn-border: #ff6666;
  --see-bg: #ffffcc;
  --see-border: #ffdd66;
  --th: #ededed;
  /* pygments (رنگ‌های پیش‌فرض Sphinx) */
  --k: #007020; --s: #4070a0; --m: #208050; --c: #408090;
  --nf: #06287e; --nc: #0e84b5; --o: #666666; --si: #70a0d0;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #222222; --text: #cfd0d0; --heading: #e6e6e6; --muted: #9aa0a6;
    --link: #48a9d7; --link-visited: #9b9be0; --link-hover: #7fd3f7;
    --bar: #2b2b2b; --bar-border: #444; --sidebar: #2b2b2b; --border: #444;
    --code-bg: #2d3120; --code-border: #4f5a36; --code-gutter: #353a27; --code-no: #8c9672; --code-head: #3a4129;
    --literal-bg: #3a3a3a; --hl-line: #5a5220;
    --note-bg: #333; --note-border: #555; --warn-bg: #4a2a2a; --warn-border: #c44;
    --see-bg: #3d3b21; --see-border: #8a7f2a; --th: #333;
    --k: #8fd35e; --s: #8fb6e8; --m: #8fd3a8; --c: #8fb3c0;
    --nf: #7fb0ff; --nc: #5fc8f0; --o: #b0b0b0; --si: #a8c8f0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #222222; --text: #cfd0d0; --heading: #e6e6e6; --muted: #9aa0a6;
  --link: #48a9d7; --link-visited: #9b9be0; --link-hover: #7fd3f7;
  --bar: #2b2b2b; --bar-border: #444; --sidebar: #2b2b2b; --border: #444;
  --code-bg: #2d3120; --code-border: #4f5a36; --code-gutter: #353a27; --code-no: #8c9672; --code-head: #3a4129;
  --literal-bg: #3a3a3a; --hl-line: #5a5220;
  --note-bg: #333; --note-border: #555; --warn-bg: #4a2a2a; --warn-border: #c44;
  --see-bg: #3d3b21; --see-border: #8a7f2a; --th: #333;
  --k: #8fd35e; --s: #8fb6e8; --m: #8fd3a8; --c: #8fb3c0;
  --nf: #7fb0ff; --nc: #5fc8f0; --o: #b0b0b0; --si: #a8c8f0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 16px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.7;
}
:lang(fa) body, body:lang(fa) { font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif; line-height: 1.85; }
button, select, input { font-family: inherit; }
a { color: var(--link); text-decoration: none; }
a:visited { color: var(--link-visited); }
a:hover { color: var(--link-hover); text-decoration: underline; }
a:focus-visible, button:focus-visible, select:focus-visible {
  outline: 2px solid var(--link); outline-offset: 2px; border-radius: 2px;
}
code, pre, .sig { font-family: Menlo, Consolas, "DejaVu Sans Mono", "Courier New", monospace; }

.skip { position: absolute; inset-inline-start: -9999px; }
.skip:focus { inset-inline-start: 8px; top: 8px; background: var(--bg); padding: 4px 10px; z-index: 10; }

/* نوار بالا و پایین (related) */
.related {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px 16px;
  background: var(--bar);
  border-bottom: 1px solid var(--bar-border);
  padding: 6px 16px;
  font-size: 14px;
  line-height: 1.6;
}
.related.bottom { border-top: 1px solid var(--bar-border); border-bottom: 0; margin-top: 32px; }
.related ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; }
.crumbs li + li::before { content: "»"; padding: 0 6px; color: var(--muted); }
.rel-right li + li::before { content: "|"; padding: 0 8px; color: var(--muted); }
.brand a { color: var(--heading); font-weight: 700; }
.mark {
  display: inline-block; font: 700 11px/18px Menlo, Consolas, monospace; direction: ltr;
  background: #3776ab; color: #ffd43b; border-radius: 3px; padding: 0 4px; margin-inline-end: 6px;
}
.picker { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.picker select { font: inherit; font-size: 13px; background: var(--bg); color: var(--text); border: 1px solid var(--bar-border); border-radius: 3px; padding: 0 4px; }

/* بدنه و نوار کناری */
.document { display: flex; align-items: flex-start; }
.body {
  flex: 1 1 auto; min-width: 0;
  padding: 8px 32px 24px;
  max-width: 980px;
}
.sphinxsidebar {
  flex: 0 0 250px; order: -1;
  background: var(--sidebar);
  border-inline-end: 1px solid var(--border);
  font-size: 14px; line-height: 1.7;
  align-self: stretch;
}
.sidebar-inner { position: sticky; top: 0; padding: 12px 16px 24px; max-height: 100vh; overflow: auto; }
.sphinxsidebar h3 { font-size: 17px; font-weight: 500; margin: 18px 0 6px; color: var(--heading); }
.sphinxsidebar h3:first-child { margin-top: 4px; }
.sphinxsidebar h4 { font-size: 14px; font-weight: 500; margin: 14px 0 2px; color: var(--heading); }
.sphinxsidebar p { margin: 0; }
.sphinxsidebar ul, .sphinxsidebar ol { margin: 0; padding: 0; padding-inline-start: 16px; }
.sphinxsidebar ul ul { padding-inline-start: 14px; }
.toctree { padding-inline-start: 0 !important; list-style: none; }
.toctree li { margin: 2px 0; }
.toctree li.current > a { font-weight: 700; color: var(--heading); }
.toctree .range { display: block; font-size: 12px; color: var(--muted); }

/* عنوان‌ها */
h1, h2, h3 { color: var(--heading); font-weight: 500; line-height: 1.4; }
h1 { font-size: 30px; margin: 24px 0 2px; }
h2 { font-size: 23px; margin: 36px 0 10px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.headerlink { visibility: hidden; color: var(--muted) !important; padding: 0 6px; font-size: .8em; text-decoration: none !important; }
h1:hover .headerlink, h2:hover .headerlink, dt:hover .headerlink, .headerlink:focus { visibility: visible; }
.subtitle { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.lead { max-width: 72ch; }
.body p { max-width: 75ch; }
.hint { font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); font-size: 13px; }

code.literal {
  background: var(--literal-bg); padding: 1px 5px; border-radius: 3px;
  font-size: .86em; unicode-bidi: isolate; white-space: nowrap;
}

/* بلوک کد با شماره‌ی خط */
.highlight-python {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 3px;
  margin: 12px 0 6px;
  overflow: hidden;
}
.code-head {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--code-head); border-bottom: 1px solid var(--code-border);
  padding: 2px 10px; font: 12px/1.9 Menlo, Consolas, monospace; color: var(--muted);
}
.copy {
  font-size: 12px; cursor: pointer;
  background: var(--bg); color: var(--text); border: 1px solid var(--code-border); border-radius: 3px; padding: 0 10px;
}
pre.highlight {
  margin: 0; padding: 6px 0; overflow-x: auto;
  font-size: 13.5px; line-height: 1.6; text-align: left; direction: ltr;
  counter-reset: none;
}
.ln { display: flex; min-width: max-content; scroll-margin-top: 80px; }
.ln .no {
  flex: 0 0 3.4em; text-align: right; padding-right: 12px; margin-right: 12px;
  color: var(--code-no) !important; background: var(--code-gutter);
  border-right: 1px solid var(--code-border); user-select: none; text-decoration: none !important;
}
.ln .no:hover { color: var(--link) !important; }
.ln .src { white-space: pre; padding-right: 16px; }
.ln:target, .ln.hot { background: var(--hl-line); }
.ln:target .no, .ln.hot .no { background: var(--hl-line); color: var(--heading) !important; font-weight: 700; }

/* رشته‌های فارسی داخل کد ترتیب کد را به هم نریزند */
.highlight [class^="s"], .sig [class^="s"] { unicode-bidi: isolate; }

/* رنگ‌بندی سینتکس */
.highlight .k, .highlight .kn, .highlight .kc, .highlight .ow, .highlight .nb, .highlight .bp { color: var(--k); }
.highlight .k, .highlight .kn, .highlight .kc, .highlight .ow { font-weight: 700; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sa, .highlight .se, .sig .s1, .sig .s2, .sig .sa, .sig .se { color: var(--s); }
.highlight .si, .sig .si { color: var(--si); font-style: italic; }
.highlight .mi, .highlight .mf, .sig .mi, .sig .mf { color: var(--m); }
.highlight .c, .highlight .c1 { color: var(--c); font-style: italic; }
.highlight .nf, .sig .nf { color: var(--nf); }
.highlight .nc, .highlight .nn, .sig .nc, .sig .nn { color: var(--nc); font-weight: 700; }
.highlight .o, .sig .o { color: var(--o); }
.sig .k, .sig .kn, .sig .kc, .sig .ow, .sig .nb, .sig .bp { color: var(--k); }
.sig .k, .sig .kn, .sig .kc, .sig .ow { font-weight: 700; }

/* فهرست توضیح خط‌ها — مثل تعریف توابع در مستندات پایتون */
.line-list { margin: 0; }
.line-entry { margin: 0 0 14px; scroll-margin-top: 16px; }
.line-entry dt {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  border-top: 2px solid var(--code-border);
  background: var(--code-bg);
  padding: 4px 10px;
}
.line-entry .lnum { font-weight: 700; white-space: nowrap; font-size: 14px; }
.line-entry .sig {
  direction: ltr; unicode-bidi: isolate; text-align: left;
  font-size: 13px; overflow-x: auto; white-space: pre; max-width: 100%; flex: 1 1 0; min-width: 0;
}
.line-entry dd { margin: 6px 0 0; margin-inline-start: 26px; max-width: 75ch; }
.line-entry.blank dt { background: transparent; border-top: 1px dashed var(--border); padding: 0 10px; }
.line-entry.blank dd { color: var(--muted); font-size: 14px; margin-top: 0; }
.line-entry:target dt, .line-entry.hot dt { background: var(--hl-line); }
a.lref { white-space: nowrap; border-bottom: 1px dotted currentColor; }
a.lref:hover { text-decoration: none; }
a.lref.ext::after { content: "↗"; font-size: .75em; padding-inline-start: 2px; }

/* کادرها (admonition) */
.admonition { margin: 18px 0; padding: 8px 14px; border: 1px solid; border-radius: 3px; }
.admonition p { margin: 4px 0; }
.admonition-title { font-weight: 700; }
.admonition-title::after { content: ":"; }
.note { background: var(--note-bg); border-color: var(--note-border); }
.warning { background: var(--warn-bg); border-color: var(--warn-border); }
.seealso { background: var(--see-bg); border-color: var(--see-border); }
.rel-list { margin: 6px 0; }
.rel-list dt { font-weight: 700; margin-top: 8px; }
.rel-list dd { margin: 0; margin-inline-start: 22px; }

/* جدول‌ها */
.table-wrap { overflow-x: auto; }
table.docutils { border-collapse: collapse; margin: 10px 0; font-size: 15px; }
table.docutils th, table.docutils td { border: 1px solid var(--border); padding: 4px 10px; text-align: start; vertical-align: top; }
table.docutils th { background: var(--th); font-weight: 500; }

/* فهرست صفحه‌ی اول */
.toc-big { padding: 0; list-style: none; }
.toc-big li { margin-bottom: 8px; }
.toc-title { margin: 0; font-size: 17px; }
.toc-desc { margin: 0; font-size: 13px; color: var(--muted); }

/* صفحه‌ی قبلی/بعدی */
.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--border); }
.pager a { display: flex; flex-direction: column; max-width: 48%; }
.pager .next { text-align: end; margin-inline-start: auto; }
.pager small { color: var(--muted); font-size: 12px; }

/* فرم ورود صفحه‌ی کد کامل */
.login {
  max-width: 360px; margin: 24px 0; padding: 18px 20px 20px;
  background: var(--sidebar); border: 1px solid var(--border); border-radius: 3px;
  display: flex; flex-direction: column; gap: 4px;
}
.login-intro { margin: 0 0 8px; }
.login label { font-size: 14px; font-weight: 500; margin-top: 6px; }
.login input {
  font: 15px Menlo, Consolas, monospace; padding: 6px 8px; text-align: left;
  background: var(--bg); color: var(--text); border: 1px solid var(--bar-border); border-radius: 3px;
}
.login input:focus { outline: 2px solid var(--link); outline-offset: 0; border-color: var(--link); }
.login-error { margin: 8px 0 0; padding: 4px 10px; background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 3px; font-size: 14px; }
.login button, .btn-primary {
  font-size: 15px; font-weight: 500; cursor: pointer; margin-top: 12px;
  background: var(--link); color: #fff; border: 0; border-radius: 3px; padding: 6px 18px; align-self: flex-start;
}
.login button:disabled { opacity: .6; cursor: progress; }
.code-actions { display: flex; gap: 14px; align-items: center; margin: 16px 0 4px; }
.code-actions .btn-primary { margin-top: 0; }
.btn-link { font-size: 14px; background: none; border: 0; color: var(--link); cursor: pointer; padding: 0; }
.btn-link:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* سؤال‌های تمرینی */
.quiz { padding-inline-start: 22px; }
.quiz:lang(fa) { list-style: persian; }
.quiz .q { margin: 0 0 14px; }
.quiz .q-text { margin: 0 0 4px; font-weight: 500; }
.quiz details { background: var(--sidebar); border: 1px solid var(--border); border-radius: 3px; padding: 4px 12px; max-width: 75ch; }
.quiz summary { cursor: pointer; color: var(--link); font-size: 14px; }
.quiz details[open] summary { margin-bottom: 4px; }
.quiz details p { margin: 4px 0 6px; }

.footer { text-align: center; font-size: 13px; color: var(--muted); padding: 12px 16px 28px; }

/* موبایل */
@media (max-width: 860px) {
  .document { flex-direction: column; }
  .sphinxsidebar { order: 1; flex: none; width: 100%; border-inline-end: 0; border-top: 1px solid var(--border); }
  .sidebar-inner { position: static; max-height: none; }
  .body { padding: 4px 16px 16px; width: 100%; }
  h1 { font-size: 25px; }
  h2 { font-size: 20px; }
  .line-entry dd { margin-inline-start: 4px; }
  .rel-right .picker span { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .ln, .line-entry dt { transition: background-color .25s; }
}
@media print {
  .related, .sphinxsidebar, .pager, .copy, .hint { display: none; }
}
