/* ==========================================================================
   Bioelectrum component layer. Every value here comes from tokens.css.
   Order: reset → primitives → chrome → sections → components → responsive.
   ========================================================================== */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--space-2));
}

body {
  margin: 0;
  background: var(--field);
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--size-body);
  line-height: var(--leading-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  transition: background var(--dur-base) var(--ease), color var(--dur-base) var(--ease);
}

a { color: inherit; }
a:hover { color: var(--text-muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: var(--accent); color: var(--on-accent); }
img { max-width: 100%; }

/* --- Primitives --------------------------------------------------------- */

.shell { width: min(var(--shell), calc(100% - (var(--gutter)))); margin-inline: auto; }
.measure { max-width: var(--measure); }
.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); font-weight: 400; }

.label {
  font-family: var(--font-mono);
  font-size: var(--size-label);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-faint);
}

.skip {
  position: absolute;
  left: var(--space-4);
  top: var(--space-4);
  transform: translateY(-200%);
  background: var(--accent);
  color: var(--on-accent);
  padding: var(--space-2) var(--space-3);
  z-index: var(--z-skip);
}
.skip:focus { transform: none; }

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

.btn {
  display: inline-block;
  border: var(--hairline) solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: var(--size-meta);
  letter-spacing: var(--tracking-wide);
  padding: 10px var(--space-4);
  cursor: pointer;
  border-radius: var(--radius);
  transition: opacity var(--dur-fast) var(--ease);
}
.btn:hover { color: var(--on-accent); opacity: 0.86; }
.btn--ghost { background: transparent; color: var(--text); }
.btn--ghost:hover { background: var(--accent); color: var(--on-accent); opacity: 1; }

/* Underlined text link — the site's tertiary action */
.link {
  display: inline-block;
  margin-top: 28px;
  font-family: var(--font-mono);
  font-size: var(--size-meta);
  text-decoration: none;
  border-bottom: var(--hairline) solid var(--rule-strong);
  padding-bottom: 2px;
  transition: border-color var(--dur-fast) var(--ease);
}
.link:hover { border-bottom-color: var(--accent); color: var(--text); }
.link--inline { margin-top: 0; }

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

header.site {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--field);
  border-bottom: var(--hairline) solid var(--rule);
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  min-height: var(--header-h);
}
.lockup { display: flex; align-items: center; gap: var(--space-3); text-decoration: none; color: var(--text); }
.lockup:hover { color: var(--text); }
.lockup svg { display: block; flex: none; }
.word { font-size: 20px; letter-spacing: 0.01em; line-height: 1; }
.word b { font-weight: 700; }
.word span { font-weight: 300; }
.word-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.26em;
  color: var(--text-faint);
  margin-top: 6px;
}

nav.primary { display: flex; align-items: center; gap: 28px; }
nav.primary a {
  position: relative;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: var(--tracking-wide);
  text-decoration: none;
  color: var(--text-muted);
  padding-block: var(--space-1);
}
nav.primary a:hover { color: var(--text); }
nav.primary a[aria-current="true"] { color: var(--text); }
nav.primary a[aria-current="true"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: var(--hairline);
  background: var(--accent);
}

.nav-actions { display: flex; align-items: center; gap: var(--space-4); }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  padding: 0;
  border: var(--hairline) solid var(--rule-strong);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.theme-toggle svg { display: block; }
/* The button shows the icon of the ACTION, matching its aria-label:
   moon while light (go dark), sun while dark (go light). */
