/*
 * base.css — reset, shell, and every component the pages share.
 *
 * House rules for anyone extending this file:
 *   - colours come from tokens.css, never from a literal;
 *   - icons are inline SVG, never emoji;
 *   - a card, chip or table declared here should not be re-declared per page;
 *   - nothing may scroll the document sideways at 320px.
 */
@import url('./tokens.css');

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg-dim);
  font: 400 var(--fs-md)/1.6 var(--mono);
  letter-spacing: var(--ls);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 500; color: var(--fg); letter-spacing: var(--ls); }
p  { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
a  { color: inherit; text-decoration: none; }
ul, ol { margin: 0 0 1em; padding-left: 1.2em; }
li { margin: 0.25em 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
img, svg, canvas { max-width: 100%; }
code, kbd { font-family: var(--mono); }

:focus-visible {
  outline: 1px solid var(--live);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection { background: var(--live); color: #000; }

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

.colony-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  /* The field is liveliest in the margins and calmest across the reading
     column, so body copy never has to out-contrast a cell sitting behind it.
     Horizontal, not radial: the canvas is fixed, so a vertical falloff would
     shift under the text as the page scrolls, while a horizontal one holds
     wherever the reader is. On a phone the column is the whole width, and the
     field correctly settles down everywhere. */
  -webkit-mask-image: linear-gradient(to right,
    #000 0%, rgba(0, 0, 0, 0.30) 12%, rgba(0, 0, 0, 0.20) 50%,
    rgba(0, 0, 0, 0.30) 88%, #000 100%);
  mask-image: linear-gradient(to right,
    #000 0%, rgba(0, 0, 0, 0.30) 12%, rgba(0, 0, 0, 0.20) 50%,
    rgba(0, 0, 0, 0.30) 88%, #000 100%);
}

.shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

main { flex: 1 0 auto; padding: 32px 0 64px; }

/* Hidden by size, not by offset: a -9999px skip link is a real element hanging
   off the left of the document, and every layout audit reports it as overflow. */
.skip {
  position: absolute;
  left: 0; top: 0;
  width: 1px; height: 1px;
  padding: 0; overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip:focus {
  left: 12px; top: 12px; z-index: 40;
  width: auto; height: auto;
  min-height: 40px;
  display: inline-flex; align-items: center;
  padding: 8px 12px;
  overflow: visible; clip-path: none;
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--line-hi); border-radius: var(--r-sm);
}

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

.nav {
  position: sticky; top: 0; z-index: 20;
  min-height: var(--nav-h);
  border-bottom: 1px solid var(--line);
  background: var(--bg-sink);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.nav-in {
  display: flex; align-items: center; gap: 16px;
  min-height: var(--nav-h);
  max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter);
}
.nav-mark { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.nav-mark svg { display: block; width: 20px; height: 20px; color: var(--live); }
.nav-mark:hover b { color: var(--live); }
.nav-mark b {
  font: 500 var(--fs-md)/1 var(--mono);
  letter-spacing: var(--ls-wide);
  color: var(--fg);
  text-transform: uppercase;
}
.nav-links { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav-links a {
  display: inline-flex; align-items: center;
  min-height: 40px; padding: 0 10px;
  font-size: var(--fs-sm); color: var(--fg-dim);
  border-radius: var(--r-sm);
  transition: color .14s ease, background .14s ease;
}
.nav-links a:hover { color: var(--fg); background: var(--live-dim); }
/* The page you are on is marked the way the site marks a live cell: the green
   block, with the text knocked out of it. Same green as ::selection, so the
   accent reads as one idea rather than two. */
.nav-links a[aria-current="page"] {
  color: var(--bg);
  background: var(--live);
  font-weight: 500;
}
.nav-links a[aria-current="page"]:hover { background: var(--live); color: var(--bg); }
/* The connect button. Green when it is holding an address, because green is
   what this site uses for alive. */
.wallet-btn {
  flex: 0 0 auto;
  margin-left: auto;
  min-height: 34px; padding: 0 12px;
  font: 500 var(--fs-xs)/1 var(--mono); letter-spacing: var(--ls);
  color: var(--fg-dim);
  background: transparent;
  border: 1px solid var(--line); border-radius: 999px;
  cursor: pointer; white-space: nowrap;
  transition: color .14s ease, background .14s ease, border-color .14s ease;
}
.wallet-btn:hover { color: var(--live); border-color: var(--live-dim); background: var(--live-dim); }
.wallet-btn.is-on {
  color: var(--bg); background: var(--live); border-color: var(--live);
}
.wallet-btn.is-on:hover { background: var(--live); color: var(--bg); }
.wallet-btn.is-wrong {
  color: var(--bg); background: var(--birth); border-color: var(--birth);
}
.wallet-btn.is-absent { opacity: .45; cursor: not-allowed; }
.wallet-btn:disabled:hover { color: var(--fg-dim); background: transparent; border-color: var(--line); }
/* The links already push right on desktop, so the button sits after them. */
.nav-links + .wallet-btn { margin-left: 12px; }

.nav-toggle {
  display: none;
  min-width: 44px; min-height: 40px;
  align-items: center; justify-content: center;
  background: none; border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--fg-dim); cursor: pointer;
}
.nav-toggle svg { width: 15px; height: 15px; }

@media (max-width: 780px) {
  .nav-toggle { display: inline-flex; margin-left: 8px; }
  .wallet-btn { margin-left: auto; }
  .nav-links {
    display: none;
    position: absolute; left: 0; right: 0; top: var(--nav-h);
    flex-direction: column; gap: 0;
    padding: 6px var(--gutter) 12px;
    background: #000;
    border-bottom: 1px solid var(--line);
  }
  .nav-links.open { display: flex; }
  .nav-links a { min-height: 44px; padding: 0 4px; font-size: var(--fs-md); }
}

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

.foot {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding: 18px 0 24px;
  font-size: var(--fs-sm);
  color: var(--fg-dim);
}
.foot-in {
  display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center;
  max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter);
}
.foot-in .spacer { flex: 1 1 auto; }
.foot a { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; }
.foot a:hover { color: var(--fg); }
/* The colony on every page is run by Conway's rule, so the credit sits with the
   chain rather than off in the contact links. */
.foot-credit { color: var(--fg-dim); }
.foot-credit:hover { color: var(--live); }
.foot-credit .ext { width: 11px; height: 11px; opacity: .7; flex: 0 0 auto; }

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

.grid { display: grid; gap: 12px; }
.grid.two   { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four  { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 880px) { .grid.three, .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grid.two, .grid.three, .grid.four { grid-template-columns: minmax(0, 1fr); } }

.card {
  display: block;
  padding: var(--pad);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: transparent;
  transition: border-color .16s ease, background .16s ease;
}
a.card:hover, a.card:focus-visible {
  border-color: var(--live-dim);
  background: var(--live-dim);
}
a.card:hover .card-t, a.card:focus-visible .card-t { color: var(--live); }
.card h3, .card .card-t {
  display: block;
  margin: 0 0 4px;
  font-size: var(--fs-lg); font-weight: 500; color: var(--fg);
}
.card p, .card .card-d {
  display: block; margin: 0;
  font-size: var(--fs-sm); line-height: 1.65; color: var(--fg-dim);
}
/* `> label` — the prompt prefix that marks a card as a destination. */
.card .card-t::before { content: "> "; color: var(--live); }

.panel {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg-raise);
}
.panel > h2 { font-size: var(--fs-lg); margin-bottom: 10px; }

/* ------------------------------------------------------------- typography */

.eyebrow {
  display: block;
  margin: 0 0 10px;
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--fg-faint);
}
.h-page { font-size: clamp(20px, 4.4vw, 30px); line-height: 1.2; margin: 0 0 10px; }
.h-sect { font-size: var(--fs-xl); margin: 0 0 12px; }
.lede   { max-width: 62ch; font-size: var(--fs-md); line-height: 1.75; color: var(--fg-dim); }
.prose  { max-width: 68ch; line-height: 1.8; color: var(--fg-dim); }
.prose h2 { font-size: var(--fs-xl); margin: 32px 0 10px; }
.prose h3 { font-size: var(--fs-lg); margin: 24px 0 8px; }
.prose strong { color: var(--fg); font-weight: 500; }
.prose code { color: var(--live); font-size: 0.94em; }
.section { margin: 0 0 40px; }
.section:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------ chips */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  font-size: var(--fs-xs); letter-spacing: var(--ls);
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--fg-dim); white-space: nowrap;
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.chip.alive,
.chip.live       { color: var(--live);  border-color: var(--live-dim); }
.chip.replicating{ color: var(--birth); border-color: var(--birth-dim); }
.chip.starving   { color: var(--fade);  border-color: var(--fade-dim); }
.chip.crowded    { color: var(--burn);  border-color: var(--burn-dim); }
.chip .pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .28 } }
@media (prefers-reduced-motion: reduce) { .chip .pulse { animation: none; } }

/* --------------------------------------------------------------- wordmark */

/* js/wordmark.js emits .wm on the svg and .wm-caret on the trailing block for
   every caller that asks for a caret, so the blink is declared once, here —
   three pages used to carry three private copies under two different names. */
.wm { display: block; width: 100%; height: auto; }
.wm-caret { animation: wm-blink 1.06s step-end infinite; }
@keyframes wm-blink { 0%, 50% { opacity: 1 } 50.01%, 100% { opacity: 0 } }
@media (prefers-reduced-motion: reduce) { .wm-caret { animation: none; } }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 0 16px;
  font: 500 var(--fs-sm)/1 var(--mono); letter-spacing: var(--ls);
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--line-hi); border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color .14s ease, background .14s ease, color .14s ease;
}
.btn:hover { background: var(--live-dim); border-color: var(--live-dim); color: var(--live); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.primary { color: var(--live); border-color: var(--live-dim); }
.btn.primary:hover { border-color: var(--live); background: var(--live-dim); }
.btn.ghost { border-color: var(--line); color: var(--fg-dim); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

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

.tbl-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }
table.tbl { width: 100%; min-width: 520px; border-collapse: collapse; font-size: var(--fs-sm); }
table.tbl th, table.tbl td {
  padding: 9px 14px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
}
table.tbl th {
  font-weight: 400; font-size: var(--fs-xs); text-transform: uppercase;
  letter-spacing: var(--ls-wide); color: var(--fg-faint);
  border-bottom-color: var(--line);
}
table.tbl td { color: var(--fg-dim); }
table.tbl td.k { color: var(--fg); }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover td { background: var(--bg-raise); }
.num { font-variant-numeric: tabular-nums; }
.mono-cut { max-width: 22ch; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------------- meta */

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 18px; font-size: var(--fs-sm); }
.kv dt { color: var(--fg-faint); }
.kv dd { margin: 0; color: var(--fg); overflow-wrap: anywhere; min-width: 0; }
/* block, not inline-block: an inline-block under `overflow-wrap: anywhere`
   shrinks to one character wide instead of wrapping the URL. */
.kv dd a { display: block; min-height: 40px; line-height: 1.5; padding: 9px 0; overflow-wrap: anywhere; }

.stat-row { display: flex; flex-wrap: wrap; gap: 10px; }
.stat {
  flex: 1 1 130px;
  padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--r);
}
.stat .lbl { display: block; font-size: var(--fs-xs); letter-spacing: var(--ls-wide); text-transform: uppercase; color: var(--fg-faint); }
.stat .val { display: block; margin-top: 4px; font-size: var(--fs-xl); color: var(--fg); font-variant-numeric: tabular-nums; }
.stat .val.live { color: var(--live); }
/* A number that links to the explorer still needs a thumb-sized hit area.
   inline-block with a 40px line box, never flex: these cells set
   `overflow-wrap: anywhere`, and a flex container under that rule collapses to
   one character wide. The stat gets the extra height rather than overlapping
   its own label. */
.stat .val a { display: inline-block; line-height: 40px; }
.stat:has(.val a) .val { margin-top: 0; }

/* ------------------------------------------------------------------ pre/code */

pre.code {
  margin: 0 0 14px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: var(--fs-sm); line-height: 1.7;
  color: var(--fg-mid);
  background: var(--bg-raise);
  border: 1px solid var(--line); border-radius: var(--r);
}
pre.code .c { color: var(--fg-faint); }
pre.code .s { color: var(--live); }
kbd {
  padding: 1px 5px; font-size: var(--fs-xs); color: var(--fg);
  border: 1px solid var(--line-hi); border-radius: 4px; background: var(--bg-raise);
}

/* --------------------------------------------------------------- utility */

.dim   { color: var(--fg-dim); }
.faint { color: var(--fg-faint); }
.ink   { color: var(--fg); }
.hl    { color: var(--live); }
.small { font-size: var(--fs-sm); }
.xs    { font-size: var(--fs-xs); }
.mt-8  { margin-top: 8px; }  .mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.nowrap { white-space: nowrap; }
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
