/* ============================================================
   Stateful AI — editorial, local-first, proof-first.
   Light-mode-default warm-paper. Clean dark-mode invert.
   One Vermilion accent. One Approve-Amber human-gate beat.
   ============================================================ */

:root {
  /* Light (default) — warm paper */
  --paper: #F4F1EA;
  --paper-2: #EEEAE0;       /* a hair deeper, for inset blocks */
  --ink: #14110F;
  --graphite: #5A554E;
  --hairline: #D8D2C6;
  --vermilion: #D9442B;
  --sage: #5E7A6B;
  --amber: #C8841F;        /* solid decorative node (the gate dot) */
  --amber-text: #A65A0E;   /* amber AS TEXT — WCAG AA (4.55:1) on paper */

  /* type */
  --font-display: "Space Grotesk", system-ui, "Segoe UI", Arial, sans-serif;
  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* layout */
  --maxw: 1200px;
  --gutter: clamp(20px, 5vw, 64px);
  --section-pad: clamp(72px, 11vw, 128px);
  --measure: 68ch;

  /* type scale — major third (1.25) from 16px */
  --t-xs: 0.78rem;     /* mono kickers, captions */
  --t-sm: 0.9rem;
  --t-base: 1rem;      /* 16px body baseline (serif runs larger) */
  --t-body: 1.18rem;   /* serif reading size */
  --t-lg: 1.5rem;
  --t-xl: 1.95rem;
  --t-2xl: 2.6rem;
  --t-hero: clamp(2.75rem, 6vw, 5rem);

  --reveal-y: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14110F;
    --paper-2: #1B1713;
    --ink: #ECE6DA;
    --graphite: #A39C90;
    --hairline: #2E2823;
    --vermilion: #E8593F;   /* slightly brightened for contrast on dark */
    --sage: #88A595;
    --amber: #E0A046;
    --amber-text: #E0A046;  /* on near-black, the bright amber already clears AA */
  }
}
/* Explicit theme overrides (toggle) */
:root[data-theme="dark"] {
  --paper: #14110F;
  --paper-2: #1B1713;
  --ink: #ECE6DA;
  --graphite: #A39C90;
  --hairline: #2E2823;
  --vermilion: #E8593F;
  --sage: #88A595;
  --amber: #E0A046;
  --amber-text: #E0A046;
}
:root[data-theme="light"] {
  --paper: #F4F1EA;
  --paper-2: #EEEAE0;
  --ink: #14110F;
  --graphite: #5A554E;
  --hairline: #D8D2C6;
  --vermilion: #D9442B;
  --sage: #5E7A6B;
  --amber: #C8841F;
  --amber-text: #A65A0E;
}

/* ---------- reset ---------- */
*, *::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(--font-serif);
  font-size: var(--t-body);
  line-height: 1.62;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .35s ease, color .35s ease;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; line-height: 1.04; margin: 0; }
p { margin: 0 0 1.1em; }
::selection { background: var(--vermilion); color: var(--paper); }

/* ---------- skip link ---------- */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--ink); color: var(--paper);
  padding: 10px 16px; font-family: var(--font-mono); font-size: var(--t-sm);
  border-radius: 0 0 4px 0;
}
.skip-link:focus { left: 0; }

/* ---------- focus ---------- */
:focus-visible { outline: 2px solid var(--vermilion); outline-offset: 3px; }

/* ---------- layout helpers ---------- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: var(--section-pad); border-top: 1px solid var(--hairline); position: relative; }
.section:first-of-type { border-top: 0; }

/* the editorial 12-col grid */
.grid12 { display: grid; grid-template-columns: repeat(12, 1fr); gap: clamp(20px, 3vw, 40px); }

.measure { max-width: var(--measure); }

/* mono numbered kicker — small-caps print column rule label */
.kicker {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--graphite);
  margin: 0 0 1.4rem;
  display: flex; align-items: center; gap: .6em;
}
.kicker .num { color: var(--vermilion); }
.kicker::after {
  content: ""; flex: 1 1 auto; height: 1px; background: var(--hairline);
  margin-left: .4em; max-width: 120px;
}

