/*
  Backroom site styles, shared by every page under public/.

  Served statically by nginx from this directory; the relay binary never
  touches it. No build step: what is in this file is what ships. Cloudflare
  caches this file at the edge but not the HTML, so any edit here must bump
  the ?v=N on every page's stylesheet link in the same commit.

  Design system: "Workshop". The jck.xyz monochrome studio system made
  utilitarian. Ink on paper, no colour, no shadow; hairlines carry all the
  structure. Fraunces for display, Karla for body, IBM Plex Mono for labels
  and code. Left-aligned, square corners (8/12px), stroke-only illustrations
  in the isometric mark's language. Light and dark are the same neutral
  values swapped; the accent collapses onto the ink tone.
*/

:root {
  --paper:      #f6f6f4;
  --paper-deep: #efefec;
  --ink:        #1b1b1a;
  --muted:      #83837f;
  --faint:      rgba(27, 27, 26, 0.35);
  --rule:       rgba(27, 27, 26, 0.15);
  --rule-soft:  rgba(27, 27, 26, 0.08);
  --accent:     #1b1b1a;
  --accent-soft: rgba(27, 27, 26, 0.05);
  --card:       #ffffff;
  --code-bg:    rgba(27, 27, 26, 0.055);
  --good:       #1b1b1a;
  --bad:        #1b1b1a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:      #161615;
    --paper-deep: #131312;
    --ink:        #ececea;
    --muted:      #8b8b87;
    --faint:      rgba(236, 236, 234, 0.35);
    --rule:       rgba(236, 236, 234, 0.15);
    --rule-soft:  rgba(236, 236, 234, 0.08);
    --accent:     #ececea;
    --accent-soft: rgba(236, 236, 234, 0.06);
    --card:       #1c1c1b;
    --code-bg:    rgba(236, 236, 234, 0.07);
    --good:       #ececea;
    --bad:        #ececea;
  }
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Karla", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--ink); color: var(--paper); }

/* ---------- type ---------- */

.mono, table, code, pre, kbd, .kicker, .pill, .crumbs {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

h1, h2, h3 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.08;
  text-wrap: balance;
  margin: 0;
}

h1 { font-size: clamp(2.7rem, 6.4vw, 4.6rem); }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.3rem); }
h3 { font-size: 1.25rem; }

p { margin: 1rem 0 0; text-wrap: pretty; }
p.lede {
  font-size: 1.12rem;
  line-height: 1.65;
  color: var(--muted);
  max-width: 40em;
}

a {
  color: inherit;
  text-decoration: none;
}
article.prose a, .body a, .sec-note a, .footnote a {
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--faint);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.2s;
}
article.prose a:hover, .body a:hover { text-decoration-color: var(--ink); }

