/* ==========================================================================
   base.css — reset, document defaults, typography, layout primitives
   Replaces Bootstrap's reset + grid + utilities (~228KB) with the ~5% of it
   this site actually used. Everything here uses CSS logical properties so
   RTL needs no separate stylesheet.
   ========================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-block-start: calc(var(--header-height) + var(--space-4));
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color var(--duration-base) var(--ease-in-out),
              color var(--duration-base) var(--ease-in-out);
}

:lang(ar) body { font-family: var(--font-arabic); }

img, svg, video, canvas { display: block; max-width: 100%; height: auto; }

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

button { background: none; border: none; padding: 0; cursor: pointer; }

a { color: var(--accent-text); text-decoration: none; }

ul, ol { list-style: none; padding: 0; }

:target { scroll-margin-block-start: calc(var(--header-height) + var(--space-6)); }

/* Hide content until the theme + language are applied, so there's no flash of
   wrong-theme or untranslated content. Removed by app.js on boot. A <noscript>
   rule in the document re-reveals it if JS never runs. */
html.is-booting body { visibility: hidden; }

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */
h1, h2, h3, h4 {
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

h1 { font-size: var(--text-4xl); font-weight: var(--weight-black); letter-spacing: var(--tracking-tighter); }
h2 { font-size: var(--text-3xl); font-weight: var(--weight-black); letter-spacing: var(--tracking-tighter); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p { text-wrap: pretty; }

/* Arabic needs more leading and no negative tracking — the letterforms
   connect, so tightening them degrades legibility. */
:lang(ar) h1,
:lang(ar) h2,
:lang(ar) h3,
:lang(ar) h4 {
  letter-spacing: var(--tracking-normal);
  line-height: var(--leading-snug);
}

.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

/* Latin-script strings (tech names, emails, URLs) rendered inside the Arabic
   RTL flow get reordered by the bidi algorithm — ".NET Developer" renders as
   "NET Developer.". `plaintext` resolves each element's direction from its own
   first strong character instead of the ambient one. */
.bidi-auto { unicode-bidi: plaintext; }

/* Digits/symbols have no strong directional character at all, so `plaintext`
   has nothing to resolve and falls back to the ambient RTL. Phone numbers must
   be forced LTR explicitly. */
.bidi-ltr { direction: ltr; unicode-bidi: isolate; }

/* --------------------------------------------------------------------------
   Layout primitives
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

.container-narrow { max-width: var(--container-narrow); }

.section { padding-block: var(--section-gap); position: relative; }
.section-subtle { background-color: var(--bg-subtle); }

.stack { display: flex; flex-direction: column; }
.stack-2 { gap: var(--space-2); }
.stack-3 { gap: var(--space-3); }
.stack-4 { gap: var(--space-4); }
.stack-5 { gap: var(--space-5); }
.stack-6 { gap: var(--space-6); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}
.cluster-2 { gap: var(--space-2); }
.cluster-4 { gap: var(--space-4); }

/* Auto-fitting card grid. `--col-min` sets the smallest a column may get
   before the grid drops one — no breakpoint soup, no col-md-6 col-lg-4. */
.grid {
  display: grid;
  gap: var(--grid-gap, var(--space-5));
  grid-template-columns: repeat(auto-fit, minmax(min(var(--col-min, 18rem), 100%), 1fr));
}

/* Explicit two-column split for editorial sections (about, timelines). */
.split {
  display: grid;
  gap: clamp(var(--space-6), 4vw, var(--space-9));
  align-items: start;
}
@media (min-width: 60rem) {
  .split { grid-template-columns: var(--split, 1fr 1fr); }
  .split-sticky > :first-child { position: sticky; top: calc(var(--header-height) + var(--space-6)); }
}

.flow > * + * { margin-block-start: var(--flow-space, var(--space-4)); }

/* --------------------------------------------------------------------------
   Accessibility helpers
   -------------------------------------------------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* A visible, high-contrast focus ring on every interactive element. Uses
   :focus-visible so it appears for keyboard users without adding a ring to
   every mouse click. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* #main only receives focus programmatically (skip link, back-to-top). It's a
   scroll target, not a control, so a ring around the whole page would be
   noise — the destination heading is the visible cue. */
main:focus { outline: none; }

.skip-link {
  position: absolute;
  inset-block-start: var(--space-3);
  inset-inline-start: var(--space-3);
  z-index: 200;
  transform: translateY(-200%);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: var(--weight-semibold);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  transition: transform var(--duration-fast) var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(0); }

/* --------------------------------------------------------------------------
   Motion preferences
   Honours the OS-level "reduce motion" setting: kills transitions, scroll
   animation, and the decorative background motion, while leaving all content
   visible (reveal animations resolve to their end state via .is-revealed
   being applied immediately in JS).
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

::selection { background: var(--accent); color: var(--accent-contrast); }
