/* ════════════════════════════════════════════════════════════════════
   CFS PRO — BASE
   Reset, typography, RTL primitives, scrollbar, selection.
   ════════════════════════════════════════════════════════════════════ */

/* ── RESET ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  color-scheme: light;
}
[data-theme="dark"] { color-scheme: dark; }

html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  line-height: var(--lh-norm);
  font-weight: var(--fw-reg);
  font-feature-settings: "ss01", "cv11", "kern" 1, "calt" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  overflow-x: hidden;
  direction: rtl;
}

img, svg, video, canvas, audio, iframe, embed, object {
  display: block;
  max-width: 100%;
}

svg { fill: currentColor; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
input, textarea, select { font-family: var(--font-sans); }
input[type="number"], input.mono { font-family: var(--font-mono); }
textarea { resize: vertical; }

a {
  color: var(--text-link);
  text-decoration: none;
  text-underline-offset: 3px;
  transition: color var(--d-2) var(--ease-out);
}
a:hover { text-decoration: underline; }

ul, ol { list-style: none; }

table { border-collapse: collapse; border-spacing: 0; width: 100%; }

hr {
  border: 0;
  height: 1px;
  background: var(--grad-hairline);
  margin: var(--s-4) 0;
}

[hidden] { display: none !important; }

/* ── TYPOGRAPHY SCALE ─────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--fw-sem);
  line-height: var(--lh-snug);
  letter-spacing: var(--tr-snug);
  color: var(--text-1);
  text-wrap: balance;
}

h1 { font-size: var(--fs-32); font-weight: var(--fw-bold); letter-spacing: var(--tr-tight); line-height: var(--lh-tight); }
h2 { font-size: var(--fs-24); font-weight: var(--fw-sem); letter-spacing: var(--tr-snug); }
h3 { font-size: var(--fs-20); font-weight: var(--fw-sem); }
h4 { font-size: var(--fs-16); font-weight: var(--fw-sem); }
h5 { font-size: var(--fs-14); font-weight: var(--fw-sem); }
h6 { font-size: var(--fs-12); font-weight: var(--fw-sem); text-transform: uppercase; letter-spacing: var(--tr-wide); color: var(--text-3); font-family: var(--font-mono); }

p { line-height: var(--lh-norm); text-wrap: pretty; }

.serif      { font-family: var(--font-serif); }
.display    { font-family: var(--font-display); }
.mono       { font-family: var(--font-mono); font-feature-settings: "tnum" 1, "zero" 1; letter-spacing: var(--tr-mono); }
.sans       { font-family: var(--font-sans); }

.num        { font-family: var(--font-mono); font-feature-settings: "tnum" 1, "zero" 1; font-variant-numeric: tabular-nums; }
.unit       { font-family: var(--font-mono); font-size: .85em; color: var(--text-3); margin-inline-start: 2px; }

.txt-1      { color: var(--text-1); }
.txt-2      { color: var(--text-2); }
.txt-3      { color: var(--text-3); }
.txt-accent { color: var(--accent); }
.txt-ok     { color: var(--ok-tx); }
.txt-warn   { color: var(--warn-tx); }
.txt-err    { color: var(--err-tx); }

.t-10 { font-size: var(--fs-10); }
.t-11 { font-size: var(--fs-11); }
.t-12 { font-size: var(--fs-12); }
.t-13 { font-size: var(--fs-13); }
.t-14 { font-size: var(--fs-14); }
.t-15 { font-size: var(--fs-15); }
.t-16 { font-size: var(--fs-16); }
.t-18 { font-size: var(--fs-18); }
.t-20 { font-size: var(--fs-20); }
.t-24 { font-size: var(--fs-24); }
.t-32 { font-size: var(--fs-32); }

.fw-reg  { font-weight: var(--fw-reg); }
.fw-med  { font-weight: var(--fw-med); }
.fw-sem  { font-weight: var(--fw-sem); }
.fw-bold { font-weight: var(--fw-bold); }

.up    { text-transform: uppercase; letter-spacing: var(--tr-wide); }
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-10);
  font-weight: var(--fw-sem);
  letter-spacing: var(--tr-wide);
  text-transform: uppercase;
  color: var(--text-3);
}

/* English / Latin runs inside RTL paragraphs should stay LTR */
.ltr, [lang="en"], .inci { direction: ltr; unicode-bidi: isolate; text-align: start; font-family: var(--font-mono); }
.rtl { direction: rtl; unicode-bidi: isolate; }

/* ── SELECTION ─────────────────────────────────────────────────── */
::selection {
  background: var(--accent-200);
  color: var(--ink-950);
}
[data-theme="dark"] ::selection {
  background: rgba(184,149,78,.35);
  color: var(--paper);
}

/* ── SCROLLBAR ─────────────────────────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
  border: 2px solid var(--bg);
  transition: background var(--d-2) var(--ease-out);
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
*::-webkit-scrollbar-corner { background: transparent; }

/* ── FOCUS RING (keyboard only) ────────────────────────────────── */
:focus { outline: none; }
:focus-visible {
  outline: none;
  box-shadow: var(--sh-focus);
  border-radius: var(--r-2);
  transition: box-shadow var(--d-1) var(--ease-out);
}
button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  z-index: var(--z-raised);
  position: relative;
}

/* ── ARIA / A11Y HELPERS ──────────────────────────────────────── */
.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;
}
[aria-busy="true"] { cursor: progress; }
[aria-disabled="true"], [disabled] { opacity: .55; cursor: not-allowed; }

/* ── PLACEHOLDER ──────────────────────────────────────────────── */
::placeholder { color: var(--text-3); opacity: 1; }

/* ── LAYOUT PRIMITIVES ────────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.row   { display: flex; align-items: center; gap: var(--s-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.grid  { display: grid; gap: var(--s-3); }
.center { display: flex; align-items: center; justify-content: center; }
.spacer { flex: 1; }
.gap-1 { gap: var(--s-1); }
.gap-2 { gap: var(--s-2); }
.gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); }
.gap-6 { gap: var(--s-6); }

.hide { display: none !important; }
@media (max-width: 768px) { .hide-md { display: none !important; } }
@media (max-width: 640px) { .hide-sm { display: none !important; } }
