/* p2d — v2 dense/terminal */

:root {
  --bg: #0b0b0c;
  --bg-panel: #131316;
  --bg-hi: #1a1a1f;
  --fg: #d4cfc5;
  --fg-hi: #f5f1e8;
  --fg-mute: #6b6660;
  --fg-dim: #4a463f;
  --border: #2a2825;
  --border-hi: #45413a;

  --amber: #d4a017;     /* supply lens */
  --mauve: #c084fc;     /* capital lens */
  --green: #4ade80;     /* resource lens */
  --red: #f87171;

  --mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--fg-hi);
  text-decoration: none;
  border-bottom: 1px solid var(--fg-dim);
}
a:hover { color: var(--amber); border-bottom-color: var(--amber); }

::selection { background: var(--amber); color: var(--bg); }

/* ─── layout ─── */
.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 96px;
}

.page-wide {
  max-width: none;
  margin: 0;
  padding: 0;
}

/* ─── header ─── */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.wordmark {
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg-hi);
  border: none;
  font-size: 15px;
}
.wordmark:hover { color: var(--amber); }

.nav { display: flex; gap: 18px; }
.nav a { border: none; color: var(--fg-mute); font-size: 13px; }
.nav a:hover { color: var(--fg-hi); }
.nav a.active { color: var(--fg-hi); }

/* ─── intro block ─── */
.intro {
  margin-bottom: 40px;
}
.intro h1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg-hi);
  margin: 0 0 8px;
  letter-spacing: 0.02em;
}
.intro p {
  margin: 0;
  color: var(--fg-mute);
  max-width: 60ch;
}

/* ─── post list ─── */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.post-list li {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  align-items: baseline;
}
.post-list li:last-child { border-bottom: 1px solid var(--border); }
.post-list .date {
  color: var(--fg-mute);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.post-list .title {
  color: var(--fg-hi);
  border: none;
  font-weight: 500;
}
.post-list .title:hover { color: var(--amber); }
.post-list .desc {
  color: var(--fg-mute);
  font-size: 13px;
  margin-top: 2px;
}

/* ─── post body ─── */
.post h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--fg-hi);
  margin: 0 0 4px;
}
.post .meta {
  color: var(--fg-mute);
  font-size: 13px;
  margin-bottom: 32px;
}
.post p { margin: 0 0 18px; max-width: 68ch; }
.post h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg-hi);
  margin: 32px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.post blockquote {
  border-left: 2px solid var(--border-hi);
  padding-left: 16px;
  margin: 18px 0;
  color: var(--fg-mute);
  font-style: normal;
}
.post code {
  background: var(--bg-panel);
  padding: 1px 6px;
  border: 1px solid var(--border);
  font-size: 13px;
}
.post h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-hi);
  margin: 24px 0 6px;
}
.post ul, .post ol {
  margin: 0 0 18px;
  padding-left: 22px;
  max-width: 68ch;
}
.post li { margin: 0 0 6px; }
.post strong { color: var(--fg-hi); font-weight: 600; }
.post pre {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 14px 16px;
  margin: 0 0 18px;
  max-width: 80ch;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.55;
}
.post pre code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: inherit;
  color: var(--fg);
}
.post table {
  border-collapse: collapse;
  margin: 8px 0 22px;
  width: 100%;
  max-width: 80ch;
  font-size: 13px;
}
.post th, .post td {
  border-bottom: 1px solid var(--border);
  padding: 6px 12px 6px 0;
  text-align: left;
  vertical-align: top;
}
.post th {
  color: var(--fg-mute);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
  border-bottom: 1px solid var(--border-hi);
}
.post td.num, .post th.num { text-align: right; padding-right: 14px; font-variant-numeric: tabular-nums; }
.post tr.total td { border-top: 1px solid var(--border-hi); font-weight: 600; color: var(--fg-hi); }
.post figure {
  margin: 24px 0;
  max-width: 80ch;
}
.post figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  background: #000;
}
.post figcaption {
  color: var(--fg-mute);
  font-size: 12px;
  margin-top: 8px;
  letter-spacing: 0.02em;
}
.post hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 32px 0;
  max-width: 68ch;
}
.post .tldr {
  border: 1px solid var(--border-hi);
  background: var(--bg-panel);
  padding: 14px 18px;
  margin: 0 0 28px;
  max-width: 68ch;
}
.post .tldr .label {
  color: var(--amber);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-right: 8px;
}
.post .repo-link {
  color: var(--fg-mute);
  font-size: 12px;
  margin-bottom: 24px;
}

