/* spwn site: shared styles for the landing page and the docs. No build step. */

:root {
  --paper: #eef1f5;
  --paper-2: #e3e8ee;
  --surface: #ffffff;
  --ink: #15202b;
  --ink-2: #4a5866;
  --ink-3: #7b8794;
  --rule: #cfd6de;
  --parent: #0b7a75;      /* the running world */
  --parent-soft: #d6efed;
  --child: #c97a05;       /* a fork of it */
  --child-soft: #fbe9c6;
  --term-bg: #10181f;
  --term-ink: #dbe4ec;
  --term-dim: #7f8d99;
  --link: #0b5f8a;
  --focus: #0b7a75;

  --display: "Bricolage Grotesque", "Avenir Next", "Helvetica Neue", sans-serif;
  --sans: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --measure: 70ch;
  --gutter: clamp(16px, 4vw, 48px);
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f161d;
    --paper-2: #141d26;
    --surface: #182230;
    --ink: #e6ecf2;
    --ink-2: #aab6c2;
    --ink-3: #7f8d99;
    --rule: #2a3745;
    --parent: #3fbfb5;
    --parent-soft: #123a3a;
    --child: #f0a63a;
    --child-soft: #3e2d10;
    --term-bg: #0a1016;
    --term-ink: #dbe4ec;
    --link: #6cc1ea;
    --focus: #3fbfb5;
  }
}
:root[data-theme="dark"] {
  --paper: #0f161d;
  --paper-2: #141d26;
  --surface: #182230;
  --ink: #e6ecf2;
  --ink-2: #aab6c2;
  --ink-3: #7f8d99;
  --rule: #2a3745;
  --parent: #3fbfb5;
  --parent-soft: #123a3a;
  --child: #f0a63a;
  --child-soft: #3e2d10;
  --term-bg: #0a1016;
  --term-ink: #dbe4ec;
  --link: #6cc1ea;
  --focus: #3fbfb5;
}

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

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  font-feature-settings: "kern", "liga";
  text-rendering: optimizeLegibility;
}

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: clamp(40px, 6.4vw, 76px); font-weight: 500; letter-spacing: -0.03em; }
.hero h1 { font-size: clamp(36px, 4.1vw, 52px); text-wrap: balance; }
h2 { font-size: clamp(28px, 3.4vw, 40px); }
h3 { font-size: 22px; }
h4 { font-size: 18px; }

p, li { max-width: var(--measure); }
p { margin: 0 0 1em; }

