/* Obzio Academy base styles: layer order, the font face, reset, element defaults and utilities.
 * Semantic and component tokens from tokens.css only, never --ref-* primitives or raw px, rem, ms or colour
 * values, and logical properties only (rtl-rules.md R-02 to R-05); css-lint.test.ts enforces both. Exceptions
 * carry an ALLOW-LIST comment with the reason. Served from a content-hashed URL (ADR-PLAT-01).
 * Layers (ADR-PLAT-02 §2): reset < base < components (components.css) < utilities, so a utility class always wins
 * and unlayered page CSS from other lanes overrides all of them. */
@layer reset, base, components, utilities;

/* Noto Sans Arabic, variable 400 to 700, for Arabic code points only: digits, Latin and IDs fall through the token
 * stacks to the Latin face, so a mixed line shows one set of digits (ADR-PLAT-02 §5). */
@font-face {
  font-family: "Noto Sans Arabic";
  src: url("/fonts/NotoSansArabic-wght.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFF;
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }
  body { margin: 0; }
  h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
  button, input, select, textarea { font: inherit; color: inherit; }
  button { cursor: pointer; background: none; border: 0; padding: 0; }
  fieldset { min-inline-size: 0; margin: 0; padding: 0; border: 0; }
  legend { padding: 0; }
  svg { flex-shrink: 0; }
  img, video { max-inline-size: 100%; block-size: auto; }
  [hidden] { display: none !important; }
}

@layer base {
  html {
    scrollbar-color: var(--color-border-strong) transparent;
    /* A focused or scrolled-to element stays clear of the sticky top bar and the fixed bottom bars. */
    scroll-padding-block: calc(var(--topbar-height) + var(--space-2)) calc(var(--bottom-nav-height) + var(--space-4));
  }
  html:has(.sticky-actions) { scroll-padding-block-end: var(--action-bar-clearance); }
  body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--text-body);
    line-height: var(--lh-body);
    font-weight: var(--weight-regular);
    font-synthesis: none;
    -webkit-font-smoothing: antialiased;
    /* At 200% text a word wider than its column breaks instead of spilling out of it. */
    overflow-wrap: break-word;
  }
  h1, h2, h3 { text-wrap: balance; }
  /* Arabic has no italic (R-16): emphasis is carried by weight. */
  :lang(ar) :is(em, i, cite, dfn, var) { font-style: normal; }
  :lang(ar) em { font-weight: var(--weight-semibold); }
  a { color: var(--color-primary); text-decoration-thickness: var(--border-width); text-underline-offset: 0.3em; }
  a:hover { color: var(--color-primary-hover); }
  a, button, input, label, select, summary, textarea { touch-action: manipulation; }
  input, textarea { caret-color: var(--color-primary); }
  :focus-visible { outline: var(--focus-ring-width) solid var(--color-focus); outline-offset: var(--focus-ring-offset); }
  ::selection { background: color-mix(in srgb, var(--color-primary) 22%, transparent); }
  hr { block-size: var(--border-width); margin-block: var(--space-6); border: 0; background: var(--color-border); }
  main { display: block; }
  main:focus { outline: none; }
  @media (min-width: 1024px) { html { scroll-padding-block: var(--space-6); } }
}

@layer utilities {
  /* ALLOW-LIST (tokens): the standard 1px visually-hidden box. */
  .visually-hidden, .skip-link:not(:focus) { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

  /* ---------- Bidi helpers (R-07, R-08, R-11) ---------- */
  .ltr { direction: ltr; unicode-bidi: isolate; font-family: var(--font-latin); }
  .n { font-family: var(--font-numeric); font-variant-numeric: lining-nums proportional-nums; direction: ltr; unicode-bidi: isolate; }
  td .n, .tabular { font-variant-numeric: lining-nums tabular-nums; }
  .id {
    display: inline-block;
    direction: ltr;
    unicode-bidi: isolate;
    font-family: var(--font-latin);
    font-size: var(--text-latin-sm);
    line-height: 1.45;
    font-weight: var(--weight-latin-medium);
    color: var(--color-text-muted);
    background: var(--color-surface-sunken);
    border-radius: var(--radius-xs);
    padding-inline: var(--space-1-5);
    white-space: nowrap;
    vertical-align: 0.08em;
  }
  .term { font-family: var(--font-latin); direction: ltr; unicode-bidi: isolate; }
  .untranslated { text-decoration: underline dotted var(--color-text-muted); }
  .nobr { white-space: nowrap; }

  /* ---------- Type ---------- */
  .t-display { font-size: var(--text-display); line-height: var(--lh-display); font-weight: var(--weight-semibold); }
  .t-h1 { font-size: var(--text-h1); line-height: var(--lh-h1); font-weight: var(--weight-semibold); }
  .t-h2 { font-size: var(--text-h2); line-height: var(--lh-h2); font-weight: var(--weight-semibold); }
  .t-h3 { font-size: var(--text-h3); line-height: var(--lh-h3); font-weight: var(--weight-semibold); }
  .t-body-lg { font-size: var(--text-body-lg); line-height: var(--lh-body-lg); }
  .t-body { font-size: var(--text-body); line-height: var(--lh-body); }
  .t-label { font-size: var(--text-label); line-height: var(--lh-label); font-weight: var(--weight-medium); }
  .t-caption { font-size: var(--text-caption); line-height: var(--lh-caption); }
  .muted { color: var(--color-text-muted); }
  .strong { font-weight: var(--weight-semibold); }
  .reading { max-inline-size: var(--reading-max); }

  /* ---------- Layout ---------- */
  .stack > * + * { margin-block-start: var(--space-4); }
  .stack-sm > * + * { margin-block-start: var(--space-2); }
  .stack-lg > * + * { margin-block-start: var(--space-6); }
  .row { display: flex; align-items: center; gap: var(--space-2); }
  .row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
  .grow { flex: 1; min-inline-size: 0; }
  .spacer { flex: 1; }
  @media (max-width: 1023.98px) { .desktop-only { display: none !important; } }
  @media (min-width: 1024px) { .mobile-only { display: none !important; } }
}
