/* Reset & base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html.reduce-motion { scroll-behavior: auto; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--white); color: var(--ink-2);
  font-family: var(--font-body); font-size: var(--fs-1); line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg, video { max-width: 100%; height: auto; display: block; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--ink); line-height: var(--lh-tight); margin: 0 0 var(--space-2); font-weight: 700; letter-spacing: -0.005em; text-wrap: balance; }
html[lang="fa"] h1, html[lang="fa"] h2, html[lang="fa"] h3 { letter-spacing: 0; line-height: 1.35; }
h1 { font-size: var(--fs-5); font-weight: 800; }
h2 { font-size: var(--fs-4); }
h3 { font-size: var(--fs-3); }
h4 { font-size: var(--fs-2); }
p { margin: 0 0 var(--space-2); max-width: 70ch; }
a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--blue-ink); }
ul, ol { padding-inline-start: 1.4em; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-4) 0; }
small, .small { font-size: var(--fs-0); }
strong { color: var(--ink); }
bdi, .ltr { unicode-bidi: isolate; }
.ltr { direction: ltr; }
.num { font-variant-numeric: tabular-nums; }
code { font-family: var(--font-mono); font-size: 0.9em; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: start; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink); font-weight: 700; font-size: var(--fs-0); background: var(--soft-100); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; inset-inline-start: var(--gutter); top: -100px; background: var(--blue); color: var(--white); padding: 0.6rem 1rem; z-index: 100; border-radius: var(--radius); }
.skip-link:focus { top: var(--gutter); }

/* Layout */
.wrap { width: min(100% - 2 * var(--gutter), var(--max)); margin-inline: auto; }
.wrap--narrow { width: min(100% - 2 * var(--gutter), 820px); margin-inline: auto; }
.grid { display: grid; gap: var(--space-3); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.split { display: grid; gap: var(--space-4); align-items: start; }
@media (min-width: 900px) { .split { grid-template-columns: 5fr 7fr; } .split--rev { grid-template-columns: 7fr 5fr; } .split--eq { grid-template-columns: 1fr 1fr; } }
.section { padding-block: var(--space-5); }
.section--tight { padding-block: var(--space-4); }
.section--soft { background: var(--soft-100); }
.section--dark { background: var(--blue); color: var(--soft-200); }
.section--dark h1, .section--dark h2, .section--dark h3, .section--dark strong { color: var(--white); }
.section--dark a { color: var(--white); }
.section--dark p { color: var(--soft-200); }
@media (min-width: 900px) { .section { padding-block: var(--space-6); } }
.stack > * + * { margin-top: var(--space-2); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.flow > * + * { margin-top: var(--space-3); }

/* Section header: number eyebrow + connecting rule (precision/connection) */
.sec-head { display: grid; gap: var(--space-1); margin-bottom: var(--space-4); max-width: 780px; }
.eyebrow { font-size: var(--fs-0); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--blue); display: flex; align-items: center; gap: 0.75rem; font-family: var(--font-en); }
html[lang="fa"] .eyebrow { letter-spacing: 0; font-family: var(--font-fa); }
.eyebrow::before { content: ""; width: 28px; height: 2px; background: var(--blue); flex: none; }
.section--dark .eyebrow { color: var(--soft); } .section--dark .eyebrow::before { background: var(--soft); }
.sec-head .lede { font-size: var(--fs-2); color: var(--muted); }
.section--dark .lede { color: var(--soft-200); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 44px; padding: 0.55rem 1.25rem; border-radius: var(--radius); border: 1.5px solid var(--blue); background: var(--blue); color: var(--white); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: background var(--dur-1) var(--ease-out), color var(--dur-1), border-color var(--dur-1), transform var(--dur-1) var(--ease-out); }
.btn:hover { background: var(--blue-ink); border-color: var(--blue-ink); color: var(--white); }
.btn:active { transform: translateY(1px); }
.btn--ghost { background: transparent; color: var(--blue); }
.btn--ghost:hover { background: var(--soft-100); color: var(--blue-ink); }
.btn--light { background: var(--white); color: var(--blue); border-color: var(--white); }
.btn--light:hover { background: var(--soft-200); border-color: var(--soft-200); color: var(--blue-ink); }
.btn--outline-light { background: transparent; color: var(--white); border-color: var(--soft); }
.btn--outline-light:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.btn--sm { min-height: 36px; padding: 0.3rem 0.9rem; font-size: var(--fs-0); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn .arrow { width: 1em; height: 1em; transition: transform var(--dur-1) var(--ease-out); }
html[dir="rtl"] .btn .arrow { transform: scaleX(-1); }
.btn:hover .arrow { transform: translateX(3px); }
html[dir="rtl"] .btn:hover .arrow { transform: scaleX(-1) translateX(3px); }
.link-more { font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 0.35rem; }
.link-more:hover { text-decoration: underline; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,0.92); backdrop-filter: saturate(140%) blur(8px); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: var(--space-3); min-height: 68px; }
.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand img { height: 32px; width: auto; }
.nav { margin-inline-start: auto; display: none; align-items: center; gap: 0.25rem; }
.nav a { color: var(--ink-2); text-decoration: none; padding: 0.5rem 0.7rem; border-radius: var(--radius); font-weight: 500; position: relative; }
.nav a:hover { color: var(--blue); background: var(--soft-100); }
.nav a.is-active { color: var(--blue); font-weight: 700; }
.nav a.is-active::after { content: ""; position: absolute; inset-inline: 0.7rem; bottom: 2px; height: 2px; background: var(--blue); }
.header-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 0.5rem; }
@media (min-width: 1024px) { .nav { display: flex; } .header-actions { margin-inline-start: 0; } .nav-toggle { display: none; } }
.lang-switch { font-family: var(--font-en); font-weight: 600; text-decoration: none; padding: 0.45rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius); color: var(--blue); font-size: var(--fs-0); }
html[lang="en"] .lang-switch { font-family: var(--font-fa); }
.lang-switch:hover { background: var(--soft-100); }
.nav-toggle { background: none; border: 1px solid var(--line); border-radius: var(--radius); min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; cursor: pointer; color: var(--blue); }
.nav-toggle svg { width: 22px; height: 22px; }
.mobile-nav { display: none; border-top: 1px solid var(--line); background: var(--white); }
.mobile-nav.is-open { display: block; }
.mobile-nav ul { list-style: none; margin: 0; padding: var(--space-2) 0; }
.mobile-nav a { display: block; padding: 0.75rem var(--gutter); text-decoration: none; color: var(--ink-2); font-weight: 500; border-inline-start: 3px solid transparent; }
.mobile-nav a.is-active, .mobile-nav a:hover { color: var(--blue); border-color: var(--blue); background: var(--soft-100); }
.mobile-nav .mobile-cta { padding: var(--space-2) var(--gutter); }
@media (min-width: 1024px) { .mobile-nav { display: none !important; } }

