/* Shared styles for index.html, projects/*.html and their Arabic counterparts under ar/. Plain CSS, no build step.

   Tokens come in three layers:
     1. primitives  raw values (colours, sizes, durations); nothing else uses them directly
     2. semantic    what a value is for (surface, text, accent); light by default, dark below
     3. component   per-component knobs built on the semantic layer
   Components read only layers 2 and 3. */

/* ============================================================
   1. PRIMITIVES
   ============================================================ */
:root {
  /* neutrals, day */
  --gray-0: #ffffff;
  --gray-25: #fbfcfd;
  --gray-50: #f6f7f9;
  --gray-100: #eceef2;
  --gray-200: #e1e4ea;
  --gray-300: #cfd4dd;
  --gray-500: #5d6675;   /* 5.4:1 on gray-50 */
  --gray-600: #434b57;
  --gray-950: #0d1014;

  /* neutrals, night */
  --night-1000: #06070a;
  --night-950: #0a0b0e;
  --night-900: #0e1014;
  --night-850: #111318;
  --night-800: #0f131a;
  --night-750: #12161d;
  --night-700: #151a22;
  --night-650: #121720;
  --chalk-50: #f2f4f7;
  --chalk-200: #c3c9d3;
  --chalk-300: #b6bdc8;
  --chalk-400: #98a1ae;  /* 6.6:1 on night-800 */
  --chalk-500: #8d96a3;  /* 5.9:1 on night-950 */

  /* amber, the one accent */
  --amber-300: #ffc069;
  --amber-400: #f0a73a;
  --amber-500: #c4780f;
  --amber-600: #a8630b;  /* 4.7:1 under white text */
  --amber-700: #9a5808;  /* 5.2:1 as text on gray-50 */
  --amber-800: #8a4f06;
  --amber-ink: #14100a;

  /* status */
  --teal-400: #3ecfb2;
  --teal-700: #0b7a67;

  /* type */
  --font-display: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --fs-2xs: .75rem;      /* 12 */
  --fs-xs: .8125rem;     /* 13 */
  --fs-sm: .875rem;      /* 14 */
  --fs-base: 1rem;       /* 16 */
  --fs-md: 1.0625rem;    /* 17 */
  --fs-lg: 1.25rem;      /* 20 */
  --fs-xl: clamp(1.3rem, 2.4vw, 1.6rem);
  --fs-2xl: clamp(1.85rem, 4.2vw, 2.75rem);
  --fs-3xl: clamp(2rem, 4.6vw, 3.1rem);
  --fs-display: clamp(2.8rem, 8vw, 5.4rem);
  --lh-tight: 1.04;
  --lh-snug: 1.25;
  --lh-body: 1.65;
  --lh-read: 1.75;
  --measure: 52ch;       /* body copy: 65-75 characters a line in Inter (measured) */

  /* space, 4-point scale */
  --sp-1: .25rem;
  --sp-2: .5rem;
  --sp-3: .75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;

  /* shape */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-pill: 999px;

  /* layers */
  --z-sheet: 90;
  --z-nav: 100;
  --z-skip: 200;

  /* motion */
  --dur-1: 150ms;
  --dur-2: 200ms;
  --dur-3: 280ms;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

/* ============================================================
   2. SEMANTIC (day by default)
   ============================================================ */
:root {
  --bg: var(--gray-50);
  --bg-deep: var(--gray-100);
  --surface: var(--gray-0);
  --surface-2: var(--gray-25);
  --border: var(--gray-200);
  --border-strong: var(--gray-300);
  --text: var(--gray-950);
  --text-soft: var(--gray-600);
  --text-mute: var(--gray-500);
  --accent: var(--amber-700);
  --accent-fill: linear-gradient(145deg, var(--amber-600), var(--amber-800));
  --on-accent: var(--gray-0);
  --accent-wash: rgba(168, 99, 11, .09);
  --accent-line: rgba(168, 99, 11, .30);
  --success: var(--teal-700);
  --glow-a: rgba(196, 120, 15, .18);
  --glow-b: rgba(37, 99, 235, .10);
  --grid-dot: rgba(13, 16, 20, .09);
  --shadow-1: 0 1px 2px rgba(13, 16, 20, .05), 0 4px 12px rgba(13, 16, 20, .04);
  --shadow-2: 0 2px 6px rgba(13, 16, 20, .07), 0 18px 40px -12px rgba(13, 16, 20, .16);
  --glass: rgba(255, 255, 255, .80);
  --band-bg: var(--night-800);
  --band-cell: var(--night-650);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: var(--night-950);
  --bg-deep: var(--night-1000);
  --surface: var(--night-850);
  --surface-2: var(--night-900);
  --border: rgba(255, 255, 255, .10);
  --border-strong: rgba(255, 255, 255, .18);
  --text: var(--chalk-50);
  --text-soft: var(--chalk-300);
  --text-mute: var(--chalk-500);
  --accent: var(--amber-400);
  --accent-fill: linear-gradient(145deg, var(--amber-300), var(--amber-400));
  --on-accent: var(--amber-ink);
  --accent-wash: rgba(240, 167, 58, .12);
  --accent-line: rgba(240, 167, 58, .36);
  --success: var(--teal-400);
  --glow-a: rgba(240, 167, 58, .16);
  --glow-b: rgba(64, 120, 255, .14);
  --grid-dot: rgba(255, 255, 255, .08);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 2px 8px rgba(0, 0, 0, .45), 0 24px 60px -20px rgba(0, 0, 0, .75);
  --glass: rgba(12, 14, 18, .78);
  --band-bg: var(--night-750);
  --band-cell: var(--night-700);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--night-950);
    --bg-deep: var(--night-1000);
    --surface: var(--night-850);
    --surface-2: var(--night-900);
    --border: rgba(255, 255, 255, .10);
    --border-strong: rgba(255, 255, 255, .18);
    --text: var(--chalk-50);
    --text-soft: var(--chalk-300);
    --text-mute: var(--chalk-500);
    --accent: var(--amber-400);
    --accent-fill: linear-gradient(145deg, var(--amber-300), var(--amber-400));
    --on-accent: var(--amber-ink);
    --accent-wash: rgba(240, 167, 58, .12);
    --accent-line: rgba(240, 167, 58, .36);
    --success: var(--teal-400);
    --glow-a: rgba(240, 167, 58, .16);
    --glow-b: rgba(64, 120, 255, .14);
    --grid-dot: rgba(255, 255, 255, .08);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 2px 8px rgba(0, 0, 0, .45), 0 24px 60px -20px rgba(0, 0, 0, .75);
    --glass: rgba(12, 14, 18, .78);
    --band-bg: var(--night-750);
    --band-cell: var(--night-700);
    color-scheme: dark;
  }
}
/* the flagship band is dark in both themes: it re-maps the semantic layer */
.flagship {
  --surface: rgba(255, 255, 255, .05);
  --surface-2: rgba(255, 255, 255, .03);
  --border: rgba(255, 255, 255, .12);
  --border-strong: rgba(255, 255, 255, .22);
  --text: var(--chalk-50);
  --text-soft: var(--chalk-200);
  --text-mute: var(--chalk-400);
  --accent: var(--amber-400);
  --accent-fill: linear-gradient(145deg, var(--amber-300), var(--amber-400));
  --on-accent: var(--amber-ink);
  --accent-wash: rgba(240, 167, 58, .12);
  --accent-line: rgba(240, 167, 58, .38);
  --success: var(--teal-400);
  color-scheme: dark;
}

