:root {
  /* palette — warm ink, bone, mosaic gold, byzantine teal */
  --bg:        #0e0d0a;
  --bg-2:      #14120e;
  --ink:       #e9e2d0;
  --ink-2:     #cfc7b3;
  --mute:      #7a7367;
  --rule:      #2a271f;
  --gold:      #d29a4e;
  --gold-dim:  #8a6836;
  --azure:     #3f7e83;
  --azure-dim: #2a5459;
  --stone:     #1c1a14;
  --selection: #d29a4e;

  /* typography */
  --f-serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --f-mono:  "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* measure */
  --measure: 68ch;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--f-serif);
  font-variation-settings: "opsz" 14, "SOFT" 30;
  font-weight: 400;
  font-size: 17px;
  line-height: 1.62;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(1400px 800px at 85% -10%, rgba(210, 154, 78, 0.06), transparent 55%),
    radial-gradient(1200px 700px at -10% 30%, rgba(63, 126, 131, 0.045), transparent 55%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  /* editorial: old-style figures in prose (lowercase digits with ascenders/descenders) */
  font-variant-numeric: oldstyle-nums proportional-nums;
  font-feature-settings: "kern" 1, "liga" 1;
}

/* very subtle film grain for depth */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: .035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.8 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

::selection { background: var(--selection); color: var(--bg); }

a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--gold-dim); transition: color .15s ease, border-color .15s ease; }
a:hover { color: var(--gold); border-bottom-color: var(--gold); }

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 4rem auto;
  max-width: var(--measure);
}

code, pre, kbd, .mono {
  font-family: var(--f-mono);
  /* engineering: lining tabular figures, slashed zero, programmer ligatures */
  font-variant-numeric: tabular-nums slashed-zero;
  font-variant-ligatures: contextual;
  font-feature-settings: "calt" 1, "ss02" 1, "zero" 1;
}

/* ---------- layout containers ---------- */
.wrap  { max-width: 1240px; margin: 0 auto; padding: 0 28px; }
.prose { max-width: var(--measure); margin: 0 auto; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
}
.site-header::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  bottom: -28px;
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  background: linear-gradient(
    to bottom,
    rgba(14, 13, 10, 0.85) 0%,
    rgba(14, 13, 10, 0.55) 60%,
    rgba(14, 13, 10, 0)    100%
  );
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 50%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 0%, #000 50%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}
.site-header .inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  max-width: 1400px; margin: 0 auto;
  position: relative;
  z-index: 1;
}
.brand {
  display: inline-flex; align-items: center; gap: 12px;
  font-family: var(--f-mono);
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--ink);
  border: 0;
}
.brand .glyph {
  display: inline-block; width: 18px; height: 18px;
}
.nav {
  display: flex; gap: 28px;
  font-family: var(--f-mono);
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: lowercase;
}
.nav a { border: 0; color: var(--ink-2); }
.nav a:hover { color: var(--gold); }
.nav .pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--rule);
  color: var(--mute);
  font-size: 11.5px;
}
.nav .pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px var(--gold); animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .8; } 50% { opacity: .35; } }

/* ---------- hero ---------- */
.hero { position: relative; padding: 72px 28px 56px; overflow: hidden; }
.hero-inner { max-width: 1240px; margin: 0 auto; position: relative; }

