:root {
  --bg: #0b1110;
  --bg-2: #111a18;
  --card: #121c1a;
  --line: #22322f;
  --text: #e7efed;
  --muted: #8fa5a1;
  --accent: #2bb3a3;
  --accent-ink: #04201c;
  --prod: #e2b33c;
  --radius: 16px;
  --sans: "Space Grotesk", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "IBM Plex Sans Arabic", ui-monospace, Consolas, monospace;
}
:root[data-theme="light"] {
  --bg: #f6f5f1;
  --bg-2: #efede7;
  --card: #ffffff;
  --line: #e1ddd3;
  --text: #15201e;
  --muted: #5d6b68;
  --accent: #0f8a7d;
  --accent-ink: #ffffff;
  --prod: #a8790a;
}

/* Language switch: only the active language is shown */
html[data-lang="en"] body [lang="fr"], html[data-lang="en"] body [lang="ar"],
html[data-lang="fr"] body [lang="en"], html[data-lang="fr"] body [lang="ar"],
html[data-lang="ar"] body [lang="en"], html[data-lang="ar"] body [lang="fr"] { display: none !important; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 17px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}
a { color: inherit; }
ul, ol { list-style: none; }
.wrap { width: min(1080px, 100% - 32px); margin-inline: auto; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; gap: 24px; height: 64px; }
.logo { font-weight: 700; font-size: 20px; text-decoration: none; letter-spacing: -.5px; }
.dot { color: var(--accent); }
.links { display: flex; gap: 22px; margin-inline-start: auto; }
.links a { text-decoration: none; color: var(--muted); font-size: 15px; }
.links a:hover { color: var(--text); }
.toggles { display: flex; gap: 8px; }
.pill {
  font: 500 13px var(--mono); color: var(--text);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px;
  height: 34px; min-width: 42px; padding: 0 12px; cursor: pointer;
}
.pill:hover { border-color: var(--accent); }

/* Hero */
.hero-top { display: grid; grid-template-columns: 1fr 300px; gap: 48px; align-items: end; }
.portrait { position: relative; }
.portrait img {
  display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover;
  border-radius: 20px; border: 1px solid var(--line);
}
.portrait figcaption {
  position: absolute; inset-inline-start: 12px; bottom: 12px; font-size: 12px;
  padding: 4px 10px; border-radius: 999px; color: #e7efed; background: rgba(8, 14, 13, .7);
}
.hero { padding: 96px 0 72px; }
.kicker { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; letter-spacing: .5px; }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
h1 { font-size: clamp(56px, 11vw, 128px); line-height: .95; letter-spacing: -3px; font-weight: 700; margin: 18px 0 28px; }
.lead { font-size: clamp(20px, 2.4vw, 26px); line-height: 1.4; max-width: 760px; }
.sub { color: var(--muted); margin-top: 14px; max-width: 640px; }
.cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 11px 20px; border-radius: 999px; text-decoration: none; font-weight: 500; font-size: 15px;
  border: 1px solid var(--line); background: var(--bg-2);
  transition: border-color .15s, transform .15s;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  margin-top: 64px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.stats div { background: var(--bg); padding: 22px 24px; }
.stats dt { font-size: 40px; font-weight: 700; line-height: 1; color: var(--accent); }
.stats dd { color: var(--muted); font-size: 14px; margin-top: 8px; }

/* Sections */
.section { padding: 72px 0; border-top: 1px solid var(--line); }
.h2 { display: flex; align-items: baseline; gap: 14px; font-size: clamp(30px, 4vw, 44px); letter-spacing: -1px; margin-bottom: 36px; }
.num { font-size: 14px; color: var(--accent); letter-spacing: 0; }
.h3 { font-size: 20px; margin: 56px 0 18px; }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; display: flex; flex-direction: column; gap: 12px;
  transition: border-color .2s, transform .2s;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); transform: translateY(-2px); }
