/* Rendered-markdown typography for lessons, prompts, and the admin preview.
   Wrapped content gets class "markdown-body". Shared by the student site and
   the admin's live preview so authors see exactly what students see.
   Logical properties only — the same sheet serves LTR (en) and RTL (fa). */

.markdown-body {
  font-size: 1.02rem;
  line-height: 1.85;
  overflow-wrap: break-word;
}

.markdown-body > :first-child { margin-block-start: 0; }
.markdown-body > :last-child { margin-block-end: 0; }

.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  font-weight: 800;
  line-height: 1.35;
  margin-block: 1.6em 0.5em;
  letter-spacing: -0.01em;
}
.markdown-body h2 {
  font-size: 1.45rem;
  padding-block-end: 0.35rem;
  border-block-end: 3px solid transparent;
  border-image: linear-gradient(90deg, #6366f1, #ec4899, transparent 70%) 1;
}
[dir="rtl"] .markdown-body h2 {
  border-image: linear-gradient(-90deg, #6366f1, #ec4899, transparent 70%) 1;
}
.markdown-body h3 { font-size: 1.2rem; }
.markdown-body h4 { font-size: 1.05rem; }

.markdown-body p { margin-block: 0.8em; }

.markdown-body a {
  color: #4f46e5;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: #c7d2fe;
  text-underline-offset: 3px;
}
.markdown-body a:hover { text-decoration-color: #4f46e5; }

/* Lists with playful markers */
.markdown-body ul,
.markdown-body ol { padding-inline-start: 1.5em; margin-block: 0.8em; }
.markdown-body li { margin-block: 0.3em; }
.markdown-body ul li::marker { color: #6366f1; }
.markdown-body ol li::marker { color: #6366f1; font-weight: 800; }

/* Inline code chip */
.markdown-body code {
  background: #eef0ff;
  color: #4338ca;
  border: 1px solid #e0e3ff;
  border-radius: 6px;
  padding: 0.08em 0.4em;
  font-size: 0.88em;
  font-weight: 600;
}

/* Fenced code blocks (Pygments emits .highlight) */
.markdown-body .highlight,
.md-preview .highlight {
  background: #0f172a;
  border-radius: 14px;
  margin-block: 1rem;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.15);
  overflow: hidden;
}
.markdown-body .highlight pre,
.md-preview .highlight pre {
  margin: 0;
  padding: 1rem 1.15rem;
  background: none;
  color: #e2e8f0;
  overflow-x: auto;
  font-size: 0.92rem;
  line-height: 1.65;
}
.markdown-body .highlight code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-weight: 400;
  font-size: 1em;
}

/* Pygments tokens — tuned for the dark block above */
.highlight .c, .highlight .c1, .highlight .cm,
.highlight .ch, .highlight .cs { color: #7c8aa5; font-style: italic; }
.highlight .k, .highlight .kn, .highlight .kd,
.highlight .kp, .highlight .kr { color: #c084fc; font-weight: 600; }
.highlight .kc { color: #f472b6; font-weight: 600; }        /* True/False/None */
.highlight .ow, .highlight .o { color: #94a3b8; }
.highlight .nb { color: #60a5fa; }                          /* print, input… */
.highlight .nf, .highlight .fm { color: #38bdf8; }          /* function names */
.highlight .nc, .highlight .ne { color: #fbbf24; }          /* class names */
.highlight .nd { color: #f472b6; }                          /* decorators */
.highlight .s, .highlight .sa, .highlight .s1, .highlight .s2,
.highlight .sd, .highlight .se, .highlight .sh { color: #34d399; }
.highlight .si { color: #6ee7b7; }                          /* f-string {} */
.highlight .mi, .highlight .mf, .highlight .mh,
.highlight .mo, .highlight .mb { color: #fbbf24; }
.highlight .n { color: #e2e8f0; }
.highlight .p { color: #94a3b8; }
.highlight .err { color: #fca5a5; }

/* Tables */
.markdown-body table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  margin-block: 1rem;
  border: 1px solid #e4e7fb;
  border-radius: 12px;
  overflow: hidden;
  font-size: 0.95rem;
}
.markdown-body th {
  background: linear-gradient(180deg, #eef0ff, #e6e9ff);
  color: #3730a3;
  font-weight: 800;
  text-align: start;
  padding: 0.6rem 0.9rem;
  border-block-end: 1px solid #dbdfff;
}
.markdown-body td {
  padding: 0.55rem 0.9rem;
  border-block-end: 1px solid #eef0fb;
  text-align: start;
}
.markdown-body tr:last-child td { border-block-end: none; }
.markdown-body tbody tr:nth-child(even) { background: #fafbff; }

/* Blockquote */
.markdown-body blockquote {
  margin: 1rem 0;
  padding: 0.6rem 1.1rem;
  border-inline-start: 4px solid #a5b4fc;
  background: #f5f6ff;
  border-radius: 0 12px 12px 0;
  color: #4b5077;
}
[dir="rtl"] .markdown-body blockquote { border-radius: 12px 0 0 12px; }

/* Admonition callouts: !!! tip "Title" */
.markdown-body .admonition {
  border-radius: 14px;
  padding: 0.85rem 1.1rem;
  margin-block: 1.1rem;
  border: 1.5px solid;
  background: #f5f8ff;
  border-color: #bfdbfe;
}
.markdown-body .admonition > .admonition-title {
  font-weight: 800;
  margin-block: 0 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.markdown-body .admonition > .admonition-title::before { content: "📘"; }
.markdown-body .admonition.tip,
.markdown-body .admonition.hint {
  background: #f0fdf6; border-color: #bbf7d0;
}
.markdown-body .admonition.tip > .admonition-title::before,
.markdown-body .admonition.hint > .admonition-title::before { content: "💡"; }
.markdown-body .admonition.warning,
.markdown-body .admonition.caution {
  background: #fffaf0; border-color: #fde68a;
}
.markdown-body .admonition.warning > .admonition-title::before,
.markdown-body .admonition.caution > .admonition-title::before { content: "⚠️"; }
.markdown-body .admonition.danger,
.markdown-body .admonition.error {
  background: #fef5f5; border-color: #fecaca;
}
.markdown-body .admonition.danger > .admonition-title::before,
.markdown-body .admonition.error > .admonition-title::before { content: "🚫"; }
.markdown-body .admonition.example {
  background: #faf5ff; border-color: #e9d5ff;
}
.markdown-body .admonition.example > .admonition-title::before { content: "🧪"; }
.markdown-body .admonition > p:last-child { margin-block-end: 0; }

/* Math (server-rendered MathML) */
.markdown-body math {
  font-size: 1.08em;
}
.markdown-body math[display="block"] {
  /* keep the UA's `display: block math` so native centering works */
  margin-block: 1rem;
  font-size: 1.2em;
}

/* Media & misc */
.markdown-body img {
  max-width: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(30, 33, 64, 0.12);
}
.markdown-body hr {
  border: none;
  border-block-start: 3px dashed #dfe3ff;
  margin-block: 1.6rem;
}
.markdown-body kbd {
  background: #1e2140;
  color: #fff;
  border-radius: 6px;
  padding: 0.1em 0.5em;
  font-size: 0.82em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  box-shadow: inset 0 -2px 0 rgba(255, 255, 255, 0.25);
}
.markdown-body mark {
  background: #fef08a;
  border-radius: 4px;
  padding: 0.05em 0.25em;
}
.markdown-body details {
  border: 1.5px solid #e4e7fb;
  border-radius: 12px;
  padding: 0.6rem 1rem;
  margin-block: 1rem;
  background: #fafbff;
}
.markdown-body summary { cursor: pointer; font-weight: 700; }
