/* DATASYNC — paper, ink, and five greys. Every colour below was counted off the banner's pixels;
   the coordinate each one came from is in SPEC.md §1. There is no accent colour in this identity,
   so there is none here either, apart from the two state colours named at the bottom. */

:root {
  /* measured */
  --paper: #F8F7F4;        /* modal colour of the banner crop, 14 018 px, e.g. (304,120) */
  --paper-hi: #FAF9F6;     /* (300,60) */
  --paper-lo: #F3F2EF;     /* (20,50) */
  --paper-warm: #FAF8F3;   /* warmest common ground, chroma 7 */
  --ink: #000000;          /* (286,120) is #050505, (45,74) is #070601 */
  --chrome-hi: #7D7D7D;    /* (360,110) */
  --chrome-mid: #5C5B5A;   /* (380,118) */
  --chrome-lo: #4D4D4D;    /* (346,95) */
  --chrome-dk: #3B3B3B;    /* (460,110) */
  --chrome-black: #0D0D0B; /* (420,100) */
  --line: #9C9B98;         /* (80,120) */
  --white: #FFFFFF;

  /* derived for legibility, all measured against --paper off the rendered pixels */
  --body: #1C1C1A;         /* 15.0:1 on paper */
  --dim: #464643;          /* 9.2:1 on paper */
  --faint: #5F5F5B;        /* 5.9:1 on paper, measured off the rendered pixels */
  --rule: #DCDAD4;
  --rule-strong: #BDBAB3;

  /* NOT in the banner — stated in the SPEC. Used only for a cell's MATCH / MISMATCH verdict. */
  --ok: #0B5D2E;           /* 7.1:1 on paper */
  --bad: #7A1420;          /* 9.4:1 on paper */

  --serif: Newsreader, Georgia, 'Times New Roman', serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --gutter: 16px;
  --col: 760px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--body);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.62;
  font-synthesis-weight: none;
}

/* ── generated plates, laid full-frame ──────────────────────────────────────────────────────────
   NOT mix-blend-mode. On a light ground `screen` can only lighten, so a plate whose ground is
   white erases what is under it. Instead each plate's modal ground was re-mapped per channel in
   PIL to exactly #F8F7F4, so the plate's own paper IS --paper to the byte and it can simply be
   laid down normally. See SPEC.md §2. */
.plate {
  /* absolute, not fixed: the plate is this document's letterhead, not a parallax layer that
     follows the reader down the page. */
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 960px;
  z-index: -2;
  background: var(--paper) no-repeat;
  background-image: url('/img/plate-field.webp');
  /* shifted so the fan's convergence node lands in the left margin, where the banner puts it
     relative to the hand — the right of the frame stays empty paper, as it does in the banner. */
  background-position: -480px top;
  background-size: 1500px auto;
  pointer-events: none;
}
.plate::after {
  /* the paper fades back in below the fold, so the plate never fights the cells */
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(248,247,244,0) 0%, rgba(248,247,244,.25) 16%, rgba(248,247,244,.86) 30%, var(--paper) 44%),
    linear-gradient(180deg, rgba(248,247,244,0) 0%, rgba(248,247,244,.5) 52%, rgba(248,247,244,.92) 82%, var(--paper) 100%);
}
.plate-foot {
  position: relative;
  height: 320px;
  margin-top: 56px;
  background: var(--paper) url('/img/plate-gap.webp') no-repeat center top;
  background-size: 1200px auto;
}
.plate-foot::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--paper) 0%, rgba(248,247,244,0) 34%, rgba(248,247,244,.6) 86%, var(--paper) 100%);
}

/* ── frame ──────────────────────────────────────────────────────────────────────────────────── */
.page { max-width: calc(var(--col) + 120px); margin: 0 auto; padding: 0 var(--gutter); }

