/* Reset, typography, RTL, focus, scrollbars and small utilities. */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 22px;
  font-weight: 400;
  font-feature-settings: normal;
  direction: rtl;
  text-align: start;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled, [aria-disabled="true"] { cursor: not-allowed; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
table { border-collapse: collapse; width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 0; }

h1 { font-size: 22px; line-height: 30px; font-weight: 700; letter-spacing: 0; }
h2 { font-size: 18px; line-height: 26px; font-weight: 650; }
h3 { font-size: 15px; line-height: 22px; font-weight: 650; }
.display { font-size: 28px; line-height: 36px; font-weight: 700; }
.small { font-size: 13px; line-height: 20px; }
.micro { font-size: 12px; line-height: 16px; font-weight: 500; }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.muted { color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; }
.mono, code, kbd { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.break { overflow-wrap: anywhere; }
.center { text-align: center; }
.danger-text { color: var(--danger-text); }
.success-text { color: var(--success-text); }
.warning-text { color: var(--warning-text); }
.primary-text { color: var(--primary-text); }

/* focus: visible for keyboard users only */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

::selection { background: var(--primary-soft); color: var(--text); }

[hidden] { display: none !important; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed;
  inset-block-start: 8px;
  inset-inline-start: 8px;
  z-index: 100;
  transform: translateY(-200%);
  background: var(--surface);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  transition: transform var(--dur-fast) var(--ease);
}
.skip-link:focus { transform: none; }

/* layout helpers */
.stack { display: flex; flex-direction: column; gap: var(--sp-5); min-width: 0; }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.row { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.row-wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.between { justify-content: space-between; }
.gap-sm { gap: var(--sp-2); }
.gap-lg { gap: var(--sp-5); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-5); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-5); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-5); }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
}

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