.kicker, .micro {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

strong { font-weight: 700; }
em { font-style: italic; }

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

/* ---------- shell ---------- */

.wrap {
  width: min(68rem, 100% - 2.5rem);
  margin-inline: auto;
}

header.top {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

header.top .wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 3.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}
.brand svg { width: 22px; height: auto; display: block; }
.brand .dim { color: var(--muted); font-weight: 700; }

nav.primary {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.85rem;
  font-weight: 700;
}
nav.primary a { color: var(--muted); transition: color 0.2s; }
nav.primary a:hover { color: var(--ink); }
nav.primary a[aria-current="page"] { color: var(--ink); }
nav.primary a.cta {
  background: var(--ink);
  color: var(--paper);
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  transition: opacity 0.2s;
}
nav.primary a.cta:hover { opacity: 0.88; }

@media (max-width: 44rem) {
  nav.primary { gap: 1rem; }
  nav.primary a.optional { display: none; }
}
@media (max-width: 30rem) {
  nav.primary { font-size: 0.78rem; }
  .brand { font-size: 1rem; }
}
@media (max-width: 24rem) {
  .brand .dim { display: none; }
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  border-radius: 8px;
  padding: 0.8rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 700;
  transition: opacity 0.2s, border-color 0.2s;
}
.btn.solid, .btn.fill { background: var(--ink); color: var(--paper); }
.btn.solid:hover, .btn.fill:hover { opacity: 0.88; }
.btn.ghost, .btn:not(.solid):not(.fill) { border: 1px solid var(--rule); color: var(--ink); }
.btn.ghost:hover, .btn:not(.solid):not(.fill):hover { border-color: var(--ink); }
.btn .arr { transition: transform 0.25s; }
.btn:hover .arr { transform: translateX(3px); }

.pill {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
}
.pill .ok { color: var(--ink); }

/* ---------- illustrations ---------- */

.illo { display: block; width: 100%; height: auto; }
.illo .s  { stroke: var(--ink); fill: none; stroke-linejoin: round; stroke-linecap: round; }
.illo .m  { stroke: var(--faint); fill: none; stroke-linejoin: round; stroke-linecap: round; }
.illo .dash { stroke-dasharray: 5 7; }
.illo text {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  fill: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.illo .tf { fill: var(--ink); }
.art {
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--card);
  padding: 1.4rem;
}
@media (prefers-reduced-motion: no-preference) {
  .illo .flow { stroke-dasharray: 5 7; animation: flow 1.5s linear infinite; }
  @keyframes flow { to { stroke-dashoffset: -12; } }
}

/* legacy names used by the relay landing's diagram */
.pipe-figure {
  margin: 3rem 0 0;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--card);
  overflow-x: auto;
}
.pipe-figure svg { display: block; width: 100%; min-width: 40rem; height: auto; }
.pipe-figure .stroke { stroke: var(--ink); }
.pipe-figure .soft   { stroke: var(--faint); }
.pipe-figure .accent { stroke: var(--ink); }
.pipe-figure text {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  fill: var(--muted);
}
.pipe-figure .label { fill: var(--ink); }
.pipe-figure .tiny  { fill: var(--muted); }
@media (prefers-reduced-motion: no-preference) {
  .cipher-flow { stroke-dasharray: 5 7; animation: flow 1.5s linear infinite; }
}

/* ---------- hero ---------- */

.hero { padding: 5rem 0 3.5rem; }
.hero .wrap.duo-hero {
  display: grid;
  gap: 3rem;
  align-items: center;
}
@media (min-width: 56rem) {
  .hero .wrap.duo-hero { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); }
}
.hero-sub {
  margin-top: 1.5rem;
  max-width: 36rem;
  font-size: 1.12rem;
  line-height: 1.65;
  color: var(--muted);
}
.hero-sub b, .hero-sub strong { color: var(--ink); }
.hero-actions {
  margin-top: 2.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: center;
}
.hero h1 { margin-top: 1.4rem; }

.fade { opacity: 0; animation: fade 0.7s ease forwards; animation-delay: var(--d, 0s); }
@keyframes fade { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .fade { animation: none; opacity: 1; }
}

/* ---------- marquee ---------- */

.marquee { border-block: 1px solid var(--rule); overflow: hidden; }
.marquee-in {
  display: flex;
  width: max-content;
  white-space: nowrap;
  padding: 0.8rem 0;
  animation: marq 34s linear infinite;
}
.marquee-in span {
  display: inline-flex;
  align-items: center;
  gap: 1.4rem;
  padding-right: 1.4rem;
  color: var(--muted);
}
.marquee-in i { width: 3px; height: 3px; border-radius: 999px; background: var(--muted); opacity: 0.5; }
@keyframes marq { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .marquee-in { animation: none; } }

/* ---------- numbered sections ---------- */

section.num { padding: 4.75rem 0 0; }
section.num > .wrap > .head, .blk-head {
  display: flex;
  align-items: baseline;
  gap: 1.1rem;
}
section.num .no {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  white-space: nowrap;
}
section.num .rule-line, .blk-head .rule-line {
  flex: 1;
  border-top: 1px solid var(--rule);
  align-self: center;
}
section.num .body {
  margin-top: 1.1rem;
  max-width: 44rem;
  color: var(--muted);
  font-size: 1.02rem;
}
section.num .body.wide { max-width: none; }
section.num .body b, section.num .body strong { color: var(--ink); }
section.num .body ul { margin: 1rem 0 0; padding-left: 1.2rem; }
section.num .body li { margin-top: 0.5rem; }

