/* =========================================================================
   Muster — the operating system for agentic software teams
   Field-report / build-log homepage. One stylesheet, no framework.
   Palette: warm bone paper, deep pine ink, single reserved ember "live" accent.
   ========================================================================= */

/* ---- Tokens -------------------------------------------------------------- */
:root {
  /* color — OKLCH with hex fallback */
  --paper:      #F4EFE4;
  --paper-2:    #EFE8D9;          /* subtle inset / card on paper */
  --ink:        #221F1A;
  --ink-soft:   #4A463D;
  --pine:       #25402F;
  --pine-deep:  #1B3023;
  --bone-rule:  #DDD4C2;
  --ember:      #DE7330;
  --ember-deep: #B9551C;
  --console:    #14201B;
  --console-2:  #1B2C24;          /* console card */
  --console-fg: #ECE7DC;
  --console-mut:#9DB0A2;
  --console-rule:#2C4337;

  /* type */
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --measure: 66ch;
  --rail-w: 232px;

  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-5: 3rem;
  --space-6: 4.5rem;
  --space-7: 7rem;
}

@supports (color: oklch(0.5 0.1 160)) {
  :root {
    --paper:      oklch(0.972 0.008 85);
    --paper-2:    oklch(0.950 0.012 84);
    --ink:        oklch(0.235 0.010 60);
    --ink-soft:   oklch(0.420 0.014 65);
    --pine:       oklch(0.380 0.055 155);
    --pine-deep:  oklch(0.300 0.050 155);
    --bone-rule:  oklch(0.860 0.018 80);
    --ember:      oklch(0.685 0.170 48);
    --ember-deep: oklch(0.560 0.150 45);
    --console:    oklch(0.175 0.012 160);
    --console-2:  oklch(0.225 0.016 160);
    --console-fg: oklch(0.940 0.010 90);
    --console-mut:oklch(0.720 0.018 150);
    --console-rule: oklch(0.320 0.020 158);
  }
}

/* ---- Reset / base -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.125rem;
  line-height: 1.65;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: var(--pine); text-decoration-color: var(--bone-rule); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--pine); }

h1, h2, h3 { font-family: var(--display); font-weight: 600; color: var(--ink); line-height: 1.1; }
strong { font-weight: 600; }

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

/* skip link */
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--pine); color: var(--console-fg);
  padding: 0.6rem 1rem; font-family: var(--mono); font-size: 0.8rem;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

/* ---- Layout -------------------------------------------------------------- */
.doc {
  /* editorial column, set slightly left of center to give the rail room */
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.4rem;
}

section { scroll-margin-top: 4.5rem; }

.band { padding: var(--space-6) 0; }
.band-paper { background: var(--paper); color: var(--ink); }
.band-paper--alt { background: var(--paper-2); }

/* full-bleed console interludes */
.band-console {
  background: var(--console);
  color: var(--console-fg);
}
.band-console h1, .band-console h2, .band-console h3 { color: var(--console-fg); }
.band-console a { color: var(--ember); text-decoration-color: var(--ember-deep); }

/* hairline divider */
.rule { border: 0; border-top: 1px solid var(--bone-rule); margin: var(--space-4) 0; }
.band-console .rule { border-top-color: var(--console-rule); }

/* ---- Mono helpers -------------------------------------------------------- */
.mono { font-family: var(--mono); }
.meta {
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  text-transform: none;
}
.band-console .meta { color: var(--console-mut); }
.kicker {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pine);
  margin: 0 0 0.8rem;
}
.band-console .kicker { color: var(--ember); }

/* section numbering */
.secnum { color: var(--pine); font-variant-numeric: tabular-nums; }
.band-console .secnum { color: var(--ember); }

