@font-face { font-family: "Bricolage Grotesque"; src: url("/fonts/bricolage-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Bricolage Grotesque"; src: url("/fonts/bricolage-800.woff2") format("woff2"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Martian Mono"; src: url("/fonts/martian-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }

/* tokens/tokens.ts, light set */
:root {
  --bg: #FFFFFF;
  --surface: #F6F6F6;
  --line: #D2D2D2;
  --ink: #161616;
  --ink-muted: #5E5E5E;
  --ink-faint: #808080;
  --accent: #CC3A1A;
  --gutter: clamp(20px, 5vw, 64px);
  --sans: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --mono: "Martian Mono", ui-monospace, monospace;
}
/* dark set */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161616;
    --surface: #191919;
    --line: #353535;
    --ink: #F4F4F4;
    --ink-muted: #A4A4A4;
    --ink-faint: #7B7B7B;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); scroll-padding-top: 88px; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: var(--accent); color: #FFFFFF; }

a { color: inherit; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--accent); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

.mono { font-family: var(--mono); font-size: 11px; letter-spacing: .02em; color: var(--ink-faint); line-height: 1.5; }
.label { text-transform: lowercase; }

/* ---------- bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.home { display: block; text-decoration: none; }
.lockup { display: block; height: 28px; width: auto; }
.langs { display: flex; gap: 14px; font-family: var(--mono); font-size: 12px; }
.langs a { color: var(--ink-faint); text-decoration: none; }
.langs a[aria-current] { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }

/* ---------- layout ---------- */
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(40px, 8vh, 88px) var(--gutter) 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
main { min-width: 0; max-width: 70ch; }
.toc { display: none; }

@media (min-width: 1000px) {
  .wrap { grid-template-columns: 240px minmax(0, 1fr); column-gap: clamp(48px, 6vw, 96px); }
  .toc { display: block; position: sticky; top: 100px; align-self: start; max-height: calc(100vh - 120px); overflow-y: auto; padding-top: 6px; }
  .toc ol { list-style: none; margin-top: 12px; display: grid; gap: 6px; }
  .toc a { font-size: 14px; line-height: 1.35; color: var(--ink-muted); text-decoration: none; display: block; }
  .toc a:hover, .toc a.on { color: var(--ink); }
  .toc a.on { box-shadow: -10px 0 0 -8px var(--accent); }
}

/* ---------- document ---------- */
h1 {
  font-weight: 800;
  font-size: clamp(40px, 6vw, 72px);
  line-height: .95;
  letter-spacing: -.035em;
  margin-top: 12px;
  text-wrap: balance;
}
.version { margin-top: 16px; font-size: 12px; }

article { margin-top: clamp(40px, 6vh, 64px); }
article h2 {
  font-weight: 800;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -.015em;
  margin: 56px 0 16px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
article h2:first-child { margin-top: 0; }
article p, article ul, article ol { margin: 0 0 16px; }
article a { overflow-wrap: anywhere; }
article ul, article ol { padding-left: 1.25em; }
article li { margin-bottom: 8px; }
article li::marker { color: var(--ink-faint); }
article strong { font-weight: 800; }
article em { font-style: normal; font-family: var(--mono); font-size: .82em; }

.table { overflow-x: auto; margin: 8px 0 24px; border: 1px solid var(--line); border-radius: 6px; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 15px; line-height: 1.45; }
th, td { text-align: left; vertical-align: top; padding: 10px 14px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
th { font-family: var(--mono); font-weight: 400; font-size: 11px; color: var(--ink-muted); background: var(--surface); }
td:first-child { font-weight: 800; }

@media (max-width: 699px) {
  .table { overflow: visible; border: 0; border-radius: 0; }
  table, tbody, tr, td { display: block; min-width: 0; width: 100%; }
  thead { display: none; }
  tr { border: 1px solid var(--line); border-radius: 6px; padding: 4px 0; margin-bottom: 12px; }
  td { border: 0; padding: 6px 14px; }
  td:first-child { font-size: 16px; padding-top: 10px; }
  td:not(:first-child)::before {
    content: attr(data-label);
    display: block;
    font-family: var(--mono); font-size: 10px; letter-spacing: .02em; color: var(--ink-faint);
    margin-bottom: 2px;
  }
}

/* ---------- footer ---------- */
footer {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 24px var(--gutter) max(24px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
footer a { text-decoration: none; }
footer a:hover { color: var(--ink); }

@media print {
  .bar, .toc, footer { display: none; }
  .wrap { display: block; padding: 0; }
  body { font-size: 11pt; }
  a { text-decoration: none; }
}
