/* ==========================================================================
   Base — reset, typography, utilities
   ========================================================================== */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
  background: var(--bg);
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Film grain over the whole site — subtle, never interactive */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background-image: var(--grain);
  opacity: 0.05;
  mix-blend-mode: overlay;
}

/* At least one screen tall: the footer starts below the fold, so content rendered after data
   arrives never pushes visible elements around (no layout shift). */
main {
  flex: 1 0 auto;
  display: block;
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100dvh - var(--header-h));
}

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

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: var(--lh-tight);
  color: var(--heading);
  letter-spacing: -0.01em;
  text-wrap: balance;
}
html[lang='ar'] h1,
html[lang='ar'] h2,
html[lang='ar'] h3 { font-weight: 700; letter-spacing: 0; line-height: 1.3; }
html[lang='ar'] h4, html[lang='ar'] h5, html[lang='ar'] h6 { font-family: var(--font-body); font-weight: 600; }

h1 { font-size: var(--fs-4xl); }
h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); font-family: var(--font-body); font-weight: 600; }

p { margin: 0 0 var(--sp-4); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}
a:hover { color: var(--heading); }
.link {
  color: var(--c-beige);
  text-decoration: underline;
  text-decoration-color: rgba(200, 186, 160, 0.4);
  text-underline-offset: 3px;
}
.link:hover { text-decoration-color: currentColor; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
.prose ul, .prose ol { padding-inline-start: 1.25em; margin-bottom: var(--sp-4); }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li { margin-bottom: var(--sp-2); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-8) 0; }
table { border-collapse: collapse; width: 100%; }
dialog { color: inherit; }
[hidden] { display: none !important; }

::selection { background: rgba(176, 40, 31, 0.55); color: #fff; }

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

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--c-ink-600) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--c-ink-600); border-radius: 10px; border: 2px solid var(--bg); }

/* Hide untranslated static text until i18n has run (fails open after 1.5s) */
html.i18n-pending [data-i18n] { animation: i18n-reveal 0s linear 1.5s forwards; visibility: hidden; }
@keyframes i18n-reveal { to { visibility: visible; } }

/* --------------------------------------------------------------- utilities */
.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--narrow { max-width: calc(var(--container-narrow) + var(--gutter) * 2); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 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: var(--sp-4);
  top: -100px;
  z-index: 10000;
  padding: var(--sp-3) var(--sp-5);
  background: var(--c-ivory);
  color: var(--c-ink-900);
  border-radius: var(--radius);
  font-weight: 600;
}
.skip-link:focus { top: var(--sp-4); }

.stack { display: flex; flex-direction: column; gap: var(--stack-gap, var(--sp-4)); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, var(--sp-3)); }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

.mono { font-family: var(--font-mono); letter-spacing: 0.02em; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-clamp-2, .line-clamp-3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.line-clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.line-clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }

/* Small uppercase investigative label */
.label {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: 500;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-muted);
}
html[lang='ar'] .label { font-family: var(--font-body); font-size: var(--fs-xs); text-transform: none; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--c-beige);
}
.eyebrow::before {
  content: '';
  width: 28px;
  height: 1px;
  background: var(--accent);
}
html[lang='ar'] .eyebrow { font-family: var(--font-body); font-size: var(--fs-sm); text-transform: none; letter-spacing: 0; }

/* Paper surface used for documents, how-it-works and legal pages */
.paper {
  color: var(--paper-ink);
  background-color: var(--c-paper);
  background-image: var(--paper-fibers), linear-gradient(180deg, #F1EADC 0%, var(--c-paper) 60%, var(--c-paper-2) 100%);
}
.paper h1, .paper h2, .paper h3, .paper h4 { color: #1D1915; }
.paper .muted { color: var(--paper-ink-muted); }
.paper .label { color: var(--paper-ink-muted); }
.paper .eyebrow { color: #7A2A20; }

.reveal { opacity: 0; transform: translateY(14px); transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out); }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}