.theme-toggle .icon-light { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-light { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-light { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-dark { display: none; }
}

.menu-btn {
  display: none;
  background: none;
  border: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}
#mobile-nav { display: none; border-top: var(--hairline) solid var(--rule); padding: var(--space-4) 0 20px; }
#mobile-nav.open { display: block; }
/* Scoped to nav so the drawer's CTA keeps its .btn styling — an
   unscoped #mobile-nav a would outrank .btn on specificity. */
#mobile-nav nav a {
  display: block;
  padding: var(--space-2) 0;
  font-family: var(--font-mono);
  font-size: var(--size-meta);
  text-decoration: none;
  color: var(--text-muted);
}
#mobile-nav nav a[aria-current="true"] { color: var(--text); }

/* --- Hero --------------------------------------------------------------- */

.hero { position: relative; overflow: hidden; color: var(--plate-text); background: var(--plate); }
.hero-shade {
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.018) 0 4px, transparent 4px 8px),
    var(--plate-scrim);
  pointer-events: none;
}
.hero-inner {
  position: relative; z-index: 1;
  min-height: calc(100svh - var(--header-h));
  display: flex; flex-direction: column; justify-content: center;
  padding: var(--space-9) 0 80px;
}
.hero-mark {
  position: absolute; top: 50%; right: -8%;
  width: min(560px, 58vw);
  transform: translateY(-50%);
  color: var(--plate-text); opacity: 0.9; pointer-events: none;
}
.regs {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--size-caption);
  letter-spacing: 0.16em;
  color: var(--plate-muted);
  line-height: 1.85;
  margin: 0 0 var(--space-7);
}
h1 {
  margin: 0;
  max-width: 17ch;
  font-size: var(--size-display);
  font-weight: 400;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  text-wrap: balance;
}
.nowrap { white-space: nowrap; }
.lede { margin: 28px 0 0; max-width: 54ch; font-size: var(--size-body); color: var(--plate-lede); }
.hero-links { display: flex; gap: 36px; margin-top: 36px; flex-wrap: wrap; }
.hero-links a {
  color: var(--plate-text);
  text-decoration: none;
  border-bottom: var(--hairline) solid rgba(255,255,255,.4);
  padding-bottom: 2px;
  font-family: var(--font-mono);
  font-size: var(--size-meta);
  transition: border-color var(--dur-fast) var(--ease);
}
.hero-links a:hover { color: var(--plate-text); border-bottom-color: var(--plate-text); }
.mission {
  margin: var(--space-7) 0 0;
  padding-top: 28px;
  border-top: var(--hairline) solid var(--plate-rule);
  max-width: var(--measure-tight);
  font-size: 22px;
  font-weight: 300;
  line-height: 1.4;
}

/* --- Sections ----------------------------------------------------------- */

section { padding: var(--section-y) 0; border-top: var(--hairline) solid var(--rule); }
h2 {
  margin: 0;
  font-size: var(--size-h2);
  font-weight: 400;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-snug);
}
h3 { margin: var(--space-3) 0 0; font-size: var(--size-h3); font-weight: 600; }
.section-head { margin-top: 36px; }
.split { display: grid; grid-template-columns: 5fr 7fr; gap: var(--space-7); }
.stack-lg { margin-top: var(--space-7); }
.stack-md { margin-top: var(--space-6); }
.stack-sm { margin-top: var(--space-5); }

/* --- Rule list (architecture properties) -------------------------------- */

.rule-list { margin: 56px 0 0; padding: 0; border-top: var(--hairline) solid var(--rule); list-style: none; }
.rule-list > * {
  display: grid;
  grid-template-columns: 4fr 8fr;
  gap: var(--space-6);
  align-items: baseline;
  padding: 22px 0;
  border-bottom: var(--hairline) solid var(--rule);
}
.rule-list dt, .v-name { font-size: var(--size-lead); font-weight: 400; }
.rule-list dd { margin: 0; color: var(--text-muted); }


.callout {
  margin: 36px 0 0;
  font-style: italic;
  font-weight: 300;
  font-size: var(--size-lead);
  color: var(--text-muted);
}

/* --- Value cards -------------------------------------------------------- */

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px; margin: 36px 0 0; padding: 0; list-style: none; }
.facts p { margin: var(--space-3) 0 0; color: var(--text-muted); max-width: 36ch; }

/* --- Roadmap rows ------------------------------------------------------- */

.v-row {
  display: grid;
  grid-template-columns: 3fr 6fr 3fr;
  gap: var(--space-5);
  align-items: baseline;
  padding: 18px 0;
  border-bottom: var(--hairline) solid var(--rule);
}
.status { font-family: var(--font-mono); font-size: 13px; color: var(--status-plan); text-align: right; }
.status.live { color: var(--status-live); }
.status.live::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: var(--space-2);
  background: var(--status-live);
  vertical-align: 0.12em;
}

/* --- Diagrams ----------------------------------------------------------- */

figure { margin: 0; }