/* ─── projects ─── */
.project-card {
  display: block;
  border: 1px solid var(--border);
  padding: 20px 22px;
  margin-bottom: 16px;
  color: inherit;
  border-bottom: 1px solid var(--border);
  transition: border-color 0.1s;
}
.project-card:hover {
  border-color: var(--border-hi);
  color: inherit;
}
.project-card .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.project-card .name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-hi);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.project-card .open {
  color: var(--amber);
  font-size: 13px;
}
.project-card .desc {
  color: var(--fg-mute);
  margin: 0 0 12px;
  max-width: 64ch;
}
.project-card .stats {
  color: var(--fg-dim);
  font-size: 12px;
  display: flex;
  gap: 16px;
}
.project-card .stats span::before { content: '·  '; color: var(--fg-dim); }
.project-card .stats span:first-child::before { content: ''; }

/* ─── graph page ─── */
.graph-shell {
  display: grid;
  grid-template-columns: 220px 1fr 400px;
  grid-template-rows: 44px auto 1fr 28px;
  grid-template-areas:
    "header  header  header"
    "kpis    kpis    kpis"
    "sidebar canvas  inspect"
    "footer  footer  footer";
  height: 100vh;
  background: var(--bg);
}

.graph-header .tagline {
  color: var(--fg-mute);
  font-size: 12px;
  margin-left: 4px;
}

/* ─── KPI strip ─── */
.kpi-strip {
  grid-area: kpis;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border);
}
.kpi-tile {
  padding: 14px 18px 16px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 92px;
}
.kpi-tile:last-child { border-right: none; }
.kpi-tile .v {
  font-size: 22px;
  color: var(--fg-hi);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-tile .l {
  color: var(--fg);
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.35;
}
.kpi-tile .c {
  color: var(--fg-mute);
  font-size: 11px;
  margin-top: auto;
  padding-top: 8px;
  line-height: 1.35;
}
.kpi-tile .c::before { content: '↳ '; color: var(--fg-dim); }

.graph-header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.graph-header .left { display: flex; gap: 16px; align-items: baseline; }
.graph-header .crumb { color: var(--fg-mute); }
.graph-header .crumb a { border: none; color: var(--fg-mute); }
.graph-header .crumb a:hover { color: var(--fg-hi); }
.graph-header .title { color: var(--fg-hi); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; font-size: 12px; }
.graph-header .right { display: flex; gap: 14px; align-items: center; }
.graph-header .search input {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 8px;
  width: 200px;
  outline: none;
}
.graph-header .search input:focus { border-color: var(--amber); }

.graph-sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--border);
  padding: 18px 16px;
  overflow-y: auto;
  font-size: 12px;
}
.graph-sidebar h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-mute);
  font-weight: 600;
  margin: 0 0 8px;
}
.graph-sidebar .section { margin-bottom: 22px; }

.lens-list, .layer-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.lens-list li, .layer-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  cursor: pointer;
  user-select: none;
  color: var(--fg);
}
.lens-list li:hover, .layer-list li:hover { color: var(--fg-hi); }
.lens-list .swatch {
  display: inline-block;
  width: 10px;
  height: 2px;
}
.lens-list li.active { color: var(--fg-hi); }
.lens-list li.inactive { color: var(--fg-dim); }
.lens-list li.inactive .swatch { opacity: 0.3; }

.layer-list .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 0;
  background: var(--fg-dim);
}
.layer-list .count {
  margin-left: auto;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}

.graph-canvas {
  grid-area: canvas;
  position: relative;
  overflow: hidden;
}
.graph-canvas svg { display: block; width: 100%; height: 100%; }

