@font-face {
  font-family: 'Amiri';
  src: url('fonts/amiri-bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Plex Arabic';
  src: url('fonts/plex-ar-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Plex Arabic';
  src: url('fonts/plex-ar-semibold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  --paper: #f5f1e8;
  --paper-2: #efe9db;
  --paper-3: #e6dfcd;
  --card: #fbf9f4;

  --ink: #14203a;
  --ink-2: #33405d;
  --ink-3: #6b7590;

  --gold: #9d7526;
  --gold-2: #c19a4c;
  --gold-line: rgba(157, 117, 38, 0.32);

  --green: #3b6d11;
  --rule: rgba(20, 32, 58, 0.14);
  --rule-soft: rgba(20, 32, 58, 0.07);

  --font-display: 'Amiri', 'Times New Roman', serif;
  --font-sans: 'Plex Arabic', ui-sans-serif, system-ui, -apple-system, sans-serif;

  --text-eyebrow: clamp(0.72rem, 0.68rem + 0.16vw, 0.82rem);
  --text-body: clamp(1rem, 0.96rem + 0.2vw, 1.1rem);
  --text-lead: clamp(1.12rem, 1rem + 0.6vw, 1.4rem);
  --text-h3: clamp(1.16rem, 1.06rem + 0.5vw, 1.44rem);
  --text-h2: clamp(1.75rem, 1.35rem + 2vw, 3.1rem);
  --text-h1: clamp(2.05rem, 1.35rem + 4.6vw, 5.1rem);

  --pad-x: clamp(1.15rem, 0.6rem + 3vw, 4.5rem);
  --gap-section: clamp(4.5rem, 3rem + 7vw, 9.5rem);
  --measure: 62ch;

  --head-h: 66px;

  --dur: 260ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0 31px,
    rgba(20, 32, 58, 0.042) 31px 32px
  );
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.75;
  /* clip, not hidden: `hidden` computes overflow-y to auto, which makes body its
     own scroll container and breaks window scrolling plus position: sticky. */
  overflow-x: clip;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.14; margin: 0; }
h1 { font-size: var(--text-h1); letter-spacing: -0.01em; }
h2 { font-size: var(--text-h2); }
h3 { font-size: var(--text-h3); font-family: var(--font-sans); font-weight: 600; line-height: 1.3; }
p { margin: 0; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }

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

.wrap { width: 100%; max-width: 1240px; margin-inline: auto; padding-inline: var(--pad-x); }

.eyebrow {
  font-size: var(--text-eyebrow);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin: 0;
}
:root[dir="rtl"] .eyebrow { letter-spacing: 0.06em; }

.skip {
  position: absolute;
  inset-inline-start: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.7rem 1.1rem;
  z-index: 100;
}
.skip:focus { inset-inline-start: 0.5rem; top: 0.5rem; }

/* ── header ─────────────────────────────────────────── */

.site-head {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule-soft);
}
.site-head__in {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 2rem);
  min-height: var(--head-h);
}
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; margin-inline-end: auto; }
.brand img {
  width: 34px; height: 34px;
  border-radius: 9px;
  border: 1px solid var(--gold-line);
}
.brand b { font-family: var(--font-display); font-size: 1.22rem; font-weight: 700; letter-spacing: 0; }