/* the editor's-pen vermilion mark on key phrases */
.mark {
  background-image: linear-gradient(var(--vermilion), var(--vermilion));
  background-repeat: no-repeat;
  background-position: 0 88%;
  background-size: 100% 2px;
  padding-bottom: 1px;
}

/* mono chips — the honesty chips */
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 1.6rem 0 0; padding: 0; list-style: none; }
.chip {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.02em;
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 6px 13px;
  white-space: nowrap;
  background: var(--paper-2);
}
.chip::before { content: "› "; color: var(--sage); }

/* monospace bits inline */
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
.mono { font-family: var(--font-mono); }

/* ---------- buttons / CTAs ---------- */
.cta {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--t-base);
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  padding-bottom: 4px;
  position: relative;
}
.cta::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--vermilion);
  transform-origin: left center;
  transition: transform .28s ease;
}
.cta:hover::after, .cta:focus-visible::after { transform: scaleX(1.0) translateY(2px); }
.cta-lg { font-size: var(--t-lg); }
@media (prefers-reduced-motion: reduce) { .cta::after { transition: none; } }

/* ===========================================================
   HEADER / NAV
   =========================================================== */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  -webkit-backdrop-filter: saturate(120%) blur(8px);
  backdrop-filter: saturate(120%) blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease, background-color .3s ease;
}
.site-header.scrolled { border-bottom-color: var(--hairline); }
.nav { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-block: 18px; }
.brand { display: flex; align-items: baseline; gap: 12px; text-decoration: none; color: var(--ink); }
.brand .word { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; letter-spacing: -0.03em; }
.brand .dot { color: var(--vermilion); }
.brand .sub { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--graphite); letter-spacing: 0.06em; }
@media (max-width: 620px) { .brand .sub { display: none; } }

.nav-links { display: flex; align-items: center; gap: 26px; }
.nav-links a {
  font-family: var(--font-mono); font-size: var(--t-xs); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--graphite); text-decoration: none;
  transition: color .2s ease;
}
.nav-links a:hover { color: var(--ink); }
.nav-links a.nav-cta { color: var(--ink); }
.nav-links a.nav-cta .u { color: var(--vermilion); }
@media (max-width: 860px) { .nav-links .nav-only-wide { display: none; } }

.theme-toggle {
  font-family: var(--font-mono); font-size: var(--t-xs); letter-spacing: .04em;
  background: transparent; border: 1px solid var(--hairline); color: var(--graphite);
  border-radius: 999px; padding: 6px 11px; cursor: pointer; line-height: 1;
  transition: color .2s ease, border-color .2s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--graphite); }

/* ===========================================================
   HERO
   =========================================================== */
.hero { padding-block: clamp(56px, 9vw, 104px) var(--section-pad); border-top: 0; }
.hero .grid12 { align-items: start; }
.hero-copy { grid-column: 1 / span 7; }
.hero-art  { grid-column: 8 / span 5; }
@media (max-width: 980px) {
  .hero-copy { grid-column: 1 / -1; }
  .hero-art  { grid-column: 1 / -1; margin-top: 36px; }
}

