/* app.css - self-hosted fonts, reset, typography, focus, motion, layout
   primitives. Logical properties only: physical left/right is a lint error.
   Depends on tokens.css. */

/* ---------- self-hosted fonts (no runtime CDN) ---------- */
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/vazirmatn/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/vazirmatn/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/vazirmatn/Vazirmatn-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/vazirmatn/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter/inter-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter/inter-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter/inter-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter/inter-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/jetbrains-mono/jetbrains-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/jetbrains-mono/jetbrains-mono-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/jetbrains-mono/jetbrains-mono-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
* {
  margin: 0;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}
html:focus-within {
  scroll-behavior: smooth;
}
body {
  min-block-size: 100dvh;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: var(--lh-body);
  font-weight: var(--weight-regular);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img,
picture,
svg,
video,
canvas {
  display: block;
  max-inline-size: 100%;
}
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}
a {
  color: var(--c-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover {
  color: var(--c-primary-hover);
}
ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding: 0;
}
table {
  border-collapse: collapse;
}
[hidden] {
  display: none !important;
}

/* ---------- locale typography ---------- */
[lang="fa"] {
  --font-body: var(--font-fa);
  --lh-body: 1.85;
  --lh-body-sm: 1.75;
}
[lang="en"] {
  --font-body: var(--font-en);
  --lh-body: 1.65;
  --lh-body-sm: 1.6;
}
/* LTR islands: phone, cards, IBAN, national code, ISBN, URLs, emails, code */
bdi,
.iso-ltr,
code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}
.numeric {
  font-variant-numeric: tabular-nums;
}

/* ---------- headings ---------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: var(--lh-h2);
  font-weight: var(--weight-semibold);
  text-wrap: balance;
  overflow-wrap: break-word;
}
.h-display { font-size: var(--text-display); line-height: var(--lh-display); font-weight: var(--weight-bold); }
h1 { font-size: var(--text-h1); line-height: var(--lh-h1); font-weight: var(--weight-bold); }
h2 { font-size: var(--text-h2); line-height: var(--lh-h2); }
h3 { font-size: var(--text-h3); line-height: var(--lh-h3); }
h4 { font-size: var(--text-title); line-height: var(--lh-title); }
p { max-inline-size: var(--measure); }
.small { font-size: var(--text-body-sm); line-height: var(--lh-body-sm); }
.caption { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--c-text-3); }
.muted { color: var(--c-text-2); }
.strong { font-weight: var(--weight-semibold); }

/* ---------- focus ---------- */
:focus-visible {
  outline: var(--focus-width) solid var(--c-focus);
  outline-offset: var(--focus-offset);
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) {
  outline: none;
}
/* keep focused elements clear of sticky headers/bottom nav */
:target,
[tabindex="-1"]:focus {
  scroll-margin-block-start: calc(var(--topbar-h) + var(--space-4));
  scroll-margin-block-end: calc(var(--bottomnav-h) + var(--space-4));
}

/* ---------- skip link ---------- */
.skip-link {
  position: absolute;
  inset-block-start: -100%;
  inset-inline-start: var(--space-4);
  z-index: var(--z-top);
  background: var(--c-surface);
  color: var(--c-text);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  box-shadow: var(--e2);
  font-weight: var(--weight-semibold);
}
.skip-link:focus {
  inset-block-start: var(--space-2);
}

/* ---------- landmarks & layout ---------- */
.container {
  max-inline-size: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--space-4);
}
@media (min-width: 768px) {
  .container { padding-inline: var(--space-6); }
}
.stack > * + * { margin-block-start: var(--space-4); }
.stack-tight > * + * { margin-block-start: var(--space-2); }
.stack-loose > * + * { margin-block-start: var(--space-8); }
.ui-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.ui-row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.grid-stats { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .grid-stats { grid-template-columns: repeat(4, 1fr); }
}
.prose { max-inline-size: var(--measure); }
.prose > * + * { margin-block-start: var(--space-4); }
.prose h2, .prose h3 { margin-block-start: var(--space-8); }
.prose ul, .prose ol { padding-inline-start: var(--space-6); }
.prose blockquote {
  border-inline-start: 3px solid var(--c-border-strong);
  padding-inline-start: var(--space-4);
  color: var(--c-text-2);
}
.sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
/* long tokens never break prose but may break in code/IDs */
.overflow-anywhere { overflow-wrap: anywhere; }

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 200% text / 400% zoom safety ---------- */
@media (max-width: 480px) {
  .container { padding-inline: var(--space-3); }
}
