/* Fonts: self-hosted, SIL Open Font License (fonts/LICENSE-*.txt). */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Vazirmatn";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/vazirmatn-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

:root {
  --bg: #ffffff;
  --bg-subtle: #f6f7f9;
  --text: #0b0d12;
  --text-2: #424955;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --accent: #1d72b8;
  --accent-hover: #175f9a;
  --accent-soft: #e9f2fb;
  --on-accent: #ffffff;
  --bubble-out: #1d72b8;
  --on-bubble-out: #ffffff;
  --notice-bg: #fff8e6;
  --notice-border: #f0d58c;
  --notice-text: #5c4300;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.04), 0 12px 32px -12px rgb(16 24 40 / 0.18);
  --radius: 14px;
  --radius-sm: 10px;
  --container: 70rem;
  --prose: 44rem;
  --font: "Inter", "Vazirmatn", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0e15;
    --bg-subtle: #10151f;
    --text: #eef1f6;
    --text-2: #b4bccb;
    --muted: #8a93a3;
    --border: #1d2431;
    --border-strong: #2a3343;
    --accent: #5aa2f5;
    --accent-hover: #7bb5f7;
    --accent-soft: rgb(90 162 245 / 0.12);
    --on-accent: #06101f;
    --bubble-out: #2f7fd6;
    --on-bubble-out: #ffffff;
    --notice-bg: #221c0b;
    --notice-border: #574616;
    --notice-text: #f2d995;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 16px 40px -16px rgb(0 0 0 / 0.6);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
html[dir="rtl"] { font-size: 106.25%; }
[dir="rtl"] body { line-height: 1.9; font-feature-settings: normal; }

h1, h2, h3 { color: var(--text); letter-spacing: -0.02em; }
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3 { letter-spacing: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 0.18em; }

code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 0.08em 0.38em;
  border-radius: 6px;
  direction: ltr;
  unicode-bidi: isolate;
}
pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 1rem 1.1rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  direction: ltr;
  text-align: left;
  font-size: 0.9rem;
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; }

.container { max-width: var(--container); margin-inline: auto; padding-inline: 24px; }

.skip { position: absolute; inset-inline-start: -999px; }
.skip:focus { inset-inline-start: 16px; top: 8px; background: var(--bg); padding: 0.4rem 0.7rem; border-radius: 8px; z-index: 10; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.icon { width: 20px; height: 20px; flex: none; }

/* Header */
.site-header { border-bottom: 1px solid var(--border); }
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  min-height: 64px;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 650;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}
.brand:hover { color: var(--text); text-decoration: none; }
.brand img { border-radius: 8px; }
.nav { margin-inline-start: auto; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1.4rem; }
.nav a { color: var(--text-2); font-size: 0.94rem; font-weight: 500; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); text-decoration: none; }
.lang-switch {
  color: var(--text-2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.15rem 0.75rem;
  font-size: 0.86rem;
  font-weight: 500;
}
.lang-switch:hover { color: var(--text); background: var(--bg-subtle); text-decoration: none; }
.header-tools { display: flex; align-items: center; gap: 0.9rem; }
.icon-link { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--text-2); }
.icon-link:hover { color: var(--text); text-decoration: none; }
.header-tools .icon-link { padding: 0.25rem; margin: -0.25rem; border-radius: 8px; }

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.72rem 1.25rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  font-size: 0.97rem;
  border: 1px solid transparent;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.button:hover { background: var(--accent-hover); color: var(--on-accent); text-decoration: none; }
.button.secondary { background: transparent; color: var(--text); border-color: var(--border-strong); }
.button.secondary:hover { background: var(--bg-subtle); color: var(--text); }
.button .icon { width: 18px; height: 18px; }

/* Home: hero */
.hero { padding-block: 5.5rem 5rem; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 4rem; align-items: center; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 600;
  margin: 0 0 1.4rem;
}
.eyebrow .icon { width: 15px; height: 15px; }
.hero h1 {
  font-size: clamp(2.3rem, 4.6vw, 3.4rem);
  line-height: 1.06;
  letter-spacing: -0.035em;
  font-weight: 700;
  margin: 0 0 1.25rem;
}
[dir="rtl"] .hero h1 { line-height: 1.35; letter-spacing: 0; font-weight: 800; }
.hero .lead { font-size: 1.16rem; color: var(--text-2); margin: 0 0 2rem; max-width: 36rem; }
.hero .note { font-size: 0.88rem; color: var(--muted); margin: 1.25rem 0 0; }

