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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Exactly the nav height: a section's top rule then lands on the nav's bottom rule, so anchors show one line, not two. */
  scroll-padding-top: var(--nav-h);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: anywhere;
  overflow-x: hidden;
  overflow-x: clip;
}

h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
/* halt: CJK punctuation (、，。) takes half a character width, so big headlines have no holes after commas. */
h1, h2, h3 { font-weight: 900; overflow-wrap: anywhere; font-feature-settings: "halt"; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.skip {
  position: absolute; left: var(--gutter); top: -100px; z-index: 100;
  background: var(--ink); color: var(--paper); padding: 10px 16px; font-weight: 700;
}
.skip:focus { top: 12px; }

/* Highlighter: a marker stroke behind the text. Its width follows --hl-progress (0 → 1). */
mark.hl {
  color: inherit;
  background-color: transparent;
  background-image: linear-gradient(var(--hl), var(--hl));
  background-repeat: no-repeat;
  /* Measured from the top of the text box (Archivo: baseline at ~0.88em; Chinese glyphs end ~0.12em lower).
     The stroke ends at the bottom of the Chinese characters; under Latin it reads as a thick underline. */
  background-position: 0 0.76em;
  background-size: calc(var(--hl-progress, 1) * 100%) 0.26em;
  /* The stroke bleeds a little past the text without adding space next to it. */
  padding: 0 0.06em;
  margin: 0 -0.06em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* Buttons: square, ink. */
.btn {
  display: inline-flex; align-items: center; gap: 0.6em;
  min-height: 48px; padding: 0 22px;
  border: var(--rule) solid var(--ink);
  font-weight: 800; font-size: var(--fs-sm); letter-spacing: 0.01em; line-height: 1;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.btn--primary { background: var(--ink); color: var(--paper); }
.btn--primary::after { content: "→"; font-weight: 400; transition: transform .2s var(--ease); }
.btn--primary:hover { background: var(--paper); color: var(--ink); }
.btn--primary:hover::after { transform: translateX(3px); }
.btn--secondary { background: transparent; color: var(--ink); }
.btn--secondary:hover { background: var(--ink); color: var(--paper); }

/* Nav */
.site-nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--paper);
  border-bottom: var(--rule) solid var(--line);
  transition: background-color .6s var(--ease);
}
.nav {
  max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter);
  height: var(--nav-h);
  display: flex; align-items: center; gap: 32px;
}
.nav__brand { font-weight: 900; font-size: 1.25rem; letter-spacing: -0.03em; margin-right: auto; }
.nav__links { display: flex; gap: 28px; font-size: var(--fs-sm); font-weight: 600; }
.nav__link { position: relative; padding: 4px 0; }
.nav__link::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: var(--rule);
  background: var(--ink); transform: scaleX(0); transform-origin: left; transition: transform .25s var(--ease);
}
.nav__link:hover::after { transform: scaleX(1); }
.nav__cta { min-height: 40px; padding: 0 16px; }

@media (max-width: 767px) {
  .nav__links { display: none; }
  .nav__cta::after { display: none; }
}

/* Footer */
.site-footer { border-top: var(--rule) solid var(--line); }
.foot {
  max-width: var(--maxw); margin: 0 auto;
  padding: 24px var(--gutter) 32px;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px 32px;
}
.foot__brand { font-weight: 900; font-size: 1.25rem; letter-spacing: -0.03em; margin-right: auto; }
.foot__note { color: var(--muted); font-size: var(--fs-sm); }
.foot__links { display: flex; gap: 24px; font-size: var(--fs-sm); font-weight: 600; }
.foot__links a:hover { text-decoration: underline; text-underline-offset: 4px; }
@media (max-width: 767px) { .foot__brand { flex-basis: 100%; } }

.load-error {
  max-width: var(--maxw); margin: 0 auto; padding: var(--section-pad) var(--gutter);
  font-size: var(--fs-lead); font-weight: 700;
}