.site-nav { display: flex; align-items: center; gap: clamp(0.9rem, 1.6vw, 1.7rem); }
.site-nav a {
  text-decoration: none;
  font-size: 0.95rem;
  color: var(--ink-2);
  padding-block: 0.35rem;
  border-bottom: 1px solid transparent;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.site-nav a:hover { color: var(--ink); border-bottom-color: var(--gold); }
@media (max-width: 620px) { .site-nav { display: none; } }

.lang {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.36rem 0.85rem;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.lang:hover { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 8%, transparent); }

/* ── buttons ────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.82rem 1.5rem;
  border-radius: 2px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease),
              color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { background: #0a1226; box-shadow: 0 8px 22px -12px rgba(20, 32, 58, 0.6); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn--ghost:hover { background: transparent; border-color: var(--gold); color: var(--gold); box-shadow: none; }
.btn[aria-disabled="true"] {
  background: transparent;
  color: var(--ink-3);
  border-color: var(--rule);
  border-style: dashed;
  cursor: default;
  pointer-events: none;
}
.btn small { display: block; font-weight: 400; font-size: 0.72rem; opacity: 0.8; }

/* ── hero sequence ──────────────────────────────────── */

/* Rotation takes the first ~28% (see rotEnd in app.js); the rest is the
   screen tour, so this height buys reveals of dwell, not idle scroll. */
.seq { position: relative; height: 230svh; }
.seq__stage {
  position: sticky;
  top: 0;
  height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
}
/* Single column: the canvas is a real grid item in the middle row, so it takes
   whatever the headline and captions leave over. A fixed percentage inset cannot
   know how many lines the headline wraps to, and collided with it on small
   screens and in English. */
.seq__viz {
  grid-row: 2;
  grid-column: 1;
  /* The stage centres its items, so without an explicit stretch this collapses
     to content height and the canvas (height: 100%) collapses with it. */
  align-self: stretch;
  justify-self: stretch;
  min-height: 0;
  padding-bottom: 2%;
  z-index: 0;
}
.seq__canvas { display: block; width: 100%; height: 100%; }
.seq__copy {
  grid-row: 1;
  grid-column: 1;
  align-self: start;
  /* The stage sticks to top: 0, so its first 66px sit under the sticky header.
     Clear it or the headline's first line is clipped. */
  padding-top: calc(var(--head-h) + clamp(0.4rem, 2vh, 1.4rem));
  text-align: center;
  pointer-events: none;
  z-index: 2;
}
.seq__copy h1 { margin-top: 0.5rem; text-wrap: balance; }

/* Lead and tour occupy the same slot: the lead is the intro, the tour replaces
   it once scrolling starts, so neither costs extra vertical space. */
.seq__swap {
  display: grid;
  margin-top: 0.9rem;
  min-height: 5.2rem;
}
.seq__swap > * { grid-area: 1 / 1; transition: opacity 320ms var(--ease); }
@media (max-width: 430px) { .seq__swap { min-height: 4.4rem; margin-top: 0.7rem; } }

.seq__copy p.lead {
  font-size: var(--text-lead);
  color: var(--ink-2);
  max-width: 34ch;
  margin: 0 auto;
  text-wrap: pretty;
}
.seq__tour { list-style: none; margin: 0; padding: 0; display: grid; }
.seq__tour li {
  grid-area: 1 / 1;
  opacity: 0;
  transition: opacity 300ms var(--ease);
}
.seq__tour li[data-active="true"] { opacity: 1; }
.seq__tour b {
  display: block;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--text-h3);
  line-height: 1.3;
}
.seq__tour span {
  display: block;
  color: var(--ink-2);
  font-size: 1rem;
  margin-top: 0.15rem;
}
.seq__stage[data-phase="intro"] .seq__tour { opacity: 0; }
.seq__stage[data-phase="tour"] .lead { opacity: 0; }

@media (min-width: 900px) {
  .seq__stage { grid-template-columns: 1fr 1fr; }
  /* Two columns: the canvas leaves the flow and owns the inline-end half. */
  .seq__viz { position: absolute; inset: 0; inset-inline-start: 50%; padding-bottom: 0; }
  .seq__copy {
    grid-row: 2;
    align-self: center;
    text-align: start;
    padding-top: 0;
    padding-inline-end: clamp(1rem, 3vw, 3rem);
  }
  .seq__copy p.lead { margin-inline: 0; }
  .seq__swap { min-height: 4.6rem; }
  .seq__cta { grid-column: 1; justify-content: flex-start; padding-inline-start: var(--pad-x); }
  .seq__hint { grid-column: 1; justify-self: start; padding-inline-start: var(--pad-x); }
  .seq__loader { grid-column: 2; }
}
.seq__cta {
  grid-row: 3;
  grid-column: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  justify-content: center;
  padding-bottom: clamp(1.4rem, 4vh, 3rem);
  z-index: 3;
  transition: opacity 400ms var(--ease), transform 400ms var(--ease);
}
.seq__cta[data-hidden="true"] { opacity: 0; transform: translateY(12px); pointer-events: none; }

.seq__hint {
  grid-row: 3;
  grid-column: 1;
  justify-self: center;
  align-self: end;
  padding-bottom: clamp(1.4rem, 4vh, 3rem);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  transition: opacity 300ms var(--ease);
}
.seq__hint[data-hidden="true"] { opacity: 0; }

.seq__loader {
  grid-row: 2;
  grid-column: 1;
  margin: 0;
  justify-self: center;
  align-self: center;
  z-index: 4;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  transition: opacity 400ms var(--ease);
}
.seq__loader[hidden] { display: block; opacity: 0; pointer-events: none; }

/* ── features ───────────────────────────────────────── */

.section { padding-block: var(--gap-section); }
.section__head { max-width: var(--measure); }
.section__head h2 { margin-top: 0.55rem; text-wrap: balance; }
.section__head p { color: var(--ink-2); margin-top: 0.9rem; }

