/* ============================================================
   the anatomy of borg — research edition
   design language: warm paper, editorial serif, muted earth
   (after the GWTC-5 gravitational-wave research deck)
   ============================================================ */

:root {
  --paper: #F4F0E8;
  --paper-2: #ECE6D9;
  --panel: #FBF9F3;
  --ink: #26221F;
  --ink-2: #4E4841;
  --ink-3: #756D63;
  --line: #C2B9AA;
  --line-soft: #D5CDBE;

  --net: #58758A;         /* slate blue — network / senses */
  --sats: #C06F3E;        /* terracotta — economy / money */
  --mind: #3F7774;        /* desaturated teal — memory / cognition */
  --loop: #263A49;        /* deep slate navy — control / loops */
  --danger: #A8503C;
  --warn: #B08A3E;

  --font-body: "Quattrocento Sans", "Trebuchet MS", -apple-system, sans-serif;
  --font-display: "Unna", Georgia, "Times New Roman", serif;
  --font-mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;

  /* legacy aliases (page-local styles) */
  --ink-dim: var(--ink-2);
  --ink-faint: var(--ink-3);
  --bg-3: var(--panel);
  --net-soft: rgba(88, 117, 138, 0.12);
  --mind-soft: rgba(63, 119, 116, 0.12);
  --sats-soft: rgba(192, 111, 62, 0.12);
  --loop-soft: rgba(38, 58, 73, 0.10);

  --radius: 3px;
  --nav-h: 64px;
  --maxw: 1160px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: rgba(63, 119, 116, 0.22); }

/* ---------------- nav ---------------- */

nav.top {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: rgba(244, 240, 232, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
nav.top .brand {
  font-family: var(--font-display);
  font-size: 19px;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: baseline;
  gap: 12px;
  letter-spacing: 0.01em;
}
nav.top .brand .sub {
  font-family: var(--font-body);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
}
nav.top .links { display: flex; gap: 2px; overflow-x: auto; }
nav.top .links a {
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  text-decoration: none;
  padding: 8px 12px;
  transition: color 0.2s;
  border-bottom: 1px solid transparent;
}
nav.top .links a:hover { color: var(--ink); }
nav.top .links a.active { color: var(--ink); border-bottom-color: var(--ink); }
@media (max-width: 900px) {
  nav.top { padding: 0 18px; }
  nav.top .brand .sub { display: none; }
  nav.top .links a { padding: 6px 7px; font-size: 10px; }
}

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

main { position: relative; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 32px; }
.page { padding-top: calc(var(--nav-h) + 64px); padding-bottom: 120px; }

section { margin-bottom: 104px; }

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

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.eyebrow::before {
  content: "";
  width: 34px; height: 1px;
  background: var(--ink-2);
}
h1.display {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(42px, 6.2vw, 74px);
  letter-spacing: 0;
  line-height: 1.06;
  margin-bottom: 28px;
}
h1.display em, h2.sec em { font-style: italic; }
h2.sec {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(28px, 3.4vw, 40px);
  line-height: 1.12;
  margin-bottom: 20px;
}
h3.sub {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  margin-bottom: 10px;
}
p.lede {
  font-size: clamp(18px, 2vw, 21px);
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 760px;
}
p.body, .col p { color: var(--ink-2); max-width: 700px; }
p.body + p.body { margin-top: 12px; }
.mono { font-family: var(--font-mono); font-size: 0.85em; }
.dim { color: var(--ink-3); }
.acc-sats { color: var(--sats); }
.acc-net { color: var(--net); }
.acc-mind { color: var(--mind); }
.acc-loop { color: var(--loop); }
.acc-danger { color: var(--danger); }

strong { color: var(--ink); font-weight: 700; }
em { font-style: italic; }

/* ---------------- reveal animations ---------------- */

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.reveal.in { opacity: 1; transform: none; }
.reveal[data-delay="1"] { transition-delay: 0.08s; }
.reveal[data-delay="2"] { transition-delay: 0.16s; }
.reveal[data-delay="3"] { transition-delay: 0.24s; }
.reveal[data-delay="4"] { transition-delay: 0.32s; }

/* ---------------- panels / cards ---------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px;
  position: relative;
}
.panel.glow-sats { border-top: 2px solid var(--sats); }
.panel.glow-net { border-top: 2px solid var(--net); }
.panel.glow-mind { border-top: 2px solid var(--mind); }
.panel.glow-loop { border-top: 2px solid var(--loop); }

.grid { display: grid; gap: 20px; }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 960px) { .grid.c3, .grid.c4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  transition: border-color 0.3s;
}
.card:hover { border-color: var(--ink-3); }
.card .k {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}
.card .v {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1.05;
}
.card .u { font-size: 13.5px; color: var(--ink-2); margin-top: 8px; }

.stat-big .v { font-size: clamp(38px, 4vw, 52px); }

/* ---------------- code / refs ---------------- */

code, .code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--paper-2);
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  padding: 1px 6px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.ref {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}
.ref b { color: var(--ink-2); font-weight: 500; }

pre.block {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.75;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 26px;
  overflow-x: auto;
  color: var(--ink);
}
pre.block .c { color: var(--ink-3); }
pre.block .k { color: var(--loop); }
pre.block .s { color: var(--mind); }
pre.block .n { color: var(--sats); }

/* ---------------- figures & annotations ---------------- */

figure.fig { margin: 32px 0 8px; }
.fighead {
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 14px;
}
figcaption {
  font-size: 13.5px;
  color: var(--ink-2);
  margin-top: 14px;
  line-height: 1.55;
}
figcaption .fno {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--ink);
  white-space: nowrap;
  margin-right: 6px;
}

