/* ============================================================
   base — reset, type, layout, bilingual mechanism, chrome
   ============================================================ */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body,
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd,
ol,
ul {
  margin: 0;
}

ol[class],
ul[class] {
  list-style: none;
  padding: 0;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

/* ---- bilingual: CSS does the switching, no JS reflow -------
   Every string ships as a sibling pair. The inactive one is
   removed from the a11y tree too, so screen readers and
   copy-paste both get exactly one language. */
[lang="zh"],
[lang="en"] {
  display: none;
}
html[data-lang="zh"] [lang="zh"],
html[data-lang="en"] [lang="en"] {
  display: revert;
}
html[data-lang="zh"] span[lang="zh"],
html[data-lang="en"] span[lang="en"] {
  display: inline;
}

html[data-lang="zh"] {
  --font-display: "Source Han Serif SC", "Songti SC", "Noto Serif CJK SC",
    "Iowan Old Style", Georgia, serif;
  --measure: 40em;
}

/* ---- page -------------------------------------------------- */
body {
  background: var(--ink-page);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Paper grain. One repeating SVG, fixed, non-interactive —
   atmosphere without a network request.

   The same noise tile serves both stamps, but not the same way
   round: the turbulence renders light-on-transparent, so over ink
   it lays on as an additive dust at 3.5% and needs no blend mode,
   while over paper the identical layer would fog the page. There
   it multiplies at 5% instead, which darkens the grain into the
   sheet rather than washing it out. Both values are tokens so the
   stamp decides. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--grain-o);
  mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- links & focus ---------------------------------------- */
a {
  color: inherit;
  text-decoration: none;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}
/* ---- headings ---------------------------------------------- */
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: var(--lh-snug);
  letter-spacing: -0.014em;
  text-wrap: balance;
}
h1 {
  font-size: var(--t-h1);
  line-height: var(--lh-tight);
  letter-spacing: -0.03em;
}
h2 {
  font-size: var(--t-h2);
  letter-spacing: -0.022em;
}
h3 {
  font-size: var(--t-h3);
}
h4 {
  font-size: var(--t-h4);
}

.lede {
  font-size: var(--t-lead);
  color: var(--text-2);
  max-width: var(--measure);
  text-wrap: pretty;
}
.prose {
  max-width: var(--measure);
  color: var(--text-2);
}
.prose p + p {
  margin-top: var(--s-4);
}
.prose strong {
  color: var(--text-1);
  font-weight: 600;
}
.prose em {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--text-1);
}
code,
kbd,
.mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}
code {
  color: var(--accent-strong);
  background: var(--ink-inset);
  padding: 0.1em 0.36em;
  border-radius: 3px;
  border: 1px solid var(--hair);
}

/* ---- layout ------------------------------------------------ */
.wrap {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

section[id] {
  scroll-margin-top: 5rem;
}
.band {
  padding-block: var(--s-section);
  border-top: 1px solid var(--hair);
}
.band--flush {
  border-top: 0;
}
.band--inset {
  background: linear-gradient(180deg, var(--ink-raised), var(--ink-page) 70%);
}
/* The hero already closes on a full section of space, so the band
   that follows it must not open with another one — two stacked
   section paddings read as a hole in the page. */
.hero + .band,
.page-head + .band {
  padding-top: var(--s-7);
}

/* Section head: eyebrow + rule + title + note, the editorial
   rhythm that repeats across all four pages. */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.eyebrow::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--hair);
}
.sec-head {
  display: grid;
  gap: var(--s-4);
  margin-bottom: var(--s-7);
}
.sec-head__row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: var(--s-5);
}
.sec-head h2 {
  max-width: 22ch;
}
.sec-head .lede {
  max-width: 46ch;
  font-size: var(--t-body);
}

.note {
  font-size: var(--t-fine);
  color: var(--text-3);
  max-width: 62ch;
}
.note code {
  font-size: 0.92em;
}

/* ---- header ------------------------------------------------ */
.site-head {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--scrim);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--hair);
}
.site-head__in {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  height: 4rem;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  margin-right: auto;
}
.brand__mark {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
}
.brand__mark b {
  font-weight: 400;
  color: var(--accent);
}
.brand__tag {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  padding-left: var(--s-3);
  border-left: 1px solid var(--hair-2);
}

