/* Humanity Infrastructure — prototype B (precise)
   Spacing scale: 4 / 8 / 12 / 16 / 24 / 32 / 48 / 64 / 96
   Type scale:    12 / 13 / 14 / 15 / 17 / 20 / 24 / 32 / 44 / 56  */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --ink: #16181d;
  --ink-2: #3f434b;
  --muted: #666b75;
  --line: #e4e1da;
  --line-strong: #cfcbc2;
  --accent: #1d6a4b;
  --accent-ink: #145239;
  --accent-soft: #e6f2ec;
  --amber: #8a5a00;
  --amber-soft: #fbf1dc;
  --focus: #1d6a4b;

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Liberation Sans", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px;

  --radius: 10px;
  --radius-sm: 6px;
  --measure: 60ch;
  --container: 1120px;
  --gutter: 24px;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  font-feature-settings: "cv11", "ss01", "calt";
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
p { text-wrap: pretty; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-ink); }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font: inherit; }
svg { display: inline-block; vertical-align: middle; flex: none; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

.container { max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }
.measure { max-width: var(--measure); }
.muted { color: var(--muted); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: var(--s-4); top: -100px;
  background: var(--ink); color: #fff; padding: var(--s-2) var(--s-3);
  border-radius: var(--radius-sm); z-index: 100; text-decoration: none; font-weight: 500;
}
.skip-link:focus { top: var(--s-4); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .container {
  display: flex; align-items: center; gap: var(--s-5); height: 56px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 600; text-decoration: none; letter-spacing: -0.01em; white-space: nowrap;
}
.brand:hover { color: var(--ink); }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--accent); color: #fff; display: grid; place-items: center;
}
.site-nav { margin-left: auto; display: flex; align-items: center; gap: var(--s-1); }
.site-nav a {
  text-decoration: none; color: var(--ink-2); font-size: 14px; font-weight: 500;
  padding: 6px 10px; border-radius: var(--radius-sm);
  transition: background-color .15s ease, color .15s ease;
}
.site-nav a:hover { background: var(--surface-2); color: var(--ink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 8px;
  font-size: 14px; font-weight: 500; text-decoration: none; cursor: pointer;
  border: 1px solid transparent; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: #000; color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--ink-2); color: var(--ink); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-github { margin-left: var(--s-2); }

/* ---------- Hero ---------- */
.hero { padding: var(--s-9) 0 var(--s-8); border-bottom: 1px solid var(--line); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--s-8); align-items: end; }
.eyebrow {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); display: inline-flex; align-items: center; gap: 10px;
}
.eyebrow::before { content: ""; width: 20px; height: 1px; background: var(--line-strong); }
.hero h1 {
  margin-top: var(--s-5);
  font-size: clamp(36px, 4.6vw, 56px); line-height: 1.06; letter-spacing: -0.025em; font-weight: 600;
}
.hero h1 em { font-style: normal; color: var(--accent-ink); }
.hero .tagline { margin-top: var(--s-5); font-size: 20px; line-height: 1.4; color: var(--ink-2); max-width: 32ch; }
.hero-actions { margin-top: var(--s-6); display: flex; gap: var(--s-3); flex-wrap: wrap; }
.hero-aside {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: var(--s-5);
}
.hero-aside h2 { font-size: 13px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }
.policy-line { margin-top: var(--s-3); font-size: 17px; font-weight: 500; line-height: 1.4; }
.legend { margin-top: var(--s-4); display: grid; gap: var(--s-3); }
.legend li { display: flex; align-items: flex-start; gap: var(--s-3); font-size: 13.5px; color: var(--ink-2); }
.legend li .badge { flex: none; margin-top: 1px; }