/* ============================================================
   3. COMPONENT (declared on both scopes so the band re-computes them)
   ============================================================ */
:root, .flagship {
  --gutter: clamp(var(--sp-4), 4.5vw, var(--sp-10));
  --page-max: 1200px;
  --section-y: clamp(4.5rem, 10vw, 8rem);

  --control-h: 2.75rem;                 /* 44px touch target */
  --control-radius: var(--r-pill);
  --control-bg: var(--surface);
  --control-border: var(--border);
  --control-hover-border: var(--accent-line);
  --control-hover-bg: var(--accent-wash);

  --card-bg: var(--surface);
  --card-border: var(--border);
  --card-radius: var(--r-lg);
  --card-pad: clamp(var(--sp-5), 3vw, var(--sp-8));
  --card-shadow: var(--shadow-1);

  --media-radius: var(--r-md);
  --media-border: 1px solid var(--border);
  --media-shadow: 0 1px 2px rgba(13, 16, 20, .06), 0 12px 28px -14px rgba(13, 16, 20, .28);

  --tag-bg: var(--accent-wash);
  --tag-text: var(--text-soft);
}

/* ============================================================
   BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 6rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.nav-open { overflow: hidden; }
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
p { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.03em; margin: 0; text-wrap: balance; }
button, a { touch-action: manipulation; }
button { font: inherit; }
code {
  font-family: var(--font-mono); font-size: .86em;
  background: var(--tag-bg); border: 1px solid var(--border);
  border-radius: 5px; padding: .05em .35em;
  overflow-wrap: anywhere;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--r-xs); }
::selection { background: var(--accent-wash); color: var(--text); }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.print-only { display: none; }

/* one icon set: an inline sprite, used as <svg class="i"><use href="#i-..."/></svg> */
.i { width: 1em; height: 1em; flex: none; }

.skip {
  position: fixed; top: var(--sp-2); inset-inline-start: var(--sp-2); z-index: var(--z-skip);
  transform: translateY(-160%);
  background: var(--accent); color: var(--on-accent);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-sm);
  font: 500 var(--fs-sm) var(--font-body);
  transition: transform var(--dur-2) var(--ease);
}
.skip:focus { transform: none; }

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

.eyebrow {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font: 500 var(--fs-sm)/1.3 var(--font-body);
  color: var(--accent);
}
.eyebrow::before { content: ""; width: 1.4rem; height: 1px; background: var(--accent-line); }

/* ============================================================
   AMBIENT BACKGROUND
   ============================================================ */
.canvasfield {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1100px 620px at 12% -8%, var(--glow-a), transparent 62%),
    radial-gradient(900px 560px at 92% 4%, var(--glow-b), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg) 55%, var(--bg-deep) 100%);
}
.canvasfield::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
  background-size: 34px 34px;
  -webkit-mask-image: radial-gradient(120% 78% at 50% 0%, #000 12%, transparent 72%);
  mask-image: radial-gradient(120% 78% at 50% 0%, #000 12%, transparent 72%);
}

/* ============================================================
   NAV
   ============================================================ */
.nav {
  position: fixed; inset: var(--sp-3) 0 auto; z-index: var(--z-nav);
  display: flex; justify-content: center;
  padding-inline: var(--gutter);
}
.nav-inner {
  width: 100%; max-width: var(--page-max);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-1); padding-inline-start: var(--sp-4);
  min-height: calc(var(--control-h) + var(--sp-2));
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  box-shadow: var(--shadow-1);
  transition: box-shadow var(--dur-3) var(--ease), border-color var(--dur-3) var(--ease);
}
.nav.scrolled .nav-inner { box-shadow: var(--shadow-2); border-color: var(--border-strong); }

.brand { display: flex; align-items: center; gap: var(--sp-3); margin-inline-end: auto; min-width: 0; border-radius: var(--r-sm); }
.brand-mark {
  width: 2rem; height: 2rem; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: var(--accent-fill);
  color: var(--on-accent);
  font: 700 .8rem/1 var(--font-display); letter-spacing: -.02em;
}
.brand-name { font: 600 .95rem/1.1 var(--font-display); letter-spacing: -.02em; white-space: nowrap; min-width: 0; }
.brand-name span { display: block; font: 400 var(--fs-2xs)/1.4 var(--font-body); color: var(--text-mute); letter-spacing: 0; margin-top: 2px; }
@media (max-width: 400px) { .brand-name span { display: none; } }

.links { display: none; align-items: center; gap: 2px; }
.links a {
  position: relative; display: inline-flex; align-items: center;
  min-height: 2.25rem; padding: 0 var(--sp-3); border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 500; color: var(--text-soft);
  transition: color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}
.links a:hover { color: var(--text); background: var(--accent-wash); }
.links a[aria-current="location"] { color: var(--text); }
.links a[aria-current="location"]::after {
  content: ""; position: absolute; left: 50%; bottom: 3px;
  width: 14px; height: 2px; margin-left: -7px; border-radius: 2px;
  background: var(--accent);
}
.nav-tools { display: flex; align-items: center; gap: var(--sp-2); }

.icon-btn {
  width: var(--control-h); height: var(--control-h); display: grid; place-items: center; flex: none;
  border: 1px solid var(--control-border); border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text-soft); cursor: pointer;
  transition: color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.icon-btn:hover { color: var(--accent); border-color: var(--control-hover-border); }
.icon-btn .i { width: 18px; height: 18px; }
.icon-btn .sun { display: none; }
.icon-btn .moon { display: block; }
:root[data-theme="dark"] .icon-btn .sun { display: block; }
:root[data-theme="dark"] .icon-btn .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-btn .sun { display: block; }
  :root:not([data-theme="light"]) .icon-btn .moon { display: none; }
}
html:not(.js) #burger { display: none; }

