/* ============================================================
   Base — typography, layout primitives, global behaviors.
   Components and pages compose on top of these.
   ============================================================ */

html {
  font-size: 16px;
  background: var(--color-bg);
  color: var(--color-text);
  /* Native smooth scroll for anchor jumps. Browsers ship a great
     scroll experience by default; no JS interception needed. */
  scroll-behavior: smooth;
  /* Hide native scrollbar visually — scroll still works fully.
     IE/Edge legacy + Firefox + WebKit all handled. */
  -ms-overflow-style: none;
  scrollbar-width: none;
  /* Disable the iOS rubber-band overscroll effect. Without this,
     dragging up at the bottom reveals the fixed .hero-bg through the
     matte-glass footer for a fraction of a second. With this set the
     page stops dead at the document edges so the footer always reads
     as the absolute end of the page. Same intent on Android Chrome. */
  overscroll-behavior: none;
  -webkit-overscroll-behavior: none;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;
  width: 0;
  background: transparent;
}

body {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  background: var(--color-bg);
  color: var(--color-text);
  font-feature-settings: "ss01", "cv11";
  overflow-x: hidden;
  /* Belt-and-braces — some iOS Safari builds honor overscroll-behavior
     on body but not html (or vice-versa). Set both. */
  overscroll-behavior: none;
  -webkit-overscroll-behavior: none;
}

/* CN typography swap — body class toggled by i18n.js */
body.lang-cn {
  font-family: var(--font-cn);
  letter-spacing: 0;
}

/* zh-TW override — reorder the stack so PingFang TC / Noto Sans TC
   lead. SC fonts can render TC glyphs as fallback, but the typographic
   shapes (e.g. 為 / 為, 經 / 經) differ enough that TC readers notice. */
body.lang-zh-tw {
  --font-cn: "Noto Sans TC", "PingFang TC", "Noto Sans SC", "PingFang SC", "Microsoft JhengHei", "Microsoft YaHei", var(--font-sans);
}

body.lang-cn .display,
body.lang-cn h1, body.lang-cn h2, body.lang-cn h3 {
  font-family: var(--font-cn);
  font-weight: 500;
  letter-spacing: 0;
}

/* ------------------------------------------------------------
   Latin fragments inside CN copy.
   i18n.js wraps Latin runs (proper nouns, acronyms, alphanumerics
   like "Matrix Investment Group", "ARA", "EN590", "Bloomberg",
   "ICE", etc.) in <span class="lang-en-frag"> when the active
   language is zh-CN or zh-TW. The fragment must render in the
   original English font stack — same context as if the page were
   in English mode — so the typography of those words is preserved.

   Default: sans (matches body copy, eyebrows, links, CTAs).
   Display contexts: serif (matches headings, hero tagline,
   editorial display text). letter-spacing is restored to the
   English defaults inside the fragment so kerning of Latin
   glyphs is correct (the lang-cn override sets letter-spacing
   to 0 globally, which over-tightens English words).
   ------------------------------------------------------------ */
body.lang-cn .lang-en-frag {
  font-family: var(--font-sans);
  letter-spacing: var(--tr-normal);
}
body.lang-cn .display .lang-en-frag,
body.lang-cn h1 .lang-en-frag,
body.lang-cn h2 .lang-en-frag,
body.lang-cn h3 .lang-en-frag,
body.lang-cn .editorial-grid__heading .lang-en-frag,
body.lang-cn .hero__tagline .lang-en-frag {
  font-family: var(--font-display);
  letter-spacing: var(--tr-display);
}
body.lang-cn .eyebrow .lang-en-frag,
body.lang-cn .stat__label .lang-en-frag,
body.lang-cn .stat__suffix .lang-en-frag {
  font-family: var(--font-sans);
  letter-spacing: var(--tr-eyebrow);
}

/* Lock scroll while hero animation runs. Gated on html.js — with
   JavaScript disabled nothing would ever remove the class, so the
   lock (and the ceremony it protects) must simply not apply. */
.js body.is-locked {
  overflow: hidden;
  height: 100vh;
}

/* ---------- Display & headings ---------- */