/* Home: a chat drawn in HTML */
.preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  max-width: 400px;
  width: 100%;
  justify-self: end;
}
.preview-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  font-size: 1.2rem;
}
.preview-head strong { display: block; font-size: 0.95rem; line-height: 1.3; }
.preview-head span { font-size: 0.8rem; color: var(--muted); }
.preview-body { padding: 1.2rem 1.1rem 1rem; display: grid; gap: 0.6rem; background: var(--bg-subtle); }
.bubble {
  max-width: 85%;
  padding: 0.55rem 0.85rem;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0;
}
.bubble.in { background: var(--bg); border: 1px solid var(--border); justify-self: start; border-end-start-radius: 6px; }
.bubble.out { background: var(--bubble-out); color: var(--on-bubble-out); justify-self: end; border-end-end-radius: 6px; }
.preview-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.preview-foot .icon { width: 14px; height: 14px; }

/* Home: sections */
.section { padding-block: 5rem; border-top: 1px solid var(--border); }
.section-head { max-width: 40rem; margin-bottom: 2.75rem; }
.section-head .label { font-size: 0.8rem; font-weight: 600; color: var(--accent); margin: 0 0 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
[dir="rtl"] .section-head .label { text-transform: none; letter-spacing: 0; font-size: 0.9rem; }
.section h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); line-height: 1.2; margin: 0 0 0.8rem; font-weight: 700; }
[dir="rtl"] .section h2 { line-height: 1.5; }
.section-head p { color: var(--text-2); margin: 0; font-size: 1.05rem; }
.section.section-cta { border-top: 0; padding-top: 0; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2rem; counter-reset: step; }
.steps li { counter-increment: step; }
.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  font-weight: 650;
  font-size: 0.92rem;
  margin-bottom: 1rem;
}
[dir="rtl"] .steps li::before { content: counter(step, persian); }
.steps h3, .feature h3, .card h3 { font-size: 1.05rem; margin: 0 0 0.35rem; font-weight: 650; letter-spacing: -0.01em; }
[dir="rtl"] .steps h3, [dir="rtl"] .feature h3, [dir="rtl"] .card h3 { letter-spacing: 0; }
.steps p, .feature p, .card p { margin: 0; color: var(--text-2); font-size: 0.96rem; }
.steps strong { color: var(--text); font-weight: 600; white-space: nowrap; }
.section-note { margin: 2.5rem 0 0; color: var(--muted); font-size: 0.92rem; }

.features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.feature { background: var(--bg); padding: 1.75rem 1.6rem; }
.feature-icon {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 1.1rem;
}

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem; }

.cta {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}
.cta h2 { margin: 0 0 0.5rem; }
.cta p { margin: 0; color: var(--text-2); max-width: 34rem; }

/* Pages */
.page { max-width: var(--prose); margin-inline: auto; padding: 4rem 24px 5rem; }
.page-head { margin-bottom: 2.5rem; padding-bottom: 2rem; border-bottom: 1px solid var(--border); }
.page-head h1 { font-size: clamp(2rem, 4vw, 2.6rem); line-height: 1.12; letter-spacing: -0.03em; margin: 0 0 0.75rem; font-weight: 700; }
[dir="rtl"] .page-head h1 { line-height: 1.4; letter-spacing: 0; }
.page-head .description { font-size: 1.12rem; color: var(--text-2); margin: 0; }
.page-head .meta { font-size: 0.86rem; color: var(--muted); margin: 1rem 0 0; }

.prose { color: var(--text-2); }
.prose strong { color: var(--text); font-weight: 600; }
.prose h2 { font-size: 1.4rem; line-height: 1.3; margin: 2.75rem 0 0.75rem; font-weight: 650; }
.prose h3 { font-size: 1.1rem; margin: 2rem 0 0.5rem; font-weight: 650; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.1rem; }
.prose ul, .prose ol { padding-inline-start: 1.3rem; }
.prose li { margin-block: 0.35rem; }
.prose li::marker { color: var(--muted); }
[dir="rtl"] .prose ol { list-style-type: persian; }
.prose table { border-collapse: collapse; width: 100%; margin: 1.25rem 0 1.75rem; font-size: 0.9rem; line-height: 1.55; }
.prose th, .prose td { border-bottom: 1px solid var(--border); padding: 0.75rem 0.6rem; text-align: start; vertical-align: top; }
.prose thead th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; border-bottom-color: var(--border-strong); }
[dir="rtl"] .prose thead th { text-transform: none; letter-spacing: 0; font-size: 0.88rem; }
.prose td:first-child { color: var(--text); }

