/* ==========================================================================
   AL HAJAR — site stylesheet
   Tokens follow the Al Hajar brand guide v1.0
   ========================================================================== */

:root {
  /* Colors */
  --paper:        #f0eee9;
  --paper-deep:   #e8e6e0;
  --cream:        #efece5;
  --sand:         #dacaad;     /* "Mashraq" sub-brand */
  --ink:          #0a0a0a;
  --ink-2:        #2c2c2c;
  --ink-mute:     #5a5a5a;
  --stratum:      #131820;     /* "Stratum" sub-brand */
  --deep:         #041228;
  --gold:         #ad8f5c;
  --gold-soft:    #c5a878;
  --rule:         rgba(0, 0, 0, 0.12);
  --rule-strong:  rgba(0, 0, 0, 0.28);
  --rule-light:   rgba(255, 255, 255, 0.14);

  /* Type */
  --font-sans:    "Inter Tight", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-ar:      "IBM Plex Sans Arabic", "Inter Tight", sans-serif;
  --font-display-ar: "Reem Kufi", "IBM Plex Sans Arabic", serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", monospace;

  /* Scale */
  --step--1: 0.8125rem;   /* 13 */
  --step-0:  0.9375rem;   /* 15 */
  --step-1:  1.0625rem;   /* 17 */
  --step-2:  1.375rem;    /* 22 */
  --step-3:  1.875rem;    /* 30 */
  --step-4:  2.625rem;    /* 42 */
  --step-5:  3.75rem;     /* 60 */
  --step-6:  5.5rem;      /* 88 */

  /* Layout */
  --container: 1320px;
  --gutter: clamp(20px, 4vw, 56px);
  --nav-h: 72px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--paper);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: var(--step-1);
  font-weight: 400;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Utility */
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.mono { font-family: var(--font-mono); font-size: var(--step--1); letter-spacing: 0.04em; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::before {
  content: "";
  width: 8px; height: 8px;
  background: var(--gold);
  display: inline-block;
}

.ar { font-family: var(--font-ar); direction: rtl; }
.ar-display { font-family: var(--font-display-ar); direction: rtl; font-weight: 600; }

/* ===== Top nav ===== */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in oklab, var(--paper) 92%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.nav-inner {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.brand .b-ar {
  font-family: var(--font-display-ar);
  font-size: 26px;
  line-height: 1;
  color: var(--ink);
  direction: rtl;
}
.brand .b-lat {
  font-family: var(--font-sans);
  font-size: 18px;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.brand .b-mark {
  width: 8px; height: 8px;
  background: var(--gold);
  align-self: center;
}
.nav-links { display: flex; gap: 28px; align-items: center; }
.nav-links a {
  font-size: var(--step-0);
  color: var(--ink-2);
  padding: 6px 2px;
  position: relative;
  font-weight: 500;
}
.nav-links a[aria-current="page"] { color: var(--ink); }
.nav-links a[aria-current="page"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px;
  height: 1px; background: var(--gold);
}
.nav-meta {
  display: flex; align-items: center; gap: 18px;
  font-family: var(--font-mono); font-size: 12px;
  letter-spacing: 0.08em; color: var(--ink-mute);
}
.nav-lang { display: flex; gap: 6px; }
.nav-lang button {
  background: transparent;
  border: 1px solid var(--rule);
  padding: 4px 10px;
  font-family: var(--font-mono); font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.08em;
}
.nav-lang button.active { background: var(--ink); color: var(--cream); border-color: var(--ink); }

@media (max-width: 800px) {
  .nav-links, .nav-meta { display: none; }
  .nav-inner { gap: 12px; }
  .nav-toggle { display: inline-flex; }
}
@media (min-width: 801px) {
  .nav-toggle, .nav-mobile { display: none !important; }
}

/* Hamburger toggle */
.nav-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 40px; height: 40px;
  background: transparent;
  border: 1px solid var(--rule-strong);
  padding: 0;
  cursor: pointer;
}
.nav-toggle span { display: block; width: 18px; height: 1.5px; background: var(--ink); position: relative; }
.nav-toggle span::before, .nav-toggle span::after {
  content: ""; position: absolute; left: 0; width: 18px; height: 1.5px; background: var(--ink);
}
.nav-toggle span::before { top: -6px; }
.nav-toggle span::after  { top: 6px; }

.nav-mobile {
  position: fixed; inset: var(--nav-h) 0 0 0;
  background: var(--paper);
  z-index: 49;
  padding: 24px var(--gutter) 40px;
  transform: translateY(-110%);
  transition: transform 0.25s ease;
  display: flex; flex-direction: column; gap: 6px;
  overflow-y: auto;
}
.nav-mobile.open { transform: translateY(0); }
.nav-mobile a {
  display: block;
  padding: 16px 0;
  font-size: 22px; font-weight: 500;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
}
.nav-mobile a[aria-current="page"] { color: var(--gold); }
.nav-mobile .meta {
  margin-top: 18px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em;
  color: var(--ink-mute); display: flex; justify-content: space-between;
}

/* ===== Responsive layout utilities ===== */
/* .split = 2-column grid that stacks below 800px. Override columns via inline --split-cols. */
.split {
  display: grid;
  grid-template-columns: var(--split-cols, 1fr 1fr);
  gap: var(--split-gap, clamp(28px, 4vw, 64px));
  align-items: var(--split-align, start);
}
@media (max-width: 800px) {
  .split { grid-template-columns: 1fr !important; }
  .split[data-reverse-mobile] { display: flex; flex-direction: column-reverse; }
}

/* KPI strip: 4 cols → 2 cols → 1 col */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(20px, 3vw, 40px);
  margin-top: clamp(40px, 6vw, 80px);
  border-top: 1px solid var(--rule);
  padding-top: 32px;
}
@media (max-width: 800px) { .kpi-strip { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px) { .kpi-strip { grid-template-columns: 1fr; } }

/* Toolbar (filters) */
.toolbar-row {
  display: flex; gap: 16px; flex-wrap: wrap;
  align-items: center; justify-content: space-between;
}

/* ===== Bilingual (EN default / AR with RTL) — no German ===== */
[data-lang="ar"], [data-lang-block="ar"] { display: none !important; }

html[lang="ar"] [data-lang="en"]       { display: none !important; }
html[lang="ar"] [data-lang="ar"]       { display: inline !important; }
html[lang="ar"] [data-lang-block="en"] { display: none !important; }
html[lang="ar"] [data-lang-block="ar"] { display: block !important; }

/* Arabic typography */
html[lang="ar"] {
  font-family: var(--font-ar);
}
html[lang="ar"] body,
html[lang="ar"] .lede,
html[lang="ar"] p,
html[lang="ar"] li {
  font-family: var(--font-ar);
  font-weight: 400;
}
html[lang="ar"] .h1,
html[lang="ar"] .h2,
html[lang="ar"] .h3,
html[lang="ar"] .h-display {
  font-family: var(--font-display-ar);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.15;
}
html[lang="ar"] .h-display { line-height: 1.05; }

/* Force-LTR opt-out (technical labels, slugs, URLs, code) — strict */
[data-keep-ltr] {
  direction: ltr !important;
  unicode-bidi: embed;
}
[data-keep-ltr]:not(input):not(textarea) { text-align: start; }

/* Global logical property fixes for shared chrome */
html[dir="rtl"] .nav-toggle span::before,
html[dir="rtl"] .nav-toggle span::after { left: 0; }
html[dir="rtl"] pre,
html[dir="rtl"] code { direction: ltr; text-align: left; unicode-bidi: embed; }
html[dir="rtl"] .nav-meta,
html[dir="rtl"] .brand,
html[dir="rtl"] .mono { direction: ltr; }
/* Crumb path separators: container LTR but labels can be Arabic — use bdo or keep LTR layout w/ Arabic spans */
html[dir="rtl"] .crumb { text-align: start; }
.section { padding: clamp(56px, 8vw, 120px) 0; }
.section.tight { padding: clamp(40px, 5vw, 72px) 0; }
.section.dark { background: var(--stratum); color: var(--cream); }
.section.dark .eyebrow { color: rgba(239, 236, 229, 0.6); }
.section.sand { background: var(--sand); color: var(--deep); }
.section.cream { background: var(--cream); }

/* Mobile-aware code blocks */
@media (max-width: 800px) {
  pre { font-size: 11px; padding: 16px 18px; }
}

.h-display {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: clamp(48px, 8vw, 120px);
  line-height: 0.92;
  letter-spacing: -0.045em;
  color: var(--ink);
  margin: 0;
}
.h-display.alt {
  font-family: var(--font-display-ar);
  direction: rtl;
  letter-spacing: 0;
  font-size: clamp(56px, 9vw, 140px);
}
.section.dark .h-display { color: var(--cream); }

.h1 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: clamp(36px, 5vw, 64px);
  line-height: 1;
  letter-spacing: -0.035em;
  color: var(--ink);
  margin: 0;
}
.h2 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin: 0;
}
.h3 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0;
}
.section.dark .h1, .section.dark .h2, .section.dark .h3 { color: var(--cream); }