/* ---- Top bar ------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.55rem max(1.4rem, calc((100vw - 1180px) / 2));
  background: color-mix(in oklab, var(--paper) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.2) blur(8px);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--bone-rule);
  transform: translateY(-110%);
  transition: transform 0.28s ease;
}
.topbar.is-visible { transform: translateY(0); }
@media (prefers-reduced-motion: reduce) { .topbar { transition: none; } }

.topbar__brand {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--display); font-weight: 600; font-size: 1.1rem;
  color: var(--ink); text-decoration: none; letter-spacing: -0.01em;
}
.topbar__brand svg { width: 20px; height: 24px; display: block; }

.topbar__nav {
  display: flex; gap: 1.1rem; margin-left: 0.6rem;
  font-family: var(--mono); font-size: 0.8rem;
}
.topbar__nav a { color: var(--ink-soft); text-decoration: none; }
.topbar__nav a:hover { color: var(--pine); }
.topbar__spacer { flex: 1; }
.topbar__cta { display: flex; gap: 0.5rem; }

@media (max-width: 760px) {
  .topbar__nav { display: none; }
}

/* ---- Buttons / chips ----------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-family: var(--mono); font-size: 0.82rem; line-height: 1;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--pine);
  border-radius: 3px;
  color: var(--pine); background: transparent;
  text-decoration: none; white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn:hover { background: var(--pine); color: var(--paper); }
.btn--solid { background: var(--pine); color: var(--paper); }
.btn--solid:hover { background: var(--pine-deep); }
.btn--sm { padding: 0.45rem 0.7rem; font-size: 0.76rem; }

/* the reserved ember "live" chip — anything ember is a seam into the running system */
.btn--live {
  border-color: var(--ember);
  color: var(--ember-deep);
  background: color-mix(in oklab, var(--ember) 10%, var(--paper));
}
.btn--live:hover { background: var(--ember); color: #fff; border-color: var(--ember); }
.band-console .btn--live {
  color: var(--ember); background: color-mix(in oklab, var(--ember) 14%, var(--console));
}
.band-console .btn--live:hover { color: var(--console); background: var(--ember); }

.band-console .btn {
  border-color: var(--console-mut); color: var(--console-fg);
}
.band-console .btn:hover { background: var(--console-fg); color: var(--console); }

/* inline live chip showing the bare host */
.livechip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--mono); font-size: 0.82rem;
  padding: 0.18rem 0.5rem;
  border: 1px solid var(--ember);
  border-radius: 3px;
  background: color-mix(in oklab, var(--ember) 9%, var(--paper));
  color: var(--ember-deep);
  text-decoration: none;
  white-space: nowrap;
}
.livechip:hover { background: var(--ember); color: #fff; }
.livechip::before { content: "▸"; font-size: 0.7em; }
.band-console .livechip { background: color-mix(in oklab, var(--ember) 14%, var(--console)); color: var(--ember); }

/* archived-snapshot sibling: muted twin */
.snapchip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-family: var(--mono); font-size: 0.76rem;
  color: var(--ink-soft); text-decoration: none;
  border-bottom: 1px dotted var(--bone-rule);
}
.snapchip:hover { color: var(--pine); }
.snapchip::before { content: "⤓"; }
.band-console .snapchip { color: var(--console-mut); }

/* ---- Hero ---------------------------------------------------------------- */
.hero { padding-top: var(--space-6); padding-bottom: var(--space-5); }
.hero__mark { width: 56px; height: 72px; margin-bottom: 1.4rem; display: block; }

.hero__wordmark {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(3.1rem, 11vw, 5.2rem);
  line-height: 0.95; letter-spacing: -0.02em; margin: 0 0 0.4rem;
}
.hero__lede {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(1.4rem, 3.6vw, 2rem);
  line-height: 1.18; color: var(--pine); margin: 0 0 1.6rem;
  max-width: 24ch;
}
.hero__sub { max-width: 60ch; color: var(--ink-soft); margin: 0 0 1.2rem; }
.hero__pitch {
  font-size: 1.22rem; line-height: 1.4; max-width: 40ch; margin: 0 0 2rem;
  font-weight: 500;
}
.hero__pitch b { color: var(--pine); font-weight: 600; }

.hero__cta { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: var(--space-5); }

