/* NanoHome — "White Manifest" design system
   Spec: docs/design-guidelines.md + Build Addendum (docs/build-plan-review.md).
   Register rule: Space Grotesk announces, Inter explains, IBM Plex Mono proves. */

/* ---------- Fonts (3 files, latin subsets; Inter + Space Grotesk are variable) ----------
   /fonts/* is cached immutable for a year at unversioned URLs: if a font file
   ever changes, change its FILENAME (e.g. Inter-var.2.woff2) and update these
   @font-face rules plus the preload tags on every page. ---------- */
@font-face {
  font-family: "Space Grotesk";
  src: url(/fonts/SpaceGrotesk-var.woff2) format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url(/fonts/Inter-var.woff2) format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url(/fonts/IBMPlexMono-400.woff2) format("woff2");
  font-weight: 400;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --paper: #ffffff;
  --mist: #f6f9fb;
  --ink: #0b1f33;
  --slate: #5b6b7a;
  --hairline: #e3e9ee;
  --petrol: #0b5563;
  --petrol-dark: #083e49;
  --signal: #c2410c;
  --signal-lg: #ea580c;
  --green: #12805c;
  --cyan: #0891b2;

  --font-display: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --container: 1200px;
  --nav-h: 64px;
  --anchor-offset: 96px;
}

/* ---------- Reset-lite ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 100%; }
body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
}
img, svg { max-width: 100%; }

/* ---------- Type scale ---------- */
h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.5rem, 5vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  max-width: 22ch;
}
h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2rem;
  line-height: 1.15;
  letter-spacing: -0.005em;
}
h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.25rem;
  line-height: 1.3;
}
p, ul, ol { max-width: 34rem; }
.text-secondary { font-size: 0.9375rem; color: var(--slate); }

.eyebrow {
  display: block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--slate);
  margin-bottom: 24px;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  letter-spacing: 0.05em;
  color: var(--ink);
}
.mono .label { color: var(--slate); }
.mono .ok { color: var(--green); }
.mono .temp { color: var(--ink); }
.sample-tag {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.16em;
  color: var(--slate);
  text-transform: uppercase;
}

/* ---------- Links ---------- */
a { color: var(--petrol); text-decoration: none; transition: color 150ms ease-out; }
p a:not(.btn), li a:not(.btn) { text-decoration: underline; text-decoration-color: var(--hairline); text-underline-offset: 3px; }
p a:not(.btn):hover, li a:not(.btn):hover { text-decoration-color: var(--petrol); }
a:hover, a:focus-visible { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--petrol); outline-offset: 2px; border-radius: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.9375rem;
  line-height: 1.2;
  padding: 12px 24px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 150ms ease-out, color 150ms ease-out, border-color 150ms ease-out;
}
.btn-primary { background: var(--petrol); color: #fff; }
.btn-primary:hover { background: var(--petrol-dark); text-decoration: none; }
.btn-primary:focus-visible { outline: 2px solid var(--petrol); outline-offset: 2px; text-decoration: none; }
.btn-secondary { background: var(--paper); color: var(--ink); border-color: var(--ink); }
.btn-secondary:hover { color: var(--petrol); border-color: var(--petrol); text-decoration: none; }

/* ---------- Screen-reader-only ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--paper);
  color: var(--petrol);
  padding: 12px 24px;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------- Nav ---------- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper);
  border-bottom: 1px solid var(--hairline);
}
.site-nav .nav-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
  min-height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
}
.lockup:hover { text-decoration: none; }
.lockup .name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.lockup .rule {
  width: 1px;
  height: 16px;
  background: var(--hairline);
}
.lockup .descriptor {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--slate);
  white-space: nowrap;
}
.nav-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px 32px;
  list-style: none;
}
.nav-links a {
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--ink);
  padding: 8px 0;
}
.nav-links a:hover { color: var(--petrol); text-decoration: none; }
.nav-links a[aria-current="page"] { color: var(--petrol); box-shadow: 0 2px 0 0 var(--petrol); }
.nav-links .btn { padding: 10px 20px; color: #fff; }
.nav-links .btn:hover { color: #fff; }

/* ---------- Layout ---------- */
.container { max-width: var(--container); margin: 0 auto; padding: 0 24px; }
main { display: block; }
.section {
  border-bottom: 1px solid var(--hairline);
  padding: 144px 0;
  scroll-margin-top: var(--anchor-offset);
}
.section:last-of-type { border-bottom: 0; }
.section-band { background: var(--mist); }
.section h2 { margin-bottom: 24px; }
.heading-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.heading-row h2 { margin-bottom: 0; }
.section .section-body > * + * { margin-top: 16px; }

/* Page-as-route: vertical line + waypoint dot per section (desktop only) */
.route-page { position: relative; }
.route-page::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: max(24px, calc((100vw - var(--container)) / 2 + 24px));
  width: 1px;
  background: var(--hairline);
}
.route-page .section { position: relative; }
.route-page .section::before {
  content: "";
  position: absolute;
  top: 148px;
  left: max(24px, calc((100vw - var(--container)) / 2 + 24px));
  width: 7px;
  height: 7px;
  margin-left: -3px;
  border-radius: 50%;
  background: var(--petrol);
  box-shadow: 0 0 0 1.5px var(--ink), 0 0 0 4px var(--paper);
}
.route-page .section .container,
.route-page .hero .container { padding-left: 64px; }

