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

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

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-en);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  overflow-wrap: break-word;
}

/* Per-language font stacks avoid mixed glyph shapes from Han unification. */
:lang(zh-Hans) body,
body:lang(zh-Hans) {
  font-family: var(--font-zh-hans);
  line-height: var(--lh-cjk);
}
:lang(zh-Hant) body,
body:lang(zh-Hant) {
  font-family: var(--font-zh-hant);
  line-height: var(--lh-cjk);
}
:lang(ja) body,
body:lang(ja) {
  font-family: var(--font-ja);
  line-height: var(--lh-cjk);
  line-break: strict;
}

h1,
h2,
h3 {
  line-height: 1.3;
  margin: 0 0 var(--space-2);
}
h1 {
  font-size: 1.6rem;
}
h2 {
  font-size: 1.15rem;
}
h3 {
  font-size: 1rem;
}
p {
  margin: 0 0 var(--space-3);
}

a {
  color: var(--c-link);
  text-underline-offset: 2px;
}
a:hover {
  text-decoration-thickness: 2px;
}

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

:focus-visible {
  outline: 2px solid var(--c-focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-2);
  top: -100px;
  z-index: 100;
  padding: var(--space-2) var(--space-3);
  background: var(--c-bg);
  border: 2px solid var(--c-focus);
  border-radius: var(--radius);
}
.skip-link:focus {
  top: var(--space-2);
}

/* Reduced motion: switch transitions and animations off entirely. Do NOT use the common
   "transition-duration: 0.01ms" hack: transition-property defaults to `all`, so a non-zero duration
   would add a (tiny) transition to every property of every element, delaying e.g. hover colours
   by a frame instead of removing motion. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* MathML token elements must not inherit word-wrapping (otherwise "64" can render as "6"). */
math,
math * {
  overflow-wrap: normal;
  word-break: normal;
  line-break: auto;
}