/* metric strip — the load-bearing hero element, plain mono, works CSS-off */
.metricstrip {
  border-top: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
  padding: 1.4rem 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem 1.6rem;
  font-family: var(--mono);
}
.metric { line-height: 1.25; }
.metric__n {
  display: block; font-size: 1.5rem; font-weight: 600; color: var(--pine);
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.metric__l { display: block; font-size: 0.78rem; color: var(--ink-soft); margin-top: 0.15rem; }

/* ---- Prose --------------------------------------------------------------- */
.h2 {
  font-size: clamp(1.7rem, 4.2vw, 1.95rem);
  margin: 0 0 0.4rem; letter-spacing: -0.01em;
}
.h3 {
  font-family: var(--body); font-weight: 600;
  font-size: 1.3rem; line-height: 1.25; margin: 2rem 0 0.5rem;
}
.lead { font-size: 1.22rem; line-height: 1.5; color: var(--ink); }
.doc p { max-width: var(--measure); }
.band-console .lead { color: var(--console-fg); }

.note {
  font-family: var(--mono); font-size: 0.84rem; line-height: 1.5;
  color: var(--ink-soft); border-left: 2px solid var(--ember);
  padding: 0.2rem 0 0.2rem 0.9rem; margin: 1.4rem 0;
}
.band-console .note { color: var(--console-mut); }

/* ---- Tables (proof sections) -------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 1.4rem 0; }
table.proof {
  width: 100%; border-collapse: collapse;
  font-size: 0.95rem;
}
table.proof th, table.proof td {
  text-align: left; vertical-align: top;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--bone-rule);
}
table.proof thead th {
  font-family: var(--mono); font-size: 0.74rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--pine); border-bottom: 1.5px solid var(--ink);
  font-weight: 600;
}
table.proof tbody tr:last-child td { border-bottom: 1.5px solid var(--ink); }
table.proof .yes { color: var(--ember-deep); font-weight: 600; }
table.proof .no  { color: var(--ink-soft); }
.band-console table.proof th, .band-console table.proof td { border-bottom-color: var(--console-rule); }
.band-console table.proof thead th { color: var(--ember); border-bottom-color: var(--console-fg); }

/* ---- Ledger (two-column mono) ------------------------------------------- */
.ledger {
  font-family: var(--mono); font-size: 0.86rem;
  border: 1px solid var(--bone-rule); border-radius: 4px;
  margin: 1.4rem 0; overflow: hidden;
}
.ledger__row {
  display: grid; grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--bone-rule);
}
.ledger__row:last-child { border-bottom: 0; }
.ledger__row > div { padding: 0.55rem 0.8rem; }
.ledger__row > div:first-child {
  border-right: 1px solid var(--bone-rule);
  color: var(--ink-soft);
}
.ledger__head > div { background: var(--pine); color: var(--paper); font-weight: 600; }
.ledger__head > div:first-child { border-right-color: var(--pine-deep); color: var(--paper); }

/* ---- Architecture figure: four planes ----------------------------------- */
.planes {
  display: grid; gap: 0.7rem; margin: 1.6rem 0;
}
.plane {
  border: 1px solid var(--bone-rule); border-left: 3px solid var(--pine);
  border-radius: 4px; padding: 0.9rem 1.1rem; background: var(--paper);
}
.plane__h {
  font-family: var(--mono); font-size: 0.86rem; font-weight: 600;
  color: var(--pine); letter-spacing: 0.02em; margin: 0 0 0.15rem;
}
.plane__d { font-size: 0.98rem; color: var(--ink-soft); margin: 0; }
.plane--live { border-left-color: var(--ember); }
.plane--live .plane__h { color: var(--ember-deep); }

/* ---- Receipt walk (one defect, end to end) ------------------------------ */
.receipt {
  display: grid; gap: 0; margin: 1.6rem 0;
  border: 1px solid var(--bone-rule); border-radius: 5px; overflow: hidden;
  font-family: var(--mono); font-size: 0.86rem;
}
.receipt__step {
  display: grid; grid-template-columns: 8.5rem 1fr; gap: 0.8rem;
  padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--bone-rule);
}
.receipt__step:last-child { border-bottom: 0; }
.receipt__k { color: var(--pine); font-weight: 600; }
.receipt__v { color: var(--ink); line-height: 1.45; }
.receipt__v .hash { color: var(--ember-deep); }
.receipt__step--fix { background: color-mix(in oklab, var(--ember) 8%, var(--paper)); }
@media (max-width: 560px) {
  .receipt__step { grid-template-columns: 1fr; gap: 0.15rem; }
}

/* ---- Build-Trail phase timeline ----------------------------------------- */
.phases { margin: 1.6rem 0; display: grid; gap: 0; }
.phase {
  display: grid; grid-template-columns: 3.2rem 1fr auto;
  align-items: baseline; gap: 0.9rem;
  padding: 0.7rem 0; border-bottom: 1px solid var(--bone-rule);
}
.phase:last-child { border-bottom: 0; }
.phase__id {
  font-family: var(--mono); font-weight: 600; color: var(--pine);
  font-size: 0.95rem;
}
.phase__name { font-weight: 500; }
.phase__meta { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-soft); white-space: nowrap; }