/* ---------- Hero ---------- */
.hero { padding: 120px 0 96px; border-bottom: 1px solid var(--hairline); }
.hero p.lede { margin-top: 24px; }
.hero .cta-row {
  margin-top: 40px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.hero .cta-row .aside-link { font-size: 0.9375rem; color: var(--slate); }
.hero .cta-row .aside-link:hover { color: var(--petrol); }

/* ---------- Custody rail (horizontal, home) ---------- */
.rail { margin-top: 48px; max-width: 56rem; }
.rail-svg { display: block; width: 100%; height: auto; }
.rail-svg .rail-line { stroke: var(--ink); stroke-width: 1.5; }
.rail-svg .rail-line.flow {
  stroke-dasharray: 4 6;
  stroke-linecap: round;
  animation: flow 1.6s linear infinite;
}
.rail-svg .ring { fill: #fff; stroke: var(--ink); stroke-width: 1.5; }
.rail-svg .core { fill: var(--petrol); }
.rail-svg .tick { stroke: var(--green); stroke-width: 2; fill: none; }
@keyframes flow { to { stroke-dashoffset: -20; } }

.rail-beats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 16px;
  max-width: 56rem;
}
.rail-beat .mono { display: block; margin-bottom: 8px; }
.rail-beat p { font-size: 0.9375rem; color: var(--slate); }
@media (min-width: 768px) {
  .rail-beat:nth-child(2) { text-align: center; }
  .rail-beat:nth-child(2) p, .rail-beat:nth-child(3) p { margin-left: auto; }
  .rail-beat:nth-child(3) { text-align: right; }
}

/* ---------- Vertical rail (how-it-works steps) ---------- */
.step-rail { list-style: none; max-width: none; }
.step-rail .step {
  position: relative;
  padding: 0 0 96px 64px;
  border-left: 1.5px solid var(--hairline);
  margin-left: 6px;
  scroll-margin-top: var(--anchor-offset);
}
.step-rail .step:last-child { padding-bottom: 24px; }
.step-rail .step::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--ink);
}
.step-rail .step::after {
  content: "";
  position: absolute;
  left: -3.5px;
  top: 7.5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--petrol);
  transform: scale(0);
  transition: transform 200ms ease-out;
}
.step-rail .step.lit::after { transform: scale(1); }
.step-rail .step .step-label {
  display: block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--slate);
  margin-bottom: 8px;
}
.step-rail .step h2 { margin-bottom: 16px; }
.step-rail .step p + p { margin-top: 16px; }

/* ---------- Status chips ---------- */
.chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: 4px;
  border: 1px solid;
}
.chip-transit { color: var(--petrol); border-color: var(--petrol); background: #fff; }
.chip-delivered { color: var(--green); border-color: var(--green); background: #fff; }
.chip-exception { color: var(--signal); border-color: var(--signal); background: #fff; }

/* ---------- Record artifact ---------- */
.artifact {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgb(11 31 51 / 0.06);
  padding: 24px;
  max-width: 34rem;
  margin-top: 24px;
}
.artifact .artifact-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--hairline);
}
.artifact table { width: 100%; border-collapse: collapse; }
.artifact td {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.05em;
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}
.artifact tr:last-child td { border-bottom: 0; }
.artifact td.t { color: var(--slate); white-space: nowrap; }

/* ---------- Ledger strip ---------- */
.ledger {
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  padding: 12px 0;
  overflow-x: auto;
}
.ledger .mono { white-space: nowrap; }

/* ---------- Ruled rows with mini-rail bullets ---------- */
.ruled { list-style: none; max-width: 40rem; }
.ruled > li {
  padding: 24px 0 24px 56px;
  border-bottom: 1px solid var(--hairline);
  position: relative;
}
.ruled > li:first-child { border-top: 1px solid var(--hairline); }
.ruled > li .mini-rail { position: absolute; left: 0; top: 32px; }
.ruled > li h3 { margin-bottom: 8px; }
.ruled > li p { font-size: 0.9375rem; color: var(--slate); }

/* ---------- Two-column definition (We do / We never) ---------- */
.duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  max-width: 56rem;
}
.duo .cell { border-top: 2px solid var(--petrol); padding-top: 24px; }
.duo .cell.never { border-top-color: var(--ink); }
.duo h3 { margin-bottom: 12px; }
.duo p.verbs {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.25rem;
  line-height: 1.5;
}
.duo p.note { margin-top: 12px; font-size: 0.9375rem; color: var(--slate); }

