/* =========================================================
   Base: reset, typography, layout helpers, language switch.
   Uses tokens only (see tokens.css).
   ========================================================= */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-16);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

h1, h2, h3, p, ul, ol, dl, dd, figure, blockquote { margin: 0; padding: 0; }
ul, ol { list-style: none; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

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

::selection { background: var(--accent-soft); color: var(--text); }

[hidden] { display: none !important; }

/* ---------- Type roles ---------- */
.t-display {
  font-size: var(--fs-80);
  font-weight: var(--fw-light);
  line-height: var(--lh-tight);
  letter-spacing: var(--track-display);
}
.t-h2 {
  font-size: var(--fs-56);
  font-weight: var(--fw-light);
  line-height: var(--lh-tight);
  letter-spacing: var(--track-display);
}
.t-h3 {
  font-size: var(--fs-22);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
}
.t-lead {
  font-size: var(--fs-18);
  color: var(--text-muted);
  max-width: var(--measure);
}
.t-body { color: var(--text-muted); max-width: var(--measure); }
.t-small { font-size: var(--fs-14); color: var(--text-muted); }
.t-caption { font-size: var(--fs-12); color: var(--text-faint); }

/* Section label: sentence case, small, quiet (never all caps) */
.t-label {
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  color: var(--accent);
}

/* Chinese reading mode: more air in body text, steadier headings */
html[data-lang="zh"] body { line-height: var(--lh-zh); }
html[data-lang="zh"] .t-display { line-height: 1.18; letter-spacing: 0.01em; font-weight: var(--fw-regular); }
html[data-lang="zh"] .t-h2 { line-height: 1.25; letter-spacing: 0.01em; font-weight: var(--fw-regular); }
html[data-lang="zh"] .t-h3 { letter-spacing: 0.02em; }

/* ---------- Layout helpers ---------- */
.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--narrow { max-width: calc(var(--container-narrow) + var(--gutter) * 2); }

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

.section-head { display: grid; gap: var(--s-4); margin-bottom: var(--s-8); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute; left: var(--s-4); top: -3rem;
  background: var(--text); color: var(--bg);
  padding: var(--s-2) var(--s-4); border-radius: var(--r-sm);
  z-index: 100;
}
.skip-link:focus { top: var(--s-4); }

/* ---------- Language switch ----------
   Every bilingual string is written twice:
   <span lang="zh-Hans">…</span><span lang="en">…</span>
   The <html data-lang> value decides which one shows. */
html[data-lang="zh"] body [lang="en"] { display: none !important; }
html[data-lang="en"] body [lang="zh-Hans"] { display: none !important; }

/* ---------- Motion preference ---------- */
@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;
  }
}