.hero-meta {
  font-family: var(--f-mono);
  font-size: 12.5px;
  color: var(--mute);
  letter-spacing: .06em;
  text-transform: lowercase;
  display: flex; gap: 18px; flex-wrap: wrap;
  margin-bottom: 28px;
}
.hero-meta span b {
  color: var(--ink-2);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.hero-meta .sep { color: var(--rule); }

.wordmark-wrap {
  position: relative;
  height: clamp(180px, 30vw, 360px);
  margin: 10px 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wordmark-wrap h1.wordmark {
  position: relative; z-index: 2;
  margin: 0;
  font-family: var(--f-serif);
  font-variation-settings: "opsz" 144, "SOFT" 0, "wght" 540;
  font-weight: 540;
  font-size: clamp(88px, 17vw, 240px);
  letter-spacing: -0.03em;
  line-height: .9;
  color: var(--ink);
  text-shadow: 0 2px 40px rgba(0,0,0,.6), 0 1px 0 rgba(0,0,0,.4);
}
.wordmark-wrap h1.wordmark em {
  font-style: italic;
  color: var(--gold);
  font-variation-settings: "opsz" 144, "SOFT" 50, "wght" 500;
}

/* typesetter's crop marks — four L-shaped fiducials framing the wordmark */
.wordmark-wrap::before {
  content: "";
  position: absolute;
  inset: 14px 6% 14px 6%;
  pointer-events: none;
  opacity: .55;
  background:
    /* each corner: two 22px lines forming an L */
    linear-gradient(var(--gold-dim), var(--gold-dim)) top    left  / 22px 1px  no-repeat,
    linear-gradient(var(--gold-dim), var(--gold-dim)) top    left  / 1px  22px no-repeat,
    linear-gradient(var(--gold-dim), var(--gold-dim)) top    right / 22px 1px  no-repeat,
    linear-gradient(var(--gold-dim), var(--gold-dim)) top    right / 1px  22px no-repeat,
    linear-gradient(var(--gold-dim), var(--gold-dim)) bottom left  / 22px 1px  no-repeat,
    linear-gradient(var(--gold-dim), var(--gold-dim)) bottom left  / 1px  22px no-repeat,
    linear-gradient(var(--gold-dim), var(--gold-dim)) bottom right / 22px 1px  no-repeat,
    linear-gradient(var(--gold-dim), var(--gold-dim)) bottom right / 1px  22px no-repeat;
}

.tagline {
  font-family: var(--f-serif);
  font-variation-settings: "opsz" 28, "SOFT" 100;
  font-size: clamp(19px, 2.2vw, 24px);
  line-height: 1.4;
  color: var(--ink-2);
  max-width: 56ch;
  margin: 28px auto 0;
  text-align: center;
  text-wrap: balance;
}
.tagline em { color: var(--gold); font-style: italic; }

.cta-row {
  display: flex; flex-wrap: wrap; gap: 14px;
  justify-content: center;
  margin: 38px auto 0;
  align-items: center;
}
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 22px;
  border: 1px solid var(--gold-dim);
  border-radius: 2px;
  font-family: var(--f-mono);
  font-size: 13.5px;
  letter-spacing: .02em;
  color: var(--ink);
  transition: all .18s ease;
}
.btn:hover { background: var(--gold); color: var(--bg); border-color: var(--gold); }
.btn.ghost { border-color: var(--rule); color: var(--ink-2); }
.btn.ghost:hover { border-color: var(--ink); color: var(--ink); background: transparent; }
.btn .arrow { transition: transform .18s ease; }
.btn:hover .arrow { transform: translateX(3px); }

.shell {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: 2px;
  font-family: var(--f-mono);
  font-size: 13px;
  color: var(--ink-2);
}
.shell .prompt { color: var(--gold); user-select: none; }
.shell .copy {
  margin-left: 4px;
  color: var(--mute);
  cursor: pointer;
  border: 0;
  transition: color .15s ease;
}
.shell .copy:hover { color: var(--gold); }

/* ---------- epigraph ---------- */
.epigraph {
  padding: 64px 28px;
  max-width: 920px; margin: 0 auto;
  text-align: center;
}
.epigraph blockquote {
  margin: 0;
  font-family: var(--f-serif);
  font-style: italic;
  font-variation-settings: "opsz" 36, "SOFT" 100;
  font-size: clamp(22px, 2.8vw, 30px);
  line-height: 1.35;
  color: var(--ink);
  text-wrap: balance;
  letter-spacing: -0.01em;
}
.epigraph blockquote::before,
.epigraph blockquote::after {
  content: "—";
  display: block;
  color: var(--gold);
  font-style: normal;
  margin: 14px auto;
  letter-spacing: 0;
}
.epigraph .attr {
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--mute);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-top: 22px;
}

/* ---------- sections ---------- */
section.chapter {
  padding: 48px 28px 72px;
}
.chapter-inner { max-width: 1240px; margin: 0 auto; }

.numeral {
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--gold);
  letter-spacing: .16em;
  text-transform: uppercase;
  display: inline-block;
  margin-bottom: 18px;
}

h2.chapter-title {
  font-family: var(--f-serif);
  font-variation-settings: "opsz" 72, "SOFT" 30, "wght" 420;
  font-weight: 420;
  font-size: clamp(36px, 5vw, 54px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
  text-wrap: balance;
  max-width: 26ch;
}
h2.chapter-title em { color: var(--gold); font-style: italic; }

h3 {
  font-family: var(--f-serif);
  font-variation-settings: "opsz" 36, "SOFT" 50;
  font-weight: 500;
  font-size: 24px;
  line-height: 1.25;
  margin: 0 0 10px;
  color: var(--ink);
}

p { margin: 0 0 1em; }
p.lead {
  font-size: 19.5px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: var(--measure);
}

/* editorial drop cap on the opening paragraph of Chapter I */
#problem .prose > p.lead:first-of-type::first-letter {
  font-family: var(--f-serif);
  font-variation-settings: "opsz" 144, "SOFT" 0, "wght" 500;
  font-size: 4.4em;
  line-height: .88;
  float: left;
  margin: 0.08em 0.12em -0.05em 0;
  color: var(--gold);
}

