/* ==========================================================================
   base.css — reset, typography, layout primitives, small utility layer
   All values come from tokens.css. Logical properties only (RTL-safe).
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  border-color: var(--border);
}

* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in oklab, var(--muted-foreground) 40%, transparent) transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  background: var(--background);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.65;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

html[lang="ar"] body {
  font-family: var(--font-arabic);
  line-height: 1.8;
  letter-spacing: 0;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

html[lang="ar"] h1,
html[lang="ar"] h2,
html[lang="ar"] h3 {
  letter-spacing: 0;
  line-height: 1.35;
}

p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; list-style: none; }
figure, blockquote { margin: 0; }
img, svg, canvas, video { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }
summary { cursor: pointer; }
hr { border: 0; border-top: 1px solid var(--border); margin: 0; }
[hidden] { display: none !important; }

::selection {
  background: color-mix(in oklab, var(--primary) 26%, transparent);
  color: var(--foreground);
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: color-mix(in oklab, var(--muted-foreground) 32%, transparent);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: color-mix(in oklab, var(--muted-foreground) 55%, transparent);
  background-clip: content-box;
}

.tabular-nums { font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.skip-link {
  position: fixed;
  inset-block-start: -100px;
  inset-inline-start: 1rem;
  z-index: 200;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 600;
  transition: inset-block-start 0.15s ease;
}
.skip-link:focus { inset-block-start: 1rem; }

/* ---------------------------------------------------------------- layout */
.container {
  width: 100%;
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: 1rem;
}
@media (min-width: 768px) { .container { padding-inline: 1.75rem; } }
@media (min-width: 1280px) { .container { padding-inline: 2rem; } }

.container-wide { max-width: 1480px; }

.section { padding-block: 2.5rem; }
.section-sm { padding-block: 1.5rem; }
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-block-end: 1.25rem;
  flex-wrap: wrap;
}
.section-title { font-size: 1.2rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.section-desc { color: var(--muted-foreground); font-size: 0.85rem; }

.rule { height: 1px; background: var(--border); }

.stack { display: grid; gap: 1rem; }

/* ------------------------------------------------------------- utilities */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.block { display: block; }
.inline-block { display: inline-block; }
.hidden { display: none !important; }
.relative { position: relative; }
.absolute { position: absolute; }
.sticky { position: sticky; }
.fixed { position: fixed; }
.overflow-hidden { overflow: hidden; }
.isolate { isolation: isolate; }

.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.items-baseline { align-items: baseline; }
.items-stretch { align-items: stretch; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.self-start { align-self: flex-start; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0%; }
.min-w-0 { min-width: 0; }
.w-full { width: 100%; }
.h-full { height: 100%; }

.gap-1 { gap: 0.25rem; }
.gap-1\.5 { gap: 0.375rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-5 { gap: 1.25rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

.mt-1 { margin-block-start: 0.25rem; }
.mt-2 { margin-block-start: 0.5rem; }
.mt-3 { margin-block-start: 0.75rem; }
.mt-4 { margin-block-start: 1rem; }
.mt-6 { margin-block-start: 1.5rem; }
.mt-8 { margin-block-start: 2rem; }
.mb-1 { margin-block-end: 0.25rem; }
.mb-2 { margin-block-end: 0.5rem; }
.mb-3 { margin-block-end: 0.75rem; }
.mb-4 { margin-block-end: 1rem; }
.mb-6 { margin-block-end: 1.5rem; }
.mb-8 { margin-block-end: 2rem; }
.mx-auto { margin-inline: auto; }

.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.ps-1 { padding-inline-start: 0.25rem; }
.ps-2 { padding-inline-start: 0.5rem; }
.ps-3 { padding-inline-start: 0.75rem; }
.ps-4 { padding-inline-start: 1rem; }
.pe-2 { padding-inline-end: 0.5rem; }
.pe-3 { padding-inline-end: 0.75rem; }
.pe-4 { padding-inline-end: 1rem; }

.text-xs { font-size: 0.75rem; line-height: 1.45; }
.text-sm { font-size: 0.8125rem; line-height: 1.55; }
.text-base { font-size: 0.9375rem; }
.text-lg { font-size: 1.0625rem; line-height: 1.5; }
.text-xl { font-size: 1.25rem; line-height: 1.35; }
.text-2xl { font-size: 1.5rem; line-height: 1.25; }
.text-3xl { font-size: 1.875rem; line-height: 1.15; }
.text-4xl { font-size: 2.25rem; line-height: 1.05; }
.text-5xl { font-size: 3rem; line-height: 1; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }
.text-muted { color: var(--muted-foreground); }
.text-primary { color: var(--primary); }
.text-destructive { color: var(--destructive); }
.text-center { text-align: center; }
.text-start { text-align: start; }
.text-end { text-align: end; }
.uppercase { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.06em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leading-tight { line-height: 1.25; }
.whitespace-nowrap { white-space: nowrap; }

.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-2xl { border-radius: var(--radius-2xl); }
.rounded-full { border-radius: 999px; }
.border { border: 1px solid var(--border); }
.border-b { border-block-end: 1px solid var(--border); }
.border-t { border-block-start: 1px solid var(--border); }

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

.muted-surface {
  background: var(--muted);
  border-radius: var(--radius-lg);
}

/* responsive helper grid */
.grid-auto {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
}
.grid-auto-sm { grid-template-columns: repeat(auto-fill, minmax(min(100%, 10.5rem), 1fr)); }

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