.hero h1 {
  font-size: var(--t-hero);
  font-weight: 700;
  margin: 0 0 1.1rem;
  max-width: 16ch;
}
.hero .lede {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(1.15rem, 2.2vw, 1.5rem); letter-spacing: -0.01em;
  color: var(--ink); line-height: 1.28; margin: 0 0 1.4rem; max-width: 30ch;
}
.hero .body { color: var(--graphite); max-width: 56ch; font-size: 1.12rem; }
.hero .body strong { color: var(--ink); font-weight: 600; }
.hero-actions { margin-top: 1.9rem; display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.hero-actions .secondary {
  font-family: var(--font-mono); font-size: var(--t-xs); letter-spacing: .05em;
  text-transform: uppercase; color: var(--graphite); text-decoration: none;
}
.hero-actions .secondary:hover { color: var(--ink); }

/* ---- artifact chain (hero proof) ---- */
.artifact {
  border: 1px solid var(--hairline);
  background: var(--paper-2);
  padding: 18px clamp(16px, 2vw, 22px);
  font-family: var(--font-mono);
  font-size: clamp(0.74rem, 1.15vw, 0.84rem);
  line-height: 1.95;
  color: var(--ink);
}
.artifact .a-head {
  color: var(--graphite); font-size: 0.72rem; letter-spacing: .08em;
  text-transform: uppercase; margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--hairline);
  display: flex; justify-content: space-between; gap: 10px;
}
.artifact .a-line { display: block; white-space: pre-wrap; word-break: break-word; }
.artifact .a-prompt { color: var(--graphite); }
.artifact .a-prompt .ch { color: var(--vermilion); }
.artifact .a-prompt .drop { color: var(--ink); }
.artifact .emoji { font-family: var(--font-serif); } /* let emoji render natively */
.artifact .id { color: var(--ink); }
.artifact .tick { color: var(--sage); }
.artifact .cos .id { color: var(--ink); font-weight: 600; }
.artifact .gate {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--hairline);
  color: var(--amber-text);
}
.artifact .gate .thumb {
  display: inline-block;
  filter: saturate(1.1);
}
.artifact .gate-note { color: var(--graphite); font-size: 0.7rem; letter-spacing: .04em; }

/* ===========================================================
   WHO WE ARE
   =========================================================== */
.who h2 { grid-column: 1 / span 7; font-size: var(--t-2xl); max-width: 16ch; }
.who .who-sub { grid-column: 9 / span 4; }
.who .who-body { grid-column: 1 / span 8; margin-top: 2.4rem; }
@media (max-width: 980px) {
  .who h2, .who .who-sub, .who .who-body { grid-column: 1 / -1; }
  .who .who-sub { margin-top: 1.2rem; }
}
.who .who-sub p {
  font-family: var(--font-display); font-weight: 500; font-size: 1.12rem;
  letter-spacing: -0.01em; line-height: 1.32; color: var(--graphite);
}
.who-body p { max-width: var(--measure); }
.who-body code { color: var(--vermilion); background: var(--paper-2); padding: 1px 5px; border-radius: 3px; }
.who-body strong { font-weight: 600; }

/* ===========================================================
   HOW IT WORKS
   =========================================================== */
.how h2 { font-size: var(--t-2xl); max-width: 17ch; margin-bottom: .9rem; }
.how .how-sub {
  font-family: var(--font-display); font-weight: 500; color: var(--graphite);
  font-size: 1.1rem; letter-spacing: -0.01em; max-width: 50ch; margin-bottom: 2.2rem;
}

/* four-step pipeline */
.pipeline { position: relative; margin: 2.6rem 0 1rem; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
@media (max-width: 760px) { .steps { grid-template-columns: 1fr 1fr; } }
@media (max-width: 440px) { .steps { grid-template-columns: 1fr; } }
.step { padding: 22px 22px 26px 0; border-left: 1px solid var(--hairline); padding-left: 20px; position: relative; }
.step:first-child { border-left: 0; padding-left: 0; }
@media (max-width: 760px) {
  .step { border-left: 0; padding-left: 0; padding-right: 0; border-top: 1px solid var(--hairline); padding-top: 18px; }
  .step:first-child, .step:nth-child(2) { border-top: 0; }
}
@media (max-width: 440px) {
  .step { border-top: 1px solid var(--hairline); }
  .step:first-child { border-top: 0; }
  .step:nth-child(2) { border-top: 1px solid var(--hairline); }
}
.step .s-kick {
  font-family: var(--font-mono); font-size: var(--t-xs); letter-spacing: .1em;
  text-transform: uppercase; color: var(--graphite); margin-bottom: 12px;
  display: flex; align-items: baseline; gap: 8px;
}
.step .s-kick .s-num { color: var(--vermilion); }
.step .s-desc { font-family: var(--font-serif); font-size: 1.02rem; line-height: 1.45; color: var(--ink); margin-bottom: 14px; }
.step .s-agent { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--graphite); }
.step .s-agent .e { font-size: 1rem; }

