:root {
  --bg: #040407;
  --bg-2: #0d0f1c;
  --navy: #1b1f3b;
  --ink: #f2efe9;
  --muted: rgba(242, 239, 233, 0.62);
  --faint: rgba(242, 239, 233, 0.12);
  --coral: #d97757;
  --coral-strong: #b85c3e; /* white text on it reaches 4.5:1 (WCAG AA); --coral stays for accents */
  --teal: #2a9d8f;
  --amber: #d99a2b;
  --violet: #7b6cc4;
  --blue: #3e7cb1;
  --rose: #c2557a;
  --f-display: "Readex Pro", "IBM Plex Sans Arabic", "Segoe UI", sans-serif;
  --f-body: "IBM Plex Sans Arabic", "Segoe UI", sans-serif;
  --f-latin: "Space Grotesk", "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --gutter: clamp(16px, 5vw, 72px);
  /* Reading direction: bars grow from the reading start, the text shade sits on the text side. */
  --origin-start: right;
  --fade-angle: 270deg;
}
[dir="ltr"] { --origin-start: left; --fade-angle: 90deg; }
html:lang(en) { --f-display: "Space Grotesk", "Segoe UI", sans-serif; }

* { margin: 0; padding: 0; box-sizing: border-box; }
html { background: var(--bg); }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.75;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body.is-loading { overflow: hidden; }
::selection { background: var(--coral); color: #fff; }

a { color: inherit; text-decoration: none; }
code { font-family: var(--f-mono); font-size: 0.86em; color: var(--amber); }
button, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--coral); outline-offset: 4px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Word reveal (built by main.js) ---------- */
/* 0.3em of room above and below each masked word: Arabic letters reach past the line box (ح، ج، ي، أ). */
.split .w { display: inline-block; overflow: hidden; vertical-align: top; padding-block: 0.3em; margin-block: -0.3em; }
.split .wi { display: inline-block; will-change: transform; }

/* No loading screen: until the fonts are ready the hero waits hidden, then its words rise in (main.js). */
body.is-loading .hero-inner, body.is-loading .scroll-cue { visibility: hidden; }