.nav-cta { display: none; }
.nav-back {
  display: inline-flex; align-items: center; gap: var(--sp-2); white-space: nowrap;
  min-height: var(--control-h); padding: 0 var(--sp-4); border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 500; color: var(--text-soft);
  border: 1px solid var(--control-border); background: var(--surface-2);
  transition: color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.nav-back:hover { color: var(--accent); border-color: var(--control-hover-border); }
.nav-back .i { width: 15px; height: 15px; }

/* language switch: a plain link to the same page in the other language */
.lang {
  display: inline-flex; align-items: center; white-space: nowrap;
  min-height: var(--control-h); padding: 0 var(--sp-4); border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 500; color: var(--text-soft);
  border: 1px solid var(--control-border); background: var(--surface-2);
  transition: color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.lang:hover { color: var(--accent); border-color: var(--control-hover-border); }
.lang[lang="ar"] { font-family: "IBM Plex Sans Arabic", var(--font-body); }
.sheet a.sheet-lang { display: none; }
@media (max-width: 479px) {
  /* the home nav is full at phone width: the switch moves into the sheet */
  .lang-home { display: none; }
  .sheet a.sheet-lang { display: inline-flex; align-self: flex-start; margin-top: var(--sp-6); font: 500 var(--fs-base)/1.2 var(--font-body); border-bottom: 0; padding: 0 var(--sp-5); }
  .sheet a.sheet-lang[lang="ar"] { font-family: "IBM Plex Sans Arabic", var(--font-body); }
  /* a case study at phone width keeps the mark, the back link, the switch and the theme */
  .nav-case .brand-name { display: none; }
}

@media (min-width: 1360px) {
  .links { display: flex; }
  #burger { display: none; }
}
@media (min-width: 1560px) {
  .nav-cta {
    display: inline-flex; align-items: center; gap: var(--sp-2);
    min-height: var(--control-h); padding: 0 var(--sp-4); border-radius: var(--r-pill);
    background: var(--text); color: var(--bg);
    font-size: var(--fs-sm); font-weight: 500;
    transition: opacity var(--dur-2) var(--ease);
  }
  .nav-cta:hover { opacity: .86; }
  .nav-cta .i { width: 15px; height: 15px; }
}

/* mobile sheet */
.sheet {
  position: fixed; inset: 0; z-index: var(--z-sheet);
  display: flex; flex-direction: column; justify-content: center;
  padding: 6rem var(--gutter) var(--sp-8);
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  opacity: 0; visibility: hidden;
  transition: opacity var(--dur-2) var(--ease), visibility var(--dur-2);
}
.sheet.open { opacity: 1; visibility: visible; }
.sheet a:not(.btn) {
  font-family: var(--font-display); font-size: clamp(1.5rem, 7vw, 2.1rem); font-weight: 600;
  letter-spacing: -.03em; padding: var(--sp-2) 0; border-bottom: 1px solid var(--border);
}
.sheet a[aria-current="location"] { color: var(--accent); }
.sheet .btn { margin-top: var(--sp-6); align-self: flex-start; }

/* ============================================================
   CONTROLS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: calc(var(--control-h) + 4px); padding: 0 var(--sp-6); border-radius: var(--control-radius);
  font: 500 .92rem/1.2 var(--font-body);
  border: 1px solid transparent; cursor: pointer;
  transition: background-color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease), opacity var(--dur-2) var(--ease);
}
.btn .i { width: 16px; height: 16px; }
.btn-primary { background: var(--accent-fill); color: var(--on-accent); }
.btn-primary:hover { opacity: .9; }
.btn-ghost { background: var(--control-bg); border-color: var(--control-border); color: var(--text); }
.btn-ghost:hover { border-color: var(--control-hover-border); color: var(--accent); }
.cta-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-8); }

.ghost-link, .copy-link {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: var(--control-h); padding: 0 var(--sp-4);
  font: 500 var(--fs-sm)/1.2 var(--font-body); color: var(--text);
  border: 1px solid var(--control-border); border-radius: var(--control-radius);
  background: var(--control-bg);
  cursor: pointer;
  transition: color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}
a.ghost-link:hover, .copy-link:hover { color: var(--accent); border-color: var(--control-hover-border); background: var(--control-hover-bg); }
.ghost-link .i, .copy-link .i { width: 15px; height: 15px; }
.ghost-link.is-static { color: var(--text-mute); background: transparent; border-color: transparent; padding-inline: var(--sp-1); cursor: default; }
.read-link { background: var(--text); color: var(--bg); border-color: var(--text); }
a.read-link:hover { background: var(--text); color: var(--bg); border-color: var(--text); opacity: .86; }
.copy-link .ok { display: none; }
.copy-link.done { color: var(--success); border-color: var(--success); }
.copy-link.done .ok { display: block; }
.copy-link.done .no { display: none; }
html:not(.js) .copy-link, html:not(.js) .copy { display: none; }
.copy-fallback {
  flex-basis: 100%; width: 100%; margin-top: var(--sp-1);
  font: 400 var(--fs-xs) var(--font-mono); color: var(--text);
  background: var(--surface-2); border: 1px solid var(--accent-line);
  border-radius: var(--r-xs); padding: var(--sp-2) var(--sp-3);
}

/* ============================================================
   HERO
   ============================================================ */
.hero { position: relative; padding: clamp(7rem, 15vh, 9.5rem) 0 clamp(3rem, 7vh, 4.5rem); }
.hero-grid { display: grid; gap: clamp(var(--sp-8), 5vw, 3.25rem); }
.hero-copy { min-width: 0; }
.hero-photo {
  margin: 0; justify-self: center; width: min(100%, 20rem);
  border: var(--media-border); border-radius: var(--media-radius); overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-2);
}
.hero-photo img { width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; }
@media (min-width: 1000px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr) clamp(17rem, 26vw, 21rem); align-items: center; }
  .hero-photo { justify-self: end; width: 100%; }
  .hero .stats { grid-column: 1 / -1; }
}

.chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: 2.25rem; padding: var(--sp-1) var(--sp-4); padding-inline-start: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--r-pill);
  background: var(--surface);
  font-size: var(--fs-sm); font-weight: 500; line-height: 1.35; color: var(--text-soft);
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
a.chip:hover { border-color: var(--accent-line); color: var(--text); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex: none; }

.hero h1 {
  font-size: var(--fs-display); line-height: .98; letter-spacing: -.045em; font-weight: 700;
  margin: var(--sp-6) 0 0;
}
.alt-name {
  margin-top: var(--sp-3); font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.05rem, 2.2vw, 1.4rem); letter-spacing: -.02em; color: var(--text-mute);
}
.role {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.15rem, 2.6vw, 1.55rem); letter-spacing: -.02em; line-height: var(--lh-snug);
  color: var(--accent); margin-top: var(--sp-4);
}
.lede {
  max-width: var(--measure); margin-top: var(--sp-5);
  font-size: clamp(var(--fs-base), 1.6vw, 1.1rem); color: var(--text-soft); line-height: 1.7;
}
@media (prefers-reduced-motion: no-preference) {
  .hero-copy { animation: arrive var(--dur-3) var(--ease) both; }
}
@keyframes arrive { from { opacity: .4; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.stats {
  margin: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--r-md);
  overflow: hidden;
}
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { padding: var(--sp-4) var(--sp-5); background: var(--surface); min-width: 0; }
.stat dt { font-size: var(--fs-xs); color: var(--text-mute); }
.stat dd {
  margin: var(--sp-1) 0 0; font-family: var(--font-display); font-weight: 600; font-size: 1.04rem;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}

/* ============================================================
   FLAGSHIP (featured project)
   ============================================================ */
.flagship {
  position: relative;
  background: var(--band-bg);
  color: var(--text);
  padding-block: clamp(3.5rem, 8vw, 6rem);
  border-block: 1px solid rgba(255, 255, 255, .06);
  overflow: hidden;
}
.flagship::before {
  content: ""; position: absolute; inset: auto; inset-block-end: -40%; inset-inline: 30% -10%; height: 80%; pointer-events: none;
  background: radial-gradient(50% 50% at 50% 50%, rgba(240, 167, 58, .14), transparent 70%);
}
.flagship .wrap { position: relative; }
.flag-grid { display: grid; gap: clamp(2.25rem, 5vw, 3.5rem); }
@media (min-width: 980px) {
  .flag-grid { grid-template-columns: minmax(0, 1fr) clamp(18rem, 27vw, 21.5rem); align-items: start; }
}
.flag-copy { min-width: 0; }
.status {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: 2.25rem; padding: var(--sp-1) var(--sp-4); padding-inline-start: var(--sp-3);
  font-size: var(--fs-sm); font-weight: 500; line-height: 1.35; color: var(--text-soft);
  border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--surface);
}
.flagship h2 { font-size: var(--fs-3xl); line-height: var(--lh-tight); margin-top: var(--sp-5); max-width: 18ch; }
.flag-lede { margin-top: var(--sp-4); max-width: var(--measure); color: var(--text-soft); font-size: var(--fs-md); line-height: 1.7; }

