@font-face {
  font-family: 'Tajawal';
  src: url('fonts/Tajawal-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Tajawal';
  src: url('fonts/Tajawal-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

:root {
  --base: #15120f;
  --panel: #1c1813;
  --panel-hi: #24201a;
  --hairline: #332e26;
  --text: #f4efe6;
  --muted: #a79e8c;
  --faint: #6b6455;

  --mrqb: #8fb8ce;
  --trading: #d9a94c;
  --imposter: #9b8cf7;

  --radius: 18px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --maxw: 1120px;
}

:root[data-theme='light'] {
  --base: #f4efe6;
  --panel: #fbf8f1;
  --panel-hi: #ffffff;
  --hairline: #ddd6c7;
  --text: #15120f;
  --muted: #6b6455;
  --faint: #948b78;

  --mrqb: #2f6f8f;
  --trading: #9a6f16;
  --imposter: #5a49c4;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Tajawal', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--base);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background 0.4s var(--ease), color 0.4s var(--ease);
}

/* Ambient light — a faint beacon sweep behind the hero */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(60rem 40rem at 78% -10%, rgba(143, 184, 206, 0.10), transparent 65%),
    radial-gradient(48rem 34rem at 12% 8%, rgba(217, 169, 76, 0.07), transparent 62%);
}
:root[data-theme='light'] body::before {
  background:
    radial-gradient(60rem 40rem at 78% -10%, rgba(47, 111, 143, 0.10), transparent 65%),
    radial-gradient(48rem 34rem at 12% 8%, rgba(154, 111, 22, 0.07), transparent 62%);
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 24px;
}

/* ---------- Header ---------- */
header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  background: color-mix(in srgb, var(--base) 78%, transparent);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease);
}
header.scrolled { border-bottom-color: var(--hairline); }

.bar {
  max-width: var(--maxw);
  margin-inline: auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.16rem;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}
.brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--mrqb);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--mrqb) 18%, transparent);
}

.controls { display: flex; gap: 8px; }

.ctl {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 7px 15px;
  cursor: pointer;
  transition: all 0.22s var(--ease);
  line-height: 1;
}
.ctl:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--text) 35%, transparent);
  background: var(--panel);
}

/* ---------- Hero ---------- */
/* padding-block, not the `padding` shorthand: .hero shares an element with
   .wrap and the shorthand would zero out .wrap's 24px inline padding,
   letting the hero text run into the screen edges on mobile. */
.hero {
  padding-block: clamp(64px, 12vw, 130px) clamp(48px, 7vw, 80px);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  border: 1px solid var(--hairline);
  background: var(--panel);
  border-radius: 999px;
  padding: 6px 14px;
  margin-bottom: 26px;
}
.pulse {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

h1 {
  font-size: clamp(2.3rem, 6.2vw, 4.2rem);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.01em;
  margin-bottom: 22px;
  max-width: 17ch;
}
h1 .accent {
  background: linear-gradient(100deg, var(--mrqb), var(--trading) 55%, var(--imposter));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.lede {
  font-size: clamp(1.02rem, 2vw, 1.2rem);
  color: var(--muted);
  max-width: 56ch;
  margin-bottom: 34px;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 34px;
  padding-top: 26px;
  border-top: 1px solid var(--hairline);
  max-width: 620px;
}
.stat .n {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  display: block;
}
.stat .l {
  font-size: 0.82rem;
  color: var(--faint);
  letter-spacing: 0.02em;
}

/* ---------- Section heading ---------- */
.sec-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 30px;
}
.sec-head h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
}
.sec-head .rule {
  flex: 1;
  height: 1px;
  background: var(--hairline);
}

/* ---------- Project cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 22px;
  padding-bottom: 96px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 30px 28px 26px;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: transform 0.4s var(--ease), border-color 0.4s var(--ease),
              box-shadow 0.4s var(--ease), background 0.4s var(--ease);
}

/* Accent bloom that fades in on hover — sits above the card background,
   below the content (which is lifted to z-index 1).
   Two things here are deliberate, not stylistic:
   - no negative z-index (isolation + z-index:-1 kills the card's paint)
   - no transform (a scaled pseudo-element inside overflow:hidden gets
     promoted to a compositing layer that fails to paint, blanking the
     whole card). Fade opacity only. */
.card::before {
  content: '';
  position: absolute;
  z-index: 0;
  top: -55%;
  inset-inline-end: -25%;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--c) 26%, transparent), transparent 68%);
  opacity: 0;
  transition: opacity 0.55s var(--ease);
  pointer-events: none;
}
/* Accent hairline along the top edge */
.card::after {
  content: '';
  position: absolute;
  z-index: 0;
  inset-inline: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--c), transparent);
  opacity: 0.55;
  transition: opacity 0.4s var(--ease);
  pointer-events: none;
}