.display,
h1.display, h2.display, h3.display {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: var(--lh-display);
  letter-spacing: var(--tr-display);
  color: var(--color-text);
  text-wrap: balance;
}

h1, .h1 {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 500;
  line-height: var(--lh-display);
  letter-spacing: var(--tr-display);
}

h2, .h2 {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 500;
  line-height: var(--lh-display);
  letter-spacing: var(--tr-display);
}

h3, .h3 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 500;
  line-height: var(--lh-tight);
  letter-spacing: var(--tr-display);
}

/* ---------- Body text ---------- */

p {
  max-width: var(--reading-max);
  line-height: var(--lh-body);
  color: var(--color-text);
}

p + p { margin-top: var(--space-3); }

.lead {
  font-size: var(--fs-md);
  line-height: 1.5;
  max-width: 56ch;
}

.muted    { color: var(--color-text-muted); }
.subtle   { color: var(--color-text-subtle); }
.brand    { color: var(--color-brand); }

/* ---------- Eyebrow / overline labels ---------- */

.eyebrow {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tr-eyebrow);
  color: var(--color-text);
  display: inline-block;
  line-height: 1;
  position: relative;
}

/* Red rule prefix — using vertical-align rather than flex baseline.
   `vertical-align: 0.32em` lifts the dash 32% of font-size above
   the text baseline, which lands it on the optical centre of any
   uppercase letterform (Inter, Noto Sans SC, Noto Sans TC, etc).
   Scales perfectly with font-size and is consistent across browsers. */
.eyebrow::before {
  content: "";
  display: inline-block;
  width: 28px;
  height: 1.5px;
  background: var(--color-brand);
  vertical-align: 0.32em;
  margin-right: 12px;
}

/* Variant without the rule (use sparingly, e.g. inside cards) */
.eyebrow--bare::before { content: none; }

.label {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tr-label);
  color: var(--color-text);
}

/* ---------- Numeric face ---------- */

.numeric {
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum", "lnum";
  letter-spacing: -0.015em;
}

/* ---------- Layout primitives ---------- */

.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gutter-x);
}

.section {
  padding-block: var(--section-y);
}

.section-tight {
  padding-block: clamp(3rem, 7vw, 6rem);
}

.divider {
  height: var(--hairline);
  background: var(--color-divider);
  border: none;
  width: 100%;
}

.rule-red {
  display: block;
  width: 64px;
  height: 2px;
  background: var(--color-brand);
  border: none;
  margin-block: var(--space-3);
}

.rule-red--thin {
  width: 24px;
  height: 1px;
}

/* ---------- Links ---------- */

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--dur-micro) var(--ease-micro);
}

a:hover { color: var(--color-brand-hover); }

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: var(--tr-label);
  color: var(--color-text);
  /* No border on the link itself — underline scoped to the
     text span so the arrow doesn't extend the red rule. */
  border-bottom: none;
  padding-bottom: 0;
  transition: color var(--dur-micro) var(--ease-micro);
}

/* Underline only the text span, not the arrow icon. */
.link-arrow > span:not(.arrow) {
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: border-color var(--dur-micro) var(--ease-micro);
}

.link-arrow .arrow {
  display: inline-block;
  transition: transform var(--dur-short) var(--ease-out);
}

.link-arrow:hover {
  color: var(--color-brand-hover);
}

.link-arrow:hover > span:not(.arrow) {
  border-color: var(--color-brand-hover);
}

.link-arrow:hover .arrow { transform: translateX(6px); }

/* ---------- Reveal helpers (set by reveals.js / GSAP) ---------- */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(32px);
}

/* ---------- Skip link ---------- */

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-2);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  padding: var(--space-2) var(--space-3);
  z-index: var(--z-modal);
  border: 1px solid var(--color-brand);
  font-size: var(--fs-sm);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  transition: top var(--dur-micro) var(--ease-micro);
}

.skip-link:focus { top: var(--space-2); }

/* ---------- Reduced-motion overrides for the JS-driven hero ---------- */

@media (prefers-reduced-motion: reduce) {
  .js [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }
  .js body.is-locked {
    overflow: auto;
    height: auto;
  }
}

/* ---------- Utilities ---------- */

.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;
}

.tabular { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

.no-scroll { overflow: hidden !important; }
