/* ZNSI base: reset, type, layout primitives and the components every site
   shares. Site stylesheets add page layouts on top. Uses only tokens.css. */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.6;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}
img, svg, video, canvas { display: block; max-width: 100%; }
img, svg { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
p, h1, h2, h3, h4, li, dd, dt, figcaption, blockquote { overflow-wrap: break-word; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
table { border-collapse: collapse; }
::selection { background: var(--vermilion); color: var(--ink); }
:focus-visible {
  outline: 2px solid var(--vermilion);
  outline-offset: 3px;
  border-radius: var(--radius);
}
[hidden] { display: none !important; }

/* ---------- Type ---------- */
h1, h2, h3, h4 {
  font-weight: 640;
  line-height: 1.08;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); letter-spacing: -0.01em; line-height: 1.25; }
h4 { font-size: var(--step-0); }
p { text-wrap: pretty; }
a { color: inherit; text-decoration-color: var(--rule-2); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--accent); }
strong { font-weight: 640; }
small { font-size: var(--step--1); }

.display {
  font-size: var(--step-6);
  font-weight: 720;
  line-height: 0.9;
  letter-spacing: var(--tracking-display);
  text-transform: uppercase;
}
.display em, .headline em { font-style: normal; color: var(--accent); }
.headline {
  font-size: var(--step-5);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: var(--tracking-display);
  text-transform: uppercase;
}
.split .headline { font-size: var(--step-4); }
.lede { font-size: var(--step-1); line-height: 1.5; color: var(--fg-2); max-width: 46ch; }
.muted { color: var(--fg-2); }
.faint { color: var(--fg-3); }
.mono { font-family: var(--font-mono); font-feature-settings: "zero"; }
.jp { font-family: var(--font-jp); font-weight: 500; letter-spacing: 0.08em; }
.caps {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  font-weight: 500;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}
.accent { color: var(--accent); }

/* "01 — The substrate" section markers */
.eyebrow {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--step--2);
  font-weight: 500;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--fg-2);
}
.eyebrow__index { color: var(--accent); }
.eyebrow::after {
  content: "";
  flex: 0 1 4rem;
  height: 1px;
  background: var(--rule-2);
}
.eyebrow--plain::after { content: none; }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--narrow { max-width: calc(820px + 2 * var(--gutter)); }
.section { padding-block: var(--space-9); position: relative; }
.section--tight { padding-block: var(--space-8); }
.section + .section { border-top: 1px solid var(--rule); }
.section--raised { background: var(--bg-raised); }
.section--sunken { background: var(--bg-sunken); }
.stack > * + * { margin-top: var(--stack, var(--space-4)); }
.stack-lg { --stack: var(--space-6); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.grid { display: grid; gap: var(--space-5); }
@media (min-width: 720px) {
  .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1000px) {
  .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.split { display: grid; gap: var(--space-7); align-items: start; }
@media (min-width: 960px) {
  .split { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--space-8); }
  .split--even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split--wide-left { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
  .split--center { align-items: center; }
}
.section-head { display: grid; gap: var(--space-4); margin-bottom: var(--space-7); max-width: 60rem; }

/* Faint die-street grid, the wafer as wallpaper */
.grid-bg {
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: -1px -1px;
}

/* ---------- Skip link ---------- */
.skip {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--vermilion);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
.skip:focus { top: var(--space-3); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgb(11 11 12 / 0.72);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--rule);
  color: var(--bone);
}
.site-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-5);
}
.brandmark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  margin-right: auto;
  white-space: nowrap;
}
.brandmark__seal { width: 28px; height: 28px; flex: none; }
.brandmark__name { font-weight: 760; letter-spacing: 0.22em; font-size: 0.95rem; }
.brandmark__label {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--bone-2);
  padding-left: var(--space-3);
  border-left: 1px solid var(--rule-2);
}
.brandmark__jp {
  font-family: var(--font-jp);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--bone-3);
}
@media (max-width: 520px) { .brandmark__jp { display: none; } }
/* On phones a site label (Status, Developers) leaves no room for the header
   button, so it moves into the menu. */
