/* Persian edition: right-to-left layout, Persian type, no italics or letter-spacing
   (letter-spacing breaks the joining of Persian letters). */
:root {
  --f-display: "Markazi Text", "Vazirmatn", Tahoma, serif;
  --f-ui: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
  --f-mono: "Vazirmatn", Tahoma, sans-serif;
  --f-code: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --f-math: "STIX Two Text", "Times New Roman", serif;
}
.site { direction: rtl; }
body { font-family: var(--f-ui); }
em { font-style: normal; font-weight: 600; }
.brand, .hero h1, .lesson-q, .toc-q, .counter-num { font-style: normal; }
.kicker, .sec-label, .panel-title, .note-title, .toc-lab b, .pager-dir {
  letter-spacing: 0; text-transform: none; font-size: 0.8125rem;
}
.brand { font: 700 1.5rem/1 var(--f-display); }
.head-links { display: flex; align-items: center; gap: 10px; }
.head-link { font: 600 0.875rem var(--f-ui); color: var(--ink); text-decoration: none; padding: 9px 12px; border-radius: 8px; }
.head-link:hover, .head-link[aria-current="page"] { background: var(--wash); }
@media (max-width: 520px) { .head-link { display: none; } }

.hero h1 { font: 700 clamp(3.25rem, 9vw, 6.25rem)/1.15 var(--f-display); letter-spacing: 0; }
.lede { font: 1.15rem/2 var(--f-ui); }
.counter-num { font-family: var(--f-ui); }
.counter-label { max-width: 13em; }
.home-sec > h2, .sec-main h2 { font-family: var(--f-display); font-weight: 700; line-height: 1.3; letter-spacing: 0; }
.home-intro { font: 1.05rem/1.95 var(--f-ui); }
.toc-num { font-family: var(--f-display); font-weight: 600; }
.toc-title { font: 700 1.6rem/1.35 var(--f-display); }
.toc-q { font: 1rem/1.8 var(--f-ui); }
.step-title { font: 700 1.35rem/1.3 var(--f-display); }
.lesson-head h1 { font: 700 clamp(2.5rem, 6vw, 4.25rem)/1.2 var(--f-display); letter-spacing: 0; }
.lesson-q { font: 500 clamp(1.15rem, 2.2vw, 1.45rem)/1.8 var(--f-ui); }
.lab-head h3 { font: 700 1.75rem/1.3 var(--f-display); }
.prose { font: 1.06rem/2 var(--f-ui); }
.lab-intro { font-size: 1rem; }
.terms dt { font: 700 1.05rem/1.9 var(--f-ui); }
.terms dd { font: 1rem/1.9 var(--f-ui); }
.note-body { font: 1rem/1.95 var(--f-ui); }
.pager-title { font: 700 1.3rem/1.4 var(--f-display); }
.book-title { font: 700 1.25rem/1.5 var(--f-display); }
.menu-num { font-family: var(--f-display); font-weight: 600; }
.readout { line-height: 1.85; }
.uses p, .tool-text, .book-text, .step-text, .fig figcaption { line-height: 1.85; }