/* numbered annotation list */
.annot { list-style: none; counter-reset: ann; margin-top: 8px; }
.annot li {
  counter-increment: ann;
  padding: 14px 0 14px 52px;
  position: relative;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-2);
  font-size: 15px;
}
.annot li:last-child { border-bottom: 0; }
.annot li::before {
  content: counter(ann, decimal-leading-zero);
  position: absolute;
  left: 0; top: 15px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 19px;
  color: var(--ink-3);
}
.annot li strong { display: block; font-size: 15.5px; margin-bottom: 3px; }
.annot li strong .ref { font-weight: 400; margin-left: 8px; }

/* ---------------- tables ---------------- */

table.spec {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  border-top: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
}
@media (max-width: 720px) {
  table.spec { display: block; overflow-x: auto; }
}
table.spec th {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  text-align: left;
  font-weight: 700;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
table.spec td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-2);
  vertical-align: top;
}
table.spec tr:last-child td { border-bottom: 0; }
table.spec td:first-child { color: var(--ink); font-weight: 700; }
table.spec .mono { font-size: 12px; }

/* pill / tag */
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 4px 12px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  white-space: nowrap;
  border-radius: 2px;
  background: transparent;
}
.pill.sats { color: var(--sats); border-color: var(--sats); }
.pill.net { color: var(--net); border-color: var(--net); }
.pill.mind { color: var(--mind); border-color: var(--mind); }
.pill.loop { color: var(--loop); border-color: var(--loop); }
.pill.danger { color: var(--danger); border-color: var(--danger); }
.pill.warn { color: var(--warn); border-color: var(--warn); }

/* ---------------- diagrams ---------------- */

.diagram-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
}
.diagram-shell svg { display: block; width: 100%; height: auto; }

svg .node-box { fill: var(--paper); stroke: var(--line); }
svg .node-label { font-family: var(--font-body); font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }
svg .node-sub { font-family: var(--font-body); font-size: 9.5px; }
svg text { user-select: none; }

.flow { stroke-dasharray: 4 6; animation: flowdash 1.4s linear infinite; }
.flow.slow { animation-duration: 2.6s; }
.flow.fast { animation-duration: 0.8s; }
@keyframes flowdash { to { stroke-dashoffset: -10; } }

/* ---------------- process steps ---------------- */

.steps { position: relative; margin: 24px 0; }
.steps::before {
  content: "";
  position: absolute;
  left: 21px; top: 8px; bottom: 8px;
  width: 1px;
  background: var(--line);
}
.step { position: relative; padding: 0 0 36px 68px; }
.step:last-child { padding-bottom: 0; }
.step .n {
  position: absolute;
  left: 0; top: 0;
  width: 44px; height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 19px;
  color: var(--ink-2);
}
.step h4 { font-family: var(--font-display); font-size: 20px; font-weight: 400; margin-bottom: 4px; padding-top: 8px; }
.step p { font-size: 14.5px; color: var(--ink-2); }

/* ---------------- footer / page nav ---------------- */

footer.foot {
  border-top: 1px solid var(--line);
  padding: 48px 32px 64px;
  text-align: center;
  color: var(--ink-3);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
footer.foot .reg {
  font-family: var(--font-display);
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
  font-size: 17px;
  color: var(--ink-2);
  display: block;
  margin-bottom: 10px;
}

.pagenav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin-top: 48px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
@media (max-width: 760px) { .pagenav { grid-template-columns: 1fr; } }
.pagenav a {
  text-decoration: none;
  padding: 24px 26px;
  display: block;
  border-right: 1px solid var(--line);
  transition: background 0.25s;
}
.pagenav a:last-child { border-right: 0; }
@media (max-width: 760px) { .pagenav a { border-right: 0; border-bottom: 1px solid var(--line); } .pagenav a:last-child { border-bottom: 0; } }
.pagenav a:hover { background: var(--panel); }
.pagenav .dir { font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.pagenav .t { color: var(--ink); font-family: var(--font-display); font-size: 18px; }

/* tooltip */
.tip {
  position: fixed;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--ink-2);
  border-radius: 2px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--ink-2);
  max-width: 310px;
  z-index: 200;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s, transform 0.18s;
  box-shadow: 0 8px 30px rgba(42, 39, 36, 0.14);
  line-height: 1.5;
}
.tip.on { opacity: 1; transform: none; }
.tip b { color: var(--ink); display: block; font-size: 13.5px; margin-bottom: 3px; }

/* range slider */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 2px;
  background: var(--line);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--panel);
  border: 2px solid var(--sats);
  cursor: pointer;
}

/* misc */
.hr { height: 1px; background: var(--line); margin: 36px 0; border: 0; }
svg.clock-face { max-width: 100%; height: auto; }
.mt-1 { margin-top: 10px; } .mt-2 { margin-top: 20px; } .mt-3 { margin-top: 32px; } .mt-4 { margin-top: 48px; }
.mb-2 { margin-bottom: 20px; } .mb-3 { margin-bottom: 32px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: start; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.legend .pill { cursor: default; }

.takeaway {
  border-left: 2px solid var(--ink);
  padding: 4px 0 4px 20px;
  margin-top: 24px;
  font-size: 15.5px;
  color: var(--ink-2);
}
.takeaway b {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  color: var(--ink);
  font-size: 17px;
  margin-right: 8px;
}

@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.blink { animation: blink 1.8s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