.lede {
  font-family: var(--font-sans);
  font-size: clamp(18px, 1.4vw, 22px);
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 56ch;
  text-wrap: pretty;
}
.section.dark .lede { color: rgba(239, 236, 229, 0.82); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 22px;
  background: var(--ink);
  color: var(--cream);
  font-size: var(--step-0);
  font-weight: 500;
  letter-spacing: -0.01em;
  border: 1px solid var(--ink);
  transition: background 0.15s, color 0.15s;
}
.btn:hover { background: transparent; color: var(--ink); }
.btn .arr { font-family: var(--font-mono); font-size: 14px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.btn.ghost:hover { background: var(--ink); color: var(--cream); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn.gold:hover { background: transparent; color: var(--ink); border-color: var(--ink); }
.section.dark .btn.ghost { color: var(--cream); border-color: var(--rule-light); }
.section.dark .btn.ghost:hover { background: var(--cream); color: var(--ink); }

/* ===== Cards / grid ===== */
.grid { display: grid; gap: clamp(20px, 2vw, 36px); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

/* ===== Footer ===== */
.foot {
  background: var(--stratum);
  color: var(--cream);
  padding: 72px 0 32px;
}
.foot a { color: rgba(239, 236, 229, 0.78); }
.foot a:hover { color: var(--gold); }
.foot .row { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 48px; }
@media (max-width: 800px) { .foot .row { grid-template-columns: 1fr 1fr; } }
.foot h4 {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--gold);
  margin: 0 0 18px;
}
.foot ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.foot li { font-size: var(--step-0); }
.foot .meta {
  margin-top: 56px; padding-top: 24px;
  border-top: 1px solid var(--rule-light);
  display: flex; justify-content: space-between; gap: 16px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em;
  color: rgba(239, 236, 229, 0.55);
}

/* ===== Social / share ===== */
.foot-soc {
  display: flex; gap: 8px; margin-top: 22px;
}
.foot-soc .soc {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  color: rgba(239, 236, 229, 0.78);
  border: 1px solid rgba(255,255,255,0.14);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.foot-soc .soc:hover {
  color: var(--ink); background: var(--gold); border-color: var(--gold);
}

.share {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.share .share-label {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-mute);
  margin-inline-end: 6px;
}
.share .soc {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-2);
  border: 1px solid var(--rule-strong);
  background: transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  cursor: pointer;
  padding: 0;
}
.share .soc:hover {
  color: var(--cream); background: var(--ink); border-color: var(--ink);
}
.share .soc-copy.copied {
  background: var(--gold); border-color: var(--gold); color: var(--ink);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 0 10px; width: auto;
}

/* ===== Notice / callout ===== */
.notice {
  border: 1px solid var(--rule);
  padding: 18px 22px;
  display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: start;
  background: rgba(255, 255, 255, 0.4);
}
.notice .dot { width: 8px; height: 8px; background: var(--gold); margin-top: 9px; }

/* ===== Image placeholder (until real assets are uploaded) ===== */
.ph {
  position: relative;
  background:
    repeating-linear-gradient(135deg,
      rgba(0,0,0,0.04) 0 1px, transparent 1px 14px),
    var(--cream);
  border: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-mute);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase;
  aspect-ratio: 4 / 5;
}
.ph.wide { aspect-ratio: 16 / 9; }
.ph.square { aspect-ratio: 1 / 1; }
.ph.tall { aspect-ratio: 3 / 4; }

/* ===== Tables (specs) ===== */
.spec-table {
  width: 100%; border-collapse: collapse;
  font-size: var(--step-0);
}
.spec-table th, .spec-table td {
  text-align: left;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.spec-table th {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 500;
  width: 32%;
}
.spec-table td { color: var(--ink-2); }

/* ===== Tags ===== */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--rule);
  background: transparent;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.tag.gold { border-color: var(--gold); color: var(--gold); }
.tag.solid { background: var(--ink); color: var(--cream); border-color: var(--ink); }

/* ===== Code blocks ===== */
pre, code {
  font-family: var(--font-mono);
  font-size: 13px;
}
pre {
  background: var(--stratum);
  color: var(--cream);
  padding: 22px 26px;
  overflow-x: auto;
  line-height: 1.55;
  border-left: 3px solid var(--gold);
}
pre .k { color: #c5a878; }
pre .s { color: #b5d8a8; }
pre .c { color: #7a8290; font-style: italic; }
pre .n { color: #f3b591; }
code.inline {
  background: rgba(0,0,0,0.06);
  padding: 2px 6px;
  border-radius: 2px;
  color: var(--ink);
}

/* ===== Loading state ===== */
.loading {
  display: grid; place-items: center;
  padding: 80px 0;
  color: var(--ink-mute);
  font-family: var(--font-mono); font-size: 12px;
  letter-spacing: 0.12em; text-transform: uppercase;
}
.loading::before {
  content: ""; display: block; width: 24px; height: 24px;
  border: 1.5px solid var(--rule); border-top-color: var(--gold);
  border-radius: 50%; margin-bottom: 14px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
