/* fivecell.com
 * White paper, near-black text, one accent.  Modern serif with
 * some character.  No parchment.  No fleurons.  No display caps.
 * The work is the typography + the things being said; aesthetic
 * restraint is the point.
 *
 * Reference points: a London Review of Books long essay, the
 * print edition of n+1, Tufte's Visual Display, a modern academic
 * monograph that knows how to set a page.
 */

@import url("https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,300;0,8..60,400;0,8..60,500;0,8..60,600;0,8..60,700;1,8..60,400;1,8..60,500&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
  --paper:        #fdfcfa;
  --paper-mute:   #f3f1ec;
  --paper-deep:   #ecebe5;
  --ink:          #15130f;
  --ink-soft:     #3d3a33;
  --ink-mute:     #7a766c;
  --rule:         #dad6cc;
  --rule-soft:    #ebe7dd;
  --accent:       #a02c2c;       /* tufte-ish red, marginal-note red */
  --accent-dim:   #c87575;
  --accent-deep:  #7a1f1f;
  --max-w:        660px;
  --max-w-wide:   1040px;
}

* { box-sizing: border-box; }

html { background: var(--paper); }
body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Source Serif 4", "Source Serif Pro", "Charter",
               "Iowan Old Style", Georgia, serif;
  font-size: 19px;
  line-height: 1.6;
  font-feature-settings: "kern", "liga", "calt", "onum";
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

::selection { background: var(--accent); color: var(--paper); }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-dim);
  transition: color 140ms ease, border-color 140ms ease;
}
a:hover { color: var(--accent-deep); border-bottom-color: var(--accent-deep); }

code, pre, .mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular,
               Menlo, monospace;
}

main { display: block; }

/* ───── topbar ───────────────────────────────────────── */

.topbar {
  border-bottom: 1px solid var(--rule);
  background: rgba(253, 252, 250, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: var(--max-w-wide);
  margin: 0 auto;
  padding: 18px 36px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.brand {
  font-family: "Source Serif 4", serif;
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.01em;
  color: var(--ink);
  border-bottom: none;
}
.brand:hover { color: var(--accent); border-bottom: none; }
.brand .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  margin-right: 10px;
  transform: translateY(-2px);
}
.topbar nav {
  display: flex;
  gap: 28px;
}
.topbar nav a {
  font-size: 16px;
  color: var(--ink-soft);
  border-bottom: none;
  font-weight: 400;
}
.topbar nav a:hover { color: var(--accent); border-bottom: none; }

/* ───── hero ─────────────────────────────────────────── */

.hero {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 96px 36px 36px;
}
.hero .kicker {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 26px;
}
.hero h1 {
  font-family: "Source Serif 4", serif;
  font-weight: 600;
  font-size: clamp(44px, 7vw, 76px);
  line-height: 1.02;
  letter-spacing: -0.025em;
  margin: 0 0 28px;
  color: var(--ink);
}
.hero h1 em {
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
}
.hero .subhead {
  font-size: clamp(20px, 2.1vw, 24px);
  font-weight: 400;
  line-height: 1.45;
  color: var(--ink-soft);
  max-width: 580px;
  margin: 0 0 40px;
}
.cta-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "Source Serif 4", serif;
  font-weight: 500;
  font-size: 17px;
  padding: 12px 22px;
  border-radius: 4px;
  border-bottom: none;
  transition: background 140ms ease, color 140ms ease, transform 100ms ease;
}
.cta.primary {
  background: var(--accent);
  color: var(--paper);
}
.cta.primary:hover {
  background: var(--accent-deep);
  color: var(--paper);
  border-bottom: none;
  transform: translateY(-1px);
}
.cta.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
}
.cta.secondary:hover {
  color: var(--accent);
  border-color: var(--accent);
  border-bottom-color: var(--accent);
}
.cta .arrow { transition: transform 140ms ease; }
.cta:hover .arrow { transform: translateX(3px); }

/* ───── essay body ───────────────────────────────────── */

.essay {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 40px 36px 0;
}
.essay p {
  margin: 0 0 22px;
  font-size: 19px;
  line-height: 1.65;
  color: var(--ink);
}
.essay p em.strong {
  font-style: italic;
  color: var(--accent);
  font-weight: 500;
}
.essay h2 {
  font-family: "Source Serif 4", serif;
  font-weight: 600;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 56px 0 18px;
  color: var(--ink);
}

/* ───── agent-loop list ──────────────────────────────── */

.agent-loop {
  list-style: none;
  padding: 0;
  margin: 22px 0 28px;
  border-left: 2px solid var(--accent);
}
.agent-loop li {
  position: relative;
  padding: 10px 0 10px 22px;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
}
.agent-loop li strong {
  font-weight: 600;
  color: var(--accent);
  margin-right: 6px;
}
.agent-loop li + li {
  border-top: 1px solid var(--rule-soft);
}
.agent-loop code {
  background: var(--paper-mute);
  border: 1px solid var(--rule-soft);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 13.5px;
  color: var(--ink);
}

/* ───── artifact ─────────────────────────────────────── */

