/* ============================================================
   Q HUB site — design tokens, base, typography, buttons, reveal states
   Brand: teal #6cbcc9 · navy #252b3b · Readex Pro / IBM Plex Sans Arabic / Space Grotesk
   ============================================================ */

:root {
  /* brand */
  --teal: #6cbcc9;
  --teal-hi: #8fdce8;
  --navy: #252b3b;
  --navy-900: #141926;
  --navy-800: #1b2130;
  --amber: #f2b866;

  /* light tone (default) */
  --bg: #ffffff;
  --bg-soft: #f4f7f9;
  --bg-elev: #ffffff;
  --ink: #161b28;
  --ink-2: #3a4356;
  --mut: #5d6779;
  --line: rgba(22, 27, 40, 0.09);
  --line-2: rgba(22, 27, 40, 0.16);
  --teal-ink: #1f6f7d;
  --teal-soft: rgba(108, 188, 201, 0.14);
  --teal-line: rgba(108, 188, 201, 0.42);
  --glass: rgba(255, 255, 255, 0.72);
  --glass-line: rgba(22, 27, 40, 0.08);
  --shadow-sm: 0 1px 2px rgba(22, 27, 40, 0.06), 0 6px 18px -10px rgba(22, 27, 40, 0.18);
  --shadow-md: 0 24px 54px -30px rgba(22, 27, 40, 0.34);
  --shadow-lg: 0 44px 90px -40px rgba(22, 27, 40, 0.42);
  --ok: #1e7a4e;
  --ok-soft: rgba(46, 170, 110, 0.12);
  --bad: #b4530b;
  --bad-soft: rgba(234, 120, 40, 0.12);
  --danger: #c0392b;

  /* type */
  --f-head: "Readex Pro", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --f-body: "IBM Plex Sans Arabic", "Readex Pro", system-ui, sans-serif;
  --f-num: "Space Grotesk", "Readex Pro", system-ui, sans-serif;
  --fs-hero: clamp(1.85rem, 3.3vw + 0.35rem, 3.9rem);
  --fs-h2: clamp(1.85rem, 2.6vw + 0.8rem, 3.25rem);
  --fs-h3: clamp(1.1rem, 0.5vw + 1rem, 1.35rem);
  --fs-body: 1.0625rem;
  --fs-sm: 0.9375rem;
  --fs-xs: 0.8125rem;

  /* space (8pt rhythm) */
  --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem; --s-5: 1.5rem;
  --s-6: 2rem; --s-7: 3rem; --s-8: 4rem; --s-9: 6rem;
  --sec-y: clamp(4.5rem, 9vw, 8.5rem);
  --wrap: 1240px;
  --gut: clamp(1.1rem, 4vw, 2.5rem);

  /* shape */
  --r-sm: 12px; --r-md: 18px; --r-lg: 28px; --r-xl: 36px; --r-pill: 999px;

  /* motion — one rhythm for the whole site */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 0.18s; --t-med: 0.32s; --t-slow: 0.7s;

  /* layers */
  --z-nav: 100; --z-menu: 90; --z-fab: 60; --z-wipe: 900; --z-loader: 1000; --z-modal: 500;

  color-scheme: light;
}