.modes { list-style: none; margin: var(--sp-8) 0 0; padding: 0; display: grid; gap: var(--sp-6); }
@media (min-width: 720px) { .modes { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-6); } }
.mode { border-top: 1px solid var(--accent-line); padding-top: var(--sp-4); }
.mode-word {
  display: block; font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2rem, 4vw, 2.6rem); line-height: 1; letter-spacing: -.045em;
}
.mode-name { display: block; margin-top: var(--sp-2); font-size: var(--fs-sm); font-weight: 500; color: var(--accent); }
.mode p { margin-top: var(--sp-3); color: var(--text-soft); font-size: .94rem; line-height: 1.62; }

.facts {
  margin: var(--sp-8) 0 0; display: grid; gap: 1px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: var(--border); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden;
}
@media (min-width: 720px) { .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.facts div { background: var(--band-cell); padding: var(--sp-4); min-width: 0; }
.facts dt { font-size: var(--fs-xs); color: var(--text-mute); }
.facts dd { margin: var(--sp-1) 0 0; font-size: .92rem; line-height: 1.45; color: var(--text); }
.flag-note { margin-top: var(--sp-6); max-width: var(--measure); color: var(--text-soft); font-size: .94rem; line-height: 1.66; }
.flag-note strong { color: var(--text); font-weight: 600; }

/* the device frame is the one media frame that is not the standard one */
.phone {
  margin: 0; justify-self: center; width: min(100%, 20rem);
  padding: var(--sp-2); border-radius: 2.1rem;
  background: var(--night-1000); border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .8), 0 0 0 1px rgba(240, 167, 58, .12);
}
.phone video { width: 100%; height: auto; aspect-ratio: 9 / 16; border-radius: 1.6rem; background: #1b1530; object-fit: cover; }
.phone figcaption { text-align: center; font-size: var(--fs-xs); color: var(--chalk-400); padding: var(--sp-3) var(--sp-2) var(--sp-1); }

/* ============================================================
   SECTIONS
   ============================================================ */
.section { padding-block: var(--section-y); position: relative; }
.section-head { display: flex; flex-direction: column; gap: var(--sp-3); margin-bottom: clamp(var(--sp-8), 4.5vw, var(--sp-12)); }
.section-head h2 { font-size: var(--fs-2xl); line-height: 1.06; }
.section-head p { color: var(--text-soft); max-width: var(--measure); font-size: var(--fs-base); }
.section-head .cta-row { margin-top: var(--sp-2); }

/* approach */
.approach { display: grid; gap: clamp(var(--sp-4), 2.5vw, var(--sp-6)); }
@media (min-width: 900px) { .approach { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.step { padding: var(--sp-6); border: 1px solid var(--card-border); border-radius: var(--r-md); background: var(--card-bg); }
.step-ico {
  width: 2.5rem; height: 2.5rem; border-radius: var(--r-sm);
  display: grid; place-items: center; margin-bottom: var(--sp-4);
  background: var(--accent-wash); color: var(--accent);
  border: 1px solid var(--accent-line);
}
.step-ico svg { width: 19px; height: 19px; }
.step p { color: var(--text-soft); font-size: .96rem; }
.step p strong { color: var(--text); font-weight: 600; }

/* ============================================================
   WORK GRID + CARDS
   ============================================================ */
.filters { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: calc(-1 * var(--sp-2)) 0 var(--sp-4); }
html:not(.js) .filters { display: none; }
.filters button {
  min-height: var(--control-h); padding: 0 var(--sp-4); border-radius: var(--r-pill);
  font: 500 var(--fs-sm)/1 var(--font-body); color: var(--text-soft);
  border: 1px solid var(--control-border); background: var(--control-bg); cursor: pointer;
  transition: color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}
.filters button:hover { color: var(--text); border-color: var(--border-strong); }
.filters button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.filter-status { margin: 0 0 var(--sp-5); font-size: var(--fs-sm); color: var(--text-mute); min-height: 1.4em; }

.grid-work { display: grid; gap: clamp(var(--sp-4), 2vw, var(--sp-6)); }
@media (min-width: 860px) {
  .grid-work { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-work > .card.wide, .grid-work > .card.span-2 { grid-column: 1 / -1; }
}
.card {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  padding: var(--card-pad);
  border: 1px solid var(--card-border); border-radius: var(--card-radius);
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
  transition: border-color var(--dur-2) var(--ease);
}
.card:hover, .card:focus-within { border-color: var(--border-strong); }
.card:target { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-wash), var(--card-shadow); }
/* the case study reads as a different kind of card: wider, labelled, warmer */
.card.wide {
  border-color: var(--accent-line);
  background: linear-gradient(180deg, var(--accent-wash), transparent 9rem), var(--card-bg);
}
.kicker { display: block; font-size: var(--fs-sm); font-weight: 500; color: var(--accent); margin-bottom: var(--sp-1); }

/* every screenshot sits in the same frame: radius, hairline, soft shadow, fixed ratio */
.shot {
  margin: 0 0 var(--sp-5);
  border: var(--media-border); border-radius: var(--media-radius); overflow: hidden;
  box-shadow: var(--media-shadow);
  background: var(--bg-deep);
}
.shot img { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; object-position: 50% 0; }

.card-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.card-ico {
  width: 2.6rem; height: 2.6rem; border-radius: 13px; display: grid; place-items: center; flex: none;
  background: var(--accent-wash); color: var(--accent); border: 1px solid var(--accent-line);
}
.card-ico svg { width: 20px; height: 20px; }
.platform {
  display: inline-flex; align-items: center;
  font-size: var(--fs-xs); font-weight: 500; line-height: 1.3; color: var(--text-mute);
  border: 1px solid var(--border); border-radius: var(--r-pill);
  padding: var(--sp-1) var(--sp-3); white-space: nowrap;
}
.card h3 { font-size: 1.3rem; letter-spacing: -.028em; line-height: var(--lh-snug); }
.card h3 a { border-radius: var(--r-xs); }
.card h3 a:hover { color: var(--accent); }
.card .sum { margin-top: var(--sp-2); color: var(--text-soft); font-size: .96rem; line-height: 1.62; max-width: var(--measure); }
.card > p { margin-top: var(--sp-3); color: var(--text-soft); font-size: .95rem; line-height: 1.66; max-width: var(--measure); }
.card .state { margin-top: var(--sp-3); font-size: var(--fs-sm); color: var(--text-mute); }

/* problem / built / result */
.pbr { margin: var(--sp-5) 0 0; display: grid; gap: var(--sp-3); }
.pbr > div { display: grid; gap: 2px; padding-inline-start: var(--sp-4); border-inline-start: 2px solid var(--border); }
.pbr > div:last-child { border-inline-start-color: var(--accent-line); }
.pbr dt { font-size: var(--fs-xs); font-weight: 600; color: var(--text-mute); }
.pbr dd { margin: 0; color: var(--text-soft); font-size: .93rem; line-height: 1.6; max-width: var(--measure); }
.pbr dd strong { color: var(--text); font-weight: 600; }
@media (min-width: 1100px) {
  .card.wide .pbr { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-6); }
}

.figs { list-style: none; margin: var(--sp-5) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-6); }
.figs li { display: flex; flex-direction: column; min-width: 0; }
.figs b {
  font-family: var(--font-display); font-weight: 600; font-size: 1.22rem; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; color: var(--text); line-height: 1.2;
}
.figs span { font-size: var(--fs-xs); color: var(--text-mute); line-height: 1.35; max-width: 14rem; }

.badges { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-5); }
.badges span {
  font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: .01em; line-height: 1.4;
  color: var(--tag-text); background: var(--tag-bg);
  border: 1px solid var(--border); border-radius: var(--r-xs);
  padding: 2px var(--sp-2);
}
.card-foot { margin-top: auto; padding-top: var(--sp-6); display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }

