/* T12 hand-off site stylesheet: light + dark, mobile-first, 16px gutters. */

:root {
  --ink: #1a2530;
  --muted: #53636d;
  --line: #d7e0e4;
  --paper: #f7fafb;
  --surface: #ffffff;
  --surface2: #eef4f6;
  --blue: #176b87;
  --blue-dark: #0d4d63;
  --green: #1d6a4a;
  --amber: #8a4d12;
  --red: #c0392b;
  --sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --ink: #dce6ec;
  --muted: #93a3ad;
  --line: #32414b;
  --paper: #10181e;
  --surface: #17222a;
  --surface2: #1d2b34;
  --blue: #6db3d4;
  --blue-dark: #8ec9e2;
  --green: #5cba8f;
  --amber: #d9a05f;
  --red: #e07b6d;
}

* { box-sizing: border-box; }

html { background: var(--paper); color: var(--ink); }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  padding-left: 16px;
  padding-right: 16px;
  overflow-wrap: break-word;
}

a { color: var(--blue-dark); }

code, .mono {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface2);
  padding: 0.08em 0.35em;
  border-radius: 4px;
}

pre {
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 0.86em;
  line-height: 1.55;
}
pre code { background: none; padding: 0; }

/* ---------- layout ---------- */

.page {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding-top: 18px;
  padding-bottom: 70px;
  box-sizing: border-box;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0 12px;
  margin-bottom: 26px;
}
.site-header .brand {
  font-weight: 700;
  font-size: 1.06rem;
  color: var(--ink);
  text-decoration: none;
}
.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 0.92rem;
}
.site-header nav a { text-decoration: none; color: var(--muted); }
.site-header nav a.active { color: var(--blue-dark); font-weight: 600; }

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
}
@media (min-width: 900px) {
  .layout { grid-template-columns: 232px minmax(0, 1fr); }
  .toc { position: sticky; top: 16px; align-self: start; max-height: calc(100vh - 40px); overflow-y: auto; }
}

.toc {
  font-size: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 12px 14px 16px;
}
.toc .toc-title { font-weight: 700; margin-bottom: 6px; font-size: 0.95rem; }
.toc ol { list-style: none; margin: 0; padding-left: 14px; }
.toc li { margin: 3px 0; }
.toc a { text-decoration: none; color: var(--muted); display: block; padding: 2px 4px;
         border-radius: 5px; }
.toc a.active, .toc a:hover { color: var(--blue-dark); background: var(--surface2); }
.toc .toc-note { margin-top: 10px; font-size: 0.8rem; color: var(--muted); }

main { min-width: 0; }

h1 { font-size: 1.55rem; line-height: 1.35; margin: 0 0 6px; }
h2 { font-size: 1.22rem; margin: 2.4em 0 0.6em; border-top: 1px solid var(--line);
     padding-top: 1.2em; }
.page-front h2:first-of-type { border-top: none; padding-top: 0; margin-top: 1.2em; }
h3 { font-size: 1.03rem; margin: 1.8em 0 0.5em; }
h4 { font-size: 0.97rem; margin: 1.4em 0 0.4em; }

.lede { color: var(--muted); font-size: 1.02rem; margin-top: 0; }
.updated { color: var(--muted); font-size: 0.85rem; }

section { scroll-margin-top: 14px; }

.keybox {
  background: var(--surface);
  border-left: 4px solid var(--blue);
  border-radius: 0 8px 8px 0;
  padding: 12px 16px;
  margin: 16px 0;
}
.warnbox {
  background: var(--surface);
  border-left: 4px solid var(--red);
  border-radius: 0 8px 8px 0;
  padding: 12px 16px;
  margin: 16px 0;
}
.advice {
  background: var(--surface);
  border-left: 4px solid var(--amber);
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
  margin: 14px 0;
  font-size: 0.94rem;
}

figure { margin: 24px 0 30px; }
figure img { max-width: 100%; height: auto; border: 1px solid var(--line);
             background: #fff; border-radius: 6px; }
figcaption { color: var(--muted); font-size: 0.87rem; margin-top: 8px; }

/* joint-position figure: keep it readable at 375 px, centred at wide widths */
figure img.fig-jointpos { max-width: 100%; height: auto; }
@media (min-width: 900px) {
  figure img.fig-jointpos { max-width: 640px; margin: 0 auto; display: block; }
}

/* display formula (LaTeX \[ ... \], rendered by the vendored KaTeX) */
p.formula { margin: 14px 0; text-align: center; overflow-x: auto; }

.src {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: -6px;
  margin-bottom: 18px;
}

table { border-collapse: collapse; width: 100%; font-size: 0.9rem; margin: 14px 0 20px; }
th, td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; vertical-align: top; }
th { background: var(--surface2); font-weight: 600; }
.table-wrap { overflow-x: auto; }

.num { text-align: right; font-variant-numeric: tabular-nums; }

.btn {
  font: inherit;
  font-size: 0.88rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 7px;
  padding: 5px 12px;
  cursor: pointer;
}
.btn:hover { background: var(--surface2); }

/* ---------- animations ---------- */

.anim-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 14px 12px 10px;
  margin: 20px 0 26px;
}
.anim-wrap svg { display: block; margin: 0 auto; }
.anim-wrap svg text { fill: var(--ink); font-family: var(--sans); }
[data-theme="dark"] .anim-wrap svg text { fill: var(--ink); }

.anim-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin-top: 10px;
  font-size: 0.9rem;
}
.anim-controls label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.anim-controls .val { min-width: 44px; font-variant-numeric: tabular-nums;
                      color: var(--blue-dark); font-weight: 600; }
.anim-controls input[type="range"] { width: 170px; }

.anim-caption { color: var(--muted); font-size: 0.87rem; margin-top: 8px; }

/* ---------- misc ---------- */

.glossary dt { font-weight: 700; margin-top: 14px; }
.glossary dd { margin: 2px 0 0 0; }

.steps li { margin-bottom: 1.1em; }

footer {
  border-top: 1px solid var(--line);
  margin-top: 46px;
  padding-top: 14px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* handbook bilingual switch (skill 0.5.0).  Paste into the site's stylesheet unchanged.
   Without JavaScript nothing sets data-lang, so Chinese shows. */
html[data-lang="en"] .l-zh,
html:not([data-lang="en"]) .l-en { display: none !important; }

.lang-toggle {
  font: inherit; font-size: 0.9rem; padding: 0.3rem 0.8rem; min-height: 44px; min-width: 44px;
  border: 1px solid currentColor; border-radius: 999px; background: transparent; color: inherit; cursor: pointer;
}
.lang-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
