/* Galley's site, set in Galley's own style (Feather): the page is a galley proof on the app's navy canvas.
   Colour means state and only state: cobalt waits on you, green is done, violet is the editor's words. */
:root {
  color-scheme: light dark;
  --page: light-dark(#F9FAFC, #0C0D11);
  --surface: light-dark(#FFFFFF, #121419);
  --sunk: light-dark(#F2F4F8, #181B21);
  --line: light-dark(#E7EAF0, #232731);
  --line-strong: light-dark(#D2D7E0, #2F3440);
  --ink: light-dark(#0B0D12, #F6F7FA);
  --ink-2: light-dark(#363B47, #C5CAD4);
  --ink-3: light-dark(#555C6A, #959CAA);
  --waiting: light-dark(#2442C4, #A9BBFF);
  --waiting-soft: light-dark(#EEF2FF, #1B2340);
  --waiting-line: light-dark(#C7D2FE, #2F3C6E);
  --done: light-dark(#0B6B43, #7FD8A9);
  --done-soft: light-dark(#E8F7EF, #12291F);
  --done-line: light-dark(#A9DEC2, #24533C);
  --words: light-dark(#4E2DB8, #C4B5FF);
  --words-soft: light-dark(#F3EFFF, #1F1A36);
  --words-line: light-dark(#CFC3FA, #3F3470);
  --canvas: light-dark(#12162B, #07080B);
  --canvas-ink: #EEF1FA;
  --canvas-ink-2: #B4BBD3;
  --canvas-line: rgb(255 255 255 / .09);
  --canvas-hover: rgb(255 255 255 / .06);
  --shadow: 0 1px 1px light-dark(rgb(11 13 18 / .03), rgb(0 0 0 / .4)), 0 12px 32px -12px light-dark(rgb(11 13 18 / .10), rgb(0 0 0 / .6));
  --panel-shadow: 0 0 0 1px light-dark(transparent, #1C2029), 0 24px 60px -24px rgb(8 10 24 / .55);
  --face-title: 'Fraunces', Georgia, serif;
  --face-read: 'Literata', Georgia, serif;
  --face-ui: 'Inter', system-ui, sans-serif;
  --face-code: ui-monospace, SFMono-Regular, Menlo, monospace;
  --title-weight: 340;
  --gutter: 72px;
  --margin: 300px;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; --title-weight: 320; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --title-weight: 320; } }

* { box-sizing: border-box; }
html { background: var(--canvas); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; color: var(--ink); background: var(--canvas);
  font: 400 17px/1.6 var(--face-read);
  font-optical-sizing: auto; text-rendering: optimizeLegibility; font-kerning: normal;
}
a { color: inherit; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--words-soft); color: var(--words); }
code { font: 500 .86em/1 var(--face-code); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 16px; z-index: 10; }

/* The canvas and the running head on it */
.canvas { padding: 0 10px 10px; }
.masthead {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 18px; color: var(--canvas-ink); font: 500 14px/20px var(--face-ui);
}
.brand { display: inline-flex; align-items: center; gap: 10px; margin: 0; font-size: 15px; }
.brand-home { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; }
.brand span { color: var(--canvas-ink-2); }
.brand span a { text-decoration-color: rgb(255 255 255 / .25); }
.brand span a:hover { color: var(--canvas-ink); text-decoration-color: currentColor; }
.mark { width: 26px; height: 28px; flex: none; }
.brand-home:hover .mark-caret { stroke-dasharray: 520; animation: draw-mark .5s ease-out both; }
@keyframes draw-mark { from { stroke-dashoffset: 520; } to { stroke-dashoffset: 0; } }
.masthead nav { display: flex; gap: 4px; flex-wrap: wrap; }
.masthead nav a { color: var(--canvas-ink-2); text-decoration: none; padding: 6px 12px; border-radius: 999px; }
.masthead nav a:hover { background: var(--canvas-hover); color: var(--canvas-ink); }
.masthead :focus-visible { outline-color: var(--canvas-ink); }

/* The sheet: the proof, with line numbers in the left gutter and the slip in the right margin */
.sheet {
  counter-reset: line;
  position: relative; display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr) var(--margin);
  column-gap: 40px; align-items: start;
  background: var(--surface); border-radius: 18px; box-shadow: var(--panel-shadow);
  padding: 72px 48px 40px 0;
}
.sheet > section, .sheet > footer { grid-column: 2; min-width: 0; }
.proof-line { position: relative; counter-increment: line; }
.proof-line::before {
  content: counter(line); position: absolute; left: calc(-1 * var(--gutter) - 40px); width: var(--gutter);
  text-align: right; top: .35em; font: 400 11px/1 var(--face-ui); color: var(--ink-3); opacity: .7;
  font-variant-numeric: tabular-nums; letter-spacing: .04em;
}

/* The slip: what waits on you, counting down to signed */
.slip {
  grid-column: 3; grid-row: 1 / span 20; position: sticky; top: 24px;
  border: 1px solid var(--waiting-line); background: var(--waiting-soft); border-radius: 16px;
  padding: 18px 20px; font: 400 14px/20px var(--face-ui); color: var(--ink-2);
  transition: background .5s, border-color .5s;
}
.slip-head { margin: 0 0 8px; font: 500 11px/1 var(--face-ui); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.slip-state { margin: 0 0 12px; color: var(--waiting); font: 500 15px/22px var(--face-ui); }
.slip-count { font: var(--title-weight) 40px/1 var(--face-title); font-variation-settings: 'SOFT' 100; font-variant-numeric: tabular-nums; margin-right: 4px; vertical-align: -6px; }
.slip-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.slip-list li { display: flex; gap: 10px; align-items: baseline; }
.slip-list li::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--waiting); transform: translateY(-1px); }
.slip-list li.done { color: var(--ink-3); }
.slip-list li.done::before { background: var(--done); }
.slip-list li.done a { text-decoration: line-through; text-decoration-color: var(--done-line); }
.slip-note { margin: 14px 0 0; font-size: 12px; color: var(--ink-3); }
html[data-left="0"] .slip { background: var(--done-soft); border-color: var(--done-line); }
html[data-left="0"] .slip-state { color: var(--done); }

/* The hero: the one correction that is the whole pitch */
.hero { padding-bottom: 56px; }
.superseded { margin: 0 0 18px; font: 400 12px/1.5 var(--face-ui); color: var(--ink-3); }
.superseded::before { content: ''; display: inline-block; width: 18px; height: 1px; background: var(--line-strong); vertical-align: middle; margin-right: 10px; }
h1, h2, .card-title, .promise-text, .steps h3, .handoff h3 {
  font-family: var(--face-title); font-weight: var(--title-weight); font-variation-settings: 'SOFT' 100;
  letter-spacing: -.015em; text-wrap: balance; margin: 0;
}
h1 { font-size: clamp(44px, 6.4vw, 88px); line-height: 1.04; max-width: 15ch; }
.fix { position: relative; display: inline-block; white-space: nowrap; }
.was { position: relative; color: var(--ink-3); display: none; }
.was::after { content: ''; position: absolute; left: -2%; right: -2%; top: 55%; height: 2px; background: var(--words); transform: scaleX(0); transform-origin: left; transition: transform .45s cubic-bezier(.6, 0, .2, 1); }
.caret { position: absolute; left: 50%; bottom: -.06em; width: .3em; height: .2em; translate: -50% 0; fill: none; stroke: var(--words); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lede { font-size: clamp(19px, 1.6vw, 22px); line-height: 1.6; color: var(--ink-2); max-width: 60ch; margin: 32px 0 0; text-wrap: pretty; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }

/* The correction plays once when motion is welcome; without script or motion the finished line shows. */
html.correcting .now, html.correcting .caret, html.correcting .superseded { display: none; }
html.correcting .was { display: inline; }
html.correcting.struck .was::after { transform: scaleX(1); }
html.correcting .superseded { animation: none; }
html.settled .now { animation: set .6s ease-out both; }
html.settled .caret path { stroke-dasharray: 40; animation: draw .5s .1s ease-out both; }
html.settled .superseded { animation: set .8s .4s ease-out both; }
@keyframes set { from { opacity: 0; filter: blur(2px); } to { opacity: 1; filter: none; } }
@keyframes draw { from { stroke-dashoffset: 40; } to { stroke-dashoffset: 0; } }

/* Sections */
.block { padding: 72px 0; border-top: 1px solid var(--line); }
h2 { font-size: clamp(32px, 3.6vw, 48px); line-height: 1.12; max-width: 22ch; }
.prose { font-size: 20px; line-height: 1.7; max-width: 62ch; margin: 20px 0 0; text-wrap: pretty; }
.block > .prose + * { margin-top: 36px; }

/* Buttons and chips */
.pill {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 500 14px/20px var(--face-ui); text-decoration: none; cursor: pointer;
}
.pill:hover { border-color: var(--ink-3); }
.pill.main { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.pill.main:hover { opacity: .88; }
.pill[disabled] { opacity: .45; cursor: default; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px; border-radius: 999px;
  font: 500 12px/18px var(--face-ui); border: 1px solid transparent; white-space: nowrap;
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.grey { color: var(--ink-3); background: var(--sunk); }
.chip.cobalt { color: var(--waiting); background: var(--waiting-soft); border-color: var(--waiting-line); }
.chip.green { color: var(--done); background: var(--done-soft); border-color: var(--done-line); }
.chip.outline { color: var(--ink-3); border-color: var(--line-strong); border-style: dashed; }

/* Problem: a diff too fast to read beside the one paragraph you read instead */
.versus { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 40px; }
.versus figure { margin: 0; border: 1px solid var(--line); border-radius: 16px; padding: 22px; min-height: 280px; position: relative; overflow: hidden; }
.diff-roll { position: absolute; inset: 22px 22px auto; }
.versus figcaption { position: absolute; left: 22px; bottom: 16px; font: 500 12px/1 var(--face-ui); color: var(--ink-3); }
.diff { background: var(--sunk); }
.diff-roll { display: grid; gap: 9px; animation: roll 6s linear infinite; }
.diff-roll i { display: block; height: 5px; border-radius: 3px; background: var(--line-strong); }
.diff::after { content: ''; position: absolute; inset: 0; background: linear-gradient(var(--sunk), transparent 22%, transparent 70%, var(--sunk)); pointer-events: none; }
@keyframes roll { to { transform: translateY(-50%); } }
.why-kind { margin: 0 0 10px; font: 500 12px/1 var(--face-ui); color: var(--ink-3); }
.why figcaption { position: static; margin-top: 18px; }
.why-text { margin: 0; font-size: 19px; line-height: 1.65; text-wrap: pretty; }

/* How it works */
.steps { list-style: none; counter-reset: step; padding: 0; margin: 40px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); }
.steps li { counter-increment: step; padding: 0 28px 0 0; border-right: 1px solid var(--line); }
.steps li + li { padding-left: 28px; }
.steps li:last-child { border-right: 0; }
.steps li::before { content: counter(step); display: block; font: 500 12px/1 var(--face-ui); color: var(--ink-3); margin-bottom: 14px; font-variant-numeric: tabular-nums; }
.steps h3 { font-size: 26px; line-height: 1.2; }
.steps p { color: var(--ink-2); margin: 10px 0 16px; text-wrap: pretty; }

/* A card at a gate: the one thing on the page you act on */
.card { margin-top: 48px; border: 1px solid var(--line); border-radius: 16px; padding: 26px 28px 28px; box-shadow: var(--shadow); background: var(--surface); max-width: 720px; transition: border-color .4s; }
.card.waiting { border-color: var(--waiting-line); }
.card.signed { border-color: var(--done-line); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-kind { margin: 0; font: 500 12px/1 var(--face-ui); color: var(--ink-3); }
.card-title { font-size: 28px; line-height: 1.2; }
.card-text { margin: 12px 0 22px; color: var(--ink-2); max-width: 60ch; text-wrap: pretty; }
.chip.state { transition: color .4s, background .4s, border-color .4s; }
.card.signed .chip.state { color: var(--done); background: var(--done-soft); border-color: var(--done-line); border-style: solid; }
.card.signed button[data-act], .card.signed .choices { display: none; }
.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.words { margin: 4px 0 0; padding: 14px 18px; border-left: 2px solid var(--words-line); background: var(--words-soft); border-radius: 0 12px 12px 0; }
.words p { margin: 0; font-style: italic; font-size: 19px; color: var(--words); }
.words footer { margin-top: 6px; font: 400 12px/1 var(--face-ui); color: var(--ink-3); }

/* The book's contents */
.contents { list-style: none; padding: 0; margin: 36px 0 0; max-width: 720px; }
.contents li { display: flex; align-items: baseline; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 19px; }
.contents i { flex: 1; border-bottom: 1px dotted var(--line-strong); transform: translateY(-5px); }
.contents b { font: 500 13px/1 var(--face-ui); color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* Promises */
.promise-text { font-size: clamp(30px, 3.2vw, 40px); line-height: 1.15; }
.proofs { list-style: none; padding: 0; margin: 22px 0; display: grid; }
.proofs li { padding: 10px 0; border-top: 1px solid var(--line); font: 400 15px/20px var(--face-ui); color: var(--ink-2); display: flex; gap: 10px; align-items: center; }
.proofs li::before { content: ''; width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line-strong); }
.card.signed .proofs li.yours { color: var(--done); }
.card.signed .proofs li.yours::before { background: var(--done); border-color: var(--done); box-shadow: inset 0 0 0 3px var(--surface); }
.tally { display: flex; gap: 28px; margin: 0 0 20px; font: 400 14px/20px var(--face-ui); color: var(--ink-3); }
.tally b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; margin-left: 6px; }

/* The ledger: append-only, numbered */
.ledger { list-style: none; padding: 0; margin: 36px 0 0; max-width: 760px; }
.ledger li { display: grid; grid-template-columns: 48px 64px 1fr auto; gap: 14px; align-items: baseline; padding: 13px 0; border-bottom: 1px solid var(--line); font: 400 15px/22px var(--face-ui); color: var(--ink-2); }
.ledger li::before { content: attr(data-n); color: var(--ink-3); font: 500 12px/22px var(--face-code); }
.ledger .who { font-size: 12px; color: var(--ink-3); }
.ledger li.yours .who:first-of-type { color: var(--words); }
.ledger li.fresh { animation: append .6s ease-out both; }
@keyframes append { from { opacity: 0; transform: translateY(-6px); background: var(--words-soft); } to { opacity: 1; transform: none; } }
.delete { background: none; border: 0; padding: 0; font: 400 13px/22px var(--face-ui); color: var(--ink-3); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; cursor: pointer; }

/* Local-first */
.machine { margin: 40px 0 0; border: 1px solid var(--ink); border-radius: 18px; padding: 22px; max-width: 760px; position: relative; }
.machine-name { margin: 0 0 16px; font: 500 12px/1 var(--face-ui); color: var(--ink); }
.machine-parts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.machine-parts span { border: 1px solid var(--line); border-radius: 12px; padding: 14px; font: 500 14px/20px var(--face-ui); background: var(--page); }
.machine-parts small { display: block; margin-top: 4px; font-weight: 400; font-size: 12px; line-height: 17px; color: var(--ink-3); }

/* Agents */
.exchange { margin: 36px 0 0; max-width: 760px; padding: 20px 22px; border-radius: 16px; background: var(--sunk); font: 400 13px/1.7 var(--face-code); color: var(--ink-2); white-space: pre-wrap; overflow-x: auto; }
.exchange .q, .exchange .a { color: var(--ink-3); }

/* Getting started */
.press { margin: 0 0 14px; font: 500 12px/1 var(--face-ui); color: var(--ink-3); }
html[data-left="0"] .press { color: var(--done); }
.ways { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; margin-top: 36px; align-items: start; }
.commands { list-style: none; counter-reset: cmd; padding: 0; margin: 0; display: grid; gap: 10px; }
.commands li { counter-increment: cmd; display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 12px 12px 12px 14px; background: var(--page); }
.commands li::before { content: counter(cmd); font: 500 12px/1 var(--face-ui); color: var(--ink-3); }
.commands code { font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.copy { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 4px 12px; font: 500 12px/18px var(--face-ui); cursor: pointer; }
.copy.copied { color: var(--done); border-color: var(--done-line); }
.handoff { border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.handoff h3 { font-size: 24px; line-height: 1.2; }
.handoff p { margin: 8px 0 14px; color: var(--ink-2); font-size: 16px; }
.prompt { margin: 0 0 16px; max-height: 220px; overflow: auto; padding: 14px 16px; border-radius: 12px; background: var(--sunk); font: 400 13px/1.6 var(--face-code); white-space: pre-wrap; color: var(--ink-2); }
.needs { margin: 24px 0 0; font: 400 14px/20px var(--face-ui); color: var(--ink-3); }
.open .pill { margin-top: 28px; }

/* The colophon */
.colophon { border-top: 1px solid var(--line); padding: 40px 0 8px; font: 400 14px/22px var(--face-ui); color: var(--ink-3); }
.colophon p { margin: 0 0 12px; max-width: 70ch; }
.colophon-links { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; }
.theme { background: none; border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 12px; color: var(--ink-2); font: inherit; font-size: 13px; cursor: pointer; }
.end { margin-top: 28px !important; font: 500 11px/1 var(--face-ui); letter-spacing: .12em; text-transform: uppercase; }

/* Medium: the slip moves above the page as a band; compact: one column and a bar at the bottom */
@media (max-width: 1199px) {
  :root { --gutter: 48px; }
  .sheet { grid-template-columns: var(--gutter) minmax(0, 1fr); padding-right: 32px; }
  .slip { grid-column: 2; grid-row: auto; position: sticky; top: 8px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; padding: 12px 16px; margin-bottom: 40px; box-shadow: var(--shadow); }
  .slip-head, .slip-note { display: none; }
  .slip-state { margin: 0; }
  .slip-count { font-size: 28px; vertical-align: -4px; }
  .slip-list { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; }
  .machine-parts { grid-template-columns: repeat(2, 1fr); }
  .ways { grid-template-columns: 1fr; }
}
@media (max-width: 759px) {
  body { font-size: 16px; }
  .canvas { padding: 0 6px 6px; }
  .masthead { padding: 12px 8px; }
  .masthead nav a:not([href^="https"]) { display: none; }
  .sheet { display: block; padding: 32px 18px 24px; border-radius: 14px; }
  .proof-line::before { display: none; }
  .slip { position: fixed; left: 6px; right: 6px; bottom: 6px; top: auto; margin: 0; border-radius: 14px; }
  .slip-list { display: none; }
  .block { padding: 52px 0; }
  .prose { font-size: 18px; }
  .versus, .steps { grid-template-columns: 1fr; }
  .versus figure { min-height: 0; }
  .versus figure.diff { height: 200px; }
  .steps li, .steps li + li { border-right: 0; padding: 0 0 22px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
  .card { padding: 20px; }
  .ledger li { grid-template-columns: 40px 1fr auto; }
  .ledger .who { display: none; }
  .machine-parts { grid-template-columns: 1fr; }
  .colophon { padding-bottom: 80px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Cmd+P prints a real galley: crop marks, line numbers, and whether it was signed. */
@media print {
  @page { margin: 18mm; }
  html, body, .canvas { background: #fff; color: #000; }
  .masthead nav, .slip, .actions, .pill, .copy, .delete, .theme, .diff, .skip { display: none !important; }
  .sheet { box-shadow: none; border-radius: 0; padding: 0; display: block; }
  .proof-line::before { display: block; left: -12mm; width: 8mm; color: #000; }
  .sheet::before { content: 'Galley proof, not for press'; display: block; font: 500 9pt var(--face-ui); letter-spacing: .12em; text-transform: uppercase; border-bottom: .5pt solid #000; padding-bottom: 4pt; margin-bottom: 18pt; }
  html[data-left="0"] .sheet::before { content: 'Galley proof, approved for press'; }
  .block { break-inside: avoid; }
}