/* upgrade phases: a real sequence, so they are numbered */
.phases { list-style: none; margin: 0; padding: 0; display: grid; gap: clamp(var(--sp-4), 2vw, var(--sp-6)); }
@media (min-width: 700px)  { .phases { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1060px) { .phases { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.phase { padding: var(--sp-6); border: 1px solid var(--card-border); border-radius: var(--r-md); background: var(--card-bg); }
.phase-no {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.1rem; height: 2.1rem; padding-inline: var(--sp-1); border-radius: var(--r-xs);
  font-family: var(--font-mono); font-size: .78rem; font-variant-numeric: tabular-nums;
  color: var(--accent); background: var(--accent-wash); border: 1px solid var(--accent-line);
}
.phase h3 { font-size: 1.08rem; letter-spacing: -.022em; margin: var(--sp-4) 0 var(--sp-2); }
.phase p { color: var(--text-soft); font-size: .93rem; line-height: 1.66; }

/* stack */
.grid-stack { display: grid; gap: clamp(var(--sp-4), 2vw, var(--sp-6)); }
@media (min-width: 620px) { .grid-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .grid-stack { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.pill-card { padding: var(--sp-6); border: 1px solid var(--card-border); border-radius: var(--r-md); background: var(--card-bg); }
.pill-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.pill-head h3 { font-size: 1rem; letter-spacing: -.02em; }
.pill-head .card-ico { width: 2.2rem; height: 2.2rem; border-radius: 10px; }
.pill-head .card-ico svg { width: 17px; height: 17px; }
.pill-card ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.pill-card li { display: flex; align-items: flex-start; gap: var(--sp-2); font-size: .92rem; color: var(--text-soft); }
.pill-card li .i { width: 14px; height: 14px; margin-top: .3rem; color: var(--accent); }

/* functional coverage */
.coverage {
  margin-top: clamp(var(--sp-4), 2vw, var(--sp-6));
  padding: clamp(var(--sp-5), 3vw, var(--sp-8));
  border: 1px solid var(--card-border); border-radius: var(--r-md); background: var(--card-bg);
}
.coverage-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2) var(--sp-4); margin-bottom: var(--sp-4); }
.coverage-head h3 { font-size: 1rem; letter-spacing: -.02em; }
.coverage-head span { font-size: var(--fs-sm); color: var(--text-mute); }
.domains { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: 0; padding: 0; }
.domains li {
  list-style: none; font-size: .88rem; color: var(--text-soft);
  border: 1px solid var(--border); border-radius: var(--r-pill);
  padding: var(--sp-1) var(--sp-3); background: var(--surface-2);
}

/* contact */
.contact-card {
  position: relative; overflow: hidden;
  border: 1px solid var(--card-border); border-radius: var(--r-lg);
  background: var(--card-bg);
  box-shadow: var(--shadow-2);
  padding: clamp(var(--sp-6), 5vw, 3.2rem);
  display: flex; flex-direction: column; gap: var(--sp-6);
}
.contact-card::after {
  content: ""; position: absolute; inset: -40% -10% auto; height: 70%;
  background: radial-gradient(60% 60% at 50% 0%, var(--glow-a), transparent 70%);
  pointer-events: none;
}
.contact-card > * { position: relative; }
.mail-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); margin-top: var(--sp-2); }
.mail {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.25rem, 4.4vw, 2.1rem); letter-spacing: -.035em;
  overflow-wrap: anywhere; border-radius: var(--r-xs);
  transition: color var(--dur-2) var(--ease);
}
.mail:hover { color: var(--accent); }
.copy {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: var(--control-h); padding: 0 var(--sp-4); border-radius: var(--r-pill);
  font: 500 var(--fs-xs) var(--font-body);
  border: 1px solid var(--control-border); background: var(--control-bg); color: var(--text-soft);
  cursor: pointer; transition: color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.copy:hover { color: var(--accent); border-color: var(--control-hover-border); }
.copy .i { width: 14px; height: 14px; }
.copy .ok { display: none; }
.copy.done .ok { display: block; }
.copy.done .no { display: none; }
.copy.done { color: var(--success); border-color: var(--success); }

/* ============================================================
   FOOTER
   ============================================================ */
.site-foot { border-top: 1px solid var(--border); padding-block: var(--sp-12) var(--sp-8); background: var(--surface-2); }
.foot-grid { display: grid; gap: var(--sp-8); }
@media (min-width: 760px) { .foot-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); } }
.foot-id p { margin-top: var(--sp-4); max-width: 44ch; font-size: var(--fs-sm); color: var(--text-soft); line-height: 1.6; }
.foot-id .brand { display: inline-flex; margin: 0; }
.site-foot h2 { font: 600 var(--fs-sm)/1.3 var(--font-body); letter-spacing: 0; color: var(--text); }
.site-foot ul { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: grid; gap: 2px; }
.site-foot li a {
  display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 2rem;
  font-size: var(--fs-sm); color: var(--text-soft); border-radius: var(--r-xs);
  transition: color var(--dur-2) var(--ease);
}
.site-foot li a:hover { color: var(--accent); }
.site-foot li .i { width: 15px; height: 15px; color: var(--text-mute); }
.foot-base {
  display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-6); align-items: center; justify-content: space-between;
  margin-top: var(--sp-10); padding-top: var(--sp-5); border-top: 1px solid var(--border);
  font-size: var(--fs-xs); color: var(--text-mute);
}
.foot-base a { display: inline-flex; align-items: center; min-height: 2rem; border-radius: var(--r-xs); }
.foot-base a:hover { color: var(--accent); }