.card h3 { font-size: 23px; letter-spacing: -.3px; line-height: 1.25; }
.card p { color: var(--muted); font-size: 15.5px; }
.tag-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; }
.badge {
  font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: .6px;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.badge.prod { color: var(--prod); border-color: color-mix(in srgb, var(--prod) 45%, transparent); }
.stack { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.stack li { font: 12.5px var(--mono); padding: 3px 9px; border-radius: 6px; background: var(--bg-2); color: var(--muted); }
.links-row { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 15px; font-weight: 500; }
.links-row a { text-decoration: none; color: var(--accent); }
.links-row a:hover { text-decoration: underline; }

/* Compact list */
.list li {
  display: grid; grid-template-columns: 250px 1fr auto; gap: 18px; align-items: baseline;
  padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 15.5px; color: var(--muted);
}
.list a { color: var(--text); font-weight: 600; text-decoration: none; }
.list a:hover { color: var(--accent); }
.list em { font-style: normal; font-size: 12.5px; white-space: nowrap; }

/* Timeline */
.timeline li { display: grid; grid-template-columns: 190px 1fr; gap: 24px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.timeline li:first-child { padding-top: 0; }
.when { color: var(--accent); font-size: 13.5px; padding-top: 4px; }
.timeline h3 { font-size: 19px; }
.timeline p { color: var(--muted); font-size: 15.5px; margin-top: 4px; max-width: 720px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 16px; font-size: 14.5px; }

/* Skills */
.skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.skills div { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; background: var(--card); }
.skills h3 { font: 500 12.5px var(--mono); text-transform: uppercase; letter-spacing: .8px; color: var(--accent); margin-bottom: 8px; }
.skills p { font-size: 15.5px; }
.langs { margin-top: 22px; font-size: 15px; }

/* Contact */
.big { font-size: clamp(22px, 3vw, 32px); max-width: 720px; line-height: 1.3; }
.mail {
  display: inline-block; margin-top: 22px; font-size: clamp(22px, 4.2vw, 44px); font-weight: 600; letter-spacing: -1px;
  text-decoration: none; border-bottom: 3px solid var(--accent); overflow-wrap: anywhere;
}
.mail:hover { color: var(--accent); }

.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 28px 0 40px; border-top: 1px solid var(--line); font-size: 13px; }

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* Responsive */
@media (max-width: 860px) {
  .hero-top { grid-template-columns: 1fr; gap: 32px; }
  .portrait { order: -1; width: 160px; }
  .portrait figcaption { display: none; }
  .grid, .skills { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .list li { grid-template-columns: 1fr; gap: 4px; }
  .timeline li { grid-template-columns: 1fr; gap: 6px; }
}
@media (max-width: 640px) {
  .links { display: none; }
  .toggles { margin-inline-start: auto; }
  .hero { padding: 64px 0 48px; }
  h1 { letter-spacing: -2px; }
  .section { padding: 56px 0; }
  .card { padding: 22px; }
}

/* Small muted note next to project links */
.links-row .note { font-size: 13px; font-weight: 400; color: var(--muted); align-self: center; }
.list small { display: block; font-size: 13px; margin-top: 2px; opacity: .85; }

/* Project screenshots (full-bleed at the top of each card) */
.card { --pad: 26px; padding: var(--pad); }
.card.feature { padding-top: 0; overflow: hidden; }
.shot {
  display: block; width: calc(100% + 2 * var(--pad)); max-width: none; height: auto;
  aspect-ratio: 16 / 10; object-fit: cover; object-position: top left;
  margin: 0 calc(-1 * var(--pad)) 8px; border-bottom: 1px solid var(--line); background: var(--bg-2);
}
@media (max-width: 640px) { .card { --pad: 22px; } }

/* Case study page */
.case-hero { padding: 72px 0 40px; }
.case-title { font-size: clamp(40px, 7vw, 80px); letter-spacing: -2px; margin: 16px 0 22px; }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 32px; margin-top: 36px; padding-top: 24px; border-top: 1px solid var(--line); }
.facts dt { font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: .8px; color: var(--accent); }
.facts dd { margin-top: 4px; font-size: 15.5px; }
.facts a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.case-section { padding: 56px 0; border-top: 1px solid var(--line); }
.prose { max-width: 760px; font-size: 17px; }
.prose p + p, .prose .bullets + p { margin-top: 16px; }
.bullets { list-style: disc; padding-inline-start: 20px; }
.bullets li { margin-bottom: 8px; }
.case-split { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; align-items: start; }
.case-img { width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--line); }
.parts li { padding: 16px 0; border-bottom: 1px solid var(--line); }
.parts li:first-child { padding-top: 0; }
.parts h3 { font-size: 18px; }
.parts p { color: var(--muted); font-size: 15.5px; margin-top: 4px; }
.decisions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.decisions article { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.decisions h3 { font-size: 17px; margin-bottom: 8px; }
.decisions p { color: var(--muted); font-size: 15px; }
.note-top { margin: -18px 0 20px; font-size: 14px; }
.gallery { display: grid; gap: 22px; }
.gallery img { width: 100%; height: auto; display: block; border-radius: var(--radius); border: 1px solid var(--line); }
.gallery figcaption { color: var(--muted); font-size: 14px; margin-top: 8px; }
.foot a { color: inherit; text-decoration: none; }
@media (max-width: 860px) {
  .case-split, .facts { grid-template-columns: 1fr; }
  .decisions { grid-template-columns: 1fr; }
}
@media (max-width: 640px) { .case-title { letter-spacing: -1px; } }

/* Whole card clickable when it has a case study link */
.card { position: relative; }
.card:has(.stretched) { cursor: pointer; }
.stretched::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.card .links-row a:not(.stretched) { position: relative; z-index: 2; }
.decisions.two { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 860px) { .decisions.two { grid-template-columns: 1fr; } }

/* Flow diagram + two-up gallery */
.flow { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; overflow-x: auto; }
.flow-row { display: flex; align-items: center; gap: 10px; min-width: 760px; }
.flow .node { flex: 1; border: 1px solid var(--line); background: var(--bg-2); border-radius: 12px; padding: 14px 12px; text-align: center; }
.flow .node.core { border-color: var(--accent); }
.flow .node b { display: block; font-size: 15px; }
.flow .node small { display: block; font: 12px var(--mono); color: var(--muted); margin-top: 4px; }
.flow .arrow { color: var(--accent); font-size: 20px; }
.gallery.two-up { grid-template-columns: 1fr 1fr; align-items: start; }
@media (max-width: 860px) { .gallery.two-up { grid-template-columns: 1fr; } }

/* 404 */
.notfound { min-height: calc(100vh - 180px); display: flex; flex-direction: column; justify-content: center; padding: 64px 0; }
.notfound h1 { margin: 16px 0 20px; }

/* Blog */
.posts { display: grid; gap: 18px; }
.post-card { display: flex; flex-direction: column; gap: 10px; text-decoration: none; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; transition: border-color .2s, transform .2s; }
.post-card:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); transform: translateY(-2px); }
.post-card span.mono { font-size: 13px; }
.post-card h2 { font-size: clamp(22px, 3vw, 28px); letter-spacing: -.5px; line-height: 1.25; }
.post-card p { color: var(--muted); font-size: 16px; max-width: 760px; }
.post-card .read { color: var(--accent); font-weight: 500; font-size: 15px; }
.post { max-width: 760px; margin: 0 auto; padding: 64px 0 56px; }
.post-title { font-size: clamp(34px, 5.5vw, 56px); letter-spacing: -1.5px; line-height: 1.1; margin: 16px 0 20px; }
.post-body { margin-top: 40px; font-size: 17.5px; line-height: 1.75; }
.post-body h2 { font-size: 26px; letter-spacing: -.5px; line-height: 1.3; margin: 44px 0 14px; }
.post-body p { margin: 0 0 16px; }
.post-body a { color: var(--accent); text-underline-offset: 3px; }
.post-body code { font: 14.5px var(--mono); background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.post-body pre { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; overflow-x: auto; margin: 6px 0 22px; }
.post-body pre code { background: none; border: 0; padding: 0; font-size: 13.5px; line-height: 1.65; display: block; white-space: pre; }
.post-body .flow { margin: 8px 0 22px; }
.post-body .bullets { margin: 0 0 18px; }
.post .cta { margin-top: 40px; }

/* Language switch */
.lang-switch { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg-2); }
.lang-switch button { font: 500 12.5px var(--mono); color: var(--muted); background: none; border: 0; border-radius: 999px; height: 26px; min-width: 32px; padding: 0 8px; cursor: pointer; }
.lang-switch button:hover { color: var(--text); }
html[data-lang="en"] [data-set-lang="en"], html[data-lang="fr"] [data-set-lang="fr"], html[data-lang="ar"] [data-set-lang="ar"] { background: var(--accent); color: var(--accent-ink); }
html:not([data-langs~="ar"]) .ar-only { display: none; }
.lang-switch .ar-only { font-family: "IBM Plex Sans Arabic", var(--sans); font-size: 14px; }

/* Arabic / right-to-left */
html[lang="ar"] body, html[lang="ar"] body * { letter-spacing: 0 !important; }
html[lang="ar"] body { line-height: 1.75; }
html[dir="rtl"] .arr { display: inline-block; transform: scaleX(-1); }
html[dir="rtl"] pre, html[dir="rtl"] code { direction: ltr; unicode-bidi: isolate; }
html[dir="rtl"] pre { text-align: left; }

/* Availability line */
.status { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 18px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg-2); font-size: 13px; color: var(--muted); }
.status .clock { color: var(--text); }
