/* ==========================================================================================
   Base — element defaults, type, focus and the few helpers every page leans on.
   Logical properties only (inline-start / inline-end), so one rule serves English and Arabic.
   ========================================================================================== */

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  color: var(--c-text);
  background-color: var(--c-page);
  font-feature-settings: normal; /* the template turns "salt" on, which swaps Plex's a and g */
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Headings: one weight in both scripts. Plex Arabic's 600 matches Plex Sans's 600 in colour, so a
   title does not read heavier in one language than the other. No tracking on Arabic — it is a
   joined script, and letter-spacing tears the joins. */
h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6 {
  color: var(--c-text);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  margin-block: 0 var(--s-2);
  letter-spacing: 0;
}
h1, .h1 { font-size: var(--fs-xl); }
h2, .h2 { font-size: var(--fs-lg); }
h3, .h3 { font-size: var(--fs-md); }
h4, .h4 { font-size: var(--fs-md); }
h5, .h5 { font-size: var(--fs-md); }
h6, .h6 { font-size: var(--fs-base); }
html:lang(en) h1, html:lang(en) .h1 { letter-spacing: -0.012em; }

p { font-size: inherit; margin-block: 0 var(--s-3); }
small, .small { font-size: var(--fs-sm); }
b, strong { font-weight: var(--fw-semibold); }
hr { border: 0; border-block-start: 1px solid var(--c-border); opacity: 1; margin-block: var(--s-4); color: inherit; }
dt { font-weight: var(--fw-medium); }
dd { margin-inline-start: 0; }
ul, ol { padding-inline-start: 1.4em; }
label { color: var(--c-text); }

a { color: var(--c-brand-text); text-decoration: none; text-underline-offset: 0.2em; text-decoration-thickness: 1px; transition: color var(--t-fast) var(--ease); }
a:hover { color: var(--c-brand-text-hover); text-decoration: underline; }

/* Codes and ids are data, not prose: mono, isolated from the Arabic run they sit in. */
code, kbd, samp, pre { font-family: var(--font-mono); }
code,
.card .card-body code {
  unicode-bidi: isolate;
  display: inline;
  margin: 0;
  padding: 1px 5px;
  font-size: 0.9em;
  color: var(--c-text-2);
  background-color: var(--c-surface-3);
  border-radius: var(--r-xs);
  word-break: break-word;
}
pre { color: var(--c-text-2); background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--s-3); }
pre code { padding: 0; background: none; }

::selection { background: var(--brand-200); color: var(--ink-900); }
[data-pc-theme="dark"] ::selection { background: var(--brand-700); color: #fff; }

/* Focus — one visible ring, everywhere, keyboard only. */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }

/* Helpers */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip {
  position: fixed; inset-block-start: var(--s-2); inset-inline-start: var(--s-2); z-index: 1200;
  padding: var(--s-2) var(--s-4);
  color: var(--c-on-brand); background: var(--c-brand); border-radius: var(--r-md);
  font-weight: var(--fw-medium); box-shadow: var(--e-2);
  clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap;
}
.skip:focus { clip-path: none; width: auto; height: auto; color: var(--c-on-brand); text-decoration: none; }

/* Icons that point along the reading direction turn round with it. */
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
.ph { line-height: 1; }

/* Text utilities wear text-grade colours: the template's `.text-success` is the 3:1 mark green,
   and its RTL `.text-muted` is a hard-coded light-theme grey. The template writes every utility
   as `[data-pc-direction=…] .x { … !important }`, so these carry the same attribute to outrank it. */
[data-pc-direction] .text-muted { color: var(--c-muted) !important; }
[data-pc-direction] .text-body-secondary, [data-pc-direction] .text-secondary { color: var(--c-text-2) !important; }
[data-pc-direction] .text-success { color: var(--c-ok-text) !important; }
[data-pc-direction] .text-danger { color: var(--c-bad-text) !important; }
[data-pc-direction] .text-warning { color: var(--c-warn-text) !important; }
[data-pc-direction] .text-primary, [data-pc-direction] .link-primary { color: var(--c-brand-text) !important; }
[data-pc-direction] .link-secondary { color: var(--c-text-2) !important; text-decoration-color: var(--c-border-strong) !important; }
[data-pc-direction] .link-secondary:hover { color: var(--c-text) !important; }
[data-pc-direction] .fw-semibold { font-weight: var(--fw-semibold) !important; }
[data-pc-direction] .fw-normal { font-weight: var(--fw-regular) !important; }
[data-pc-direction] .fs-6 { font-size: var(--fs-md) !important; }
[data-pc-direction] .border-bottom { border-block-end: 1px solid var(--c-border) !important; }
[data-pc-direction] .shadow { box-shadow: var(--e-2) !important; }

/* A left-to-right run (an id, a timestamp) inside an Arabic page keeps its own direction but
   lines up with the column it sits in — otherwise an LTR cell hugs the wrong edge of its header. */
[dir="rtl"] main :is(td, th, dd, dt, p, div, li)[dir="ltr"] { text-align: right; }

/* Numbers that are read down a column line up; a lone figure keeps its natural widths. */
.table, .num, .facts dd, .kv dd, time { font-variant-numeric: tabular-nums lining-nums; }

/* Thin, quiet scrollbars on the things that scroll inside the page. */
.table-responsive, .side-nav { scrollbar-width: thin; scrollbar-color: var(--c-border-strong) transparent; }

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