/* ---------- problem narrative ---------- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  margin-top: 12px;
}
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; gap: 20px; } }

.col p { color: var(--ink-2); }
.col .small-head {
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: 10px;
  border-top: 1px solid var(--rule);
  padding-top: 14px;
}

/* ---------- primitives mosaic ---------- */
.primitives {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-rows: minmax(200px, auto);
  gap: 2px;
  background: var(--rule);
  border: 1px solid var(--rule);
  margin-top: 32px;
}
.primitive {
  background: var(--bg);
  padding: 28px;
  display: flex; flex-direction: column;
  position: relative;
  transition: background .25s ease;
}
.primitive:hover { background: var(--bg-2); }
.primitive .idx {
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: .16em;
  color: var(--gold-dim);
  text-transform: uppercase;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
}
.primitive .idx::after {
  content: ""; flex: 1; height: 1px; background: var(--rule);
}
.primitive h3 { margin-top: 2px; margin-bottom: 10px; }
.primitive .spacer { flex: 1; }
.primitive p { font-size: 15.5px; color: var(--ink-2); margin-bottom: 14px; }
.primitive .codeline {
  font-family: var(--f-mono);
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--stone);
  padding: 10px 12px;
  border-left: 2px solid var(--gold-dim);
  overflow-x: auto;
  white-space: pre;
  margin-top: auto;
}
.primitive .codeline .k { color: var(--azure); }
.primitive .codeline .s { color: var(--gold); }
.primitive .codeline .c { color: var(--mute); font-style: italic; }
.primitive .codeline .fn { color: var(--ink); }
.primitive .codeline .t { color: var(--ink); }

/* asymmetric mosaic layout — 6-col grid */
/* Top    : Discovery(3x2) | Streams(3x2)         */
/* Bottom : Groups(2)      | Collections(4)       */
.primitive.discovery   { grid-column: span 3; grid-row: span 2; }
.primitive.streams     { grid-column: span 3; grid-row: span 2; }
.primitive.groups      { grid-column: span 2; grid-row: span 1; }
.primitive.collections { grid-column: span 4; grid-row: span 1; }

@media (max-width: 980px) {
  .primitives { grid-template-columns: 1fr 1fr; }
  .primitive.discovery,
  .primitive.streams,
  .primitive.groups,
  .primitive.collections { grid-column: span 2; grid-row: span 1; }
}
@media (max-width: 600px) {
  .primitives { grid-template-columns: 1fr; }
  .primitive.discovery,
  .primitive.streams,
  .primitive.groups,
  .primitive.collections { grid-column: span 1; }
}

/* ---------- code block (big) ---------- */
.codeblock {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0;
  overflow: hidden;
}
.codeblock .chrome {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(to bottom, rgba(255,255,255,.02), transparent);
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: .1em;
  color: var(--mute);
  text-transform: lowercase;
}
.codeblock .chrome .path { color: var(--ink-2); }
.codeblock .chrome .dots { display: inline-flex; gap: 6px; }
.codeblock .chrome .dots span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--rule);
}
.codeblock .chrome .dots span.on { background: var(--gold-dim); }
.codeblock pre {
  margin: 0;
  padding: 22px 24px;
  overflow-x: auto;
  font-family: var(--f-mono);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink-2);
  tab-size: 4;
}
.codeblock pre .kw  { color: var(--azure); }
.codeblock pre .mac { color: var(--azure); }
.codeblock pre .ty  { color: var(--gold); }
.codeblock pre .fn  { color: var(--ink); }
.codeblock pre .st  { color: var(--gold-dim); }
.codeblock pre .cm  { color: var(--mute); font-style: italic; }
.codeblock pre .at  { color: var(--gold); }
.codeblock pre .nm  { color: var(--ink); }
.codeblock pre .sy  { color: var(--mute); }