.menu__cta { display: none; }
@media (max-width: 520px) {
  .site-header__inner:has(.brandmark__label) > .site-header__cta { display: none; }
  .site-header__inner:has(.brandmark__label) .menu__cta { display: block; margin-top: var(--space-4); }
  .menu__cta .btn { width: 100%; }
}

.site-nav ul { display: flex; gap: var(--space-5); list-style: none; padding: 0; }
.site-nav a, .menu a {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  text-decoration: none;
  color: var(--bone-2);
  transition: color var(--dur-1);
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--bone); }
.site-nav a[aria-current="page"] { box-shadow: 0 1px 0 var(--vermilion); }

/* Mobile menu: a <details>, so it works without JS */
.menu { display: none; position: relative; }
.menu > summary {
  list-style: none;
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--rule-2);
  cursor: pointer;
  user-select: none;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { border-color: var(--vermilion); color: var(--vermilion); }
.menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 13px);
  width: min(78vw, 300px);
  background: var(--ink-1);
  border: 1px solid var(--rule-2);
  padding: var(--space-4);
}
.menu__panel ul { list-style: none; padding: 0; display: grid; }
.menu__panel a { display: block; padding: var(--space-3) 0; border-bottom: 1px solid var(--rule); font-size: var(--step--1); color: var(--bone); }
.menu__panel li:last-child a { border-bottom: 0; }
@media (max-width: 960px) {
  .site-nav { display: none; }
  .menu { display: block; }
}

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--fg);
  --btn-border: var(--rule-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-height: 48px;
  padding: 0 var(--space-5);
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 560;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--dur-1), color var(--dur-1), border-color var(--dur-1), transform var(--dur-1);
}
.btn:hover { --btn-border: var(--fg); }
.btn:active { transform: translateY(1px); }
.btn--primary { --btn-bg: var(--accent); --btn-fg: var(--accent-fg); --btn-border: var(--accent); }
.btn--primary:hover { --btn-bg: var(--vermilion-hi); --btn-border: var(--vermilion-hi); }
.paper .btn--primary:hover { --btn-bg: var(--vermilion); --btn-border: var(--vermilion); --btn-fg: var(--ink); }
.btn--small { min-height: 36px; padding: 0 var(--space-4); font-size: var(--step--2); }
.btn .arrow { transition: transform var(--dur-2) var(--ease); }
.btn:hover .arrow { transform: translateX(4px); }

.link-arrow {
  display: inline-flex;
  gap: var(--space-2);
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--accent);
}
.link-arrow::after { content: "→"; transition: transform var(--dur-2) var(--ease); }
.link-arrow:hover::after { transform: translateX(4px); }

/* ---------- Cards, specs, tables ---------- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  transition: border-color var(--dur-2), transform var(--dur-2) var(--ease);
}
a.card { text-decoration: none; }
a.card:hover { border-color: var(--rule-2); transform: translateY(-2px); }
a.card:hover .card__title { color: var(--accent); }
.card__meta { font-family: var(--font-mono); font-size: var(--step--2); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--fg-3); }
.card__title { font-size: var(--step-1); font-weight: 620; line-height: 1.25; transition: color var(--dur-1); }
.card__body { color: var(--fg-2); font-size: 0.95rem; }
.card__foot { margin-top: auto; padding-top: var(--space-3); }
/* Corner ticks, like registration marks on a mask */
.card--ticks::before, .card--ticks::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border-color: var(--accent);
  border-style: solid;
}
.card--ticks::before { top: -1px; left: -1px; border-width: 1px 0 0 1px; }
.card--ticks::after { bottom: -1px; right: -1px; border-width: 0 1px 1px 0; }

.spec { display: grid; border-top: 1px solid var(--rule); }
.spec > div {
  display: grid;
  grid-template-columns: minmax(8rem, 2fr) 3fr;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--rule);
}
.spec dt { font-family: var(--font-mono); font-size: var(--step--2); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--fg-3); padding-top: 0.2em; }
.spec dd { font-family: var(--font-mono); font-size: var(--step--1); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); }
.stats--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Labels sit at the top and values at the bottom of every cell, so values in
   a row line up however many lines their labels wrap to. */