code, kbd, pre, samp {
  font-family: var(--mono);
  font-size: 0.92em;
  font-feature-settings: "liga" 0;
}
:not(pre) > code {
  background: var(--paper-2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  color: var(--ink);
}
pre {
  margin: 0;
  background: var(--term-bg);
  color: var(--term-ink);
  padding: 18px 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  line-height: 1.5;
  font-size: 14px;
  tab-size: 2;
}
pre code { font-size: inherit; background: none; padding: 0; }

/* TOML and shell highlighting, applied by hand in the markup. */
.c  { color: var(--term-dim); }          /* comment */
.k  { color: #9fd3ff; }                  /* key */
.s  { color: #f2c98a; }                  /* string */
.t  { color: #8ee3c8; }                  /* table header */
.n  { color: #e6a1ff; }                  /* number, bool */
.p  { color: var(--term-dim); }          /* prompt */
.o  { color: #8ee3c8; }                  /* output highlight */
.ok { color: #8ee3c8; }
.w  { color: #f2c98a; }

hr { border: 0; border-top: 1px solid var(--rule); margin: 48px 0; }

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 15px;
  margin: 8px 0 28px;
}
th, td { text-align: left; vertical-align: top; padding: 9px 12px 9px 0; border-bottom: 1px solid var(--rule); }
th { font-weight: 600; color: var(--ink-2); font-size: 14px; }
td code { white-space: nowrap; }
td:first-child code { font-weight: 500; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 var(--gutter);
  height: 60px; display: flex; align-items: center; gap: 28px;
}
.brand {
  font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -0.02em;
  color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 10px;
}
.brand svg { width: 26px; height: 26px; }
.topbar nav { display: flex; gap: 22px; margin-left: auto; align-items: center; }
.topbar nav a { color: var(--ink-2); text-decoration: none; font-size: 15px; }
.topbar nav a:hover, .topbar nav a[aria-current="page"] { color: var(--ink); }
.theme-toggle {
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink-2);
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; display: grid; place-items: center;
}
.theme-toggle svg { width: 16px; height: 16px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-weight: 500; font-size: 16px;
  padding: 11px 18px; border-radius: var(--radius); text-decoration: none; border: 1px solid transparent;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--parent); color: #fff; }
.btn-ghost { border-color: var(--rule); color: var(--ink); background: var(--surface); }
.btn-ghost:hover { border-color: var(--ink-3); }

/* ---------- Landing ---------- */

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

.hero {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 48px; align-items: center;
  padding: clamp(48px, 8vw, 110px) 0 clamp(40px, 6vw, 80px);
}
.hero p.lede { font-size: clamp(18px, 1.6vw, 21px); color: var(--ink-2); margin: 24px 0 32px; max-width: 32em; }
.hero .actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.hero .install {
  margin-top: 28px; display: inline-flex; align-items: center; gap: 12px;
  font-family: var(--mono); font-size: 14px; color: var(--ink-2);
}
.hero .install code { background: var(--surface); border: 1px solid var(--rule); padding: 8px 12px; border-radius: var(--radius); color: var(--ink); white-space: nowrap; overflow-x: auto; max-width: 100%; }

/* terminal panel */
.term {
  background: var(--term-bg); color: var(--term-ink); border-radius: 10px;
  box-shadow: 0 30px 60px -30px rgba(10, 20, 30, 0.45), 0 0 0 1px rgba(255,255,255,0.04) inset;
  font-family: var(--mono); font-size: 14px; line-height: 1.6; overflow: hidden;
}
.term-bar { display: flex; gap: 6px; padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.term-bar span { width: 10px; height: 10px; border-radius: 50%; background: #2a3744; }
.term pre { background: none; padding: 18px 22px 22px; border-radius: 0; font-size: 14px; }
.term .child { color: var(--child); }
.term .parent { color: var(--parent); }
@media (prefers-color-scheme: dark) { .term .parent { color: #3fbfb5; } .term .child { color: #f0a63a; } }
.term .cursor { display: inline-block; width: 8px; height: 1.1em; background: var(--term-ink); vertical-align: text-bottom; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .term .cursor { animation: none; } }

section.band { padding: clamp(48px, 7vw, 96px) 0; border-top: 1px solid var(--rule); }
section.band > .wrap > h2 { margin-bottom: 18px; max-width: 22em; }
section.band .intro { font-size: 18px; color: var(--ink-2); max-width: 34em; margin-bottom: 40px; }

/* the world diagram */
.world { margin: 36px 0 8px; }
.world svg { width: 100%; height: auto; display: block; }
.world .box { fill: var(--surface); stroke: var(--rule); }
.world .box.parent { stroke: var(--parent); }
.world .box.child { stroke: var(--child); }
.world text { font-family: var(--mono); font-size: 13px; fill: var(--ink); }
.world text.title { font-family: var(--display); font-weight: 600; font-size: 16px; }
.world text.dim { fill: var(--ink-3); }
.world .parent-ink { fill: var(--parent); }
.world .child-ink { fill: var(--child); }
.world .svc { fill: var(--paper-2); stroke: none; }
.world .arrow { stroke: var(--ink-3); fill: none; stroke-width: 1.5; }
.world .arrow-head { fill: var(--ink-3); }
.world .cow { stroke: var(--child); stroke-dasharray: 4 4; fill: none; stroke-width: 1.5; }

/* steps: this content is a sequence */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: grid; gap: 0; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 20px; padding: 26px 0; border-top: 1px solid var(--rule); max-width: none; }
.steps li:last-child { border-bottom: 1px solid var(--rule); }
.steps li::before { content: counter(step); font-family: var(--display); font-size: 34px; font-weight: 500; color: var(--ink-3); line-height: 1; }
.steps h3 { margin-bottom: 8px; }
.steps p { color: var(--ink-2); margin: 0; }
.steps code { white-space: nowrap; }

/* two-column prose + code */
.split { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 48px; align-items: start; }
.split .notes { display: grid; gap: 22px; }
.split .notes h3 { margin-bottom: 6px; }
.split .notes p { color: var(--ink-2); margin: 0; }
.split pre { position: sticky; top: 84px; }

/* compose vs spwn.toml, side by side */
.compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.compare figure { margin: 0; min-width: 0; }
.compare figcaption { font-family: var(--mono); font-size: 13px; color: var(--ink-3); margin-bottom: 8px; }
.compare pre { margin: 0; height: 100%; box-sizing: border-box; }
.compare-note { margin: 28px 0 0; }

/* env lock: one slot, several worktrees */
.slots { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.slots li { display: grid; grid-template-columns: 150px 1fr; grid-template-rows: auto auto; column-gap: 16px; padding: 12px 14px 12px 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--rule); border-left-width: 4px; max-width: none; font-size: 15px; }
.slots .slug { font-family: var(--mono); font-weight: 500; grid-row: 1 / span 2; align-self: center; }
.slots .state { font-weight: 500; }
.slots .detail { color: var(--ink-2); font-size: 14px; }
.slots .running { border-left-color: var(--parent); }
.slots .running .state { color: var(--parent); }
.slots .parked { border-left-color: var(--ink-3); }
.slots .parked .state { color: var(--ink-2); }
.slots .waiting { border-left-color: var(--child); border-left-style: dashed; }
.slots .waiting .state { color: var(--child); }
@media (max-width: 560px) { .slots li { grid-template-columns: 1fr; } .slots .slug { grid-row: auto; margin-bottom: 2px; } }

/* host list */
.hosts { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0; border-top: 1px solid var(--rule); }
.hosts div { padding: 22px 22px 22px 0; border-bottom: 1px solid var(--rule); }
.hosts h3 { margin-bottom: 8px; }
.hosts p { margin: 0; color: var(--ink-2); font-size: 16px; }

/* plain list with rules */
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 14px 0; border-top: 1px solid var(--rule); color: var(--ink-2); max-width: 44em; }
.plain li:last-child { border-bottom: 1px solid var(--rule); }
.plain li strong { color: var(--ink); font-weight: 600; }

footer.site {
  border-top: 1px solid var(--rule); padding: 36px 0 48px; color: var(--ink-3); font-size: 14px;
}
footer.site .wrap { display: flex; gap: 24px; flex-wrap: wrap; justify-content: space-between; }
footer.site a { color: var(--ink-2); }

/* ---------- Docs ---------- */

.docs { max-width: 1200px; margin: 0 auto; padding: 0 var(--gutter); display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 56px; }
.sidebar { position: sticky; top: 60px; align-self: start; max-height: calc(100vh - 60px); overflow-y: auto; padding: 32px 0 40px; }
.sidebar h4 { font-family: var(--sans); font-size: 13px; color: var(--ink-3); font-weight: 600; margin: 22px 0 8px; }
.sidebar h4:first-child { margin-top: 0; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { max-width: none; }
.sidebar a { display: block; padding: 6px 10px; margin-left: -10px; border-radius: 4px; color: var(--ink-2); text-decoration: none; font-size: 15px; }
.sidebar a:hover { background: var(--paper-2); color: var(--ink); }
.sidebar a[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: inset 2px 0 0 var(--parent); }
.sidebar summary { display: none; }

article.doc { padding: 36px 0 96px; min-width: 0; }
article.doc > h1 { font-size: clamp(34px, 4vw, 48px); margin-bottom: 12px; }
article.doc .lede { font-size: 19px; color: var(--ink-2); margin-bottom: 36px; }
article.doc h2 { font-size: 28px; margin: 48px 0 14px; padding-top: 8px; }
article.doc h3 { margin: 32px 0 10px; }
article.doc pre { margin: 16px 0 24px; }
article.doc ul, article.doc ol { padding-left: 1.3em; }
article.doc li { margin-bottom: 6px; }
article.doc h2 a.anchor, article.doc h3 a.anchor { color: var(--ink-3); text-decoration: none; margin-left: 8px; opacity: 0; font-weight: 400; }
article.doc h2:hover a.anchor, article.doc h3:hover a.anchor { opacity: 1; }
article.doc table { font-size: 14.5px; }
.note {
  border-left: 3px solid var(--parent); background: var(--surface); padding: 14px 18px; border-radius: 0 var(--radius) var(--radius) 0;
  margin: 20px 0 24px; max-width: var(--measure);
}
.note p:last-child { margin: 0; }
.note.caution { border-left-color: var(--child); }
.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--rule); font-size: 15px; }
.pager a { text-decoration: none; }
.pager span { display: block; color: var(--ink-3); font-size: 13px; }
.pager .next { text-align: right; margin-left: auto; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 36px; }
  .split { grid-template-columns: 1fr; }
  .split pre { position: static; }
  .compare { grid-template-columns: 1fr; }
  .docs { grid-template-columns: 1fr; gap: 0; }
  .sidebar { position: static; max-height: none; padding: 20px 0 0; border-bottom: 1px solid var(--rule); }
  .sidebar details > div { padding-bottom: 16px; }
  .sidebar summary { display: block; cursor: pointer; font-weight: 500; padding: 8px 0; color: var(--ink); list-style: none; }
  .sidebar summary::-webkit-details-marker { display: none; }
  .sidebar summary::before { content: "Docs menu"; }
  .sidebar details[open] summary::before { content: "Hide menu"; }
  .topbar nav a.hide-sm { display: none; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .hero .actions .btn { flex: 1 1 auto; justify-content: center; }
  .steps li { grid-template-columns: 1fr; gap: 6px; }
  .steps li::before { font-size: 22px; }
  .hero .install { display: grid; }
  .hero .install code { overflow-x: auto; white-space: nowrap; }
}
