/* GodEngine Research (godengine.org): a calm working-paper layout on sage-grey archival paper.
   System fonts only, no external requests. Light and dark follow the OS. */

:root {
  color-scheme: light dark;
  --paper: #ecefe8;
  --paper-2: #dfe4db;
  --ink: #1b201c;
  --muted: #4c544d;
  --accent: #744a0a;
  --rev: #862819;
  --use: #2f5636;
  --rule: #c3cabd;
  --rule-strong: #78826f;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Charter, "Bitstream Charter", Cambria, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  --measure: 40rem;
  --gutter: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111412;
    --paper-2: #1a1f1b;
    --ink: #e6eae1;
    --muted: #a9b2a6;
    --accent: #dcb15a;
    --rev: #e89077;
    --use: #9cc9a2;
    --rule: #333b34;
    --rule-strong: #7f8a7c;
  }
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.65;
  font-kerning: normal;
  font-variant-numeric: oldstyle-nums proportional-nums;
  overflow-wrap: break-word;
}

@media (min-width: 48rem) {
  body { font-size: 1.1875rem; }
  :root { --gutter: 2rem; }
}

img, svg { max-width: 100%; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { text-decoration-thickness: 2px; }

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

.wrap {
  max-width: 68rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- skip link ---------- */
.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  background: var(--ink);
  color: var(--paper);
  padding: 0.55rem 0.9rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  text-decoration: none;
  border-radius: 2px;
}
.skip:focus { top: 1rem; }

/* ---------- masthead ---------- */
.masthead {
  border-top: 4px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}
.masthead__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.brand__sub { font-weight: 400; color: var(--muted); }
.brand__mark { flex: none; }
.bm-trunk, .bm-alt, .bm-main, .bm-rev { fill: none; stroke-linecap: round; }
.bm-trunk { stroke: var(--ink); stroke-width: 3; }
.bm-alt { stroke: var(--rule-strong); stroke-width: 2; }
.bm-main { stroke: var(--accent); stroke-width: 4; }
.bm-rev { stroke: var(--rev); stroke-width: 2.5; stroke-dasharray: 4 4; }
.bm-node { fill: var(--paper); stroke: var(--ink); stroke-width: 2.5; }

.nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
}
.nav a {
  display: inline-block;
  padding: 0.3rem 0;
  line-height: 1.35;
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.nav a:hover { border-bottom-color: var(--rule-strong); }
.nav a[aria-current="page"] { border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- type ---------- */
h1, h2, h3 {
  font-family: var(--serif);
  line-height: 1.2;
  color: var(--ink);
  text-wrap: balance;
}
h1 {
  font-size: clamp(2rem, 1.35rem + 3vw, 3.1rem);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0.35rem 0 1rem;
}
h2 {
  font-size: clamp(1.4rem, 1.15rem + 1vw, 1.75rem);
  font-weight: 600;
  margin: 3rem 0 0.6rem;
}
h3 { font-size: 1.2rem; margin: 2rem 0 0.4rem; }

p, ul, ol, dl { margin: 0 0 1.1rem; }
ul, ol { padding-left: 1.4rem; }
li { margin-bottom: 0.4rem; }
strong { font-weight: 600; }

.kicker {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.lede {
  font-size: 1.22em;
  line-height: 1.5;
  max-width: var(--measure);
}

.dropcap::first-letter {
  float: left;
  font-size: 3.5em;
  line-height: 0.82;
  padding: 0.07em 0.09em 0 0;
  color: var(--accent);
  font-weight: 600;
}

/* ---------- status marks ---------- */
.mark {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
  padding: 0.34rem 0.5rem 0.3rem;
  border: 1px solid currentColor;
  border-radius: 2px;
  white-space: nowrap;
  vertical-align: 0.12em;
}
.mark--use { color: var(--use); }
.mark--part { color: var(--accent); }
.mark--off { color: var(--muted); border-style: dotted; }
.mark--prop { color: var(--rev); border-style: dashed; }

.h-mark { margin: -0.15rem 0 0.9rem; }

.status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.5rem;
  margin: 1.5rem 0 0;
  padding: 0.6rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  max-width: var(--measure);
}

/* ---------- home ---------- */
.hero { padding: 3rem 0 1rem; }
.hero h1 { max-width: 22ch; }

.fork { margin: 2.25rem 0 0; max-width: 46rem; }
.fork__art { display: block; width: 100%; height: auto; }
.fork figcaption {
  margin-top: 0.6rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  max-width: var(--measure);
}
.fk-guide, .fk-trunk, .fk-alt, .fk-main, .fk-rev, .fk-bar { fill: none; stroke-linecap: round; }
.fk-guide { stroke: var(--rule); stroke-width: 1; }
.fk-trunk { stroke: var(--ink); stroke-width: 3; }
.fk-alt { stroke: var(--rule-strong); stroke-width: 2; }
.fk-main { stroke: var(--accent); stroke-width: 5; }
.fk-rev { stroke: var(--rev); stroke-width: 2.5; stroke-dasharray: 8 8; }
.fk-bar { stroke: var(--rev); stroke-width: 3; }
.fk-dot { fill: var(--ink); }
.fk-node { fill: var(--paper); stroke: var(--ink); stroke-width: 3; }
.fk-end { fill: var(--paper); stroke: var(--rule-strong); stroke-width: 2; }
.fk-end--main { fill: var(--accent); stroke: var(--accent); }
.fk-end--rev { stroke: var(--rev); }

/* The only motion: the dashed reversal path moves once, then rests. Nothing is hidden at any frame. */
@keyframes fk-march {
  from { stroke-dashoffset: 64; }
  to { stroke-dashoffset: 0; }
}
@media (prefers-reduced-motion: no-preference) {
  .fk-rev { animation: fk-march 2.4s ease-out 0.3s 1; }
}

.rail {
  border-top: 1px solid var(--rule);
  margin-top: 3rem;
  padding-top: 0.5rem;
}
.rail > h2 { margin-top: 1rem; }
.rail__body { max-width: var(--measure); }

@media (min-width: 64rem) {
  .rail {
    display: grid;
    grid-template-columns: 13rem minmax(0, var(--measure));
    gap: 3rem;
  }
  .rail > h2 {
    font-size: 1.15rem;
    line-height: 1.35;
    margin: 0.35rem 0 0;
  }
  .rail__body { padding-top: 0.1rem; }
}

.pull { margin: 0.5rem 0 1.75rem; }
.pull blockquote {
  margin: 0;
  padding: 0.1rem 0 0.1rem 1.25rem;
  border-left: 3px solid var(--accent);
  font-size: 1.3em;
  line-height: 1.45;
  font-style: italic;
}
.pull blockquote p { margin: 0; }
.pull figcaption {
  margin: 0.6rem 0 0 1.25rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
}

.toc {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0;
}
.toc li {
  margin: 0;
  padding: 1rem 0 1.1rem;
  border-bottom: 1px solid var(--rule);
}
.toc li:first-child { padding-top: 0.25rem; }
.toc li:last-child { border-bottom: 0; }
.toc a {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.3;
}
.toc a:hover .toc__t { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
.toc__n {
  flex: none;
  min-width: 2rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
}
.toc p { margin: 0.35rem 0 0 3rem; color: var(--muted); font-size: 1rem; }

.five { padding-left: 1.6rem; }
.five li { padding-left: 0.3rem; margin-bottom: 0.7rem; }
.five li::marker { font-family: var(--sans); font-weight: 700; color: var(--accent); }

.legend { margin: 0 0 1.25rem; }
.legend > div {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--rule);
}
.legend dt, .legend dd { margin: 0; }
@media (min-width: 36rem) {
  .legend > div { grid-template-columns: 12rem 1fr; gap: 1rem; align-items: baseline; }
}

/* ---------- essays ---------- */
.essay__head {
  padding: 3rem 0 0.5rem;
  max-width: var(--measure);
}
.essay__head::after { content: ""; display: table; clear: both; }

.motif {
  float: right;
  width: 4.5rem;
  height: auto;
  margin: 0 0 0.75rem 1rem;
}
@media (min-width: 48rem) {
  .motif { width: 6.5rem; margin-left: 1.5rem; }
}
.mo-box { fill: none; stroke: var(--rule-strong); stroke-width: 2; }
.mo-box--key { stroke: var(--accent); stroke-width: 3; }
.mo-thread { fill: none; stroke: var(--rule-strong); stroke-width: 2; stroke-dasharray: 3 4; }
.mo-full { fill: var(--ink); }
.mo-full--key { fill: var(--accent); }
.mo-empty { fill: none; stroke: var(--ink); stroke-width: 2; }
.mo-half { fill: var(--accent); }
.mo-line { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.mo-faint { fill: none; stroke: var(--rule-strong); stroke-width: 2; stroke-dasharray: 4 5; stroke-linecap: round; }
.mo-wall { fill: none; stroke: var(--rev); stroke-width: 4; stroke-linecap: round; }

.prose { max-width: var(--measure); }
.essay .prose > section > h2 { scroll-margin-top: 1rem; }

/* section numbers in the margin of each essay */
.essay .prose { counter-reset: sec; }
.essay .prose > section > h2::before {
  counter-increment: sec;
  content: "§ " counter(sec);
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* side notes: inline on small screens, in the right margin on wide ones */
.note {
  margin: 1rem 0 1.25rem;
  padding: 0.15rem 0 0.15rem 0.85rem;
  border-left: 2px solid var(--rule-strong);
  font-family: var(--sans);
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--muted);
}
.note__label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.15rem;
}
@media (min-width: 74rem) {
  .essay .prose { max-width: none; }
  .essay__head, .next { max-width: var(--measure); }
  .essay .prose > section {
    display: grid;
    grid-template-columns: minmax(0, var(--measure)) 15rem;
    column-gap: 3.5rem;
    align-items: start;
    padding-top: 3rem;
  }
  .essay .prose > section > * { grid-column: 1; }
  .essay .prose > section > h2 { margin-top: 0; }
  .essay .prose > section > .note {
    grid-column: 2;
    grid-row: 1 / span 40;
    margin: 0.2rem 0 0;
    padding: 0.55rem 0 0;
    border-left: 0;
    border-top: 1px solid var(--rule-strong);
  }
}

.record {
  margin: 1.5rem 0;
  padding: 0.9rem 1.1rem;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  font-size: 0.95rem;
}
.record > div {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.1rem;
  padding: 0.4rem 0;
  border-bottom: 1px dotted var(--rule);
}
.record > div:last-child { border-bottom: 0; }
.record dt {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent);
}
.record dd { margin: 0; }
@media (min-width: 36rem) {
  .record > div { grid-template-columns: 7.5rem 1fr; gap: 1rem; align-items: baseline; }
}

.example {
  margin: 1.75rem 0;
  padding: 1rem 1.2rem 0.4rem;
  border: 1px dashed var(--rule-strong);
  border-radius: 2px;
  font-size: 0.98rem;
}
.example__label {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rev);
  margin-bottom: 0.6rem;
}
.example p { margin-bottom: 0.6rem; }