/* Footer */
.site-footer { background: var(--blue-deep); color: var(--soft-200); padding-block: var(--space-5) var(--space-3); margin-top: var(--space-5); }
.site-footer a { color: var(--soft-200); text-decoration: none; }
.site-footer a:hover { color: var(--white); text-decoration: underline; }
.footer-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.footer-brand { grid-column: 1 / -1; }
@media (min-width: 900px) { .footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr 1fr; } .footer-brand { grid-column: auto; } }
.footer-brand img { height: 30px; width: auto; margin-bottom: var(--space-2); }
.site-footer h4 { color: var(--white); font-size: var(--fs-1); margin-bottom: var(--space-2); }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.footer-bottom { border-top: 1px solid rgba(143,168,199,0.25); margin-top: var(--space-4); padding-top: var(--space-2); display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: space-between; font-size: var(--fs-0); color: var(--soft); }
.motion-toggle { display: inline-flex; align-items: center; gap: 0.5rem; background: none; border: 1px solid rgba(143,168,199,0.4); color: var(--soft-200); border-radius: var(--radius); padding: 0.35rem 0.7rem; font: inherit; font-size: var(--fs-0); cursor: pointer; }
.motion-toggle[aria-pressed="true"] { background: rgba(255,255,255,0.1); color: var(--white); }
.motion-toggle .dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; }
.motion-toggle[aria-pressed="true"] .dot { background: currentColor; }

