/* Reset and element defaults. Rule for ALL css files: use logical properties
   (inline-start/end, block-start/end) instead of left/right, so Arabic (RTL)
   works without a second stylesheet. */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-block-start: var(--header-height); }

body {
  margin: 0;
  min-block-size: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
}

main { flex: 1; }

img { max-inline-size: 100%; block-size: auto; display: block; }

/* The HTML `hidden` attribute must always win, even over classes that set display (like .btn). */
[hidden] { display: none !important; }

h1, h2, h3 { line-height: 1.2; color: var(--color-slate); margin-block: 0 var(--space-3); }
h1 { font-size: var(--text-hero); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
p { margin-block: 0 var(--space-3); }

a { color: var(--color-crimson); }
a:hover { color: var(--color-crimson-dark); }

:focus-visible { outline: 3px solid var(--color-crimson); outline-offset: 2px; }

.container { inline-size: min(100% - 2 * var(--space-3), var(--container)); margin-inline: auto; }

.visually-hidden {
  position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: absolute; inset-block-start: var(--space-2); inset-inline-start: var(--space-2);
  padding: var(--space-2) var(--space-3); background: var(--color-slate); color: #fff;
  border-radius: var(--radius); transform: translateY(-200%);
}
.skip-link:focus { transform: none; z-index: 100; }

.btn {
  display: inline-block; padding: var(--space-2) var(--space-4);
  background: var(--color-crimson); color: #fff; text-decoration: none; font-weight: 700;
  border: 0; border-radius: var(--radius); cursor: pointer; font-family: inherit; font-size: inherit;
}
.btn:hover { background: var(--color-crimson-dark); color: #fff; }
.btn--ghost { background: transparent; color: var(--color-slate); border: 2px solid var(--color-slate); }
.btn--ghost:hover { background: var(--color-slate); color: #fff; }

/* ---------- Shared building blocks ---------- */
.card { padding: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--color-bg); }

/* ---------- Arabic adjustments ---------- */
/* Letter-spacing breaks the joined letters of Arabic, so it is switched off. The brand
   name is marked lang="en" in the HTML, so it keeps its spacing. */
:lang(ar), :lang(ar) * { letter-spacing: normal; text-transform: none; }
/* Arabic letters are taller: give headings more line height so nothing is clipped. */
:lang(ar) h1, :lang(ar) h2, :lang(ar) h3 { line-height: 1.45; }

/* ---------- No flash of the wrong language ---------- */
/* A tiny script in each page's <head> adds .i18n-pending; i18n.js removes it as soon as the
   language is applied. The animation is a safety net: if scripts fail, the page appears after 2s. */
html.i18n-pending body { visibility: hidden; animation: i18n-reveal 0s 2s forwards; }
@keyframes i18n-reveal { to { visibility: visible; } }
