@font-face { font-family: "Vazirmatn"; src: url("../fonts/Vazirmatn-Regular.cdc140628f11.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("../fonts/Vazirmatn-Medium.dd2193b32cbe.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("../fonts/Vazirmatn-Bold.7958481fe611.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --ink: #1b1f3b;
  --ink-soft: #4a4f6e;
  --paper: #f7f5f0;
  --card: #ffffff;
  --line: #e4e0d6;
  --brand: #2f3c9e;
  --brand-dark: #212b78;
  --accent: #f2a541;
  --ok: #2e8b57;
  --bad: #c8453b;
  --muted: #8b8fa8;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; font-family: "Vazirmatn", Tahoma, sans-serif; color: var(--ink);
  background: var(--paper); line-height: 1.9;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
.top { background: var(--ink); color: #fff; }
.top .wrap { display: flex; align-items: center; gap: 24px; height: 64px; }
.logo { color: #fff; font-weight: 700; font-size: 1.35rem; letter-spacing: -.5px; display: flex; align-items: center; gap: 8px; }
.logo:hover { text-decoration: none; }
.logo .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); display: inline-block; }
.nav { display: flex; gap: 18px; flex: 1; }
.nav a, .userbox a { color: #d8dbf0; font-size: .95rem; }
.nav a:hover, .userbox a:hover { color: #fff; text-decoration: none; }
.userbox { display: flex; gap: 14px; align-items: center; font-size: .9rem; }
.userbox form { display: inline; }
.linkbtn { background: none; border: 0; color: #d8dbf0; font: inherit; cursor: pointer; padding: 0; }

main { padding: 32px 0 60px; min-height: 70vh; }
footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; padding: 24px 0; text-align: center; }

/* ---------- elements ---------- */
h1 { font-size: 1.9rem; margin: 0 0 8px; line-height: 1.5; }
h2 { font-size: 1.3rem; margin: 32px 0 12px; }
.lead { color: var(--ink-soft); margin: 0 0 24px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.grid .card { margin: 0; display: flex; flex-direction: column; }
.grid .card .btn { margin-top: auto; align-self: flex-start; }
.grid .card .tag { align-self: flex-start; }
.meta { color: var(--muted); font-size: .85rem; display: flex; gap: 14px; flex-wrap: wrap; }
.tag { display: inline-block; background: #eef0fb; color: var(--brand); border-radius: 999px; padding: 0 10px; font-size: .8rem; }
.tag.s2 { background: #fdf1e0; color: #a86512; }

.btn {
  display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 10px;
  padding: 9px 20px; font: inherit; font-weight: 500; cursor: pointer;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.btn.accent { background: var(--accent); color: var(--ink); }
.btn.big { padding: 12px 30px; font-size: 1.05rem; }

.messages { list-style: none; padding: 0; margin: 0 0 20px; }
.messages li { background: #e7f4ec; border: 1px solid #bfe0cb; border-radius: 10px; padding: 8px 14px; }

/* ---------- hero ---------- */
.hero { background: var(--ink); color: #fff; border-radius: 22px; padding: 44px 40px; margin-bottom: 36px; position: relative; overflow: hidden; }
.hero h1 { font-size: 2.2rem; }
.hero p { color: #c9cdea; max-width: 560px; }
.hero .actions { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.hero .btn.ghost { color: #fff; border-color: #fff; }
.hero::after {
  content: "∑ ∏ C(n,k) ⌈n/2⌉ G=(V,E)"; position: absolute; left: -10px; bottom: -14px;
  font-size: 3.6rem; color: rgba(255,255,255,.06); white-space: nowrap; direction: ltr; font-family: serif;
}

/* ---------- filters ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.filters a { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 2px 14px; font-size: .9rem; color: var(--ink-soft); }
.filters a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.filters a:hover { text-decoration: none; }

/* ---------- questions ---------- */
.qtext { font-size: 1.05rem; white-space: pre-line; }
.choices { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.choices li { border: 1.5px solid var(--line); border-radius: 10px; }
.choices label { display: flex; gap: 12px; align-items: center; padding: 8px 14px; cursor: pointer; }
.choices input { accent-color: var(--brand); width: 18px; height: 18px; }
.choices li:has(input:checked) { border-color: var(--brand); background: #f2f3fc; }
.choices .let { font-weight: 700; color: var(--brand); min-width: 26px; }
.choices li.correct { border-color: var(--ok); background: #eaf6ef; }
.choices li.mine-wrong { border-color: var(--bad); background: #fbecea; }
.choices li .note { margin-inline-start: auto; font-size: .8rem; font-weight: 500; }
details { margin-top: 12px; }
details summary { cursor: pointer; color: var(--brand); font-weight: 500; }
details .sol { background: #faf8f3; border-radius: 10px; padding: 10px 14px; margin-top: 8px; white-space: pre-line; }
.qnum { font-weight: 700; color: var(--muted); margin-inline-end: 6px; }
.qhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.clear { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; font-size: .8rem; }

/* ---------- exam taking ---------- */
.examcolumns { display: grid; grid-template-columns: 1fr 200px; gap: 22px; align-items: start; }
.sidebar { position: sticky; top: 16px; }
.timer { background: var(--ink); color: #fff; border-radius: var(--radius); padding: 16px; text-align: center; }
.timer .t { font-size: 2rem; font-weight: 700; direction: ltr; font-variant-numeric: tabular-nums; }
.timer.warn { background: var(--bad); }
.palette { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 14px 0; }
.palette a { display: block; text-align: center; border: 1px solid var(--line); background: var(--card); border-radius: 8px; font-size: .85rem; color: var(--ink-soft); }
.palette a.done { background: var(--brand); color: #fff; border-color: var(--brand); }
.savestate { font-size: .8rem; color: var(--muted); text-align: center; min-height: 1.4em; }
@media (max-width: 760px) {
  .examcolumns { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 5; order: -1; }
  .palette { display: none; }
  .timer { padding: 6px; display: flex; justify-content: space-between; align-items: center; }
  .timer .t { font-size: 1.4rem; }
  .top .wrap { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; gap: 10px 16px; }
  .nav { order: 3; flex-basis: 100%; gap: 16px; }
  .hero { padding: 30px 22px; }
}

/* ---------- results ---------- */
.score { display: flex; gap: 16px; flex-wrap: wrap; }
.score .card { flex: 1; min-width: 140px; text-align: center; margin: 0; }
.score .n { font-size: 2rem; font-weight: 700; display: block; line-height: 1.4; }
.score .ok { color: var(--ok); } .score .bad { color: var(--bad); } .score .muted { color: var(--muted); }
.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: 150px 1fr 60px; gap: 12px; align-items: center; font-size: .95rem; }
.bar .track { background: #eceae3; border-radius: 999px; height: 12px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 999px; background: var(--brand); }
.bar .fill.low { background: var(--bad); } .bar .fill.mid { background: var(--accent); }
.bar .pct { text-align: left; font-weight: 500; direction: ltr; }
.weak { background: #fff6e8; border: 1px solid #f4d5a4; border-radius: var(--radius); padding: 14px 18px; margin-top: 16px; }
table.list { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: right; }
table.list th { background: #f0eee8; font-weight: 500; font-size: .9rem; }
table.rank tr.me td { background: #fff6e8; font-weight: 700; }
table.rank td:first-child { width: 70px; text-align: center; }
table.rank tr.podium td { font-weight: 500; }
table.rank td:last-child { direction: ltr; text-align: right; }

/* ---------- forms ---------- */
.formcard { max-width: 440px; margin: 0 auto; }
.formcard p { margin: 0 0 14px; }
.formcard label { display: block; font-weight: 500; margin-bottom: 4px; }
.formcard input, .formcard select { width: 100%; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px; font: inherit; background: #fff; }
.formcard input:focus, .formcard select:focus { outline: none; border-color: var(--brand); }
.formcard .helptext, .formcard .helptext ul { font-size: .78rem; color: var(--muted); margin: 4px 0 0; }
.errorlist { color: var(--bad); font-size: .85rem; padding: 0; list-style: none; margin: 0 0 4px; }
.katex { font-size: 1.05em; direction: ltr; unicode-bidi: isolate; }
.formcard textarea { width: 100%; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px; font: inherit; background: #fff; }
.formcard input[type=file] { padding: 8px; background: #faf8f3; }

/* راهنمایی پله‌پله: هر پله داخل پله‌ی قبلی است و فقط بعد از باز کردن آن دیده می‌شود */
.hints details.hint-step details.hint-step { margin-top: 10px; padding-inline-start: 12px; border-inline-start: 2px solid var(--brand); }

/* ---------- تمرین آزاد ---------- */
.verdict { margin-top: 14px; border-radius: 10px; padding: 10px 14px; font-weight: 500; }
.verdict.ok { background: #eaf6ef; color: var(--ok); border: 1px solid #bfe0cb; }
.verdict.bad { background: #fbecea; color: var(--bad); border: 1px solid #f0c7c2; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btn.small { padding: 2px 12px; font-size: .85rem; }
.bar.practice-row { grid-template-columns: 150px 1fr 60px auto; }
.bar .train { font-size: .85rem; }
.bar.with-train { grid-template-columns: 150px 1fr 60px 60px; }
@media (max-width: 600px) {
  .bar.practice-row { grid-template-columns: 1fr 70px; }
  .bar.practice-row .track { grid-column: 1 / -1; grid-row: 2; }
  .bar.practice-row .btn { grid-column: 1 / -1; justify-self: start; }
  .bar.with-train { grid-template-columns: 110px 1fr 50px 50px; }
  .practice-progress .bar { grid-template-columns: 80px 1fr 50px; }
}

/* ---------- نقشه‌ی راه ---------- */
.muted { color: var(--muted); }
.roadmap-list { display: grid; gap: 10px; }
.roadmap-week { display: block; color: inherit; margin: 0; padding: 14px 18px; }
.roadmap-week:hover { text-decoration: none; border-color: var(--brand); }
.roadmap-week.exam { background: #fdf8ef; }
.rw-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.rw-title { color: var(--ink-soft); }
.rw-cells { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 8px; font-size: .88rem; color: var(--ink-soft); }
.rw-cell span { display: block; }
.rw-cell .rw-track { color: var(--muted); font-size: .78rem; }
.roadmap-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.roadmap-col { margin: 0; padding: 16px; }
.roadmap-col h2 { margin: 0 0 10px; font-size: 1.1rem; }
.roadmap-col.track-theory { border-top: 4px solid var(--brand); }
.roadmap-col.track-graph { border-top: 4px solid var(--ok); }
.roadmap-col.track-code { border-top: 4px solid var(--accent); }
.rm-part h3 { font-size: .98rem; margin: 12px 0 6px; }
.rm-step { margin-bottom: 10px; }
.rm-site-links { font-size: .84rem; margin: -2px 0 8px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.rm-site-links a { text-decoration: none; }
.rm-source { font-size: .82rem; color: var(--muted); margin-bottom: 2px; }
.rm-items { margin: 0; padding-inline-start: 18px; font-size: .92rem; }
.rm-items li { margin: 2px 0; }
.rm-item.problem a { unicode-bidi: isolate; }
.tag.rating { margin-inline-start: 4px; font-size: .72rem; }
.roadmap-nav { justify-content: space-between; }
@media (max-width: 760px) {
  .roadmap-cols, .rw-cells { grid-template-columns: 1fr; }
}

/* پیشرفت نقشه‌ی راه */
.rm-progress { padding: 12px 18px; }
.rm-progress .bar { grid-template-columns: 150px 1fr 60px; }
.rm-progress .meta { margin: 8px 0 0; }
.rw-pct { margin-inline-start: auto; font-size: .85rem; color: var(--muted); }
.rw-pct.complete { color: var(--ok); font-weight: 500; }
.rm-items li.rm-item { position: relative; }
.rm-check { display: inline; margin: 0; }
.rm-check button {
  width: 18px; height: 18px; padding: 0; margin-inline-end: 4px; vertical-align: -3px;
  border: 2px solid var(--muted); border-radius: 4px; background: #fff; cursor: pointer;
}
.rm-check button[aria-checked="true"] { background: var(--ok); border-color: var(--ok); }
.rm-check button[aria-checked="true"]::after { content: "✓"; color: #fff; font-size: 12px; line-height: 14px; display: block; }
.rm-item.done > a, .rm-item.done { color: var(--muted); }
.rm-item.done > a { text-decoration: line-through; }
.rm-progress [hidden] { display: none; }
.rm-item:has(> .rm-check) { list-style: none; margin-inline-start: -18px; }

/* تمرین آزاد: انتخاب سطح */
.stage-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
.stage-tabs a { padding: 4px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink-soft); text-decoration: none; }
.stage-tabs a.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- search & pagination ---------- */
.search { display: flex; gap: 8px; margin-bottom: 14px; max-width: 560px; }
.search input[type=search] { flex: 1; min-width: 0; font: inherit; padding: 6px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); }
.search input[type=search]:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.result-count { color: var(--ink-soft); font-size: .9rem; margin: -8px 0 18px; }
.pager { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 28px 0 8px; }
.pager a, .pager span { min-width: 2.2em; text-align: center; padding: 2px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); }
.pager a:hover { text-decoration: none; border-color: var(--brand); color: var(--brand); }
.pager .cur { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager .gap { border: 0; background: transparent; }

/* صفحه‌های پایه (درباره/تماس) و خطا */
.footer-links { display: flex; gap: 16px; justify-content: center; margin-top: 8px; }
.footer-links a { color: var(--muted); }
.prose p { line-height: 2; margin: 0 0 12px; }
.prose p:last-child { margin-bottom: 0; }
.error-page { text-align: center; padding: 40px 22px; }
.error-page .error-code { font-size: 4rem; font-weight: 700; color: var(--brand); line-height: 1; }