/* dark tone: whole page in dark theme, and the always-dark sections in both themes */
[data-theme="dark"], .tone-dark, .nav.on-dark {
  --bg: #141926;
  --bg-soft: #1b2130;
  --bg-elev: #20273a;
  --ink: #f2f5f9;
  --ink-2: #c9d1de;
  --mut: #a9b3c4; /* was #98a3b6 — a touch lighter for small grey text on navy */
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.18);
  --teal-ink: #8fdce8;
  --teal-soft: rgba(108, 188, 201, 0.15);
  --teal-line: rgba(108, 188, 201, 0.4);
  --glass: rgba(27, 33, 48, 0.66);
  --glass-line: rgba(255, 255, 255, 0.1);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 22px -12px rgba(0, 0, 0, 0.6);
  --shadow-md: 0 26px 60px -30px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 46px 96px -40px rgba(0, 0, 0, 0.8);
  --ok: #58d39a;
  --ok-soft: rgba(88, 211, 154, 0.12);
  --bad: #f2a25c;
  --bad-soft: rgba(242, 162, 92, 0.12);
  --danger: #ff8a7a;
}
[data-theme="dark"] { color-scheme: dark; }
[data-theme="dark"] .tone-dark { --bg: #0f131d; --bg-soft: #161b28; --bg-elev: #1b2130; }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 96px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--fs-body);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
html[lang="en"] body, html[lang="zh"] body { line-height: 1.65; }
/* Arabic headings: IBM Plex Sans Arabic dots the final yeh (في / شي) — Readex Pro draws it dotless, which Saudi readers take for a typo */
html[lang="ar"] { --f-head: "IBM Plex Sans Arabic", "Readex Pro", system-ui, sans-serif; }
html[lang="en"] { --f-head: "Space Grotesk", "Readex Pro", system-ui, sans-serif; --f-body: "Space Grotesk", "IBM Plex Sans Arabic", system-ui, sans-serif; }
img, video, svg { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; touch-action: manipulation; }
h1, h2, h3, p, dl, dd, ol, ul, figure, fieldset { margin: 0; padding: 0; }
ol, ul { list-style: none; }
fieldset { border: 0; min-width: 0; }
[hidden] { display: none !important; }
::selection { background: var(--teal); color: #0f1a22; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; border-radius: 6px; }

.wrap { width: min(var(--wrap), 100% - var(--gut) * 2); margin-inline: auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums; letter-spacing: 0; direction: ltr; unicode-bidi: isolate; }
.skip { position: fixed; inset-inline-start: 16px; top: -80px; z-index: 2000; background: var(--teal); color: #0f1a22; padding: 12px 18px; border-radius: var(--r-sm); font-weight: 600; transition: top var(--t-med) var(--ease-out); }
.skip:focus { top: 16px; }

section { position: relative; padding-block: var(--sec-y); background: var(--bg); color: var(--ink); }
.tone-dark { background: var(--bg); color: var(--ink); }

/* ---------- section heads ---------- */
.sec-head { display: grid; gap: var(--s-4); max-width: 46rem; margin-bottom: clamp(2rem, 4vw, 3.5rem); justify-items: start; }
.sec-head.center { margin-inline: auto; text-align: center; justify-items: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-family: var(--f-head); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.02em;
  color: var(--teal-ink); background: var(--teal-soft); border: 1px solid var(--teal-line);
  padding: 0.4rem 0.9rem; border-radius: var(--r-pill);
}
.eyebrow::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--teal); transform: rotate(18deg); }
.sec-h { font-family: var(--f-head); font-size: var(--fs-h2); font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; text-wrap: balance; }
html[lang="en"] .sec-h, html[lang="zh"] .sec-h { line-height: 1.14; letter-spacing: -0.02em; }
.sec-p { color: var(--mut); font-size: clamp(1rem, 0.4vw + 0.95rem, 1.15rem); max-width: 40rem; text-wrap: pretty; }
.grad-t { color: var(--teal-ink); position: relative; white-space: nowrap; }
.tone-dark .grad-t, [data-theme="dark"] .grad-t { background: linear-gradient(100deg, var(--teal-hi), var(--teal)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.note { margin-top: var(--s-5); color: var(--mut); font-size: var(--fs-sm); }

/* ---------- buttons ---------- */
.btn {
  --bx: 0px; --by: 0px;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 0.7rem;
  min-height: 48px; padding: 0.7rem 1.4rem; border-radius: var(--r-pill);
  font-family: var(--f-head); font-weight: 600; font-size: var(--fs-sm); line-height: 1.2; white-space: nowrap;
  cursor: pointer; isolation: isolate; overflow: hidden;
  transform: translate(var(--bx), var(--by));
  transition: transform var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out), background-color var(--t-med) ease, border-color var(--t-med) ease, color var(--t-med) ease;
}
.btn:active { transform: translate(var(--bx), var(--by)) scale(0.97); transition-duration: var(--t-fast); }
.btn-lg { min-height: 56px; padding: 0.9rem 1.8rem; font-size: 1rem; }
.btn-sm { min-height: 44px; padding: 0.5rem 1.1rem; font-size: 0.875rem; }
.btn-p { background: var(--teal); color: #0f1a22; box-shadow: 0 10px 30px -12px rgba(108, 188, 201, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.45); }
.btn-p::before { /* sheen that crosses on hover */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
  transform: translateX(-120%); transition: transform 0.75s var(--ease-out);
}
[dir="rtl"] .btn-p::before { transform: translateX(120%); }
.btn-p:hover { background: var(--teal-hi); box-shadow: 0 16px 38px -12px rgba(108, 188, 201, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.btn-p:hover::before { transform: translateX(120%); }
[dir="rtl"] .btn-p:hover::before { transform: translateX(-120%); }
.btn-g { background: var(--glass); color: var(--ink); border: 1px solid var(--line-2); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.btn-g:hover { border-color: var(--teal); color: var(--teal-ink); background: var(--teal-soft); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* arrow that points with the reading direction */
.arr { width: 1.6em; height: 1.6em; border-radius: 50%; background: rgba(15, 26, 34, 0.12); display: grid; place-items: center; flex: none; transition: transform var(--t-med) var(--ease-spring), background-color var(--t-med) ease; }
.arr::before { content: ""; width: 0.42em; height: 0.42em; border: solid currentColor; border-width: 0 0 1.8px 1.8px; transform: rotate(45deg) translate(1px, -1px); }
[dir="ltr"] .arr::before { transform: rotate(-135deg) translate(1px, -1px); }
.btn:hover .arr { transform: translateX(-4px); background: rgba(15, 26, 34, 0.2); }
[dir="ltr"] .btn:hover .arr { transform: translateX(4px); }

.ico-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); transition: background-color var(--t-med) ease, color var(--t-med) ease, transform var(--t-med) var(--ease-spring); }
.ico-btn:hover { background: var(--teal-soft); color: var(--teal-ink); transform: rotate(18deg); }
.ico-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ico-btn .moon, [data-theme="dark"] .ico-btn .sun { display: none; }
[data-theme="dark"] .ico-btn .moon { display: block; }
.lang-btn { min-width: 44px; height: 44px; padding-inline: 0.6rem; border-radius: var(--r-pill); font-family: var(--f-num); font-weight: 600; font-size: 0.8125rem; color: var(--ink-2); transition: background-color var(--t-med) ease, color var(--t-med) ease; }
.lang-btn:hover { background: var(--teal-soft); color: var(--teal-ink); }

/* ---------- logo (inline SVG injected by core.js) ---------- */
.qmark, .qlogo { width: 100%; height: auto; overflow: visible; }
.ql-beam { fill: var(--teal); transform-box: fill-box; transform-origin: center; }
.ql-mark, .ql-en, .ql-ar, .ql-qhub { transform-box: fill-box; transform-origin: center; }
.qlogo .ql-en path, .qlogo .ql-ar path, .qlogo .ql-qhub path { fill: var(--ink); }

/* ---------- reveal states (armed only when JS runs) ---------- */
.js [data-reveal]:not(.in) { opacity: 0; transform: translateY(28px); }
.js [data-reveal="lines"]:not(.in) { opacity: 1; transform: none; }
[data-reveal] { transition: opacity var(--t-slow) var(--ease-out), transform var(--t-slow) var(--ease-out); transition-delay: calc(var(--d, 0) * 70ms); }
.ln { display: block; overflow: hidden; padding-block: 0.16em; margin-block: -0.16em; }
.ln > span { display: block; will-change: transform; }
/* section headings rise word by word (core.js wraps each word in .w > span) */
.w { display: inline-block; overflow: hidden; vertical-align: top; padding-block: 0.2em; margin-block: -0.2em; }
.w > span { display: inline-block; will-change: transform; transition: transform 0.85s var(--ease-out); transition-delay: calc(var(--w, 0) * 55ms); }
.js [data-reveal="lines"]:not(.in) .w > span { transform: translateY(115%); }
.js [data-stagger] > * { opacity: 0; transform: translateY(26px) scale(0.985); }
.js [data-stagger].in > * { opacity: 1; transform: none; transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out); transition-delay: calc(var(--i, 0) * 60ms); }

/* theme switch: a short cross-fade of the colour tokens */
.theming, .theming * { transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, fill 0.5s ease !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .js [data-reveal]:not(.in), .js [data-stagger] > *, .js [data-reveal="lines"]:not(.in) .w > span { opacity: 1; transform: none; }
}
