/* Chatter3 engineering notes — one stylesheet for every page.
   No external fonts, no CDN, no analytics: the notes have to be readable
   from a phone in mainland China, where Google Fonts is not reachable. */

:root {
  --bg: #fbfaf8;
  --ink: #16150f;
  --muted: #5d5a50;
  --line: #e2ded3;
  --surface: #ffffff;
  --code-bg: #f3f1ea;
  --accent: #1f5c3d;
  --accent-ink: #ffffff;
  --warn-bg: #fdf4e3;
  --warn-line: #e8d4a4;
  --radius: 10px;
  --wrap: 1080px;
  --measure: 68ch;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 28px; }
.wrap--narrow { max-width: 820px; }

/* ---------------------------------------------------------------- nav */
.site-head {
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 248, 0.92);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(1.4) blur(8px);
}
.site-head .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 62px;
}
.brand {
  font-weight: 680;
  letter-spacing: -0.015em;
  text-decoration: none;
  color: var(--ink);
  font-size: 16px;
  white-space: nowrap;
}
.brand span { color: var(--muted); font-weight: 500; }
.nav { display: flex; gap: 22px; align-items: center; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
  padding: 4px 0;
  white-space: nowrap;
  border-bottom: 1.5px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.nav a:hover { color: var(--ink); border-bottom-color: var(--accent); }
@media (max-width: 720px) { .nav a.secondary { display: none; } .nav { gap: 16px; } .nav a { font-size: 14px; } }

/* --------------------------------------------------------------- hero */
.hero { padding: 84px 0 72px; border-bottom: 1px solid var(--line); }
.hero h1 {
  margin: 0 0 18px;
  font-size: clamp(34px, 5.2vw, 56px);
  line-height: 1.08;
  letter-spacing: -0.028em;
  font-weight: 680;
  max-width: 19ch;
}
.hero p.lede {
  margin: 0 0 30px;
  font-size: clamp(18px, 2.2vw, 21px);
  line-height: 1.55;
  color: var(--muted);
  max-width: 58ch;
}
.hero .meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 15px; }
.hero .meta b { color: var(--ink); font-weight: 600; }
.hero .meta span:not(:last-child)::after { content: "·"; margin-left: 18px; color: #b9b3a4; }

/* The hero enters once, but only when the browser can run the script that
   animates it. The text is never faded and never invisible: it settles
   into place, so a crawler, a printer and a screenshot all read the same
   page as the reader does. */
.js [data-enter] { transform: translateY(12px); }
.js [data-enter].in { transform: none; transition: transform 0.5s ease; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
  padding: 13px 22px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px -10px rgba(31, 92, 61, 0.7); }
.btn:active { transform: translateY(0); }
.btn--quiet { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--quiet:hover { border-color: var(--accent); box-shadow: none; }

/* -------------------------------------------------------------- notes */
.notes { padding: 64px 0 40px; }
.notes > .wrap > h2, .page-head h1 { margin: 0 0 8px; font-size: clamp(28px, 3.6vw, 38px); letter-spacing: -0.022em; line-height: 1.15; font-weight: 660; }
.section-note { margin: 0 0 34px; color: var(--muted); max-width: 62ch; }
.note-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
@media (max-width: 720px) { .note-grid { grid-template-columns: 1fr; } }

.note-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 24px 22px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.note-card:hover { transform: translateY(-2px); border-color: #cfc9ba; box-shadow: 0 12px 28px -20px rgba(22, 21, 15, 0.5); }
.note-card--wide { grid-column: 1 / -1; }
.note-card .kicker {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 9px;
}
.note-card h3 { margin: 0 0 8px; font-size: 21px; line-height: 1.25; letter-spacing: -0.015em; font-weight: 640; }
.note-card p { margin: 0; color: var(--muted); font-size: 15.5px; line-height: 1.55; }

/* ------------------------------------------------------------- article */
.page-head { padding: 56px 0 30px; border-bottom: 1px solid var(--line); }
.page-head .kicker {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 14px;
}
.page-head .lede { margin: 14px 0 0; font-size: 19px; line-height: 1.55; color: var(--muted); max-width: 62ch; }
.page-head .meta { margin-top: 18px; color: var(--muted); font-size: 14.5px; }

article { padding: 40px 0 70px; }
article h2 {
  margin: 46px 0 14px;
  font-size: clamp(23px, 2.6vw, 29px);
  letter-spacing: -0.018em;
  line-height: 1.2;
  font-weight: 650;
}
article h3 { margin: 32px 0 10px; font-size: 19px; font-weight: 640; letter-spacing: -0.01em; }
article p, article ul, article ol { max-width: var(--measure); }
article p { margin: 0 0 18px; }
article ul, article ol { margin: 0 0 20px; padding-left: 22px; }
article li { margin-bottom: 8px; }
article a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
article a:hover { text-decoration-color: var(--ink); }
article strong { font-weight: 640; }
article hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }

pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  margin: 0 0 22px;
  max-width: 100%;
}
pre code { font-family: inherit; }
code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.12em 0.36em;
  border-radius: 4px;
}
pre code { background: none; padding: 0; }

blockquote {
  margin: 0 0 22px;
  padding: 14px 18px;
  border-left: 3px solid var(--accent);
  background: var(--warn-bg);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: #4a4536;
  font-size: 16px;
}
blockquote p:last-child { margin-bottom: 0; }

.callout {
  border: 1px solid var(--warn-line);
  background: var(--warn-bg);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 0 0 22px;
  font-size: 15.5px;
}
.callout p:last-child { margin-bottom: 0; }
.callout b { display: block; margin-bottom: 4px; }

table { width: 100%; border-collapse: collapse; margin: 0 0 24px; font-size: 15.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { font-weight: 640; font-size: 13.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }

figure { margin: 0 0 26px; }
figcaption { font-size: 14px; color: var(--muted); margin-top: 8px; }

/* -------------------------------------------------------------- table */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 0 0 34px; }
@media (max-width: 820px) { .stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px) { .stats { grid-template-columns: 1fr; } }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
}
.stat .v { font-size: 30px; font-weight: 660; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 13.5px; color: var(--muted); margin-top: 6px; line-height: 1.4; }

/* ------------------------------------------------------------- footer */
.site-foot { border-top: 1px solid var(--line); padding: 40px 0 54px; color: var(--muted); font-size: 15px; }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 16px 40px; justify-content: space-between; }
.site-foot a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.site-foot a:hover { border-bottom-color: var(--accent); color: var(--accent); }
.foot-links { display: flex; flex-wrap: wrap; gap: 18px; }

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  z-index: 50;
  border-radius: 0 0 var(--radius) 0;
}
.skip:focus { left: 0; }

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

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  .js [data-enter] { transform: none; }
}