.layer-bands {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}
.layer-band {
  flex: 1;
  border-bottom: 1px dashed var(--border);
  position: relative;
}
.layer-band:last-child { border-bottom: none; }
.layer-band .label {
  position: absolute;
  left: 12px;
  top: 4px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.graph-inspect {
  grid-area: inspect;
  border-left: 1px solid var(--border);
  padding: 18px 20px 28px;
  overflow-y: auto;
  font-size: 13px;
}
.graph-inspect .empty {
  color: var(--fg-dim);
  font-style: normal;
  margin-top: 24px;
}

/* ─── receipt ─── */
.receipt-block { margin-bottom: 26px; }
.receipt-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-hi);
  letter-spacing: 0.04em;
  margin: 0 0 2px;
  text-transform: uppercase;
}
.receipt-subtitle {
  color: var(--fg-mute);
  font-size: 11px;
  margin: 0 0 14px;
  line-height: 1.4;
}
.receipt-section { margin-bottom: 14px; }
.receipt-section h4 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-mute);
  font-weight: 600;
  margin: 0 0 4px;
}
.receipt-row {
  display: grid;
  grid-template-columns: 1fr auto;
  padding: 5px 0 4px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  gap: 12px;
}
.receipt-row:first-of-type { border-top: 1px solid var(--border); }
.receipt-row.headline { background: rgba(212, 160, 23, 0.04); }
.receipt-row .k { color: var(--fg); }
.receipt-row .v {
  color: var(--fg-hi);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  white-space: nowrap;
}
.receipt-row .v .u {
  color: var(--fg-mute);
  font-weight: 400;
  margin-left: 4px;
}
.receipt-row .note {
  grid-column: 1 / -1;
  color: var(--fg-dim);
  font-size: 11px;
  line-height: 1.4;
  padding-bottom: 2px;
}

.receipt-scale {
  margin-top: 18px;
  border: 1px solid var(--border);
  padding: 12px 14px 14px;
  background: var(--bg-panel);
}
.receipt-scale h4 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--amber);
  font-weight: 600;
  margin: 0;
}
.receipt-scale .sub {
  color: var(--fg-mute);
  font-size: 11px;
  margin: 2px 0 10px;
}
.receipt-scale .row {
  display: grid;
  grid-template-columns: 1fr auto;
  padding: 4px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.receipt-scale .row .k { color: var(--fg-mute); }
.receipt-scale .row .v { color: var(--fg-hi); font-variant-numeric: tabular-nums; }
.receipt-scale .row .note {
  grid-column: 1 / -1;
  color: var(--fg-dim);
  font-size: 10px;
}

.receipt-method {
  margin-top: 14px;
  font-size: 11px;
  color: var(--fg-mute);
  line-height: 1.5;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.receipt-method summary {
  cursor: pointer;
  color: var(--fg);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  list-style: none;
  user-select: none;
}
.receipt-method summary::before { content: '＋ '; color: var(--fg-mute); }
.receipt-method[open] summary::before { content: '－ '; }
.receipt-method p {
  margin: 8px 0 0;
}

/* ─── news ─── */
.news-block { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border); }
.news-block h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-mute);
  font-weight: 600;
  margin: 0 0 10px;
}
.news-list { list-style: none; padding: 0; margin: 0; }
.news-list li {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
  align-items: baseline;
}
.news-list .date {
  color: var(--fg-mute);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}
.news-list .headline { color: var(--fg-hi); line-height: 1.45; }
.news-list .tags {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
}
.news-list .tag {
  color: var(--fg-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--border);
  padding: 0 4px;
}

/* ─── inspector back button ─── */
.inspect-back {
  display: inline-block;
  color: var(--fg-mute);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  margin-bottom: 14px;
  font-family: var(--mono);
}
.inspect-back::before { content: '← '; }
.inspect-back:hover { color: var(--fg-hi); }