.rule { border: 0; border-top: 1px solid var(--gold-line); margin: 0; }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 258px), 1fr));
  gap: 1px;
  margin-top: clamp(2.2rem, 5vw, 3.6rem);
  background: var(--rule-soft);
  border: 1px solid var(--rule-soft);
}
.feature {
  background: var(--paper);
  padding: clamp(1.3rem, 2.4vw, 2rem);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  transition: background var(--dur) var(--ease);
}
.feature:hover { background: var(--card); }
.feature__num {
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
  color: var(--gold);
  font-weight: 600;
}
.feature p { color: var(--ink-2); font-size: 0.97rem; line-height: 1.7; }
.feature__note {
  margin-top: auto;
  padding-top: 0.7rem;
  font-size: 0.82rem;
  color: var(--ink-3);
  border-top: 1px solid var(--rule-soft);
}

.showcase {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: clamp(1.6rem, 4vw, 3.4rem);
  align-items: center;
  margin-top: clamp(2.6rem, 6vw, 4.5rem);
}
.showcase__media {
  display: flex;
  justify-content: center;
  gap: clamp(0.7rem, 1.6vw, 1.4rem);
}
.showcase__media figure { margin: 0; width: min(46%, 220px); }
.showcase__media img {
  border-radius: clamp(14px, 1.8vw, 22px);
  border: 1px solid rgba(20, 32, 58, 0.18);
  box-shadow: 0 28px 56px -34px rgba(20, 32, 58, 0.5);
}
.showcase__media figure:nth-child(2) { transform: translateY(clamp(1rem, 3vw, 2.4rem)); }

/* ── about ──────────────────────────────────────────── */

.about { display: grid; gap: clamp(1.6rem, 4vw, 3.2rem); grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.about p + p { margin-top: 1rem; }
.about__facts { display: grid; gap: 0; align-content: start; }
.about__fact { display: flex; gap: 1rem; padding-block: 0.95rem; border-top: 1px solid var(--rule-soft); }
.about__fact:last-child { border-bottom: 1px solid var(--rule-soft); }
.about__fact dt { color: var(--ink-3); font-size: 0.9rem; min-width: 9.5ch; margin: 0; }
.about__fact dd { margin: 0; font-weight: 600; }

/* ── download ───────────────────────────────────────── */

.download { text-align: center; }
.download h2 { text-wrap: balance; }
.download p { color: var(--ink-2); max-width: 44ch; margin: 1rem auto 0; }
.download__row { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; margin-top: 2rem; }

/* ── footer ─────────────────────────────────────────── */

.site-foot { border-top: 1px solid var(--rule); padding-block: clamp(2.4rem, 5vw, 4rem) 2.4rem; }
.site-foot__grid {
  display: grid;
  gap: 1.8rem clamp(1.5rem, 4vw, 4rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
}
.site-foot h2 { font-family: var(--font-sans); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
:root[dir="rtl"] .site-foot h2 { letter-spacing: 0.05em; }
.site-foot ul { list-style: none; margin: 0.9rem 0 0; padding: 0; display: grid; gap: 0.55rem; }
.site-foot a { text-decoration: none; color: var(--ink-2); border-bottom: 1px solid transparent; transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.site-foot a:hover { color: var(--ink); border-bottom-color: var(--gold); }
.site-foot__base {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.4rem;
  justify-content: space-between;
  align-items: baseline;
  margin-top: clamp(2rem, 5vw, 3.4rem);
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule-soft);
  font-size: 0.85rem;
  color: var(--ink-3);
}

/* ── reduced motion / no-js fallbacks ───────────────── */

:root.reduce .seq { height: auto; }
:root.reduce .seq__stage { position: static; height: auto; padding-block: var(--gap-section); }
/* With the canvas back in normal flow, the grid would auto-place it before the
   copy and bury the headline below the phone. Pin the reading order explicitly. */
:root.reduce .seq__stage { grid-template-columns: 1fr; }
:root.reduce .seq__copy {
  grid-row: 1;
  grid-column: 1;
  align-self: start;
  text-align: center;
  padding-inline-end: 0;
}
:root.reduce .seq__copy p.lead { margin-inline: auto; }
:root.reduce .seq__viz { position: static; inset: auto; grid-row: 2; grid-column: 1; padding-bottom: 0; }
:root.reduce .seq__canvas { height: 68svh; }
:root.reduce .seq__cta {
  grid-row: 3;
  grid-column: 1;
  justify-content: center;
  padding-inline-start: 0;
}
:root.reduce .seq__hint { display: none; }
:root.reduce .seq__cta[data-hidden="true"] { opacity: 1; transform: none; pointer-events: auto; }
:root.reduce .seq__swap { display: block; min-height: 0; }
:root.reduce .seq__tour { display: grid; gap: 0.9rem; margin-top: 1.2rem; }
:root.reduce .seq__tour li { grid-area: auto; opacity: 1; }
:root.reduce .seq__stage[data-phase="tour"] .lead { opacity: 1; }