/* ---------- Scene + film texture ---------- */
#scene { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
/* Over the canvas (it paints opaque black): a soft glow in the current chapter's colour. */
.scene-glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(55% 45% at 50% 42%, color-mix(in srgb, var(--scene-tint, #d97757) 14%, transparent), transparent 75%);
  opacity: var(--scene-fade, 1);
}
/* No mix-blend-mode: a blended layer over the WebGL canvas makes the browser re-blend the whole page every
   frame. Plain low opacity looks the same on near-black, and the layer is only a little larger than the screen. */
.grain {
  position: fixed; inset: -6%; z-index: 60; pointer-events: none;
  opacity: 0.035;
  animation: grain 0.9s steps(6) infinite;
}
/* No GPU: every full-screen animated layer is painted by the CPU, so the grain goes too. */
.no-gpu .grain { display: none; }
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -1%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}
.letterbox { position: fixed; inset-inline: 0; z-index: 40; height: 0; background: #000; pointer-events: none; transition: height 0.9s var(--ease); }
.letterbox-top { top: 0; }
.letterbox-bottom { bottom: 0; }
body.in-chapter .letterbox { height: 6.5vh; }

.cursor {
  position: fixed; top: 0; left: 0; z-index: 90; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border: 1px solid rgba(242, 239, 233, 0.5); border-radius: 50%; pointer-events: none;
  transition: width 0.35s var(--ease), height 0.35s var(--ease), margin 0.35s var(--ease), background 0.35s, border-color 0.35s;
  opacity: 0;
}
.cursor.on { opacity: 1; }
.cursor.big { width: 74px; height: 74px; margin: -37px 0 0 -37px; background: rgba(217, 119, 87, 0.14); border-color: var(--coral); }
@media (hover: none), (pointer: coarse) { .cursor { display: none; } }

/* ---------- HUD ---------- */
.hud {
  position: fixed; inset-block-start: 0; inset-inline: 0; z-index: 50;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 20px var(--gutter);
  background: linear-gradient(180deg, rgba(4, 4, 7, 0.7), transparent);
}
.hud-brand { font-family: var(--f-latin); font-weight: 700; letter-spacing: 0.22em; font-size: 13px; justify-self: start; }
.hud-brand span { color: var(--coral); margin: 0 4px; }
.hud-chapter { display: flex; align-items: baseline; gap: 12px; font-size: 13px; }
.hud-num { font-family: var(--f-latin); letter-spacing: 0.12em; color: var(--muted); }
.hud-num b { color: var(--ink); font-weight: 500; }
.hud-title { min-width: 7em; }
.hud-end { justify-self: end; display: flex; gap: 22px; align-items: center; font-size: 14px; }
.hud-nav { display: flex; gap: 22px; align-items: center; }
.hud-nav a, .hud-lang { position: relative; }
.hud-nav a::after, .hud-lang::after { content: ""; position: absolute; inset-inline: 0; bottom: -3px; height: 1px; background: currentColor; transform: scaleX(0); transition: transform 0.4s var(--ease); }
.hud-nav a:hover::after, .hud-lang:hover::after { transform: scaleX(1); }
.hud-cta { padding: 6px 16px; border: 1px solid currentColor; border-radius: 999px; }
.hud-cta::after { display: none; }
.hud-progress { position: absolute; inset-inline: var(--gutter); bottom: 6px; height: 1px; background: var(--faint); }
.hud-progress i { display: block; height: 100%; background: var(--ink); transform: scaleX(0); transform-origin: var(--origin-start); }

main { position: relative; z-index: 1; }

/* ---------- Hero ---------- */
.hero { position: relative; min-height: 100svh; display: grid; align-items: center; padding: 100px var(--gutter) 80px; }
.hero-inner { display: grid; gap: clamp(12px, 2.4vh, 22px); max-width: 1100px; }
.hero::before, .pin::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(var(--fade-angle), rgba(4, 4, 7, 0.78) 0%, rgba(4, 4, 7, 0.45) 38%, transparent 62%); }
.hero-inner, .ch-body { position: relative; }
.eyebrow { font-family: var(--f-latin); font-size: 13px; letter-spacing: 0.16em; color: var(--coral); text-transform: uppercase; }
.eyebrow span { color: var(--muted); margin: 0 6px; }
.hero-title {
  font-family: var(--f-display); font-weight: 700;
  font-size: clamp(42px, min(7vw, 12vh), 120px); line-height: 1.22; letter-spacing: -0.01em;
  display: grid;
}
.hero-title .accent .wi { background: linear-gradient(100deg, var(--coral), #f0b48f 55%, var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; padding-block: 0.3em; margin-block: -0.3em; }
.hero-lead { max-width: 46ch; margin-top: 6px; font-size: clamp(17px, 1.6vw, 21px); line-height: 1.9; color: var(--muted); font-weight: 300; }
.hero-meta { list-style: none; display: flex; flex-wrap: wrap; gap: clamp(20px, 4vw, 56px); margin-top: 12px; padding-top: 22px; border-top: 1px solid var(--faint); max-width: 760px; }
.hero-meta li { display: grid; }
.hero-meta b { font-family: var(--f-latin); font-weight: 300; font-size: clamp(30px, 3.4vw, 46px); line-height: 1.1; }
.hero-meta span { font-size: 14px; color: var(--muted); }
.scroll-cue { position: absolute; bottom: 28px; inset-inline-start: var(--gutter); display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }
.scroll-cue i { position: relative; width: 70px; height: 1px; background: var(--faint); overflow: hidden; }
.scroll-cue i::after { content: ""; position: absolute; inset: 0; background: var(--coral); animation: cue 2.2s var(--ease) infinite; }
@keyframes cue { 0% { transform: translateX(100%); } 100% { transform: translateX(-100%); } }
@keyframes cue-ltr { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
[dir="ltr"] .scroll-cue i::after { animation-name: cue-ltr; }

/* ---------- Chapters ---------- */
.chapter { position: relative; height: 260vh; }
.pin {
  position: sticky; top: 0; height: 100svh; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center;
  padding: 0 var(--gutter);
}
.ch-num {
  /* Sits above the bottom letterbox bar (6.5vh, shown during chapters), and line-height 1 keeps the
     whole glyph inside the box: at 0.8 and bottom: 0 the bar and .pin's overflow cut its foot
     (owner-reported twice, on a laptop). */
  position: absolute; right: calc(var(--gutter) - 1vw); bottom: 6.5vh;
  font-family: var(--f-latin); font-weight: 700; font-size: clamp(160px, min(30vw, 62vh), 460px); line-height: 1;
  color: transparent; -webkit-text-stroke: 1px color-mix(in srgb, var(--c) 55%, transparent);
  pointer-events: none; user-select: none;
}
/* The number is dir="ltr", so it sits behind the 3D subject by page direction, away from the text. */
html[dir="rtl"] .ch-num { right: auto; left: calc(var(--gutter) - 1vw); }
.ch-body { grid-column: 1; max-width: 640px; display: grid; gap: 18px; }
.ch-kicker { font-size: 14px; font-weight: 600; color: var(--c); letter-spacing: 0.02em; display: flex; align-items: center; gap: 12px; }
.ch-kicker::before { content: ""; width: 34px; height: 1px; background: var(--c); }
.ch-title { font-family: var(--f-display); font-weight: 700; font-size: clamp(36px, 4.4vw, 70px); line-height: 1.32; text-wrap: balance; }
.ch-text { color: var(--muted); font-size: clamp(16px, 1.35vw, 19px); max-width: 46ch; }

.term {
  margin-top: 10px; border-radius: 14px; overflow: hidden; text-align: left;
  background: rgba(10, 12, 24, 0.9); border: 1px solid var(--faint); /* no backdrop blur: it re-blurs the moving scene every frame */
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
}
.term-bar { display: flex; align-items: center; gap: 7px; padding: 11px 14px; border-bottom: 1px solid var(--faint); font-family: var(--f-mono); font-size: 11.5px; color: var(--muted); }
.term-bar i { width: 10px; height: 10px; border-radius: 50%; background: rgba(242, 239, 233, 0.18); }
.term-bar i:first-child { background: var(--c); }
.term-bar span { margin-inline-start: 8px; }
.term-body { min-height: 9.4em; padding: 16px 18px 18px; font-family: var(--f-mono); font-size: clamp(12px, 1vw, 14px); line-height: 1.75; color: #d7dbe8; white-space: pre-wrap; }
.term-body .caret { display: inline-block; width: 0.6em; height: 1.1em; margin-bottom: -0.2em; background: var(--c); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Spec-Kit reel ---------- */
.reel { position: relative; height: 320vh; }
.reel-pin { position: sticky; top: 0; height: 100svh; overflow: hidden; display: grid; align-content: center; gap: 34px; }
.reel-label { padding: 0 var(--gutter); font-size: 14px; color: var(--amber); font-weight: 600; }
.reel-track { list-style: none; display: flex; gap: 22px; padding: 0 var(--gutter); width: max-content; will-change: transform; }
.reel-track li {
  position: relative; width: clamp(240px, 26vw, 360px); aspect-ratio: 3 / 4; padding: 28px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 14px;
  border-radius: 20px; border: 1px solid var(--faint); overflow: hidden;
  background: linear-gradient(160deg, #2a2112, #0d0f1c 55%);
}
.reel-track li::before { content: ""; position: absolute; inset: 0; background: radial-gradient(80% 60% at 50% 0%, rgba(217, 154, 43, 0.22), transparent 70%); }
.reel-track b { position: absolute; top: 18px; inset-inline-start: 24px; font-family: var(--f-latin); font-weight: 700; font-size: 92px; line-height: 1; color: transparent; -webkit-text-stroke: 1px rgba(217, 154, 43, 0.6); }
.reel-track h3 { position: relative; font-family: var(--f-mono); font-weight: 600; font-size: 22px; text-align: start; }
.reel-track p { position: relative; color: var(--muted); font-size: 15.5px; line-height: 1.7; }

/* ---------- Tool cards (drag, swipe or Tab sideways) ---------- */
.tools { position: relative; padding: 90px 0; border-block: 1px solid var(--faint); background: var(--bg); }
.tools-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 0 var(--gutter); margin-bottom: 26px; }
.tools-hint { font-size: 14px; color: var(--muted); }
.tools-row {
  list-style: none; display: flex; gap: 18px; padding: 6px var(--gutter) 10px;
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity;
  scroll-padding-inline: var(--gutter); cursor: grab;
}
.tools-row.is-dragging { cursor: grabbing; scroll-snap-type: none; user-select: none; }
@media (pointer: fine) { .tools-row { scrollbar-width: none; } .tools-row::-webkit-scrollbar { display: none; } }
.tool-card {
  position: relative; flex: 0 0 clamp(230px, 22vw, 300px); min-height: 220px; padding: 26px;
  display: flex; flex-direction: column; gap: 14px; scroll-snap-align: start;
  border-radius: 20px; border: 1px solid var(--faint); overflow: hidden;
  background: linear-gradient(160deg, #2a1a16, var(--bg-2) 55%);
}
.tool-card::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(80% 60% at 50% 0%, rgba(217, 119, 87, 0.2), transparent 70%); }
.tool-card svg { position: relative; color: var(--coral); margin-bottom: auto; }
.tool-card h3 { position: relative; font-family: var(--f-mono); font-weight: 600; font-size: 20px; text-align: start; }
.tool-card p { position: relative; color: var(--muted); font-size: 15.5px; line-height: 1.75; }
.tool-card:focus-visible { outline-offset: -2px; border-radius: 20px; }

/* ---------- Film: request → code → site (CSS 3D, driven by film.js) ---------- */
/* Without film.js (no JS or reduced motion) the section rests on the finished site with all
   three lines visible; film.js adds .film-live and scrubs the three stages. */
.cinematic { --c: var(--coral); position: relative; background: var(--bg); }
.sticky { position: relative; overflow: hidden; display: grid; place-items: center; align-content: center; gap: 36px; min-height: 100svh; padding: 120px 20px 80px; background: radial-gradient(70% 60% at 50% 50%, #12152a, var(--bg)); }
.vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(120% 90% at 50% 45%, transparent 40%, rgba(0, 0, 0, 0.75) 100%); }
.film-stage { position: relative; z-index: 1; display: grid; place-items: center; perspective: 1400px; }
.film-rig { position: relative; width: min(620px, 88vw); aspect-ratio: 16 / 10; transform-style: preserve-3d; }
.film-rig > * { position: absolute; inset: 0; }
.film-terminal, .film-code { display: none; }
.film-terminal { margin: 0; backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(10, 12, 24, 0.94); }
.film-term-body { padding: 22px 22px 26px; font-family: var(--f-mono); font-size: clamp(13px, 1.5vw, 17px); line-height: 1.8; color: #d7dbe8; display: grid; gap: 4px; }
.film-ask { color: var(--ink); }
.film-ps { color: var(--coral); }
html:lang(ar) .film-typed { font-family: var(--f-body); } /* the mono font has no Arabic letters */
.film-ask .caret { display: inline-block; width: 0.55em; height: 1.1em; margin-inline-start: 2px; margin-bottom: -0.2em; background: var(--coral); animation: blink 1s steps(1) infinite; }
.film-code { list-style: none; display: none; align-content: center; gap: 8px; padding: 8% 10%; transform-style: preserve-3d; font-family: var(--f-mono); font-size: clamp(12px, 1.4vw, 16px); color: #cfd5ea; }
.film-code li { width: fit-content; padding: 6px 12px; border-radius: 8px; background: rgba(13, 15, 28, 0.88); border: 1px solid var(--faint); white-space: nowrap; }
.film-code b { color: var(--coral); font-weight: 600; }
.film-site { display: grid; grid-template-rows: auto 1fr auto; gap: 6%; padding: 5%; border-radius: 16px; border: 1px solid var(--faint); background: linear-gradient(160deg, #1a1420, var(--bg-2) 60%); box-shadow: 0 40px 90px rgba(0, 0, 0, 0.55); }
.film-site i, .film-site b { display: block; border-radius: 6px; }
.site-nav { display: flex; align-items: center; gap: 4%; }
.site-nav b { width: 18%; height: 10px; background: var(--coral); }
.site-nav i { width: 9%; height: 6px; background: rgba(242, 239, 233, 0.25); }
.site-nav i:first-of-type { margin-inline-start: auto; }
.site-hero { display: grid; align-content: center; gap: 12px; }
.site-title { width: 70%; height: clamp(14px, 3vw, 28px); background: linear-gradient(100deg, var(--coral), #f0b48f 55%, var(--violet)); }
.site-line { width: 52%; height: 8px; background: rgba(242, 239, 233, 0.3); }
.site-btn { width: 22%; height: clamp(16px, 2.6vw, 26px); border-radius: 999px !important; background: var(--coral-strong); }
.site-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4%; }
.site-cards i { aspect-ratio: 4 / 3; border-radius: 10px; border: 1px solid var(--faint); background: rgba(242, 239, 233, 0.06); }
.overlay { position: relative; z-index: 3; display: grid; gap: 6px; justify-items: center; text-align: center; }
.reveal-line { padding: 0 20px; font-family: var(--f-display); font-weight: 700; font-size: clamp(26px, 4.4vw, 60px); line-height: 1.32; text-shadow: 0 2px 24px rgba(4, 4, 7, 0.9); }
.reveal-line.accent { color: var(--coral); }

/* Live: a long scroll pins the stage while the three stages play. */
.cinematic.film-live { height: 380vh; }
.film-live .sticky { position: sticky; top: 0; height: 100svh; min-height: 0; padding: 0; }
.film-live .film-stage { position: absolute; inset: 0; transform: translateY(-6vh); }
.film-live .film-terminal { display: block; }
.film-live .film-code { display: grid; }
.film-live .overlay { position: absolute; inset-inline: 0; bottom: 8vh; }
.film-live .reveal-line { grid-row: 2; grid-column: 1; opacity: 0; will-change: opacity, transform; } /* the three lines share one slot */

/* ---------- Assistant ---------- */
.ask {
  position: relative; display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: clamp(28px, 5vw, 80px); align-items: center;
  padding: 180px var(--gutter) 140px; background: radial-gradient(60% 50% at 25% 50%, rgba(123, 108, 196, 0.14), transparent 70%), var(--bg);
}
.ask-intro { display: grid; gap: 18px; align-content: center; }
.ask-intro h2 { font-family: var(--f-display); font-weight: 700; font-size: clamp(40px, 5vw, 80px); line-height: 1.25; }
.ask-intro > p { color: var(--muted); max-width: 40ch; line-height: 1.8; }
.suggest { display: grid; gap: 16px; margin-top: 6px; }
.suggest-group { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.suggest-label { flex-basis: 100%; font-size: 13px; letter-spacing: 0.04em; color: var(--coral); }
.suggest button {
  cursor: pointer; text-align: start; font-size: 14px; padding: 10px 16px; border-radius: 999px;
  background: rgba(242, 239, 233, 0.04); border: 1px solid var(--faint); transition: border-color 0.3s, background 0.3s, transform 0.3s var(--ease);
}
.suggest button:hover { border-color: var(--coral); background: rgba(217, 119, 87, 0.1); transform: translateY(-2px); }

.chat {
  display: flex; flex-direction: column; height: min(680px, 78svh); border-radius: 24px; overflow: hidden;
  background: linear-gradient(180deg, rgba(20, 23, 44, 0.92), rgba(10, 12, 24, 0.95)); border: 1px solid var(--faint);
  box-shadow: 0 60px 120px rgba(0, 0, 0, 0.55);
}
.chat-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--faint); }
.chat-head b { display: block; font-size: 15px; }
.chat-status { color: var(--muted); font-size: 12.5px; }
.chat-tools { margin-inline-start: auto; display: flex; gap: 6px; }
.chat-tool { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; border: 1px solid var(--faint); background: transparent; color: var(--muted); cursor: pointer; transition: color 0.2s, border-color 0.2s; }
.chat-tool:hover { color: var(--ink); border-color: var(--muted); }
.chat-tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-privacy { padding: 10px 18px 14px; font-size: 12.5px; color: var(--muted); background: rgba(5, 6, 12, 0.5); }
.chat-privacy a, .legal-link a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.legal-link { margin-top: 28px; font-size: 14px; color: var(--muted); text-align: center; }
/* Enlarged chat: a dialog over the dimmed page (full screen on phones). */
.chat-backdrop { position: fixed; inset: 0; z-index: 88; background: rgba(4, 4, 7, 0.78); }
.chat.is-expanded { position: fixed; z-index: 89; inset-block: 4vh; inset-inline: max(4vw, calc((100vw - 1000px) / 2)); height: auto; }
/* main is its own layer (z-index 1, under the top bar); while the chat is enlarged it goes on top. */
body.chat-open { overflow: hidden; }
body.chat-open main { z-index: 87; }
.chat-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 12px var(--amber); }
.chat.online .chat-dot { background: var(--teal); box-shadow: 0 0 12px var(--teal); }
.chat.offline .chat-dot { background: var(--rose); box-shadow: 0 0 12px var(--rose); }
.msg-contact { display: inline-block; margin-top: 8px; padding: 8px 16px; border-radius: 999px; background: var(--coral-strong); color: #fff; font-size: 14px; font-weight: 600; }
.chat-messages { flex: 1; overflow-y: auto; padding: 22px 20px; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--faint) transparent; }
.msg { display: flex; flex-direction: column; max-width: 86%; min-width: 0; animation: msg-in 0.5s var(--ease); }
/* A long line or a code block scrolls inside the bubble instead of widening it past the chat box. */
.bubble { max-width: 100%; min-width: 0; }
@keyframes msg-in { from { opacity: 0; transform: translateY(12px); } }
.msg-user { align-self: flex-start; align-items: flex-start; }
.msg-assistant { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 12px 16px; border-radius: 18px; font-size: 15.5px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-user .bubble { background: var(--coral-strong); color: #fff; border-start-start-radius: 6px; }
.msg-assistant .bubble { background: rgba(242, 239, 233, 0.06); border: 1px solid var(--faint); border-start-end-radius: 6px; white-space: normal; }
.bubble p + p { margin-top: 8px; }
.bubble pre { margin: 10px 0; padding: 12px 14px; border-radius: 10px; background: #05060c; border: 1px solid var(--faint); overflow-x: auto; direction: ltr; text-align: left; font-family: var(--f-mono); font-size: 13px; line-height: 1.6; white-space: pre; }
.bubble code { unicode-bidi: isolate; direction: ltr; }
.msg small { margin-top: 5px; font-family: var(--f-mono); font-size: 11px; color: var(--muted); }
.typing { display: inline-flex; gap: 5px; padding: 4px 2px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: typing 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-5px); opacity: 1; } }
.chat-form { display: flex; gap: 10px; align-items: flex-end; padding: 14px; border-top: 1px solid var(--faint); background: rgba(5, 6, 12, 0.5); }
.chat-form textarea { flex: 1; resize: none; max-height: 140px; overflow-y: hidden; padding: 12px 16px; border-radius: 14px; background: rgba(242, 239, 233, 0.05); border: 1px solid var(--faint); line-height: 1.6; font-size: 15px; }
.chat-form textarea:focus { outline: none; border-color: var(--coral); }
.chat-form button { flex: none; width: 48px; height: 48px; border-radius: 14px; border: 0; cursor: pointer; background: var(--coral-strong); display: grid; place-items: center; transition: transform 0.3s var(--ease), opacity 0.3s; }
.chat-form button:hover { transform: scale(1.06); }
.chat-form button:disabled, .chat-form textarea:disabled { opacity: 0.5; cursor: wait; }
.chat-form svg { width: 20px; height: 20px; fill: #fff; transform: scaleX(-1); }

.toasts { position: fixed; bottom: 24px; inset-inline: 0; margin-inline: auto; z-index: 95; display: grid; gap: 10px; width: min(440px, calc(100vw - 32px)); }
.toast { padding: 12px 18px; border-radius: 14px; background: #2a1520; border: 1px solid var(--rose); font-size: 14.5px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); animation: msg-in 0.4s var(--ease); }

/* ---------- Courses ---------- */
.courses {
  position: relative; display: grid; justify-items: center; text-align: center; gap: 18px;
  padding: 160px var(--gutter) 120px;
  background: radial-gradient(50% 40% at 50% 30%, rgba(42, 157, 143, 0.12), transparent 70%), var(--bg);
}
.courses-title { font-family: var(--f-display); font-weight: 700; font-size: clamp(44px, 6vw, 96px); line-height: 1.25; }
.courses-lead { color: var(--muted); max-width: 52ch; }
.course-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(18px, 3vw, 36px); width: min(1180px, 100%); margin-top: 28px; }
.course-card {
  position: relative; display: flex; flex-direction: column; gap: 22px; padding: clamp(26px, 3vw, 44px); text-align: start;
  border-radius: 28px; border: 1px solid var(--faint); overflow: hidden;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 14%, transparent), rgba(10, 12, 24, 0.6) 55%);
  transition: border-color 0.4s, transform 0.5s var(--ease);
}
.course-card:hover, .course-card:focus-within { border-color: color-mix(in srgb, var(--c) 60%, transparent); transform: translateY(-4px); }
.course-num { font-family: var(--f-latin); font-size: 14px; letter-spacing: 0.16em; color: var(--c); }
.course-card h3 { font-family: var(--f-display); font-weight: 700; font-size: clamp(30px, 3.4vw, 46px); line-height: 1.3; }
.course-for { color: var(--muted); max-width: 46ch; }
.course-levels { list-style: none; counter-reset: level; display: flex; flex-wrap: wrap; gap: 8px; }
.course-levels li {
  counter-increment: level; display: inline-flex; align-items: center; gap: 8px; padding-block: 7px; padding-inline: 12px 14px; border-radius: 999px;
  font-size: 14px; background: rgba(242, 239, 233, 0.04); border: 1px solid var(--faint);
}
.course-levels li::before { content: counter(level); font-family: var(--f-mono); font-size: 12px; color: var(--c); }
.course-meta { font-size: 14px; color: var(--muted); }
.course-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: auto; padding-top: 8px; }
.course-actions .btn { padding: 14px 22px; }
.courses-roadmap { margin-top: 44px; color: var(--muted); text-decoration: underline; text-underline-offset: 5px; text-decoration-color: var(--faint); transition: color 0.3s, text-decoration-color 0.3s; }
.courses-roadmap:hover { color: var(--ink); text-decoration-color: var(--coral); }

/* ---------- Chat · courses · plugins (home #how and the tools page, feature 007) ---------- */
.trio { list-style: none; counter-reset: trio; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(14px, 2vw, 24px); width: min(1180px, 100%); margin-top: 34px; }
.trio-step {
  counter-increment: trio; display: grid; align-content: start; gap: 14px; padding: clamp(26px, 2.6vw, 34px); text-align: start; border-radius: 24px;
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 12%, transparent), rgba(10, 12, 24, 0.6) 70%);
}
.trio-step::before { content: "0" counter(trio); font-family: var(--f-latin); font-size: 14px; letter-spacing: 0.16em; color: var(--c); }
.trio-step h2, .trio-step h3 { font-family: var(--f-display); font-size: clamp(22px, 2vw, 28px); line-height: 1.35; }
.trio-step p { color: var(--muted); }
.trio-link { justify-self: start; margin-top: 4px; font-weight: 600; text-decoration: underline; text-underline-offset: 6px; text-decoration-color: var(--c); }
.trio-link:hover { color: var(--c); }
.how { display: grid; justify-items: center; text-align: center; gap: 18px; padding: 120px var(--gutter) 60px; }
.how-title { font-family: var(--f-display); font-weight: 700; font-size: clamp(36px, 5vw, 72px); line-height: 1.25; }
.how-lead { color: var(--muted); max-width: 52ch; }
@media (max-width: 900px) { .trio { grid-template-columns: 1fr; width: min(560px, 100%); } }
@media (max-width: 760px) { .how { padding: 100px 16px 40px; } }
.does { padding-block: 100px 120px; }

/* ---------- Proof (text only: what these tools built) ---------- */
.proof { display: grid; justify-items: center; text-align: center; gap: 18px; padding: 140px var(--gutter) 40px; background: var(--bg); }
.proof-title { font-family: var(--f-display); font-weight: 700; font-size: clamp(34px, 4.6vw, 64px); line-height: 1.3; max-width: 18ch; }
.proof-list { list-style: none; display: grid; gap: 12px; width: min(760px, 100%); margin-top: 18px; text-align: start; }
.proof-list li {
  padding: 16px 20px; border-radius: 16px; line-height: 1.75;
  border: 1px solid rgba(255, 255, 255, 0.08); background: rgba(255, 255, 255, 0.03);
  border-inline-start: 3px solid #d97757;
}
.proof-close { margin-top: 18px; font-family: var(--f-display); font-size: clamp(20px, 2vw, 26px); line-height: 1.5; color: #d97757; }
@media (max-width: 760px) { .proof { padding: 110px 16px 30px; } .does { padding-block: 80px 90px; } }

/* ---------- Finale ---------- */
.finale {
  position: relative; min-height: 100svh; display: grid; place-content: center; justify-items: center; text-align: center; gap: 22px;
  padding: 140px var(--gutter) 80px; overflow: hidden;
  background: radial-gradient(60% 45% at 50% 40%, rgba(217, 119, 87, 0.22), transparent 70%), var(--bg);
}
.finale-title { font-family: var(--f-display); font-weight: 700; font-size: clamp(64px, 13vw, 210px); line-height: 1.25; }
/* Arabic glyphs overflow the line box; background-clip: text only paints inside the box, so pad it. */
.finale-title .wi { padding-block: 0.3em; background: linear-gradient(180deg, var(--ink) 55%, rgba(242, 239, 233, 0.75)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.finale-lead { color: var(--muted); max-width: 44ch; }
.buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 10px; }
.btn { display: inline-flex; align-items: center; gap: 14px; padding: 16px 28px; border-radius: 999px; border: 1px solid rgba(242, 239, 233, 0.3); font-weight: 600; transition: transform 0.4s var(--ease), background 0.4s, border-color 0.4s; }
.btn small { font-family: var(--f-latin); font-size: 12px; color: var(--muted); }
.btn:hover { transform: translateY(-3px); border-color: var(--ink); }
.btn-primary { background: var(--coral-strong); border-color: var(--coral-strong); color: #fff; }
.btn-primary small { color: rgba(255, 255, 255, 0.75); }
/* Any lighter coral drops under 4.5:1 with white, so hover goes one step deeper. */
.btn-primary:hover { background: #a8502f; border-color: #a8502f; }
.contact { display: grid; justify-items: center; gap: 12px; margin-top: 18px; }
.contact-heading { font-size: 14px; color: var(--muted); }
.contact .btn { padding: 12px 24px; }

/* ---------- Floating WhatsApp ---------- */
/* Hidden (and out of the tab order) during the intro and while the chat input is on screen. */
.wa-float {
  position: fixed; z-index: 90; inset-inline-end: 20px; inset-block-end: calc(20px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: var(--coral); color: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(217, 119, 87, 0.35);
  transition: transform 0.3s var(--ease), opacity 0.3s, visibility 0.3s;
}
.wa-float:hover { transform: scale(1.06); }
body.is-loading .wa-float, .wa-float.is-hidden { opacity: 0; visibility: hidden; }

.credits { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px 56px; margin-top: 70px; padding-top: 36px; border-top: 1px solid var(--faint); }
.credits div { display: grid; gap: 2px; }
.credits dt { font-size: 12.5px; color: var(--muted); }
.credits dd { font-family: var(--f-latin); font-size: 17px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hud { grid-template-columns: auto 1fr auto; }
  .hud-nav { display: none; }
  .hud-chapter { justify-self: end; min-width: 0; }
  .hud-title { min-width: 0; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pin { grid-template-columns: 1fr; align-items: end; padding-bottom: 8vh; }
  .hero::before, .pin::before { background: linear-gradient(0deg, rgba(4, 4, 7, 0.88) 0%, rgba(4, 4, 7, 0.5) 45%, transparent 70%); }
  .ch-body { max-width: none; gap: 12px; }
  .ch-num { top: 11vh; bottom: auto; font-size: 44vw; }
  .term-body { min-height: 0; font-size: 11.5px; }
  .ask { grid-template-columns: 1fr; padding: 150px 16px 110px; }
  .courses { padding: 130px 16px 90px; }
  .course-grid { grid-template-columns: 1fr; }
  .chat { height: 72svh; }
  .credits { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 30px; }
  body.in-chapter .letterbox { height: 4vh; }
}
@media (max-width: 520px) {
  .tools { padding: 64px 0; }
  .tools-head { flex-direction: column; gap: 4px; }
  .chat.is-expanded { inset: 0; border-radius: 0; }
  .course-actions .btn { width: 100%; flex-direction: column; align-items: flex-start; gap: 2px; border-radius: 20px; }
  .film-code { padding: 6% 2%; font-size: 11px; }
  .hud-title { display: none; }
  .ch-text { font-size: 15px; }
  .term { display: none; }
  .msg { max-width: 94%; }
  .wa-float { width: 52px; height: 52px; inset-inline-end: 16px; inset-block-end: calc(16px + env(safe-area-inset-bottom)); }
  .toasts { bottom: calc(80px + env(safe-area-inset-bottom)); }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .grain, .scroll-cue i::after, .term-body .caret, .film-ask .caret { animation: none; }
  .letterbox { transition: none; }
  .wa-float, .wa-float:hover { transition: none; transform: none; }
}