/* Content sits above both pseudo-elements */
.card > * { position: relative; z-index: 1; }

.card:hover,
.card:focus-visible {
  transform: translateY(-5px);
  border-color: color-mix(in srgb, var(--c) 45%, var(--hairline));
  box-shadow: 0 20px 48px -22px color-mix(in srgb, var(--c) 40%, transparent),
              0 2px 10px -4px rgba(0, 0, 0, 0.25);
  background: var(--panel-hi);
  outline: none;
}
.card:hover::before, .card:focus-visible::before { opacity: 1; }
.card:hover::after, .card:focus-visible::after { opacity: 1; }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.icon {
  width: 62px;
  height: 62px;
  border-radius: 15px;
  object-fit: cover;
  border: 1px solid var(--hairline);
  background: var(--base);
  flex-shrink: 0;
  transition: transform 0.45s var(--ease), box-shadow 0.45s var(--ease);
}
.card:hover .icon {
  transform: scale(1.06) rotate(-2deg);
  box-shadow: 0 8px 22px -8px color-mix(in srgb, var(--c) 60%, transparent);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  color: var(--muted);
  background: var(--base);
  white-space: nowrap;
}
.pill.live { color: #4ade80; border-color: rgba(74, 222, 128, 0.32); }
:root[data-theme='light'] .pill.live { color: #157a3c; border-color: rgba(21, 122, 60, 0.32); }
.pill.live .d {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  animation: pulse 2.4s infinite;
}

.card h3 {
  font-size: 1.42rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 4px;
}
.card .sub {
  font-size: 0.86rem;
  color: var(--c);
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 14px;
}
.card p {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 20px;
  flex: 1;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 22px;
}
.tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--faint);
  border: 1px solid var(--hairline);
  border-radius: 7px;
  padding: 4px 9px;
  line-height: 1.4;
}

.go {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--c);
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
}
.go .arrow {
  transition: transform 0.35s var(--ease);
  display: inline-block;
}
.card:hover .go .arrow { transform: translateX(-5px); }
[dir='ltr'] .card:hover .go .arrow { transform: translateX(5px); }

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--hairline);
  padding: 34px 0;
  background: color-mix(in srgb, var(--panel) 55%, transparent);
}
.foot {
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 0.86rem;
  color: var(--faint);
}
.foot a { color: var(--muted); text-decoration: none; transition: color 0.2s; }
.foot a:hover { color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  /* Flex + long Arabic labels overflow the viewport at 375px; an equal
     3-column grid lets each label wrap instead of running off the edge. */
  .stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }
  .stat .n { font-size: 1.4rem; }
  .stat .l { font-size: 0.74rem; line-height: 1.4; }
  .card { padding: 26px 22px 22px; }
}

/* ---------- Detail page ---------- */
.back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 34px;
  transition: color 0.2s;
}
.back:hover { color: var(--text); }

.detail-hero {
  padding: 52px 0 44px;
  display: flex;
  align-items: center;
  gap: 26px;
  flex-wrap: wrap;
}
.detail-hero img {
  width: 96px; height: 96px;
  border-radius: 22px;
  border: 1px solid var(--hairline);
  box-shadow: 0 16px 42px -18px color-mix(in srgb, var(--c) 70%, transparent);
}
.detail-hero h1 { font-size: clamp(2rem, 5vw, 3rem); margin-bottom: 8px; }
.detail-hero .sub { color: var(--c); font-weight: 700; }

.prose {
  max-width: 72ch;
  padding-bottom: 40px;
}
.prose h2 {
  font-size: 1.28rem;
  font-weight: 700;
  margin: 40px 0 14px;
  padding-top: 22px;
  border-top: 1px solid var(--hairline);
}
.prose h2:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.prose p { color: var(--muted); margin-bottom: 14px; }
.prose ul { list-style: none; margin-bottom: 14px; }
.prose li {
  position: relative;
  color: var(--muted);
  padding-inline-start: 20px;
  margin-bottom: 9px;
}
.prose li::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 0.72em;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--c);
  opacity: 0.75;
}
.prose strong { color: var(--text); font-weight: 700; }

.note {
  display: flex;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-inline-start: 3px solid var(--c);
  border-radius: 12px;
  padding: 16px 18px;
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 40px;
}
.note strong { color: var(--text); }

.specs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--hairline);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  overflow: hidden;
  margin: 22px 0 40px;
}
.spec { background: var(--panel); padding: 18px 20px; }
.spec .k { font-size: 0.75rem; color: var(--faint); letter-spacing: 0.03em; }
.spec .v { font-size: 1rem; font-weight: 700; color: var(--text); }
