/* =====================================================================
   base.css — reset, RTL-first typography, accessible defaults
   Uses logical properties throughout (margin-inline, padding-inline,
   border-start/end) so the app never needs a mirrored LTR stylesheet.
   ===================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ar);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  color: var(--text-primary);
  background: var(--bg-page);
  direction: rtl;
  text-align: start;
  overflow-x: hidden;
}

/* Latin/mixed content (names, emails, receipt numbers) reads LTR inline
   even inside an RTL document (§104). Apply this class explicitly. */
.ltr-inline {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}
.numeric-input {
  direction: ltr;
  text-align: right;
  unicode-bidi: plaintext;
}

input[type="date"].numeric-input {
  text-align: right;
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0 0 var(--sp-3);
  font-weight: 600;
  color: var(--text-primary);
  line-height: var(--lh-tight);
}
h1 {
  font-size: var(--fs-h1);
}
h2 {
  font-size: var(--fs-h2);
}
h3 {
  font-size: var(--fs-h3);
}
h4 {
  font-size: var(--fs-h4);
}

p {
  margin: 0 0 var(--sp-3);
}
ul,
ol {
  margin: 0 0 var(--sp-3);
  padding-inline-start: var(--sp-5);
}

a {
  color: var(--c-blue);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

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

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

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* Visible keyboard focus everywhere — never suppressed (§77 accessibility) */
:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) {
  outline: none;
}

/* Screen-reader-only utility */
.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-to-content link (§77) */
.skip-link {
  position: absolute;
  inset-inline-start: -999px;
  top: 0;
  background: var(--c-ink);
  color: #fff;
  padding: var(--sp-2) var(--sp-4);
  z-index: 1000;
  border-radius: 0 0 var(--radius-md) 0;
}
.skip-link:focus {
  inset-inline-start: 0;
}

/* Wide content (tables, code) scrolls in its own box, page never scrolls
   sideways (§72 weak network / small screens) */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

hr {
  border: none;
  border-top: 1px solid var(--border-default);
  margin: var(--sp-5) 0;
}

::selection {
  background: var(--c-blue);
  color: #fff;
}