.head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding: 22px 0 14px;
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.brand img { display: block; }
.head nav { margin-left: auto; display: flex; gap: 16px; flex-wrap: wrap; }
.head nav a {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--dim);
  text-decoration: none;
  border-bottom: 1px solid var(--rule-strong);
  padding-bottom: 2px;
}
.head nav a:hover, .head nav a[aria-current] { color: var(--ink); border-color: var(--ink); }

.masthead { padding: 34px 0 10px; }
.masthead h1 {
  font-size: clamp(30px, 6.4vw, 48px);
  line-height: 1.1;
  font-weight: 400;
  letter-spacing: -.015em;
  margin: 0 0 12px;
}
.masthead .bio {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .04em;
  color: var(--dim);
  margin: 0 0 16px;
}
.masthead .warn {
  border: 1px solid var(--ink);
  padding: 13px 15px;
  margin: 18px 0 0;
  font-size: 16px;
  line-height: 1.5;
  background: var(--paper-hi);
}
.masthead .warn b { font-family: var(--mono); font-size: 12.5px; letter-spacing: .09em; text-transform: uppercase; display: block; margin-bottom: 5px; }

/* ── the notebook ───────────────────────────────────────────────────────────────────────────── */
/* `clip` and not `auto`: the full-bleed band below extends past the column on purpose, and clip
   contains it without creating a scroll container. */
.nb { padding: 10px 0 0; overflow-x: clip; }

.cell {
  position: relative;
  padding: 26px 0 26px 56px;
  border-top: 1px solid var(--rule);
}
.cell:first-child { border-top: 0; }
.cell--run { border-top-color: transparent; }
.cell > .n {
  position: absolute;
  left: 0;
  top: 28px;
  width: 44px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
  letter-spacing: .06em;
  user-select: none;
}

.cell--prose h2 {
  font-size: 23px;
  font-weight: 400;
  letter-spacing: -.01em;
  margin: 0 0 10px;
}
.cell--prose p { margin: 0 0 12px; max-width: var(--col); }
.cell--prose p:last-child { margin-bottom: 0; }
.cell--prose ul { margin: 0 0 12px; padding-left: 20px; max-width: var(--col); }
.cell--prose li { margin-bottom: 7px; }
.cell em { font-style: italic; }
.cell strong { font-weight: 600; }
code, .mono { font-family: var(--mono); font-size: .84em; }
code { background: var(--paper-lo); padding: 1px 4px; border: 1px solid var(--rule); overflow-wrap: anywhere; }
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }

/* ── a runnable cell ────────────────────────────────────────────────────────────────────────── */
/* The tint of a runnable cell bleeds to the window's edges, so the notebook reads as alternating
   bands of paper instead of a box with a seam down the middle of the page. */
.cell--run { background: none; }
.cell--run::before {
  content: '';
  position: absolute;
  inset: 0 -40px;
  background: var(--paper-hi);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  z-index: -1;
  pointer-events: none;
}
.cell--run + .cell--run::before { border-top: 0; }
.cell--run .ch {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.cell--run .ch h3 { font-size: 19px; font-weight: 400; margin: 0; letter-spacing: -.005em; }
.cell--run .mirrors {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
  letter-spacing: .02em;
  border: 1px solid var(--rule-strong);
  padding: 2px 6px;
  white-space: nowrap;
  overflow-x: auto;
  max-width: 100%;
}
.cell--run > p.why { margin: 0 0 14px; font-size: 16px; color: var(--dim); max-width: var(--col); }

.fields { display: grid; gap: 10px; margin-bottom: 12px; }
.f { display: grid; gap: 4px; }
.f label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
}
.f input, .f textarea, .f select {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--body);
  background: var(--white);
  border: 1px solid var(--rule-strong);
  padding: 8px 9px;
  width: 100%;
  min-width: 0;
  border-radius: 0;
}
.f textarea { resize: vertical; min-height: 68px; line-height: 1.5; }
.f input:focus, .f textarea:focus, .f select:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.f .hint { font-size: 12px; color: var(--faint); font-family: var(--mono); }
@media (min-width: 620px) { .fields.two { grid-template-columns: 1fr 1fr; } }