/* Math, code, references and number lines stay left-to-right. */
.eq { direction: ltr; }
.eq-body, var { font-family: var(--f-math); }
.code pre, .code-head span, .tool-where { font-family: var(--f-code); }
.refs { direction: ltr; text-align: left; font-family: "IBM Plex Mono", var(--f-ui); font-size: 0.8125rem; }
.refs cite { font-family: var(--f-math); font-size: 1rem; }
input[type="range"] { direction: ltr; }
.chart-tip, .chart-legend, .chart-status { direction: rtl; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.chart-svg .ticks text { font-family: var(--f-ui); font-size: 11.5px; }

/* "Networks in your field" */
.fields-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.fields-grid a {
  display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 14px 16px; border: 1px solid var(--rule);
  border-radius: 12px; background: var(--sheet); color: var(--ink); text-decoration: none;
}
.fields-grid a:hover { border-color: var(--ink-2); }
.fields-grid a[aria-current="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.field-name { font: 700 1.05rem/1.5 var(--f-ui); }
.field-who { font: 0.8125rem/1.7 var(--f-ui); color: var(--ink-2); }
@media (max-width: 960px) { .fields-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 680px) { .fields-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.field-page { padding-block: 8px 48px; }
.field-head { padding-block: clamp(24px, 4vw, 48px) 20px; }
.field-head h1 { margin: 10px 0 12px; font: 700 clamp(2.25rem, 5vw, 3.75rem)/1.25 var(--f-display); }
.field-head p { margin: 0; max-width: 60ch; font: 1.06rem/2 var(--f-ui); color: var(--ink-2); }
.field-body { display: grid; gap: 22px; margin-top: 30px; padding-top: 30px; border-top: 1px solid var(--rule); }
.field-title { margin: 0; font: 700 clamp(1.9rem, 4vw, 2.75rem)/1.3 var(--f-display); }
.field-question { margin: 0; max-width: 46ch; font: 600 1.25rem/1.8 var(--f-ui); color: var(--ink-2); }
.field-map { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 72ch; }
.field-map div { padding: 14px 16px; border-radius: 12px; background: var(--wash); }
.field-map b { display: block; margin-bottom: 4px; font: 600 0.8125rem var(--f-ui); color: var(--ink-2); }
.field-map span { font: 1rem/1.8 var(--f-ui); }
@media (max-width: 560px) { .field-map { grid-template-columns: minmax(0, 1fr); } }
.field-blocks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px 30px; }
.field-blocks section { border-top: 1px solid var(--rule-strong); padding-top: 12px; min-width: 0; }
.field-blocks h3 { margin: 0 0 6px; font: 700 1.05rem/1.6 var(--f-ui); }
.field-blocks p { margin: 0; font: 0.975rem/1.95 var(--f-ui); color: var(--ink-2); }
@media (max-width: 860px) { .field-blocks { grid-template-columns: minmax(0, 1fr); } }
.try-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-width: 76ch; }
.try-list a {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 14px 16px;
  border: 1px solid var(--rule); border-radius: 12px; background: var(--sheet); color: var(--ink); text-decoration: none;
}
.try-list a:hover { border-color: var(--ink-2); }
.try-list b { display: block; font: 700 1rem/1.6 var(--f-ui); }
.try-list span { font: 0.9375rem/1.8 var(--f-ui); color: var(--ink-2); }
.try-go { font: 600 0.8125rem var(--f-ui); color: var(--ink); white-space: nowrap; }
.field-links { display: flex; flex-wrap: wrap; gap: 8px; }
.field-links a {
  font: 500 0.8125rem/1 var(--f-ui); padding: 9px 13px; border-radius: 999px; border: 1px solid var(--rule-strong);
  color: var(--ink-2); text-decoration: none;
}
.field-links a:hover { border-color: var(--ink-2); color: var(--ink); }
.who-for { max-width: 76ch; padding: 16px 18px; border-radius: 12px; border: 1px solid var(--rule); background: var(--sheet); display: grid; gap: 12px; }
.who-for p { margin: 0; font: 0.975rem/1.9 var(--f-ui); color: var(--ink-2); }
.who-for p b { color: var(--ink); }
.lab-title-small { margin: 8px 0 0; font: 700 1.35rem/1.5 var(--f-display); }
.who-for .panel-title { margin: 0; }
.who-for a { font-weight: 600; }
.step-title::before { content: counter(step, persian) ". "; }
.field-head .kicker a { color: var(--muted); text-decoration: none; }
.field-head .kicker a:hover { color: var(--ink); }
.field-head .field-question { margin-top: 6px; }
.field-links a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: var(--sheet); }
.field-body { margin-top: 26px; }
.site { position: relative; z-index: 1; }
.theme-btn {
  font: 600 0.8125rem/1 var(--f-ui); padding: 10px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--rule-strong); background: transparent; color: var(--ink);
}
.theme-btn:hover { border-color: var(--ink-2); }