.stat { background: var(--bg); padding: var(--space-5); display: grid; gap: var(--space-4); align-content: space-between; }
.stat__value { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 0.15em; font-size: var(--step-3); font-weight: 680; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat__value small { font-size: 0.45em; font-weight: 500; color: var(--fg-2); letter-spacing: 0; white-space: nowrap; }
.stat__label { font-family: var(--font-mono); font-size: var(--step--2); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--fg-3); }

.table-wrap { overflow-x: auto; border: 1px solid var(--rule); }
.table { width: 100%; font-size: var(--step--1); }
.table th, .table td { text-align: left; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--rule); vertical-align: top; }
.table th { font-family: var(--font-mono); font-size: var(--step--2); font-weight: 500; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--fg-3); background: var(--bg-raised); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.2em 0.6em;
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-2);
  white-space: nowrap;
}
.tag--accent { border-color: var(--accent); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fg-3); flex: none; }
.dot--ok { background: var(--ok); }
.dot--warn { background: var(--warn); }
.dot--bad { background: var(--bad); }
.dot--maint { background: var(--maint); }
.dot--pulse { box-shadow: 0 0 0 0 currentColor; animation: dot-pulse 2.4s var(--ease) infinite; }
.dot--ok.dot--pulse { color: rgb(111 191 142 / 0.6); }
.dot--bad.dot--pulse { color: rgb(229 52 29 / 0.6); }
.dot--warn.dot--pulse { color: rgb(232 163 61 / 0.6); }
@keyframes dot-pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.notice {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-left: 2px solid var(--accent);
  background: var(--bg-raised);
  font-size: 0.95rem;
}

/* ---------- Ticker ---------- */
.ticker {
  display: flex;
  overflow: hidden;
  border-block: 1px solid var(--rule);
  background: var(--bg-sunken);
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}
.ticker__track {
  display: flex;
  flex: none;
  gap: var(--space-7);
  padding: var(--space-3) var(--space-7) var(--space-3) 0;
  list-style: none;
  margin: 0;
  animation: ticker 60s linear infinite;
}
.ticker:hover .ticker__track { animation-play-state: paused; }
.ticker__track li { display: flex; gap: var(--space-3); white-space: nowrap; color: var(--fg-2); }
.ticker__track a { text-decoration: none; }
.ticker__track a:hover { color: var(--fg); }
.ticker__track time { color: var(--accent); }
@keyframes ticker { to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) {
  .ticker { overflow-x: auto; }
  .ticker__track { animation: none; }
  .ticker__track[aria-hidden="true"] { display: none; }
}

/* ---------- Page heading for inner pages ---------- */
.page-hero {
  position: relative;
  padding-block: var(--space-9) var(--space-8);
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
}
.page-hero__inner { position: relative; display: grid; gap: var(--space-5); }
.page-hero h1 { font-size: var(--step-5); font-weight: 700; line-height: 0.95; letter-spacing: var(--tracking-display); text-transform: uppercase; max-width: 16ch; }
.page-hero .lede { max-width: 58ch; }
.page-hero__jp {
  position: absolute;
  right: var(--gutter);
  top: var(--space-7);
  writing-mode: vertical-rl;
  font-family: var(--font-jp);
  font-size: var(--step-2);
  letter-spacing: 0.3em;
  color: var(--fg-3);
  opacity: 0.55;
  pointer-events: none;
}
@media (max-width: 720px) { .page-hero__jp { display: none; } }

.breadcrumb { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; padding: 0; font-family: var(--font-mono); font-size: var(--step--2); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--fg-3); }
.breadcrumb li + li::before { content: "/"; margin-right: var(--space-2); color: var(--rule-2); }
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { color: var(--fg); }