.run-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
button.run {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  padding: 9px 18px;
  cursor: pointer;
  border-radius: 0;
}
button.run:hover { background: var(--chrome-dk); border-color: var(--chrome-dk); }
button.run:active { background: var(--chrome-black); }
button.run[disabled] { background: var(--line); border-color: var(--line); cursor: progress; }
button.ghost {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--rule-strong);
  padding: 9px 14px;
  cursor: pointer;
  border-radius: 0;
}
button.ghost:hover { color: var(--ink); border-color: var(--ink); }

.out {
  margin-top: 14px;
  border: 1px solid var(--rule-strong);
  border-left: 3px solid var(--ink);
  background: var(--white);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.75;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.out:empty { display: none; }
.out .k { color: var(--faint); }
.out .v { color: var(--body); }
.out .ok { color: var(--ok); font-weight: 500; }
.out .bad { color: var(--bad); font-weight: 500; }
.out .sep { color: var(--rule-strong); }
.out table { border-collapse: collapse; width: 100%; font-size: 12px; }
.out th, .out td { text-align: right; padding: 3px 8px 3px 0; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.out th { color: var(--faint); font-weight: 400; text-transform: uppercase; letter-spacing: .06em; font-size: 10.5px; }
.out td:first-child, .out th:first-child { text-align: left; }
.out .note { color: var(--faint); font-size: 11.5px; display: block; margin-top: 6px; white-space: normal; word-break: normal; overflow-wrap: anywhere; }

/* ── docs ───────────────────────────────────────────────────────────────────────────────────── */
.doc { padding: 10px 0 0; max-width: var(--col); min-width: 0; }
.doc h2 {
  font-size: 25px;
  font-weight: 400;
  margin: 38px 0 12px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  letter-spacing: -.01em;
}
.doc h3 { font-size: 18px; font-weight: 600; margin: 24px 0 8px; }
.doc p, .doc li { max-width: var(--col); }
.doc p { margin: 0 0 12px; }
.doc ul, .doc ol { padding-left: 20px; margin: 0 0 12px; }
.doc li { margin-bottom: 7px; }
.doc .tablewrap { overflow-x: auto; margin: 0 0 16px; max-width: 100%; }
.doc table { border-collapse: collapse; font-family: var(--mono); font-size: 12.5px; min-width: 100%; }
.doc th, .doc td { text-align: left; padding: 7px 14px 7px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.doc th { color: var(--faint); font-weight: 400; text-transform: uppercase; letter-spacing: .06em; font-size: 10.5px; white-space: nowrap; }
.doc td .n { font-variant-numeric: tabular-nums; }
.doc pre {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  background: var(--white);
  border: 1px solid var(--rule-strong);
  border-left: 3px solid var(--ink);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0 0 16px;
  max-width: 100%;
}
.doc pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.doc .callout {
  border: 1px solid var(--ink);
  background: var(--paper-hi);
  padding: 13px 15px;
  margin: 0 0 18px;
}
.doc .callout b { font-family: var(--mono); font-size: 12px; letter-spacing: .09em; text-transform: uppercase; display: block; margin-bottom: 5px; }

.toc { font-family: var(--mono); font-size: 12.5px; margin: 0 0 8px; padding: 0; list-style: none; }
.toc li { margin-bottom: 5px; }
.toc a { color: var(--dim); }

/* ── foot ───────────────────────────────────────────────────────────────────────────────────── */
.foot {
  border-top: 1px solid var(--rule);
  margin-top: 40px;
  padding: 18px 0 44px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .04em;
  color: var(--faint);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.foot a { color: var(--dim); }

.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (max-width: 560px) {
  body { font-size: 17px; }
  .cell { padding-left: 0; padding-top: 22px; padding-bottom: 22px; }
  .cell > .n { position: static; display: block; margin-bottom: 8px; }
  .plate { background-size: 1000px auto; background-position: -320px top; height: 620px; }
  .plate-foot { height: 200px; background-size: 760px auto; }
  .head { padding-bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