/* ─── legend in sidebar ─── */
.legend-section .legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 11px;
  color: var(--fg-mute);
}
.legend-section .dot.lg {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--fg-mute);
  display: inline-block;
}
.legend-section .line {
  width: 16px;
  height: 2px;
  display: inline-block;
}
.legend-section .line.amber { background: var(--amber); }
.legend-section .line.mauve { background: var(--mauve); background-image: linear-gradient(to right, var(--mauve) 60%, transparent 60%); background-size: 6px 2px; }
.legend-section .line.green { background-image: linear-gradient(to right, var(--green) 30%, transparent 30%); background-size: 3px 2px; }
.graph-inspect h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg-hi);
  margin: 0 0 4px;
}
.graph-inspect .layer-tag {
  display: inline-block;
  color: var(--fg-mute);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 18px;
}
.graph-inspect .blurb {
  color: var(--fg);
  margin: 0 0 18px;
}
.graph-inspect h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-mute);
  font-weight: 600;
  margin: 18px 0 8px;
}
.graph-inspect .metrics {
  list-style: none;
  padding: 0;
  margin: 0;
}
.graph-inspect .metrics li {
  display: grid;
  grid-template-columns: 1fr auto;
  padding: 4px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.graph-inspect .metrics li:last-child { border-bottom: 1px solid var(--border); }
.graph-inspect .metrics .k { color: var(--fg-mute); }
.graph-inspect .metrics .v { color: var(--fg-hi); font-variant-numeric: tabular-nums; }

.edge-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.edge-list li {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  align-items: baseline;
}
.edge-list .arrow {
  color: var(--fg-dim);
  font-size: 11px;
}
.edge-list .lens-supply { color: var(--amber); }
.edge-list .lens-capital { color: var(--mauve); }
.edge-list .lens-resource { color: var(--green); }
.edge-list .target { color: var(--fg-hi); cursor: pointer; }
.edge-list .target:hover { text-decoration: underline; }
.edge-list .weight {
  color: var(--fg-mute);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.graph-footer {
  grid-area: footer;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 11px;
  color: var(--fg-mute);
  gap: 18px;
}
.graph-footer .spacer { flex: 1; }

/* ─── graph svg styles ─── */
.node circle {
  fill: var(--bg-panel);
  stroke: var(--border-hi);
  stroke-width: 1;
  cursor: pointer;
  transition: stroke 0.1s, fill 0.1s;
}
.node:hover circle, .node.focused circle {
  stroke: var(--amber);
  fill: var(--bg-hi);
}
.node text {
  fill: var(--fg);
  font-family: var(--mono);
  font-size: 10px;
  pointer-events: none;
  text-anchor: middle;
}
.node.focused text { fill: var(--fg-hi); }
.node.dim { opacity: 0.25; }

.edge {
  stroke-opacity: 0.45;
  fill: none;
  pointer-events: none;
  transition: stroke-opacity 0.1s;
}
.edge.dim { stroke-opacity: 0.05; }
.edge.focused { stroke-opacity: 0.9; }
.edge.supply { stroke: var(--amber); }
.edge.capital {
  stroke: var(--mauve);
  stroke-dasharray: 4 4;
  animation: flow 1.4s linear infinite;
}
.edge.resource {
  stroke: var(--green);
  stroke-dasharray: 2 3;
  animation: flow 1.1s linear infinite;
}
@keyframes flow {
  to { stroke-dashoffset: -16; }
}

/* ─── mobile fallback ─── */
@media (max-width: 900px) {
  .graph-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 44px auto auto 60vh auto 28px;
    grid-template-areas:
      "header"
      "kpis"
      "sidebar"
      "canvas"
      "inspect"
      "footer";
    height: auto;
    min-height: 100vh;
  }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .kpi-tile { border-right: none; border-bottom: 1px solid var(--border); }
  .kpi-tile:nth-child(odd) { border-right: 1px solid var(--border); }
  .kpi-tile:nth-last-child(-n+2) { border-bottom: none; }
  .graph-sidebar, .graph-inspect { border: none; border-top: 1px solid var(--border); }
  .graph-header .tagline { display: none; }
}