.nav {
  display: flex;
  gap: var(--s-5);
  font-size: var(--t-small);
}
.nav a {
  color: var(--text-2);
  padding-block: var(--s-2);
  position: relative;
  transition: color var(--d-fast) var(--ease);
}
.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--d-norm) var(--ease);
}
.nav a:hover {
  color: var(--text-1);
}
.nav a:hover::after {
  transform: scaleX(1);
}
.nav a[aria-current="page"] {
  color: var(--text-1);
}
.nav a[aria-current="page"]::after {
  transform: scaleX(1);
}
/* ---- language toggle --------------------------------------- */
.lang {
  display: inline-flex;
  /* Never the flex item that loses: when the header row ran short at
     320 this pill shrank to 39px while its two buttons still measured
     64, so 中文 sat on top of the menu button. */
  flex: none;
  border: 1px solid var(--hair-2);
  border-radius: 999px;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.08em;
}
.lang button {
  background: none;
  border: 0;
  color: var(--text-3);
  padding: 0.36rem 0.62rem;
  cursor: pointer;
  transition: color var(--d-fast), background var(--d-fast);
}
.lang button:hover {
  color: var(--text-1);
}
.lang button[aria-pressed="true"] {
  background: var(--accent-fill-soft);
  color: var(--accent-on-soft);
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--hair-2);
  border-radius: 4px;
  color: var(--text-2);
  padding: 0.3rem 0.5rem;
  cursor: pointer;
}

@media (max-width: 860px) {
  .nav-toggle {
    display: block;
  }
  .nav {
    position: absolute;
    top: 4rem;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--ink-raised);
    border-bottom: 1px solid var(--hair);
    padding: var(--s-2) var(--gutter) var(--s-4);
  }
  .nav[hidden] {
    display: none;
  }
  .nav a {
    padding-block: var(--s-3);
    border-bottom: 1px solid var(--hair);
  }
}
/* The brand is the only header item that can give up space: both pills
   and the menu button have a fixed hit area that must survive a 320px
   row. Two pills leave the tag too little width to break on a word
   boundary — at 320 it split inside "FINANCE" — so it goes. */
@media (max-width: 480px) {
  .site-head__in {
    gap: var(--s-3);
  }
  .brand {
    min-width: 0;
  }
  .site-head .brand__mark {
    font-size: 0.875rem;
    line-height: 1.2;
  }
  .brand__tag {
    display: none;
  }
  .nav-toggle {
    flex: none;
  }
}
/* ---- footer ------------------------------------------------ */
.site-foot {
  border-top: 1px solid var(--hair);
  background: var(--ink-void);
  padding-block: var(--s-7) var(--s-6);
  font-size: var(--t-fine);
  color: var(--text-3);
}
.site-foot__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr));
  gap: var(--s-6);
}
.site-foot h4 {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: var(--s-3);
}
.site-foot ul {
  display: grid;
  gap: var(--s-2);
}
.site-foot__grid p {
  margin-top: var(--s-3);
}
.site-foot a:hover {
  color: var(--text-1);
}
.site-foot__base {
  margin-top: var(--s-7);
  padding-top: var(--s-4);
  border-top: 1px solid var(--hair);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-4);
  justify-content: space-between;
}
@media (max-width: 720px) {
  .site-foot__grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---- utilities --------------------------------------------- */
.vh {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip {
  position: absolute;
  left: var(--s-4);
  top: -3rem;
  z-index: 100;
  background: var(--accent-fill-soft);
  color: var(--accent-on-soft);
  padding: var(--s-2) var(--s-4);
  border-radius: 0 0 4px 4px;
  transition: top var(--d-fast) var(--ease);
}
.skip:focus {
  top: 0;
}
/* <main> carries tabindex="-1" so the skip link actually moves focus
   rather than only scrolling — Safari does not set the sequential
   focus starting point from a fragment on its own. It is a landmark
   and not a control, so it takes no ring of its own: a 2px outline
   drawn around thousands of pixels of page reads as a rendering
   fault, and the jump plus the skip link's own focus state is the
   feedback. Every real control keeps the global ring. */
main:focus {
  outline: none;
}

.num {
  font-variant-numeric: tabular-nums;
}
.rule {
  height: 1px;
  background: var(--hair);
  border: 0;
}

/* Entrance reveal — opacity + transform only. */
.reveal {
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  transition: opacity var(--d-slow) var(--ease), transform var(--d-slow)
      var(--ease);
}
.reveal.is-in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal {
    opacity: 1;
    transform: none;
  }
}

@media print {
  body::before {
    display: none;
  }
}