/* ---------- Sections ---------- */
.section { padding: var(--s-8) 0; }
.section + .section { border-top: 1px solid var(--line); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-5); margin-bottom: var(--s-6); }
.section-head h2 { font-size: 28px; line-height: 1.2; letter-spacing: -0.02em; margin-top: var(--s-3); }
.section-head p { margin-top: var(--s-3); color: var(--muted); max-width: 54ch; }
.section-head .aside-link { font-size: 14px; color: var(--ink-2); white-space: nowrap; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .01em; font-weight: 500; line-height: 1;
  border: 1px solid var(--line-strong); color: var(--ink-2); background: var(--surface);
  white-space: nowrap;
}
.badge svg { width: 11px; height: 11px; }
.badge-open { background: var(--accent-soft); border-color: #bfdccb; color: var(--accent-ink); }
.badge-closed { background: var(--surface-2); border-color: var(--line-strong); color: var(--ink-2); }
.badge-unverified { background: var(--amber-soft); border-color: #ecd6a6; color: var(--amber); }
.badge-maintainer { background: #eef0f6; border-color: #cfd5e6; color: #2f3f6e; }
.badge-friend { background: var(--surface-2); color: var(--ink-2); }
.badge-draft { background: var(--amber-soft); border-color: #ecd6a6; color: var(--amber); }
.badge-soon { background: var(--surface-2); color: var(--muted); border-style: dashed; }

/* ---------- Shelves ---------- */
.shelf-list { display: grid; gap: var(--s-5); }
.shelf {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.shelf:hover, .shelf:focus-within { border-color: var(--line-strong); box-shadow: 0 1px 2px rgba(22,24,29,.04), 0 8px 24px -16px rgba(22,24,29,.18); }
.shelf-need { padding: var(--s-6); background: var(--surface-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.shelf-need .index { font-family: var(--font-mono); font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.shelf-need h3 { margin-top: var(--s-3); font-size: 22px; line-height: 1.25; letter-spacing: -0.015em; }
.shelf-need p { margin-top: var(--s-3); color: var(--ink-2); font-size: 14.5px; }
.shelf-need .directory-link { margin-top: auto; padding-top: var(--s-5); }
.directory-link {
  display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500;
  color: var(--accent-ink); text-decoration: none;
}
.directory-link:hover { text-decoration: underline; }
.directory-link svg { width: 14px; height: 14px; transition: transform .15s ease; }
.directory-link:hover svg { transform: translateX(2px); }

.shelf-item { padding: var(--s-6); display: flex; flex-direction: column; gap: var(--s-4); }
.item-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.item-title { display: flex; align-items: baseline; gap: var(--s-3); flex-wrap: wrap; }
.item-title h4 { font-size: 20px; letter-spacing: -0.015em; }
.item-title h4 a { text-decoration: none; }
.item-title h4 a:hover { text-decoration: underline; }
.item-kicker { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.item-summary { font-size: 15.5px; color: var(--ink-2); max-width: 58ch; }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--s-4); font-size: 13.5px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; color: var(--ink-2); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.item-links { display: flex; gap: var(--s-4); font-size: 13.5px; }
.item-links a { color: var(--ink-2); display: inline-flex; align-items: center; gap: 5px; }
.item-links svg { width: 13px; height: 13px; }

.note {
  border-left: 2px solid var(--line-strong); padding: var(--s-2) 0 var(--s-2) var(--s-4);
  display: grid; gap: 6px;
}
.note-label { display: flex; align-items: center; gap: var(--s-2); font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.note p { font-size: 15px; color: var(--ink); font-style: italic; }
.note small { font-size: 12.5px; color: var(--muted); }

/* Compact shelves */
.shelf-grid { margin-top: var(--s-7); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); }
.shelf-compact {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-3);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.shelf-compact:hover, .shelf-compact:focus-within { border-color: var(--line-strong); box-shadow: 0 8px 24px -16px rgba(22,24,29,.18); }
.shelf-compact .index { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.shelf-compact h3 { font-size: 16px; line-height: 1.35; }
.shelf-compact .featured { padding-top: var(--s-3); border-top: 1px dashed var(--line); display: grid; gap: var(--s-2); }
.shelf-compact .featured h4 { font-size: 15px; }
.shelf-compact .featured h4 a { text-decoration: none; }
.shelf-compact .featured h4 a:hover { text-decoration: underline; }
.shelf-compact .featured p { font-size: 14px; color: var(--ink-2); }
.shelf-compact .also { font-size: 13.5px; color: var(--ink-2); }
.shelf-compact .directory-link { margin-top: auto; padding-top: var(--s-2); font-size: 13.5px; }

.footnote { margin-top: var(--s-6); font-size: 13.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); }
.footnote a { color: var(--ink-2); }

/* ---------- Build list ---------- */
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.card {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-3);
}
.card h3 { font-size: 17px; }
.card p { color: var(--ink-2); font-size: 14.5px; }
.card .card-actions { margin-top: auto; padding-top: var(--s-3); display: flex; flex-direction: column; gap: var(--s-2); align-items: flex-start; }
.fallback { font-size: 13px; color: var(--muted); }
.fallback a { color: var(--ink-2); word-break: break-all; }
.quest-teaser {
  margin-top: var(--s-4); border: 1px dashed var(--line-strong); border-radius: var(--radius);
  padding: var(--s-4) var(--s-5); display: flex; align-items: center; gap: var(--s-4); background: var(--surface-2);
}
.quest-teaser p { font-size: 14px; color: var(--ink-2); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; }

/* ---------- Ladder ---------- */
.ladder { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--s-8); align-items: start; }
.steps { counter-reset: step; display: grid; }
.step {
  counter-increment: step; position: relative;
  display: grid; grid-template-columns: 40px 1fr; gap: var(--s-4);
  padding: var(--s-4) 0;
}
.step + .step { border-top: 1px solid var(--line); }
.step-num {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface);
  display: grid; place-items: center; font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-2);
}
.step-num::before { content: counter(step, decimal-leading-zero); }
.step-body { display: grid; gap: 4px; }
.step-body h3 { font-size: 16px; display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.step-body p { font-size: 14px; color: var(--ink-2); }
.step-body a.step-link { font-size: 14px; font-weight: 500; color: var(--accent-ink); text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
.step-body a.step-link:hover { text-decoration: underline; }
.step-body a.step-link svg { width: 13px; height: 13px; }

.newsletter {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: var(--s-5);
  position: sticky; top: 80px;
}
.newsletter h3 { font-size: 17px; }
.newsletter p { margin-top: var(--s-2); color: var(--ink-2); font-size: 14.5px; }
.newsletter form { margin-top: var(--s-4); display: grid; gap: var(--s-2); }
.newsletter label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field { display: flex; gap: var(--s-2); }
.input {
  flex: 1; min-width: 0; height: 40px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: #9a9ea6; }
.input:hover { border-color: var(--ink-2); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29,106,75,.18); }
.input:user-invalid { border-color: #a23b3b; }
.form-hint { font-size: 12.5px; color: var(--muted); }
.form-status { font-size: 13px; color: var(--accent-ink); min-height: 1.4em; }
.form-status:empty { display: none; }

/* ---------- Ecosystem ---------- */
.ecosystem { background: var(--surface-2); border-top: 1px solid var(--line); padding: var(--s-6) 0; }
.ecosystem .container { display: flex; align-items: center; gap: var(--s-5); flex-wrap: wrap; }
.ecosystem .label { font-size: 13px; color: var(--muted); }
.ecosystem ul { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); }
.ecosystem li a { font-size: 14px; color: var(--ink-2); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.ecosystem li a:hover { color: var(--ink); text-decoration: underline; }
.ecosystem li a svg { width: 12px; height: 12px; color: var(--muted); }
.ecosystem li .pending { font-size: 12px; color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: var(--s-7) 0 var(--s-8); font-size: 13.5px; color: var(--muted); }
.footer-grid { display: grid; grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)); gap: var(--s-6); }
.site-footer h2 { font-size: 13px; color: var(--ink-2); font-weight: 600; letter-spacing: .02em; text-transform: uppercase; margin-bottom: var(--s-3); }
.site-footer ul { display: grid; gap: var(--s-2); }
.site-footer a { color: var(--ink-2); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.footer-bottom { margin-top: var(--s-6); padding-top: var(--s-4); border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; font-family: var(--font-mono); font-size: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero-grid, .ladder { grid-template-columns: minmax(0, 1fr); gap: var(--s-6); }
  .shelf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .newsletter { position: static; }
}
@media (max-width: 720px) {
  :root { --gutter: 20px; }
  .site-header .container { height: 52px; gap: var(--s-3); }
  .site-nav a:not(.btn) { display: none; }
  .hero { padding: var(--s-7) 0 var(--s-7); }
  .hero .tagline { font-size: 18px; }
  .hero-actions .btn { flex: 1 1 auto; }
  .section { padding: var(--s-7) 0; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .section-head h2 { font-size: 24px; }
  .shelf { grid-template-columns: minmax(0, 1fr); }
  .shelf-need { border-right: 0; border-bottom: 1px solid var(--line); padding: var(--s-5); }
  .shelf-need .directory-link { display: none; }
  .shelf-item { padding: var(--s-5); }
  .shelf-item .directory-link.mobile-only { display: inline-flex; }
  .shelf-grid { grid-template-columns: minmax(0, 1fr); }
  .two-col { grid-template-columns: minmax(0, 1fr); }
  .footer-grid { grid-template-columns: minmax(0, 1fr); }
  .meta { grid-template-columns: 1fr; gap: 2px; }
  .meta dt { font-size: 12px; }
  .meta dd + dt { margin-top: var(--s-2); }
}
.directory-link.mobile-only { display: none; }

/* Narrow-screen refinements */
@media (max-width: 720px) {
  .field { flex-direction: column; }
  .field .btn { width: 100%; }
  .legend li { flex-direction: column; gap: 6px; }
  .fallback a { word-break: normal; overflow-wrap: anywhere; }
  .eyebrow { align-items: flex-start; }
  .eyebrow::before { margin-top: 0.6em; }
}