/* Breadcrumbs */
.crumbs { font-size: var(--fs-0); color: var(--muted); padding-block: var(--space-2); }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; }
.crumbs li + li::before { content: "/"; margin-inline-end: 0.5rem; color: var(--soft); }
.crumbs a { color: var(--muted); text-decoration: none; } .crumbs a:hover { color: var(--blue); text-decoration: underline; }
.crumbs [aria-current] { color: var(--ink); }

/* Cards & lists */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-3); position: relative; display: flex; flex-direction: column; gap: var(--space-1); transition: border-color var(--dur-1), transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2); }
.card:hover { border-color: var(--soft); box-shadow: var(--shadow); transform: translateY(-2px); }
.card h3 { margin-bottom: 0.25rem; font-size: var(--fs-2); }
.card .num-tag { font-family: var(--font-en); font-weight: 800; color: var(--soft); font-size: var(--fs-3); line-height: 1; }
.card--link { text-decoration: none; color: inherit; }
.card--link:hover h3 { color: var(--blue); }
.card .meta { color: var(--muted); font-size: var(--fs-0); }
.pill { display: inline-block; font-size: var(--fs-0); font-weight: 600; padding: 0.15rem 0.6rem; border-radius: 999px; background: var(--soft-100); color: var(--blue); border: 1px solid var(--soft-200); }
.pill--warn { background: var(--warn-bg); color: var(--warn-ink); border-color: #F3D9A4; }
.pill--ok { background: #E6F4EA; color: var(--ok); border-color: #BEE3C9; }
.note { border-inline-start: 3px solid var(--soft); background: var(--soft-100); padding: var(--space-2) var(--space-3); border-radius: var(--radius); color: var(--ink-2); font-size: var(--fs-0); }
.note--warn { border-color: #E0A93A; background: var(--warn-bg); color: var(--warn-ink); }
.note p:last-child { margin-bottom: 0; }
.numbered { counter-reset: n; list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-2); }
.numbered > li { counter-increment: n; display: grid; grid-template-columns: 2.25rem 1fr; gap: var(--space-2); align-items: start; }
.numbered > li::before { content: counter(n, decimal-leading-zero); font-family: var(--font-en); font-weight: 800; color: var(--soft); font-size: var(--fs-2); line-height: 1.5; }
html[lang="fa"] .numbered > li::before { content: counter(n, persian); font-family: var(--font-fa); }
.steps { display: grid; gap: var(--space-3); position: relative; }
@media (min-width: 700px) { .steps--4 { grid-template-columns: repeat(4, 1fr); } .steps--3 { grid-template-columns: repeat(3, 1fr); } }
.step { position: relative; padding-top: var(--space-3); }
.step::before { content: ""; position: absolute; top: 0; inset-inline-start: 0; width: 100%; height: 2px; background: var(--line); }
.step::after { content: ""; position: absolute; top: -4px; inset-inline-start: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }
.step .step-n { font-family: var(--font-en); font-weight: 800; color: var(--blue); font-size: var(--fs-0); letter-spacing: 0.1em; }
html[lang="fa"] .step .step-n { font-family: var(--font-fa); letter-spacing: 0; }
.step h3 { font-size: var(--fs-2); margin-bottom: 0.4rem; }
.step p { font-size: var(--fs-0); color: var(--muted); margin: 0; }
.step .out { font-size: var(--fs-0); color: var(--ink); margin-top: 0.5rem; }

/* Forms */
.field { display: grid; gap: 0.35rem; margin-bottom: var(--space-2); }
.field label, .field > .label { font-weight: 600; color: var(--ink); font-size: var(--fs-0); }
.field .help { color: var(--muted); font-size: var(--fs-0); }
.field .err, .errorlist { color: var(--danger); font-size: var(--fs-0); margin: 0.25rem 0 0; padding: 0; list-style: none; }
.errorlist li::before, .field .err::before { content: "⚠ "; }
input[type="text"], input[type="email"], input[type="url"], input[type="tel"], input[type="number"], input[type="search"], select, textarea {
  font: inherit; color: var(--ink); background: var(--white); border: 1.5px solid var(--soft-300); border-radius: var(--radius); padding: 0.6rem 0.8rem; min-height: 44px; width: 100%; transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(20,52,95,0.15); outline: none; }
input[aria-invalid="true"], .field.is-invalid input { border-color: var(--danger); }
input[inputmode="decimal"], input[inputmode="numeric"] { font-variant-numeric: tabular-nums; direction: ltr; text-align: start; }
html[dir="rtl"] input[inputmode="decimal"], html[dir="rtl"] input[inputmode="numeric"] { text-align: end; }
textarea { resize: vertical; min-height: 120px; }
.choice-list { display: grid; gap: 0.5rem; }
.choice { display: grid; grid-template-columns: auto 1fr; gap: 0.75rem; align-items: start; padding: 0.75rem 1rem; border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer; transition: border-color var(--dur-1), background var(--dur-1); }
.choice:hover { border-color: var(--soft); background: var(--soft-100); }
.choice:has(input:checked) { border-color: var(--blue); background: var(--soft-100); }
.choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.choice input { margin-top: 0.35em; accent-color: var(--blue); width: 18px; height: 18px; }
.choice .label { font-weight: 600; color: var(--ink); }
.choice .sub { font-size: var(--fs-0); color: var(--muted); }
.checkbox { display: flex; gap: 0.6rem; align-items: start; font-size: var(--fs-0); }
.checkbox input { accent-color: var(--blue); width: 18px; height: 18px; margin-top: 0.3em; flex: none; }
.hp-field { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.range-row { display: grid; grid-template-columns: 1fr 120px; gap: 0.75rem; align-items: center; }
input[type="range"] { width: 100%; accent-color: var(--blue); }
.segmented { display: inline-flex; border: 1.5px solid var(--soft-300); border-radius: var(--radius); overflow: hidden; }
.segmented label { padding: 0.45rem 0.9rem; cursor: pointer; font-size: var(--fs-0); font-weight: 600; color: var(--muted); }
.segmented label:has(input:checked) { background: var(--blue); color: var(--white); }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: -3px; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }

/* Progress */
.progress { display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: 0.5rem; list-style: none; padding: 0; margin: 0 0 var(--space-3); font-size: var(--fs-0); }
.progress li { padding-top: 0.6rem; border-top: 3px solid var(--line); color: var(--muted); }
.progress li.is-done { border-color: var(--soft); color: var(--ink-2); }
.progress li.is-current { border-color: var(--blue); color: var(--blue); font-weight: 700; }
.progress-bar { height: 6px; background: var(--soft-200); border-radius: 999px; overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: var(--blue); width: 0; transition: width var(--dur-3) var(--ease-out); }

/* Charts (SVG) */
.chart { width: 100%; height: auto; font-family: var(--font-body); }
.chart text { fill: var(--ink-2); font-size: 12px; }
.chart .axis { stroke: var(--line); }
.chart .zero { stroke: var(--ink-2); stroke-dasharray: 2 3; }
.chart .bar { fill: var(--blue); transition: height var(--dur-3) var(--ease-out), y var(--dur-3) var(--ease-out), width var(--dur-3) var(--ease-out), x var(--dur-3) var(--ease-out); }
.chart .bar--soft { fill: var(--soft); }
.chart .bar--neg { fill: var(--danger); }
.chart .label { font-weight: 700; fill: var(--ink); }
figure { margin: 0; }
figcaption { font-size: var(--fs-0); color: var(--muted); margin-top: 0.5rem; }

/* Prose (markdown) */
.prose { max-width: 70ch; }
.prose h2 { margin-top: var(--space-4); font-size: var(--fs-3); }
.prose h3 { margin-top: var(--space-3); font-size: var(--fs-2); }
.prose p, .prose li { color: var(--ink-2); }
.prose blockquote { margin: var(--space-3) 0; padding-inline-start: var(--space-3); border-inline-start: 3px solid var(--blue); color: var(--ink); font-size: var(--fs-2); }
.prose table { font-size: var(--fs-0); }
.prose img { border-radius: var(--radius); }

/* Accordion */
details.acc { border-top: 1px solid var(--line); }
details.acc:last-of-type { border-bottom: 1px solid var(--line); }
details.acc summary { cursor: pointer; padding: var(--space-2) 0; font-weight: 700; color: var(--ink); list-style: none; display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); }
details.acc summary::-webkit-details-marker { display: none; }
details.acc summary::after { content: "+"; font-family: var(--font-en); font-size: 1.4em; color: var(--blue); transition: transform var(--dur-2) var(--ease-out); flex: none; }
details.acc[open] summary::after { transform: rotate(45deg); }
details.acc .acc-body { padding-bottom: var(--space-2); color: var(--ink-2); }
details.acc[open] .acc-body { animation: acc-in var(--dur-2) var(--ease-out); }
@keyframes acc-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Toast */
.toast { position: fixed; inset-inline-start: 50%; bottom: 1.25rem; transform: translate(-50%, 20px); background: var(--blue-deep); color: var(--white); padding: 0.7rem 1.2rem; border-radius: var(--radius); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity var(--dur-2), transform var(--dur-2) var(--ease-out); z-index: 60; font-size: var(--fs-0); max-width: calc(100% - 2rem); }
html[dir="rtl"] .toast { transform: translate(50%, 20px); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
html[dir="rtl"] .toast.is-on { transform: translate(50%, 0); }

/* Hero */
.hero { padding-block: var(--space-4) var(--space-5); position: relative; overflow: hidden; }
.hero h1 { font-size: var(--fs-6); max-width: 14ch; }
html[lang="fa"] .hero h1 { max-width: 18ch; }
.hero .lede { font-size: var(--fs-3); color: var(--ink-2); max-width: 36ch; font-weight: 400; }
.hero .cluster { margin-top: var(--space-3); }
.hero-grid { display: grid; gap: var(--space-4); align-items: center; }
@media (min-width: 1024px) { .hero-grid { grid-template-columns: 6fr 6fr; } .hero { padding-block: var(--space-5) var(--space-6); } }

/* Page hero (inner pages) */
.page-hero { padding-block: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); }
.page-hero h1 { max-width: 20ch; }
.page-hero .lede { font-size: var(--fs-2); color: var(--muted); max-width: 60ch; }
.page-hero--dark { background: var(--blue); border: 0; color: var(--soft-200); }
.page-hero--dark h1 { color: var(--white); } .page-hero--dark .lede { color: var(--soft-200); } .page-hero--dark .eyebrow { color: var(--soft); } .page-hero--dark .eyebrow::before { background: var(--soft); }

/* Utilities */
.mt-0 { margin-top: 0 !important; } .mb-0 { margin-bottom: 0 !important; }
.mt-2 { margin-top: var(--space-2); } .mt-3 { margin-top: var(--space-3); } .mt-4 { margin-top: var(--space-4); }
.muted { color: var(--muted); }
.text-ink { color: var(--ink); }
.center { text-align: center; }
.hide-sm { display: none; } @media (min-width: 700px) { .hide-sm { display: initial; } }
.js-only { display: none; } html.js .js-only { display: initial; } html.js .js-only-block { display: block; } .js-only-block { display: none; }
html.js .no-js-only { display: none !important; }
