/* ==========================================================================
   Innovation Hub — base.css
   Reset, document defaults, typography, icons, focus, helpers.
   Order of files: tokens.css → base.css → layout.css → components.css → pages.css
   Rules: logical properties only (inline/block, start/end) so Arabic mirrors
   by itself; colours only through --ih-* tokens; no IDs in selectors.
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: light;
  scroll-padding-block-start: calc(var(--ih-topbar) + 16px);
}
html[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ih-bg);
  color: var(--ih-text);
  font-family: var(--ih-font-sans);
  font-size: var(--ih-text-base);
  line-height: 1.43;
  font-feature-settings: "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Arabic: own font, one step larger, more line height */
html[lang="ar"] body { font-family: var(--ih-font-arabic); font-size: 15px; line-height: 1.6; }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; color: var(--ih-text); }
html[lang="ar"] :is(h1, h2, h3, h4, h5, h6) { letter-spacing: 0; line-height: 1.45; }
h1 { font-size: var(--ih-text-2xl); }
h2 { font-size: var(--ih-text-xl); }
h3 { font-size: var(--ih-text-lg); }
h4 { font-size: var(--ih-text-md); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
table { border-collapse: collapse; }
hr { border: 0; border-block-start: 1px solid var(--ih-border); margin: var(--ih-space-6) 0; }

a { color: var(--ih-link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

code, kbd, samp, pre { font-family: var(--ih-font-mono); font-size: 0.86em; }
code { background: var(--ih-surface-sunken); padding: 0.1em 0.4em; border-radius: var(--ih-radius-xs); }

::selection { background: var(--ih-purple-200); color: var(--ih-purple-950); }

:focus-visible { outline: 3px solid var(--ih-focus-ring); outline-offset: 2px; border-radius: var(--ih-radius-xs); }
:focus:not(:focus-visible) { outline: none; }

/* Numbers line up in tables, KPIs and money */
.num, td.num { font-variant-numeric: tabular-nums; } /* large standalone figures keep proportional digits */
/* Numbers, codes and Latin names inside Arabic text keep their own direction */
.ltr { direction: ltr; unicode-bidi: isolate; }

/* --------------------------------------------------------------------------
   Icons: <svg class="icon"><use href="assets/icons/icons.svg#name"/></svg>
   Directional icons (arrows, chevrons) get .icon-flip so they mirror in RTL.
   -------------------------------------------------------------------------- */
.icon {
  inline-size: 20px; block-size: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { inline-size: 16px; block-size: 16px; }
.icon-lg { inline-size: 24px; block-size: 24px; }
[dir="rtl"] .icon-flip { transform: scaleX(-1); }

/* --------------------------------------------------------------------------
   Helpers (kept small on purpose; layout belongs in layout.css)
   -------------------------------------------------------------------------- */
.sr-only {
  position: absolute !important; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; inset-inline-start: 16px; inset-block-start: -60px; z-index: 100;
  background: var(--ih-primary); color: var(--ih-text-on-brand); padding: 10px 16px; border-radius: var(--ih-radius-md);
  font-weight: 600; transition: inset-block-start var(--ih-duration-fast) var(--ih-ease);
}
.skip-link:focus { inset-block-start: 12px; text-decoration: none; }

.muted { color: var(--ih-text-muted); }
.subtle { color: var(--ih-text-subtle); }
.text-sm { font-size: var(--ih-text-sm); }
.text-xs { font-size: var(--ih-text-xs); }
.fw-600 { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-inline-size: 0; }
[hidden] { display: none !important; }

/* Until shared partials and the language are applied, hide the page to avoid a flash */
html.is-loading body { visibility: hidden; }

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