/* ==========================================================================
   Base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

body {
  background-color: var(--ink-900);
  color: var(--ink-fg-soft);
  font-family: var(--font-text);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, picture, svg, video { display: block; max-width: 100%; }
img { height: auto; }

input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
ul, ol { list-style: none; padding: 0; }

a { color: inherit; text-decoration: none; transition: color var(--dur-fast) var(--ease); }

/* ---- Headings ------------------------------------------------------------
   Every display-sized heading takes the kufi face; body-sized headings stay
   in the text face so they read as part of the paragraph flow. */

h1, h2, h3, h4 { color: var(--ink-fg); font-weight: 600; line-height: var(--lh-display); }

.display,
h1, h2 {
  font-family: var(--font-display);
  font-weight: 700;
  text-wrap: balance;
}

h3 { font-family: var(--font-text); font-size: var(--fs-h3); font-weight: 600; line-height: 1.5; }

p { text-wrap: pretty; }

/* ---- Focus ---------------------------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

:focus:not(:focus-visible) { outline: none; }

/* ---- Layout --------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---- Light chapters --------------------------------------------------------
   Inverting the text colours in one place keeps every component that lands on
   bone readable without each one re-declaring its own palette. */

.on-bone {
  background-color: var(--bone-100);
  color: var(--bone-fg-soft);
}

.on-bone h1, .on-bone h2, .on-bone h3, .on-bone h4 { color: var(--bone-fg); }

/* ---- Small caps label ------------------------------------------------------
   The one place tracking is used: these are set in the text face at a size
   where Arabic letters no longer need to look joined. */

.label {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-text);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: var(--track-label);
  color: var(--ink-fg-dim);
}

.on-bone .label { color: var(--bone-fg-dim); }

.label::before {
  content: "";
  width: 1.75rem;
  height: 1px;
  background-color: currentColor;
  opacity: 0.6;
}

.label--accent { color: var(--accent); }
.on-bone .label--accent { color: var(--accent-ink); }

/* ---- Accessibility helpers -------------------------------------------------- */

.skip-link {
  position: absolute;
  inset-inline-start: 50%;
  top: var(--space-3);
  z-index: 1000;
  translate: 50% -250%;
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: #04130b;
  font-weight: 600;
  transition: translate var(--dur-mid) var(--ease);
}

.skip-link:focus-visible { translate: 50% 0; }

/* Latin runs (phone numbers, emails, years) inside Arabic copy.
   This sets `direction`, so never put logical inset/border properties on the
   same element — they would resolve LTR. Leaf text nodes only. */
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
  font-feature-settings: "tnum";
}