/* ============================================================
   PROJECT PAGES
   ============================================================ */
.case-hero { padding: clamp(7rem, 14vh, 9rem) 0 clamp(var(--sp-8), 5vw, var(--sp-12)); }
.crumbs { font-size: var(--fs-sm); color: var(--text-mute); display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.crumbs a { color: var(--text-soft); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; border-radius: 4px; }
.crumbs a:hover { color: var(--accent); }
.case-meta { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-6); align-items: center; }
.case-hero h1 { font-size: clamp(2.2rem, 6vw, 4rem); line-height: 1.02; letter-spacing: -.04em; font-weight: 700; margin-top: var(--sp-4); max-width: 22ch; }
.case-sum { margin-top: var(--sp-5); max-width: var(--measure); font-size: clamp(var(--fs-md), 1.7vw, 1.15rem); color: var(--text-soft); line-height: 1.68; }
.share-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-6); align-items: center; }

.case-figs { margin-top: clamp(var(--sp-8), 4vw, var(--sp-10)); }
/* a strip of figures that always fills its row, whatever the count */
.case-figs .figs {
  margin: 0; display: flex; flex-wrap: wrap; gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden;
}
.case-figs .figs li { flex: 1 1 9.5rem; background: var(--surface); padding: var(--sp-4) var(--sp-5); }
.case-figs .figs b { font-size: 1.45rem; }

.case-body { padding-block: clamp(var(--sp-8), 5vw, 3.5rem) var(--section-y); }
.case-grid { display: grid; gap: clamp(var(--sp-8), 5vw, 3.5rem); }
@media (min-width: 980px) { .case-grid { grid-template-columns: minmax(0, 1fr) 19rem; align-items: start; } }
.case-main { min-width: 0; }
.case-main > * { max-width: var(--measure); }
.case-main > .case-media { max-width: none; }
.case-main section + section, .case-main .case-media + section { margin-top: clamp(var(--sp-8), 4vw, var(--sp-12)); }
.case-main h2 { font-size: var(--fs-xl); line-height: 1.15; }
.case-main p { margin-top: var(--sp-4); color: var(--text-soft); font-size: var(--fs-md); line-height: var(--lh-read); }
.case-main p strong { color: var(--text); font-weight: 600; }
.case-main ul { margin: var(--sp-4) 0 0; padding-inline-start: var(--sp-5); color: var(--text-soft); font-size: var(--fs-md); line-height: 1.7; }
.case-main li + li { margin-top: var(--sp-3); }
.case-main li strong { color: var(--text); font-weight: 600; }
.case-media { margin: 0; }
.case-media img { width: 100%; height: auto; border: var(--media-border); border-radius: var(--media-radius); box-shadow: var(--media-shadow); }
.case-media figcaption { margin-top: var(--sp-3); font-size: var(--fs-sm); color: var(--text-mute); }
.case-main h3 { margin-top: var(--sp-6); font-size: var(--fs-lg); line-height: 1.25; }
.case-main section > .case-media { margin-top: var(--sp-6); }
.case-media.pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); max-width: 36rem; }
.case-media.pair figcaption { grid-column: 1 / -1; margin-top: 0; }
.case-side { display: grid; gap: var(--sp-4); }
@media (min-width: 980px) { .case-side { position: sticky; top: 6.5rem; } }
.side-box { border: 1px solid var(--card-border); border-radius: var(--r-md); background: var(--card-bg); padding: var(--sp-5); }
.side-box h2 { font-size: 1rem; letter-spacing: -.015em; }
.side-box .badges { margin-top: var(--sp-3); }
.side-box .links-col { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-2); margin-top: var(--sp-3); }
.side-box p { margin-top: var(--sp-2); font-size: .9rem; color: var(--text-soft); line-height: 1.6; }
.case-side .phone { width: min(100%, 19rem); }