/* ---- Code block ---------------------------------------------------------- */
.code {
  font-family: var(--mono); font-size: 0.86rem; line-height: 1.6;
  background: var(--console); color: var(--console-fg);
  border-radius: 5px; padding: 1.1rem 1.2rem; margin: 1.4rem 0;
  overflow-x: auto; position: relative;
}
.code .c { color: var(--console-mut); }     /* comment */
.code .e { color: var(--ember); }            /* emphasis token */
.band-console .code { background: var(--console-2); border: 1px solid var(--console-rule); }

/* ---- The Ledger Rail (desktop telemetry margin) ------------------------- */
.rail {
  display: none;
}
@media (min-width: 1180px) {
  .doc { margin-left: max(calc((100vw - 1180px) / 2 + 1.4rem), 1.4rem); margin-right: 0; }
  .topbar { padding-left: max(1.4rem, calc((100vw - 1180px) / 2)); }
  .rail {
    display: block;
    position: fixed;
    top: 0; right: max(1.6rem, calc((100vw - 1180px) / 2));
    width: var(--rail-w);
    height: 100vh;
    padding-top: 5.5rem;
    pointer-events: none;
    z-index: 40;
  }
  .rail__inner {
    border-left: 1px solid var(--bone-rule);
    padding-left: 1rem;
    font-family: var(--mono);
    font-size: 0.74rem;
    color: var(--ink-soft);
    pointer-events: auto;
  }
  .rail__title {
    font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--pine); margin-bottom: 0.9rem;
  }
  .rail__item {
    display: flex; justify-content: space-between; gap: 0.5rem;
    padding: 0.3rem 0; border-bottom: 1px dotted var(--bone-rule);
    transition: color 0.2s ease, border-color 0.2s ease;
  }
  .rail__item .v { color: var(--ink); font-variant-numeric: tabular-nums; }
  .rail__item.is-active { color: var(--ember-deep); border-color: var(--ember); }
  .rail__item.is-active .v { color: var(--ember-deep); }
  .rail__phase {
    margin-top: 1.1rem; padding-top: 0.8rem; border-top: 1px solid var(--bone-rule);
    color: var(--ink); line-height: 1.5;
  }
  .rail__phase .lbl { color: var(--pine); display: block; font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 0.2rem; }
}

/* ---- Author ------------------------------------------------------------- */
.author__name { font-size: 1.4rem; }

/* ---- Footer -------------------------------------------------------------- */
.footer {
  background: var(--console); color: var(--console-mut);
  padding: var(--space-5) 0;
  font-family: var(--mono); font-size: 0.82rem; line-height: 1.7;
}
.footer a { color: var(--ember); }
.footer .doc > * + * { margin-top: 0.4rem; }
.footer__links { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; }

/* ---- Build-Trail SVG draw animation ------------------------------------- */
.trail-draw path, .trail-draw line, .trail-draw polyline {
  stroke-dasharray: var(--len, 200);
  stroke-dashoffset: var(--len, 200);
  animation: draw 1.4s ease-out forwards;
}
.trail-draw .ember-step { animation-delay: 1.1s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  .trail-draw path, .trail-draw line, .trail-draw polyline { stroke-dashoffset: 0; animation: none; }
}

/* small print */
.fineprint { font-family: var(--mono); font-size: 0.76rem; color: var(--ink-soft); }
.band-console .fineprint { color: var(--console-mut); }

ul.tight { padding-left: 1.2rem; }
ul.tight li { margin: 0.35rem 0; max-width: 64ch; }

/* ---- Print --------------------------------------------------------------- */
@media print {
  .topbar, .rail, .hero__cta, .btn, .livechip, .snapchip { display: none !important; }
  body, .band-console { background: #fff !important; color: #000 !important; }
  .band-console h2, .band-console h3, .band-console .lead { color: #000 !important; }
  .band { padding: 1.2rem 0; }
  a { color: #000; text-decoration: underline; }
  .doc { max-width: 100%; margin: 0; }
  .code { background: #f2f2f2; color: #000; border: 1px solid #ccc; }
}