/* ---------- Exception branch diagram ---------- */
.exception-diagram { margin-top: 24px; max-width: 34rem; overflow-x: auto; }
.exception-diagram svg { display: block; width: 100%; min-width: 480px; height: auto; }

/* ---------- Contact ---------- */
.mailto-hero {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: clamp(1.25rem, 3vw, 2rem);
  letter-spacing: 0.02em;
  color: var(--petrol);
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 4px;
  margin: 24px 0;
  word-break: break-all;
}
.mailto-hero:hover { border-bottom-color: var(--petrol); text-decoration: none; }
.router { list-style: none; max-width: 40rem; }
.router li { padding: 24px 0; border-bottom: 1px solid var(--hairline); }
.router li:first-child { border-top: 1px solid var(--hairline); }
.router li strong { display: block; margin-bottom: 4px; }
.router li p { font-size: 0.9375rem; color: var(--slate); }
.checklist { list-style: none; max-width: 34rem; }
.checklist li { position: relative; padding: 10px 0 10px 56px; }
.checklist li .mini-rail { position: absolute; left: 0; top: 18px; }

/* ---------- Mini-rail bullet (single-source artwork; markup uses an empty span) ---------- */
.mini-rail {
  display: inline-block;
  width: 40px;
  height: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 10'%3E%3Cline x1='10' y1='5' x2='30' y2='5' stroke='%230b1f33' stroke-width='1.5'/%3E%3Ccircle cx='6' cy='5' r='3.5' fill='%230b5563'/%3E%3Ccircle cx='34' cy='5' r='3.5' fill='white' stroke='%230b1f33' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--hairline);
  margin-top: 96px;
  background:
    linear-gradient(rgb(255 255 255 / 0.97), rgb(255 255 255 / 0.97)),
    repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px 80px),
    repeating-linear-gradient(0deg, var(--ink) 0 1px, transparent 1px 80px);
}
.site-footer .ledger { border-top: 0; }
.site-footer .footer-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 40px;
  flex-wrap: wrap;
  padding: 40px 0 24px;
}
.site-footer .footer-links { display: flex; gap: 24px; flex-wrap: wrap; list-style: none; }
.site-footer .footer-links a { color: var(--ink); font-size: 0.9375rem; display: inline-block; padding: 8px 0; }
.site-footer .footer-links a:hover { color: var(--petrol); }
.site-footer .legal {
  font-size: 0.8125rem;
  color: var(--slate);
  max-width: 44rem;
  padding-bottom: 40px;
}

/* ---------- 404 ---------- */
.notfound { padding: 120px 0; }
.notfound .mono { display: block; margin-bottom: 24px; }
.notfound ul { list-style: none; margin-top: 24px; }
.notfound li { padding: 8px 0; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .section { padding: 96px 0; }
  .hero { padding: 80px 0 64px; }
  .route-page .section::before { top: 100px; }
}
@media (max-width: 767px) {
  :root { --anchor-offset: 136px; }
  .route-page::before, .route-page .section::before { display: none; }
  .route-page .section .container,
  .route-page .hero .container { padding-left: 24px; }
  .section { padding: 64px 0; }
  .site-nav .nav-inner {
    flex-wrap: wrap;
    padding-top: 12px;
    padding-bottom: 12px;
    gap: 12px;
  }
  .nav-links { width: 100%; justify-content: flex-start; gap: 20px; }
  .nav-links a { padding: 10px 0; }
  .rail-beats { grid-template-columns: 1fr; }
  .duo { grid-template-columns: 1fr; }
  h2 { font-size: 1.625rem; }
  .step-rail .step { padding-left: 40px; padding-bottom: 64px; }
  .artifact { padding: 16px; }
  .artifact-scroll { overflow-x: auto; }
}
@media (max-width: 479px) {
  /* Stack the lockup so the mandatory MEDICAL LOGISTICS descriptor fits 320px */
  .lockup {
    display: grid;
    grid-template-columns: auto auto;
    column-gap: 10px;
    row-gap: 0;
    align-items: center;
    justify-content: start;
  }
  .lockup > svg { grid-row: 1 / span 2; }
  .lockup .rule { display: none; }
  .lockup .name { grid-column: 2; line-height: 1.2; }
  .lockup .descriptor { grid-column: 2; grid-row: 2; font-size: 0.5625rem; letter-spacing: 0.12em; }
  .footer-main .lockup .name { grid-column: 1; }
  .footer-main .lockup .descriptor { grid-column: 1; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .rail-svg .rail-line.flow { animation: none; }
  .step-rail .step::after { transition: none; transform: scale(1); }
  .btn, a { transition: none; }
}