.duo {
  margin-top: 1.6rem;
  display: grid;
  gap: 2rem 3.5rem;
  align-items: center;
}
@media (min-width: 54rem) {
  .duo { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .duo.flip .txt { order: 2; }
  .duo.flip .art { order: 1; }
}
.duo .txt { color: var(--muted); font-size: 1.02rem; max-width: 36rem; }
.duo .txt p + p { margin-top: 0.9rem; }
.duo .txt b, .duo .txt strong { color: var(--ink); }

/* ---------- stats strip ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
  margin-top: 4.75rem;
}
@media (min-width: 48rem) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  padding: 1.5rem 1.6rem;
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
  margin: -1px 0 0 -1px;
}
.stat .v { font-family: "Fraunces", serif; font-weight: 500; font-size: 2.4rem; letter-spacing: -0.02em; }
.stat .l { margin-top: 0.2rem; color: var(--muted); font-size: 0.85rem; font-weight: 700; }

/* ---------- twin panes (can / can never) & ledger ---------- */

.twin, .ledger {
  margin-top: 1.6rem;
  display: grid;
  gap: 1.2rem;
}
@media (min-width: 48rem) { .twin, .ledger { grid-template-columns: 1fr 1fr; } }
.pane, .ledger > div {
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
}
.pane h3, .ledger h3 {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.75rem 1.2rem;
  border-bottom: 1px solid var(--rule);
}
.pane ul, .ledger ul { list-style: none; padding: 0.4rem 0; margin: 0; }
.pane li, .ledger li { padding: 0.7rem 1.2rem; font-size: 0.95rem; font-weight: 700; }
.pane li + li, .ledger li + li { border-top: 1px solid var(--rule); }
.pane li span, .ledger li small {
  display: block;
  font-weight: 400;
  font-size: 0.86rem;
  color: var(--muted);
  margin-top: 0.1rem;
}
.footnote { margin-top: 1.3rem; color: var(--muted); font-size: 0.95rem; max-width: 44rem; }

/* ---------- cards / docs rows ---------- */

.cards, .docs-rows {
  margin-top: 1.6rem;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
}
.cards a, .docs-rows a {
  display: grid;
  grid-template-columns: 4rem 11rem 1fr auto;
  gap: 1.2rem;
  align-items: baseline;
  padding: 1.05rem 1.3rem;
  transition: background 0.2s;
}
.cards a + a, .docs-rows a + a { border-top: 1px solid var(--rule); }
.cards a:hover, .docs-rows a:hover { background: var(--paper); }
.cards .no, .docs-rows .no {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.cards h3, .docs-rows .nm { font-family: "Karla", sans-serif; font-weight: 800; font-size: 1rem; letter-spacing: 0; margin: 0; }
.cards p, .docs-rows .ds { color: var(--muted); font-size: 0.88rem; margin: 0; }
.docs-rows .ar { color: var(--muted); transition: color 0.2s, transform 0.2s; }
.docs-rows a:hover .ar { color: var(--ink); transform: translate(2px, -2px); }
@media (max-width: 44rem) {
  .cards a, .docs-rows a { grid-template-columns: 3rem 1fr auto; }
  .cards p, .docs-rows .ds { display: none; }
}

/* ---------- docs layout ---------- */

.doc {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 4rem;
  padding: 3rem 0 5rem;
}
@media (max-width: 56rem) {
  .doc { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
}

.docnav {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
}
@media (min-width: 56.01rem) {
  .docnav { position: sticky; top: 5.4rem; align-self: start; }
}
.docnav .group {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.64rem;
  color: var(--faint);
  margin: 1.6rem 0 0.5rem;
}
.docnav .group:first-child { margin-top: 0; }
.docnav a {
  display: block;
  color: var(--muted);
  padding: 0.28rem 0 0.28rem 0.9rem;
  border-left: 1px solid var(--rule);
  transition: color 0.2s;
}
.docnav a:hover { color: var(--ink); }
.docnav a[aria-current="page"] {
  color: var(--ink);
  border-left-color: var(--ink);
  font-weight: 600;
}

article.prose { max-width: 46em; }
article.prose > h1 { font-size: clamp(2.1rem, 4.5vw, 3rem); margin-top: 0.5rem; }
article.prose h2 {
  margin-top: 3rem;
  padding-top: 2.4rem;
  border-top: 1px solid var(--rule);
}
article.prose h3 { margin-top: 2.2rem; }
article.prose ul, article.prose ol { margin: 1rem 0 0; padding-left: 1.3rem; }
article.prose li { margin-top: 0.45rem; }
article.prose li::marker { color: var(--muted); }
article.prose p, article.prose li { color: color-mix(in srgb, var(--ink) 82%, var(--muted)); }
article.prose strong { color: var(--ink); }

.crumbs {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}
.crumbs a { color: var(--faint); transition: color 0.2s; }
.crumbs a:hover { color: var(--ink); }

/* callouts */
.aside {
  margin-top: 1.6rem;
  border: 1px solid var(--rule);
  border-left: 2px solid var(--ink);
  border-radius: 0 12px 12px 0;
  background: var(--card);
  padding: 1rem 1.3rem 1.2rem;
  font-size: 0.98rem;
}
.aside p:first-child { margin-top: 0; }
.aside .tag {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: 0.4rem;
}

/* prev / next */
.pager {
  margin-top: 4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.85rem;
  font-weight: 700;
}
.pager a { color: var(--muted); transition: color 0.2s; }
.pager a:hover { color: var(--ink); }
.pager small {
  display: block;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  color: var(--faint);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 0.3rem;
}
.pager .next { text-align: right; margin-left: auto; }

/* ---------- tables & code ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.4rem;
  font-size: 0.84rem;
  line-height: 1.5;
}
.table-scroll {
  overflow-x: auto;
  margin-top: 1.4rem;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--card);
}
.table-scroll table { margin-top: 0; min-width: 34rem; }
th {
  text-align: left;
  font-weight: 500;
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
  padding: 0.7rem 1.2rem 0.7rem 0;
}
td {
  border-bottom: 1px solid var(--rule-soft);
  padding: 0.65rem 1.2rem 0.65rem 0;
  vertical-align: top;
}
.table-scroll th:first-child, .table-scroll td:first-child { padding-left: 1.2rem; }
th:last-child, td:last-child { padding-right: 1.2rem; }
tr:last-child td { border-bottom: 0; }
td.serif { font-family: "Karla", system-ui, sans-serif; font-size: 0.92rem; }

code {
  font-size: 0.86em;
  background: var(--code-bg);
  border: 1px solid var(--rule-soft);
  padding: 0.06em 0.35em;
  border-radius: 6px;
}

pre {
  margin: 1.4rem 0 0;
  padding: 1.1rem 1.3rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.6;
}
pre code { background: none; border: 0; padding: 0; border-radius: 0; font-size: inherit; }
pre .c { color: var(--faint); }     /* comment */
pre .k { color: var(--ink); font-weight: 600; }  /* emphasis */

/* ---------- footer ---------- */

footer.foot {
  border-top: 1px solid var(--rule);
  margin-top: 4.75rem;
  padding: 1.8rem 0 3rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}
footer.foot .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem 2.25rem;
}
footer.foot nav { display: flex; gap: 1.5rem; }
footer.foot a { color: var(--muted); transition: color 0.2s; }
footer.foot a:hover { color: var(--ink); }
footer.foot .jck {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  opacity: 0.8;
}
footer.foot .jck svg { width: 24px; height: 24px; display: block; fill: currentColor; }
footer.foot .jck:hover { opacity: 1; color: var(--ink); }

/* ---------- motion (legacy hook kept for doc pages) ---------- */

@media (prefers-reduced-motion: no-preference) {
  .rise { animation: fade 0.7s ease both; }
  .rise.d1 { animation-delay: 0.07s; }
  .rise.d2 { animation-delay: 0.14s; }
  .rise.d3 { animation-delay: 0.21s; }
}