.diagram {
  margin: 56px 0 0;
  padding-top: var(--space-7);
  border-top: var(--hairline) solid var(--rule);
  overflow-x: auto;   /* the drawing keeps its own scroll; the page never does */
}
.diagram svg {
  display: block;
  width: 100%;
  min-width: 620px;   /* below this the labels stop being readable */
  height: auto;
  color: var(--text);
}
.diagram figcaption {
  display: flex;
  gap: var(--space-5);
  align-items: baseline;
  flex-wrap: wrap;
  padding: var(--space-4) 0 0;
  font-family: var(--font-mono);
  font-size: var(--size-caption);
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
  max-width: 78ch;
}

/* Diagram primitives — every stroke is currentColor, so both themes work
   from one drawing and no colour is encoded in the markup. */
.dg-boundary,
.dg-box {
  fill: none;
  stroke: currentColor;
  stroke-width: var(--dg-stroke);
}
.dg-boundary { stroke-dasharray: 5 4; opacity: 0.55; }
.dg-box--key { stroke-width: 2; }
.dg-flow {
  stroke: currentColor;
  stroke-width: var(--dg-stroke);
  fill: none;
}
.dg-flow--blocked { stroke-dasharray: 3 3; opacity: 0.5; }
.dg-bar { stroke: currentColor; stroke-width: 2; }
.dg-label,
.dg-sub,
.dg-key {
  fill: currentColor;
  font-family: var(--font-mono);
  text-anchor: middle;
}
.dg-label { font-size: 16px; }
.dg-sub   { font-size: 12.5px; opacity: 0.72; }
.dg-key   {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-anchor: start;
  opacity: 0.6;
}

/* --- Motion ---------------------------------------------------------------
   Two kinds, both opt-out. Reveals bring a block in once as it is scrolled to.
   Diagram pulses run only while their figure is on screen, and they carry the
   argument the prose used to: data reads in, a commitment leaves, the host is
   turned back. Nothing loops in the periphery.
   -------------------------------------------------------------------------- */

.reveal { transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease); }
:root.js .reveal { opacity: 0; transform: translateY(12px); }
:root.js .reveal.in { opacity: 1; transform: none; }

/* Pulses travel along the flow lines. Paused until the figure is in view so
   nothing animates off screen. */
.dg-pulse {
  fill: currentColor;
  opacity: 0;
  animation-play-state: paused;
  animation-timing-function: var(--ease);
  animation-iteration-count: infinite;
}
.diagram.is-visible .dg-pulse { animation-play-state: running; }

/* Fig 01 — one 5s story: read, commit, blocked. */
.dg-pulse--read    { animation-name: dg-read;    animation-duration: 5s; }
.dg-pulse--commit  { animation-name: dg-commit;  animation-duration: 5s; }
.dg-pulse--blocked { animation-name: dg-blocked; animation-duration: 5s; }
.diagram.is-visible .dg-bar { animation: dg-bar-hit 5s var(--ease) infinite; }

@keyframes dg-read {
  0%, 1%   { opacity: 0; transform: translateX(0); }
  3%       { opacity: 1; }
  20%      { opacity: 1; transform: translateX(58px); }
  23%, 100%{ opacity: 0; transform: translateX(58px); }
}
@keyframes dg-commit {
  0%, 27%  { opacity: 0; transform: translateX(0); }
  29%      { opacity: 1; }
  52%      { opacity: 1; transform: translateX(186px); }
  55%, 100%{ opacity: 0; transform: translateX(186px); }
}
@keyframes dg-blocked {
  0%, 61%  { opacity: 0; transform: translateX(0); }
  63%      { opacity: 1; transform: translateX(0); }
  73%      { opacity: 1; transform: translateX(28px); }
  76%      { opacity: 1; transform: translateX(26px); }   /* stopped at the bar */
  84%, 100%{ opacity: 0; transform: translateX(26px); }
}
@keyframes dg-bar-hit {
  0%, 72%  { stroke-width: 2; opacity: 1; }
  76%      { stroke-width: 3.4; opacity: 1; }
  82%, 100%{ stroke-width: 2; opacity: 1; }
}

/* Fig 02 — three commitments drop to the shared layer, staggered. */
.dg-pulse--drop { animation-name: dg-drop; animation-duration: 3s; }
.dg-pulse--d2   { animation-delay: 0.35s; }
.dg-pulse--d3   { animation-delay: 0.7s; }