.more { border-top: 1px solid var(--border); padding-block: clamp(var(--sp-10), 6vw, var(--sp-16)); }
.more h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
.more-grid { display: grid; gap: var(--sp-4); margin-top: var(--sp-6); }
@media (min-width: 760px) { .more-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.more-grid a {
  display: block; border: 1px solid var(--card-border); border-radius: var(--r-md); background: var(--card-bg);
  padding: var(--sp-5); transition: border-color var(--dur-2) var(--ease);
}
.more-grid a:hover { border-color: var(--accent-line); }
.more-grid b { display: block; font-family: var(--font-display); font-weight: 600; letter-spacing: -.02em; font-size: 1.04rem; }
.more-grid span { display: block; margin-top: var(--sp-2); font-size: .88rem; color: var(--text-soft); line-height: 1.5; }

/* ============================================================
   FEATURE GUIDE (the Nudge case study): a table of contents beside the sections
   ============================================================ */
.guide { border-top: 1px solid var(--border); padding-block: clamp(var(--sp-10), 6vw, var(--sp-16)); }
.guide-head { margin-bottom: clamp(var(--sp-6), 3vw, var(--sp-10)); }
.guide-grid { display: grid; gap: clamp(var(--sp-6), 4vw, var(--sp-12)); align-items: start; }
@media (min-width: 980px) { .guide-grid { grid-template-columns: 17rem minmax(0, 1fr); } }
.guide-toc { font-size: var(--fs-sm); }
@media (min-width: 980px) { .guide-toc { position: sticky; top: 6rem; max-height: calc(100vh - 7rem); overflow: auto; padding-inline-end: var(--sp-2); } }
.toc-toggle {
  display: none; width: 100%; justify-content: space-between; align-items: center;
  min-height: var(--control-h); padding: 0 var(--sp-4); border-radius: var(--r-sm);
  font: 500 var(--fs-sm)/1.2 var(--font-body); color: var(--text);
  border: 1px solid var(--control-border); background: var(--control-bg); cursor: pointer;
}
.toc-toggle::after { content: ""; width: .5rem; height: .5rem; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); margin-top: -.2rem; opacity: .6; }
.toc-toggle[aria-expanded="true"]::after { transform: rotate(-135deg); margin-top: .2rem; }
.guide-toc ol { list-style: none; margin: 0; padding: 0; }
.guide-toc > ol > li { margin-top: var(--sp-3); }
.guide-toc > ol > li > a { display: block; font-weight: 600; color: var(--text); padding: var(--sp-1) 0; border-radius: var(--r-xs); }
.guide-toc ol ol { margin-top: 2px; border-inline-start: 1px solid var(--border); }
.guide-toc ol ol a {
  display: flex; gap: var(--sp-2); align-items: baseline; padding: 3px var(--sp-3); color: var(--text-soft);
  border-radius: 0 var(--r-xs) var(--r-xs) 0; line-height: 1.4;
}
.guide-toc ol ol a span { flex: none; font-family: var(--font-mono); font-size: var(--fs-2xs); color: var(--text-mute); min-width: 2.1em; }
.guide-toc a:hover { color: var(--accent); background: var(--accent-wash); }
@media (max-width: 979px) {
  html.js .toc-toggle { display: flex; }
  html.js .guide-toc > ol { display: none; margin-top: var(--sp-3); }
  html.js .guide-toc.open > ol { display: block; }
}
.guide-body { min-width: 0; }
.guide-section + .guide-section { margin-top: clamp(var(--sp-10), 6vw, var(--sp-16)); padding-top: clamp(var(--sp-8), 4vw, var(--sp-12)); border-top: 1px solid var(--border); }
.guide-section > h2 { font-size: var(--fs-2xl); line-height: 1.1; scroll-margin-top: 6rem; }
/* the guide in three parts by specialty: implementer, functional, technical */
.guide-part + .guide-part { margin-top: clamp(var(--sp-12), 8vw, var(--sp-16)); }
.guide-part-head { margin-bottom: clamp(var(--sp-6), 4vw, var(--sp-10)); padding: var(--sp-5) var(--sp-6); border: 1px solid var(--accent-line); border-inline-start: 4px solid var(--accent); border-radius: var(--r-md); background: var(--accent-wash); scroll-margin-top: 6rem; }
.guide-part-eyebrow { margin: 0; font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.guide-part-title { margin-top: var(--sp-1); font-size: var(--fs-3xl); line-height: 1.05; }
.guide-part-intro { margin-top: var(--sp-3); max-width: var(--measure); color: var(--text-soft); font-size: var(--fs-md); line-height: 1.7; }
.guide-part[hidden], .guide-part.ver-off { display: none !important; }
html[lang="ar"] .guide-part-eyebrow, html[lang="ar"] .guide-toc > ol > li.toc-part > a { font-family: inherit; letter-spacing: 0; text-transform: none; font-weight: 700; }
.guide-toc > ol > li.toc-part { margin-top: var(--sp-6); padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.guide-toc > ol > li.toc-part:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.guide-toc > ol > li.toc-part > a { font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.guide-intro { margin-top: var(--sp-3); max-width: var(--measure); color: var(--text-soft); font-size: var(--fs-md); line-height: 1.7; }
.feature {
  margin-top: clamp(var(--sp-6), 3vw, var(--sp-8)); padding: clamp(var(--sp-5), 3vw, var(--sp-8));
  border: 1px solid var(--card-border); border-radius: var(--card-radius); background: var(--card-bg);
  display: grid; gap: var(--sp-3); scroll-margin-top: 5.5rem;
}
.feature:target { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-wash); }
.feature h3 { font-size: 1.25rem; letter-spacing: -.025em; line-height: var(--lh-snug); display: flex; gap: var(--sp-3); align-items: baseline; }
.feature-no {
  flex: none; font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; letter-spacing: 0;
  color: var(--accent); background: var(--accent-wash); border: 1px solid var(--accent-line);
  border-radius: var(--r-xs); padding: 1px var(--sp-2); line-height: 1.5;
}
.feature h4 { margin: var(--sp-2) 0 0; font: 600 var(--fs-xs)/1.3 var(--font-body); color: var(--text-mute); }
.feature p { color: var(--text-soft); font-size: .96rem; line-height: 1.65; max-width: var(--measure); }
.feature-what { color: var(--text); font-size: var(--fs-md); }
.feature-steps { margin: 0; padding-inline-start: 1.3em; color: var(--text-soft); font-size: .95rem; line-height: 1.6; max-width: var(--measure); }
.feature-steps li + li { margin-top: var(--sp-2); }
.feature-steps li::marker { color: var(--accent); font-weight: 600; }
.feature-media { margin: var(--sp-2) 0 0; }
.feature-media img, .feature-media video {
  width: 100%; height: auto; border: var(--media-border); border-radius: var(--media-radius);
  box-shadow: var(--media-shadow); background: var(--bg-deep);
}
.feature-media.portrait { max-width: 19rem; }
.feature-media:not(.portrait) { max-width: 38rem; }
.feature-media figcaption { margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--text-mute); line-height: 1.5; max-width: var(--measure); }
.feature-result strong, .feature-note strong { color: var(--text); font-weight: 600; }
.feature-edition { font-size: var(--fs-xs); color: var(--text-mute); }
/* a tall picture or clip sits beside the text where there is room */
@media (min-width: 1180px) {
  .feature.has-media { grid-template-columns: minmax(0, 1fr) 19rem; column-gap: clamp(var(--sp-6), 3vw, var(--sp-10)); }
  .feature.has-media > * { grid-column: 1; }
  .feature.has-media > .feature-media { grid-column: 2; grid-row: 1 / span 9; margin-top: 0; align-self: start; }
  .feature.has-media > .feature-media:not(.portrait) { grid-column: 1 / -1; grid-row: auto; margin-top: var(--sp-2); }
  .feature.has-media > .feature-media:not(.portrait) ~ * { grid-column: 1; }
}
@media print { .guide-toc, .feature-media video { display: none !important; } .feature { break-inside: avoid; } }

/* ============================================================
   RIGHT TO LEFT: the Arabic pages
   Latin stays in Instrument Sans / Inter; Arabic glyphs fall through to IBM Plex Sans Arabic.
   Arabic script is never letter-spaced, and wants more line-height than Latin.
   ============================================================ */
html[dir="rtl"] {
  --font-display: "Instrument Sans", "IBM Plex Sans Arabic", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Inter", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --lh-tight: 1.3;
  --lh-snug: 1.45;
  --lh-body: 1.85;
  --lh-read: 1.9;
}
html[dir="rtl"] body, html[dir="rtl"] body * { letter-spacing: 0; }
html[dir="rtl"] .alt-name { letter-spacing: -.02em; }
html[dir="rtl"] .hero h1 { line-height: 1.18; font-size: clamp(2.6rem, 7.2vw, 4.9rem); }
html[dir="rtl"] .flagship h2, html[dir="rtl"] .section-head h2, html[dir="rtl"] .case-hero h1, html[dir="rtl"] .more h2 { line-height: 1.3; }
html[dir="rtl"] .mode-word { line-height: 1.25; }
html[dir="rtl"] .card h3, html[dir="rtl"] .phase h3, html[dir="rtl"] .more-grid b, html[dir="rtl"] .pill-head h3, html[dir="rtl"] .side-box h2 { line-height: 1.5; }
html[dir="rtl"] .case-main h2 { line-height: 1.45; }
html[dir="rtl"] .brand-name { font-size: 1rem; }
html[dir="rtl"] .brand-name span { margin-top: 1px; }
html[dir="rtl"] .lede, html[dir="rtl"] .flag-lede, html[dir="rtl"] .case-sum { line-height: 1.9; }
html[dir="rtl"] .mode p, html[dir="rtl"] .step p, html[dir="rtl"] .pbr dd, html[dir="rtl"] .card .sum, html[dir="rtl"] .card > p,
html[dir="rtl"] .phase p, html[dir="rtl"] .flag-note, html[dir="rtl"] .facts dd, html[dir="rtl"] .more-grid span, html[dir="rtl"] .side-box p { line-height: 1.8; }
/* identifiers, figures, addresses: left to right inside the right-to-left text */
html[dir="rtl"] code, html[dir="rtl"] .copy-fallback, html[dir="rtl"] .print-only { direction: ltr; unicode-bidi: isolate; }
/* JetBrains Mono's "--" ligature drifts off a flag that opens an isolated run in Arabic text */
html[dir="rtl"] code { font-variant-ligatures: none; }
html[dir="rtl"] .figs b, html[dir="rtl"] .mail { direction: ltr; unicode-bidi: isolate; text-align: end; }
html[dir="rtl"] .badges span { font-family: "JetBrains Mono", "IBM Plex Sans Arabic", ui-monospace, monospace; font-size: .8rem; line-height: 1.5; }
html[dir="rtl"] .phase-no { direction: ltr; }
/* arrows that mean forward or back point the other way */
.i-flip { transform: scaleX(-1); }
/* the ambient glow mirrors too */
html[dir="rtl"] .canvasfield {
  background:
    radial-gradient(1100px 620px at 88% -8%, var(--glow-a), transparent 62%),
    radial-gradient(900px 560px at 8% 4%, var(--glow-b), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg) 55%, var(--bg-deep) 100%);
}