/* ---------- Prose ---------- */
.prose { max-width: var(--measure); font-size: 1.0625rem; line-height: 1.7; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { font-size: var(--step-2); margin-top: 2.2em; }
.prose h3 { font-size: var(--step-1); margin-top: 1.8em; }
.prose h2 + *, .prose h3 + * { margin-top: 0.6em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 0.4em; }
.prose li::marker { color: var(--accent); }
.prose blockquote { border-left: 2px solid var(--accent); padding-left: var(--space-5); font-size: var(--step-1); line-height: 1.45; color: var(--fg); }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin-block: 2.5em; }
.prose a { text-decoration-color: var(--accent); }
.prose figure { margin-block: 2em; }
.prose .footnote { font-size: var(--step--1); color: var(--fg-3); }

figure figcaption { margin-top: var(--space-3); font-family: var(--font-mono); font-size: var(--step--2); letter-spacing: 0.06em; color: var(--fg-3); }
figure figcaption b { color: var(--fg-2); font-weight: 600; }
.figure-frame { border: 1px solid var(--rule); background: var(--bg-raised); padding: var(--space-5); }

/* ---------- Code ---------- */
code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.875em; }
:not(pre) > code { padding: 0.12em 0.4em; background: var(--ink-3); border: 1px solid var(--rule); border-radius: var(--radius); }
.paper :not(pre) > code { background: var(--bg-sunken); }
.code {
  position: relative;
  background: var(--bg-sunken);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.code__bar { display: flex; justify-content: space-between; gap: var(--space-4); padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--rule); font-family: var(--font-mono); font-size: var(--step--2); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--fg-3); }
.code pre { padding: var(--space-4) var(--space-5); overflow-x: auto; font-size: 0.8125rem; line-height: 1.7; color: var(--bone-2); tab-size: 2; }
.code .k { color: var(--vermilion-hi); }
.code .s { color: #d9c9a3; }
.code .c { color: var(--bone-3); font-style: italic; }
.code .n { color: var(--bone); }

/* ---------- Footer ---------- */
.site-footer {
  position: relative;
  background: var(--bg-sunken);
  border-top: 1px solid var(--rule);
  color: var(--bone);
  padding-block: var(--space-8) var(--space-6);
  overflow: hidden;
}
.site-footer__top { display: grid; gap: var(--space-7); }
@media (min-width: 900px) { .site-footer__top { grid-template-columns: 1.3fr 2fr; } }
.site-footer__brand { display: grid; gap: var(--space-4); align-content: start; max-width: 26rem; }
.site-footer__brand img { width: 44px; height: 44px; }
.site-footer__name { font-weight: 640; font-size: var(--step-1); line-height: 1.25; }
.site-footer__jp { font-family: var(--font-jp); letter-spacing: 0.2em; color: var(--bone-3); font-size: var(--step--1); }
.site-footer__cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: var(--space-6); }
.site-footer__cols h2 { font-family: var(--font-mono); font-size: var(--step--2); font-weight: 500; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--bone-3); margin-bottom: var(--space-4); }
.site-footer__cols ul { list-style: none; padding: 0; display: grid; gap: var(--space-2); }
.site-footer__cols a { text-decoration: none; color: var(--bone-2); font-size: 0.925rem; }
.site-footer__cols a:hover { color: var(--bone); }
.site-footer__wordmark {
  margin-top: var(--space-8);
  font-size: clamp(5rem, 24vw, 20rem);
  font-weight: 780;
  line-height: 0.78;
  letter-spacing: -0.05em;
  color: transparent;
  -webkit-text-stroke: 1px rgb(237 232 223 / 0.14);
  user-select: none;
  white-space: nowrap;
}
.site-footer__legal {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-6);
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: 0.06em;
  color: var(--bone-3);
}
.site-footer__legal a { color: inherit; }

/* ---------- Reveal on scroll (site.js adds .is-pending only below the fold) ---------- */
@media (prefers-reduced-motion: no-preference) {
  [data-reveal].is-pending { opacity: 0; transform: translateY(18px); }
  [data-reveal] { transition: opacity var(--dur-3) var(--ease), transform var(--dur-3) var(--ease); }
}