/* the vermilion connector + amber gate node */
.pipe-rail { display: flex; align-items: center; gap: 0; margin-top: 18px; }
.pipe-rail .line { height: 2px; background: var(--vermilion); flex: 1 1 auto; border-radius: 2px; }
.pipe-rail .gate-node {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: var(--t-xs); letter-spacing: .05em;
  color: var(--amber-text); padding-left: 12px;
}
.pipe-rail .gate-node .dot {
  width: 11px; height: 11px; border-radius: 50%; background: var(--amber);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--amber) 22%, transparent);
  display: inline-block;
}

/* file tree + agent.yaml snippet */
.statefiles { margin-top: 2.6rem; }
.statefiles .grid12 { align-items: stretch; }
.tree-col { grid-column: 1 / span 6; }
.yaml-col { grid-column: 7 / span 6; }
@media (max-width: 860px) { .tree-col, .yaml-col { grid-column: 1 / -1; } .yaml-col { margin-top: 18px; } }

.codeblock {
  border: 1px solid var(--hairline); background: var(--paper-2);
  padding: 16px clamp(14px, 2vw, 20px); height: 100%;
  font-family: var(--font-mono); font-size: clamp(0.74rem, 1.1vw, 0.82rem);
  line-height: 1.85; color: var(--ink); overflow-x: auto;
}
.codeblock .cb-head {
  color: var(--graphite); font-size: 0.7rem; letter-spacing: .08em; text-transform: uppercase;
  margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--hairline);
}
.codeblock pre { margin: 0; white-space: pre; font: inherit; }
.tree .dir { color: var(--vermilion); }
.tree .file { color: var(--ink); }
.tree .muted { color: var(--graphite); }
.yaml .k { color: var(--sage); }
.yaml .v { color: var(--ink); }
.yaml .c { color: var(--graphite); }
.yaml .gate { color: var(--amber-text); }

.how-claim { margin-top: 2.8rem; max-width: var(--measure); }
.how-claim p { color: var(--graphite); }
.how-claim strong { color: var(--ink); font-weight: 600; }
.how-claim .pull {
  font-family: var(--font-serif); font-style: italic; font-size: 1.4rem; line-height: 1.45;
  color: var(--ink); border-left: 2px solid var(--vermilion); padding-left: 22px; margin: 1.6rem 0;
}

/* ===========================================================
   MEET THE AGENTS
   =========================================================== */
.agents h2 { font-size: var(--t-2xl); margin-bottom: .9rem; }
.agents .ag-sub {
  font-family: var(--font-display); font-weight: 500; color: var(--graphite);
  font-size: 1.1rem; letter-spacing: -0.01em; max-width: 60ch; margin-bottom: 1.6rem;
}
.agents .ag-intro { max-width: var(--measure); color: var(--graphite); margin-bottom: 2.4rem; }
.agents .ag-intro strong { color: var(--ink); font-weight: 600; }