table.official { border: 1px solid var(--border); border-radius: var(--radius); border-collapse: separate; border-spacing: 0; overflow: hidden; }
table.official th { width: 34%; font-weight: 500; color: var(--muted); background: var(--bg-subtle); font-size: 0.88rem; }
table.official th, table.official td { padding: 0.85rem 1rem; }
table.official tr:last-child th, table.official tr:last-child td { border-bottom: 0; }
table.official code { background: none; border: 0; padding: 0; font-size: 0.84rem; color: var(--text); display: inline-block; text-align: left; }
table.official a code { color: inherit; }
table.official .lines { display: grid; justify-items: start; gap: 0.3rem; }
table.official .hint { font-size: 0.82rem; color: var(--muted); }
.wrap-anywhere { overflow-wrap: anywhere; }

.notice {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  color: var(--notice-text);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 0.93rem;
  margin: 0 0 2rem;
}
.notice p { margin: 0; }
.notice .icon { margin-top: 0.2rem; }

.prose .checks { list-style: none; padding: 0; margin: 1.25rem 0 1.75rem; display: grid; gap: 0.75rem; }
.prose .checks li { margin: 0; }
.check { display: flex; gap: 0.8rem; align-items: flex-start; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.9rem 1rem; }
.check > .icon { margin-top: 0.15rem; }
.check-passed > .icon { color: var(--accent); }
.check-failed > .icon, .check-error > .icon { color: var(--notice-text); }
.check-failed { border-color: var(--notice-border); background: var(--notice-bg); }
.check p { margin: 0; }
.check-head { color: var(--text); }
.check-head strong { font-weight: 650; }
.check-meta { font-size: 0.86rem; color: var(--muted); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); }
.footer-grid { display: grid; grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)); gap: 2rem; padding-block: 3.5rem 2.5rem; }
.footer-brand p { color: var(--muted); font-size: 0.9rem; margin: 0.9rem 0 0; max-width: 20rem; }
.footer-github { margin-top: 1.1rem; font-size: 0.88rem; color: var(--muted); }
.footer-github span:not(.visually-hidden) { direction: ltr; unicode-bidi: isolate; }
.footer-col h2 { font-size: 0.85rem; font-weight: 600; color: var(--text); margin: 0 0 0.8rem; letter-spacing: 0; }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.footer-col a { color: var(--muted); font-size: 0.9rem; }
.footer-col a:hover { color: var(--text); text-decoration: none; }
.footer-bottom { border-top: 1px solid var(--border); padding-block: 1.4rem; font-size: 0.84rem; color: var(--muted); }
.footer-bottom p { margin: 0; }

/* Smaller screens */
@media (max-width: 900px) {
  .hero { padding-block: 3.5rem; }
  .hero-grid { grid-template-columns: 1fr; gap: 3rem; }
  .preview { justify-self: start; }
  .features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .container { padding-inline: 16px; }
  .page { padding: 2.5rem 16px 4rem; }
  .section { padding-block: 3.5rem; }
  .steps { grid-template-columns: 1fr; gap: 1.75rem; }
  .features { grid-template-columns: 1fr; }
  .cta { padding: 2rem 1.5rem; }
  .actions { width: 100%; }
  .actions .button { flex: 1 1 auto; justify-content: center; }
  .header-row { padding-block: 0.75rem; row-gap: 0.6rem; }
  .header-tools { order: 2; margin-inline-start: auto; }
  .nav { order: 3; width: 100%; margin-inline-start: 0; }
  .nav ul { gap: 0.25rem 1.1rem; }
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  table.official, table.official tbody { display: block; width: 100%; }
  table.official code { overflow-wrap: anywhere; word-break: break-word; }
  table.official th, table.official td { display: block; width: auto; border: 0; }
  table.official th { padding-bottom: 0.1rem; background: none; }
  table.official td { padding-top: 0; }
  table.official tr { display: block; border-bottom: 1px solid var(--border); }
  table.official tr:last-child { border-bottom: 0; }

  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: auto; }
  table.stack tr { border-bottom: 1px solid var(--border); padding-block: 0.75rem; }
  table.stack td { border: 0; padding: 0.15rem 0; }
  table.stack td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  [dir="rtl"] table.stack td::before { text-transform: none; letter-spacing: 0; font-size: 0.84rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