.rules { list-style: none; padding-left: 0; }
.rules li {
  position: relative;
  padding: 0.55rem 0 0.55rem 1.4rem;
  margin: 0;
  border-bottom: 1px solid var(--rule);
}
.rules li::before {
  content: "";
  position: absolute;
  left: 0.15rem;
  top: 1.15em;
  width: 0.55rem;
  height: 2px;
  background: var(--rev);
}

.phases { padding-left: 1.6rem; }
.phases li { padding-left: 0.3rem; margin-bottom: 0.6rem; }
.phases li::marker { font-family: var(--sans); font-weight: 700; color: var(--accent); }

/* ---------- tables ---------- */
.table-wrap {
  margin: 1.5rem 0;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  line-height: 1.45;
  font-variant-numeric: lining-nums tabular-nums;
}
caption {
  caption-side: top;
  text-align: left;
  padding-bottom: 0.5rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.55rem 0.9rem 0.55rem 0;
  border-bottom: 1px solid var(--rule);
}
th:last-child, td:last-child { padding-right: 0; }
thead th {
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 700;
  border-bottom: 2px solid var(--ink);
}
tbody th { font-weight: 600; }

/* ---------- links and buttons ---------- */
.next {
  clear: both;
  margin: 4rem 0 0;
  padding-top: 1rem;
  border-top: 4px double var(--rule-strong);
}
.next__label {
  margin: 0 0 0.2rem;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.next a { font-size: 1.3rem; font-weight: 600; }

.button {
  display: inline-block;
  padding: 0.7rem 1.1rem;
  border: 2px solid var(--accent);
  border-radius: 2px;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
}
.button:hover { background: var(--paper-2); }

/* ---------- colophon ---------- */
.colophon {
  clear: both;
  margin-top: 5rem;
  border-top: 4px double var(--rule-strong);
  font-family: var(--sans);
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--muted);
}
.colophon__inner { padding-top: 2rem; padding-bottom: 3rem; }
.colophon__brand { max-width: var(--measure); }
.colophon__name {
  margin-bottom: 0.4rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}
.colophon__name span { font-weight: 400; letter-spacing: 0.04em; text-transform: none; color: var(--muted); margin-left: 0.5rem; }
.colophon__nav ul {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}
.colophon__nav a { display: inline-block; padding: 0.25rem 0; }
.colophon__fine { max-width: var(--measure); margin-bottom: 0.5rem; }

/* ---------- motion and print ---------- */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

@media print {
  .masthead nav, .skip, .next, .colophon__nav { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .note { float: none; width: auto; margin: 0.5rem 0; }
  a { color: #000; }
  .fk-rev { animation: none; }
}

/* lining figures in the sans-serif labels; old-style figures stay in the serif text */
.kicker, .status-line, .mark, .note, .colophon, .pull figcaption, .fork figcaption,
caption, .toc__n, .next__label, .example__label,
.essay .prose > section > h2::before {
  font-variant-numeric: lining-nums tabular-nums;
}
