/* ===== BASE / RESET ===================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

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

body {
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  color: var(--stone-900);
  background: var(--paper);
  min-height: 100vh;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  /* A single word with nowhere to wrap (long compound words at large
     display font-sizes are the highest-risk case — confirmed cause of
     a 47px overflow on a legal-page heading) breaks instead of forcing
     layout past the viewport. overflow-x:hidden above already masked
     this as silently clipped/inaccessible content rather than visible
     scroll, which is worth fixing at the source either way. */
  overflow-wrap: break-word;
}

html[lang="ar"] body,
.rtl body { font-family: var(--font-body-ar); }

img, picture, svg { display: block; max-width: 100%; }
img { height: auto; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.01em;
  color: var(--stone-900);
}
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3, html[lang="ar"] h4,
.rtl h1, .rtl h2, .rtl h3, .rtl h4 {
  font-family: var(--font-display-ar);
  font-weight: 700;
  letter-spacing: 0;
}

h1 { font-size: var(--step-6); }
h2 { font-size: var(--step-4); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }

p { color: var(--stone-700); }

a { color: inherit; text-decoration: none; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
button { cursor: pointer; background: none; border: none; }

ul, ol { list-style: none; padding: 0; }

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

/* ----- Focus: visible everywhere, never suppressed ----- */
:focus-visible {
  outline: 2.5px solid var(--violet-500);
  outline-offset: 3px;
  border-radius: 4px;
}
a:focus-visible, button:focus-visible { outline-offset: 2px; }

/* ----- Selection ----- */
::selection { background: var(--gold-300); color: var(--stone-900); }

/* ----- Utility: visually hidden but accessible ----- */
.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;
}

.skip-link {
  position: fixed; top: -60px; left: var(--sp-4);
  background: var(--violet-700); color: #fff;
  padding: var(--sp-3) var(--sp-5); border-radius: var(--r-md);
  z-index: 9999; transition: top var(--dur-base) var(--ease);
  font-weight: 600;
}
.skip-link:focus { top: var(--sp-4); }

/* ----- Scrollbar (subtle, on-brand) ----- */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb { background: var(--stone-300); border-radius: 8px; border: 3px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: var(--violet-300); }