/* ---------- philosophy list ---------- */
.philosophy {
  max-width: var(--measure);
  margin: 32px auto 0;
  display: grid;
  gap: 28px;
}
.tenet {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 16px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--rule);
}
.tenet:last-child { border-bottom: 0; }
.tenet .mark {
  font-family: var(--f-mono);
  color: var(--gold);
  font-size: 12px;
  letter-spacing: .12em;
  padding-top: 8px;
}
.tenet h4 {
  margin: 0 0 6px;
  font-family: var(--f-serif);
  font-variation-settings: "opsz" 24, "SOFT" 50;
  font-weight: 500;
  font-size: 20px;
  color: var(--ink);
}
.tenet h4 em { color: var(--gold); font-style: italic; }
.tenet p { color: var(--ink-2); margin: 0; }

/* ---------- roadmap ---------- */
.roadmap {
  margin-top: 32px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
@media (max-width: 820px) { .roadmap { grid-template-columns: 1fr; } }
.stage {
  background: var(--bg);
  padding: 32px 28px;
  position: relative;
}
.stage .status {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  margin-bottom: 14px;
  color: var(--mute);
  display: inline-flex; align-items: center; gap: 8px;
}
.stage.current .status { color: var(--gold); }
.stage.current .status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 10px var(--gold);
  animation: pulse 2.2s ease-in-out infinite;
}
.stage h3 {
  font-family: var(--f-serif);
  font-variation-settings: "opsz" 28, "SOFT" 30;
  font-weight: 500;
  font-size: 22px;
  margin: 0 0 10px;
}
.stage p { font-size: 15px; color: var(--ink-2); margin: 0 0 14px; }
.stage ul {
  list-style: none; padding: 0; margin: 10px 0 0;
  font-family: var(--f-mono);
  font-size: 12.5px;
  color: var(--ink-2);
}
.stage ul li {
  padding: 6px 0;
  border-top: 1px solid var(--rule);
  display: flex; gap: 10px;
}
.stage ul li::before { content: "·"; color: var(--gold); }

/* ---------- start ---------- */
.start-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 56px;
  margin-top: 24px;
  align-items: start;
}
@media (max-width: 860px) { .start-grid { grid-template-columns: 1fr; gap: 28px; } }
.start-grid p { color: var(--ink-2); }

.links {
  display: grid;
  gap: 2px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
.links a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  font-family: var(--f-mono);
  font-size: 13px;
  color: var(--ink);
  background: var(--bg);
  border: 0;
  letter-spacing: .02em;
  transition: background .18s ease, color .18s ease;
}
.links a:hover { background: var(--bg-2); color: var(--gold); }
.links a .k { color: var(--mute); }
.links a:hover .k { color: var(--gold-dim); }
.links a .arrow { color: var(--mute); }
.links a:hover .arrow { color: var(--gold); }

/* ---------- footer ---------- */
footer.site-footer {
  margin-top: 72px;
  padding: 40px 28px 56px;
  border-top: 1px solid var(--rule);
  font-family: var(--f-mono);
  font-size: 12.5px;
  color: var(--mute);
  letter-spacing: .02em;
}
footer .inner {
  max-width: 1240px; margin: 0 auto;
  display: flex; justify-content: space-between; gap: 20px;
  flex-wrap: wrap;
}
footer a { color: var(--ink-2); border-bottom-color: var(--rule); }
footer a:hover { color: var(--gold); border-bottom-color: var(--gold); }
footer .flashbots {
  display: inline-flex; align-items: center; gap: 8px;
}
footer .flashbots::before {
  content: ""; width: 6px; height: 6px; background: var(--gold); display: inline-block; transform: rotate(45deg);
}

/* ---------- responsive header / hero ---------- */
@media (max-width: 720px) {
  .site-header .inner { padding: 12px 18px; }
  .nav { gap: 18px; font-size: 12px; }
  .nav .pill { display: none; }
  .hero { padding: 40px 18px 36px; }
  .hero-meta { font-size: 11.5px; gap: 10px 14px; margin-bottom: 18px; }
  .hero-meta .sep { display: none; }
  .cta-row { gap: 10px; }
  .btn, .shell { padding: 10px 14px; font-size: 12.5px; }
  .chapter { padding: 32px 18px 48px; }
  .codeblock pre { font-size: 12.5px; padding: 18px 16px; }
  .epigraph { padding: 40px 20px; }
}
@media (max-width: 480px) {
  .nav a:not(:first-child):not(:last-child) { display: none; } /* keep only docs + install on tiny screens */
}

/* anchor offset */
section[id] { scroll-margin-top: 70px; }

/* inline little dividers */
.rule-diamond {
  text-align: center; color: var(--gold-dim);
  margin: 28px auto;
  font-size: 12px; letter-spacing: 1em;
  user-select: none;
}

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