/* ============================================================
   MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ============================================================
   PRINT: a case study prints as a clean document
   ============================================================ */
@media print {
  @page { margin: 16mm 15mm; }
  :root, :root[data-theme="dark"], .flagship {
    --bg: #fff; --bg-deep: #fff; --surface: #fff; --surface-2: #fff; --band-bg: #fff; --band-cell: #fff;
    --border: #cfd4dd; --border-strong: #b5bcc8;
    --text: #000; --text-soft: #1f242b; --text-mute: #4a525e;
    --accent: #8a4f06; --accent-wash: transparent; --accent-line: #c9a066;
    --shadow-1: none; --shadow-2: none; --media-shadow: none; --card-shadow: none;
    color-scheme: light;
  }
  html, body { background: #fff !important; color: #000; font-size: 10.5pt; }
  .nav, .sheet, .skip, .canvasfield, .share-row, .copy-link, .copy, .filters, .filter-status,
  .more, .site-foot nav, .foot-base a, .phone, .contact-side, #copy-live, .flagship::before, .contact-card::after { display: none !important; }
  .print-only { display: block !important; font-size: 9pt; color: #4a525e; }
  .crumbs { display: none !important; }
  .case-hero { padding: 0 0 6mm; }
  .case-hero h1 { font-size: 24pt; max-width: none; }
  .case-sum { font-size: 12pt; max-width: none; }
  .case-figs { margin-top: 5mm; }
  .case-figs .figs b { font-size: 15pt; }
  .case-body { padding: 0; }
  .case-grid { display: block; }
  .case-main > * { max-width: none; }
  .case-main p, .case-main ul { font-size: 10.5pt; line-height: 1.55; }
  .case-main h2 { font-size: 14pt; }
  .case-side { position: static; margin-top: 8mm; display: block; }
  .side-box { margin-top: 4mm; padding: 4mm; }
  .case-main a[href^="http"]::after, .side-box a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8.5pt; color: #4a525e; }
  section, figure, .side-box, .figs li, .pbr > div { break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
  .case-media img { max-height: 95mm; width: auto; }
  .site-foot { background: #fff; border-top: 1px solid #cfd4dd; padding: 4mm 0 0; }
  .foot-grid { display: block; }
}

/* hero skill areas */
.skills { margin: var(--sp-6) 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 var(--sp-8); }
@media (min-width: 760px) { .skills { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.skills > div { padding: var(--sp-3) 0; border-top: 1px solid var(--border); min-width: 0; }
.skills dt { font-size: var(--fs-xs); color: var(--text-mute); }
.skills dd { margin: var(--sp-1) 0 0; font-size: var(--fs-sm); color: var(--text-soft); line-height: 1.5; }
/* certifications */
.certs { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); }
@media (min-width: 760px) { .certs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cert { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; min-width: 0; }
.cert-img { display: block; border-bottom: 1px solid var(--border); }
.cert-img img { display: block; width: 100%; height: auto; }
.cert-body { padding: var(--sp-4) var(--sp-5) var(--sp-5); }
.cert h3 { font-size: 1.1rem; letter-spacing: -.02em; }
.cert-kind { margin-top: var(--sp-2); color: var(--text-soft); font-size: var(--fs-sm); }
.cert-meta { margin-top: var(--sp-1); color: var(--text-mute); font-size: var(--fs-sm); }

/* ============================================================
   HAIRLINE FIGURES (decorative, see assets/hairline-init.js)
   The box is reserved up front (5:4, the library's ratio), so nothing shifts when a figure draws.
   Colours come from the semantic tokens; --hl-plate is the surface the figure sits on.
   ============================================================ */
.hairline {
  --hl-plate: var(--bg);
  --hairline-plate: var(--hl-plate);
  --hairline-hi: var(--accent);
  --hairline-edge: var(--text-soft);
  --hairline-mid: var(--text-mute);
  --hairline-lo: var(--border-strong);
  --hairline-stroke: .9;
  display: none; aspect-ratio: 5 / 4; width: 100%; pointer-events: auto;
}
.hairline > svg { display: block; }
/* beside the hero copy, in the empty corner; only where there is room, and never over text */
@media (min-width: 1100px) {
  .hairline.hl-corner {
    display: block; position: absolute; top: 0; inset-inline-end: var(--sp-4);
    width: clamp(17rem, 26vw, 24rem);
  }
  .hairline.hl-card { --hl-plate: var(--card-bg, var(--surface)); }
}
@media print { .hairline { display: none !important; } }
.case-hero > .wrap, .contact-card { position: relative; }
.hero-grid { position: relative; }
@media (min-width: 1100px) {
  .hairline.hl-card { top: var(--sp-6); width: clamp(15rem, 20vw, 18rem); }
}

/* ---------- guide: search, section filters, "New" mark ---------- */
.guide-tools { display: grid; gap: var(--sp-3); margin-bottom: clamp(var(--sp-6), 3vw, var(--sp-8)); }
.guide-search input {
  width: 100%; max-width: 32rem; box-sizing: border-box; padding: var(--sp-2) var(--sp-3);
  font: inherit; font-size: var(--fs-sm); color: var(--text); background: var(--card-bg);
  border: 1px solid var(--card-border); border-radius: var(--r-xs);
}
.guide-search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.guide-filters { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.guide-filter {
  font: inherit; font-size: var(--fs-xs); line-height: 1.3; color: var(--text-soft); background: transparent;
  border: 1px solid var(--border); border-radius: 999px; padding: var(--sp-1) var(--sp-3); cursor: pointer; max-width: 100%;
}
.guide-filter:hover { color: var(--accent); border-color: var(--accent-line); }
.guide-filter[aria-pressed="true"] { color: var(--accent); background: var(--accent-wash); border-color: var(--accent-line); font-weight: 600; }
.guide-filter:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.guide-count, .guide-empty { margin: 0; font-size: var(--fs-xs); color: var(--text-mute); }
.guide-section[hidden], .feature[hidden], .guide-toc li[hidden] { display: none; }
.feature-new {
  flex: none; align-self: center; font-size: var(--fs-2xs); font-weight: 600; letter-spacing: .02em; color: var(--accent);
  background: var(--accent-wash); border: 1px solid var(--accent-line); border-radius: var(--r-xs); padding: 0 var(--sp-2); line-height: 1.6;
}
.feature h3 { flex-wrap: wrap; }