@keyframes dg-drop {
  0%       { opacity: 0; transform: translateY(0); }
  6%       { opacity: 1; }
  40%      { opacity: 1; transform: translateY(56px); }
  46%, 100%{ opacity: 0; transform: translateY(56px); }
}

/* The mark breathes. It is never rotated or recoloured — brand rule. */
.hm-ring { animation: hm-ring 9s var(--ease) infinite; }
.hm-node { animation: hm-node 9s var(--ease) infinite; }
@keyframes hm-ring { 0%, 100% { opacity: 0.45; } 50% { opacity: 0.16; } }
@keyframes hm-node { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* --- Vertical cards ------------------------------------------------------ */

.verticals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-7);
  border-top: var(--hairline) solid var(--rule);
  padding-top: var(--space-7);
}
.vertical h3 { margin: var(--space-2) 0 var(--space-4); font-size: var(--size-h2); font-weight: 400; letter-spacing: var(--tracking-tight); }
.vertical p.muted { max-width: 46ch; }
.vertical .status { text-align: left; margin-top: var(--space-4); display: inline-block; }

/* --- Form --------------------------------------------------------------- */

form { display: grid; gap: 28px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); }
.field label { display: block; margin-bottom: var(--space-2); }
input, textarea {
  width: 100%;
  border: 0;
  border-bottom: var(--hairline) solid var(--rule-strong);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--size-small);
  padding: var(--space-2) 0;
  border-radius: var(--radius);
  transition: border-color var(--dur-fast) var(--ease);
}
input:focus, textarea:focus { outline: none; border-bottom-color: var(--accent); }
.field-error {
  display: none;
  margin: var(--space-2) 0 0;
  font-family: var(--font-mono);
  font-size: var(--size-caption);
  color: var(--error);
}
.field.is-invalid input,
.field.is-invalid textarea { border-bottom-color: var(--error); }
.field.is-invalid .field-error { display: block; }

.form-status {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--size-meta);
  min-height: 1.4em;
}
.form-status[data-state="error"]   { color: var(--error); }
.form-status[data-state="success"] { color: var(--success); }

/* --- Footer ------------------------------------------------------------- */

footer.site {
  border-top: var(--hairline) solid var(--rule);
  padding: var(--space-7) 0 var(--space-8);
  font-family: var(--font-mono);
  font-size: var(--size-caption);
  line-height: var(--leading-loose);
  color: var(--text-muted);
}
.foot-top { display: flex; justify-content: space-between; gap: var(--space-6); align-items: flex-start; }
.stamp {
  width: var(--space-7); height: var(--space-7);
  background: var(--accent);
  color: var(--on-accent);
  display: grid; place-items: center;
  flex: none;
}
.stamp svg { display: block; }

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

@media (max-width: 860px) {
  :root { --section-y: var(--section-y-mobile); --gutter: var(--space-6); }
  nav.primary { display: none; }
  .menu-btn { display: block; }
  .split, .facts, .pair, .rule-list > *, .v-row, .foot-top, .verticals { grid-template-columns: 1fr; }
  .rule-list > * { gap: var(--space-2); }
  .status { text-align: left; }
  .hero-mark { right: -28%; width: 70vw; opacity: 0.55; }
  .word-sub { display: none; }
  .hero-links { gap: var(--space-5); }
  /* The header CTA moves into the drawer: at 375px the bar cannot hold
     lockup + toggle + button + Menu without overflowing the viewport. */
  .nav-actions { gap: var(--space-3); }
  .nav-actions > .btn { display: none; }
  #mobile-nav .btn { margin-top: var(--space-4); }
}

/* --- Motion preference -------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  :root.js .reveal { opacity: 1; transform: none; }
  .dg-pulse { display: none; }
  .hm-ring, .hm-node { animation: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Print -------------------------------------------------------------- */

@media print {
  header.site, .theme-toggle, .menu-btn, #mobile-nav, form { display: none !important; }
  .hero { color: #000; background: #fff; }  /* print is absolute, not themed */
  .hero-shade, .hero-mark { display: none; }
  .diagram { overflow: visible; }
  .dg-pulse { display: none; }
  .reveal { opacity: 1 !important; transform: none !important; }
  .diagram svg { min-width: 0; }
  body { font-size: 11pt; }
  section { padding: 18pt 0; }
}