.roster { list-style: none; margin: 0; padding: 0; }
.roster li { border-top: 1px solid var(--hairline); }
.roster li:last-child { border-bottom: 1px solid var(--hairline); }
.agent-row {
  display: grid;
  grid-template-columns: 64px minmax(180px, 2.6fr) 4fr;
  gap: clamp(16px, 3vw, 40px);
  align-items: start;
  padding: 30px 0;
}
.agent-row.lead { padding: 38px 0; }
.agent-emoji {
  font-size: 2.4rem; line-height: 1; grid-row: span 1;
  filter: saturate(1.05);
}
.agent-row.lead .agent-emoji { font-size: 2.9rem; }
.agent-id-col .name { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; letter-spacing: -0.02em; margin-bottom: 6px; }
.agent-id-col .id { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--vermilion); margin-bottom: 8px; }
.agent-id-col .role { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--graphite); line-height: 1.5; }
.agent-blurb { color: var(--ink); font-size: 1.04rem; line-height: 1.55; }
.agent-blurb .lead-tag {
  display: inline-block; font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--sage); border: 1px solid var(--hairline);
  border-radius: 4px; padding: 2px 7px; margin-bottom: 10px;
}
@media (max-width: 720px) {
  .agent-row { grid-template-columns: 48px 1fr; }
  .agent-row .agent-blurb { grid-column: 1 / -1; margin-top: 4px; }
  .agent-emoji { font-size: 2rem; }
}
.roster-foot { font-family: var(--font-mono); font-size: var(--t-sm); color: var(--graphite); margin-top: 1.8rem; }
.roster-foot .em { color: var(--ink); }

/* ===========================================================
   WRITING / SUBSTACK
   =========================================================== */
.writing .grid12 { align-items: start; }
.writing h2 { grid-column: 1 / span 5; font-size: var(--t-2xl); max-width: 12ch; }
.writing .wr-right { grid-column: 7 / span 6; }
@media (max-width: 980px) { .writing h2, .writing .wr-right { grid-column: 1 / -1; } .writing .wr-right { margin-top: 1.6rem; } }
.writing .wr-sub { font-family: var(--font-mono); font-size: var(--t-xs); letter-spacing: .08em; text-transform: uppercase; color: var(--graphite); margin-bottom: 1.4rem; }
.pullquote {
  font-family: var(--font-serif); font-size: clamp(1.4rem, 2.6vw, 1.85rem);
  line-height: 1.34; font-weight: 400; color: var(--ink); margin: 0 0 1.4rem;
}
.pullquote .qm { color: var(--vermilion); }
.writing .wr-body { color: var(--graphite); max-width: 54ch; margin-bottom: 1.8rem; }
.writing .wr-body strong { color: var(--ink); font-weight: 600; }

/* ===========================================================
   FOOTER
   =========================================================== */
.site-footer { border-top: 1px solid var(--hairline); padding-block: clamp(56px, 9vw, 96px); }
.footer-mark { text-align: center; }
.footer-emojis { font-size: 2rem; letter-spacing: .35em; line-height: 1; margin: 0 0 14px; padding-left: .35em; }
.footer-cap { font-family: var(--font-mono); font-size: var(--t-xs); letter-spacing: .14em; text-transform: uppercase; color: var(--graphite); margin-bottom: 2.6rem; }
.footer-tagline { font-family: var(--font-serif); font-size: clamp(1.4rem, 3vw, 2rem); line-height: 1.2; max-width: 20ch; margin: 0 auto 1.6rem; font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; }
.footer-links { display: flex; justify-content: center; gap: 30px; flex-wrap: wrap; margin-bottom: 2.4rem; }
.footer-links a { font-family: var(--font-mono); font-size: var(--t-sm); letter-spacing: .03em; text-decoration: none; color: var(--ink); padding-bottom: 3px; position: relative; }
.footer-links a.primary { border-bottom: 2px solid var(--vermilion); }
.footer-links a:hover { color: var(--vermilion); }
.footer-meta { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--graphite); letter-spacing: .04em; }
.footer-meta .sep { color: var(--hairline); padding: 0 .5em; }
.footer-credit { margin-top: .8rem; }

/* ===========================================================
   SCROLL REVEAL (progressive enhancement; reduced-motion safe)
   =========================================================== */
.reveal { opacity: 0; transform: translateY(var(--reveal-y)); transition: opacity .6s ease, transform .6s ease; }
.reveal.is-in { opacity: 1; transform: none; }

/* hairline draw-in */
.section { --rule-scale: 1; }
.no-js .reveal { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
  .cta::after { transition: none; }
}

/* print niceties */
@media print {
  .site-header, .theme-toggle { display: none; }
  body { background: #fff; color: #000; }
}