.artifact {
  max-width: var(--max-w);
  margin: 64px auto 0;
  padding: 0 36px;
}
/* When the receipt is hoisted up to replace the diagram, give it
 * a bit more breathing room above the essay below. */
.artifact--hero {
  margin: 40px auto 16px;
}
.artifact--hero .caption {
  font-style: italic;
  font-size: 16px;
  color: var(--ink-mute);
  margin: 18px auto 0;
  max-width: 580px;
  line-height: 1.55;
  text-align: center;
}
.receipt {
  background: var(--paper-mute);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  padding: 28px 32px;
  position: relative;
}
.receipt .label {
  position: absolute;
  top: -10px;
  left: 24px;
  background: var(--paper);
  padding: 0 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.receipt pre {
  margin: 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  line-height: 1.85;
  color: var(--ink);
  background: transparent;
  white-space: pre-wrap;
  word-break: break-word;
}
.receipt .k   { color: var(--ink-mute); }
.receipt .s   { color: var(--ink); }
.receipt .n   { color: var(--ink); }
.receipt .c   { color: var(--ink-mute); font-style: italic; }
.receipt .sig { color: var(--accent); }
.artifact .caption {
  font-style: italic;
  font-size: 16px;
  color: var(--ink-mute);
  line-height: 1.55;
  margin: 18px 0 0;
  text-align: left;
  max-width: 560px;
}

/* ───── parties ──────────────────────────────────────── */

.parties {
  max-width: var(--max-w-wide);
  margin: 88px auto 0;
  padding: 0 36px;
}
.parties h2 {
  font-family: "Source Serif 4", serif;
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.015em;
  margin: 0 0 36px;
  color: var(--ink);
}
.parties h2 em {
  font-style: italic;
  color: var(--accent);
  font-weight: 500;
}
.party-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
}
.party-grid--four {
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
}
@media (max-width: 1024px) {
  .party-grid--four { grid-template-columns: repeat(2, 1fr); gap: 32px; }
}
@media (max-width: 880px) {
  .party-grid       { grid-template-columns: 1fr; gap: 28px; }
  .party-grid--four { grid-template-columns: 1fr; gap: 28px; }
}
.party {
  border-top: 1px solid var(--accent);
  padding-top: 18px;
}
.party h3 {
  font-family: "Source Serif 4", serif;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 12px;
}
.party p {
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0 0 12px;
}
.party p em { color: var(--ink); font-weight: 500; font-style: italic; }

/* ───── closing strip ────────────────────────────────── */

.closing {
  max-width: var(--max-w);
  margin: 96px auto 0;
  padding: 48px 36px;
  border-top: 1px solid var(--rule);
  text-align: left;
}
.closing p.tag {
  font-size: 21px;
  line-height: 1.45;
  color: var(--ink);
  margin: 0 0 32px;
  max-width: 540px;
}
.closing p.tag em {
  font-style: italic;
  color: var(--accent);
}

/* ───── footer ───────────────────────────────────────── */

footer.site {
  border-top: 1px solid var(--rule);
  background: var(--paper);
  margin-top: 72px;
}
footer.site .inner {
  max-width: var(--max-w-wide);
  margin: 0 auto;
  padding: 32px 36px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  font-size: 14px;
  color: var(--ink-mute);
}
footer.site .tag {
  font-weight: 600;
  color: var(--ink-soft);
}
footer.site .links { display: flex; gap: 22px; }
footer.site .links a {
  color: var(--ink-soft);
  border-bottom: 1px dotted var(--rule);
  font-size: 14px;
}
footer.site .links a:hover { color: var(--accent); border-bottom-color: var(--accent); }
footer.site code {
  font-size: 12.5px;
  color: var(--ink-mute);
}

/* ───── reference (API) page ─────────────────────────── */

.compendium {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 96px 36px 64px;
}
.compendium h1 {
  font-family: "Source Serif 4", serif;
  font-weight: 600;
  font-size: clamp(40px, 6vw, 64px);
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin: 0 0 18px;
  color: var(--ink);
}
.compendium .kicker {
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 26px;
  display: block;
}
.compendium .lede {
  font-size: 19px;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 560px;
  margin: 0 0 56px;
}
.compendium h2 {
  font-family: "Source Serif 4", serif;
  font-weight: 600;
  font-size: 24px;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 72px 0 24px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}
.entry { margin: 0 0 36px; }
.entry .route {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  color: var(--ink);
  margin: 0 0 8px;
}
.entry .route .verb {
  display: inline-block;
  background: var(--accent);
  color: var(--paper);
  padding: 2px 8px;
  margin-right: 10px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  border-radius: 3px;
  vertical-align: 1px;
}
.entry p.gloss {
  font-size: 16.5px;
  color: var(--ink-soft);
  margin: 0 0 12px;
  line-height: 1.55;
}
.entry pre {
  background: var(--paper-mute);
  border: 1px solid var(--rule);
  padding: 16px 20px;
  margin: 8px 0 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink);
  overflow-x: auto;
  white-space: pre;
  border-radius: 4px;
}
.entry pre .c { color: var(--ink-mute); font-style: italic; }
.entry pre .k { color: var(--accent-deep); }
.entry pre .s { color: var(--ink); }
