/* The Blueprint lab. Every colour is a zlab token (src/lab/tokens.css); --zl-skeleton carries Dusk's --skeleton,
   light and dark. The lab's cards are raised, so a well on one is --zl-well-raised. The names the blueprint walker reads
   (--surface-*, --line, --skeleton, --ink) are aliases of the zlab tokens, set once here. Type is M Saans, 14px and up. */

@font-face {
  font-family: "M Saans";
  src: url("../../public/fonts/msaans/MSaansVF.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --surface-canvas: oklch(var(--zl-canvas));
  --surface-card: oklch(var(--zl-raised));
  --surface-sunken: oklch(var(--zl-well-raised));
  --surface-fill: oklch(var(--zl-fill));
  --surface-selected: oklch(var(--zl-selected));
  --line: oklch(var(--zl-line));
  --ink: oklch(var(--zl-ink));
  --skeleton: oklch(var(--zl-skeleton));
  --muted: oklch(var(--zl-ink-muted));
  --subtle: oklch(var(--zl-ink-subtle));
  --gain: oklch(var(--zl-positive));
  --r-card: 16px;
  --r-control: 10px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--surface-canvas); }
body {
  margin: 0;
  color: var(--ink);
  background: var(--surface-canvas);
  font-family: var(--zl-font-dusk);
  font-size: var(--zl-body);
  line-height: var(--zl-body-lh);
  letter-spacing: var(--zl-body-track);
  font-weight: var(--zl-weight);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }

/* ---------- lab page ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 48px 40px 96px; }
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.top h1 { font-size: var(--zl-title-1); line-height: var(--zl-title-1-lh); letter-spacing: var(--zl-title-1-track); font-weight: var(--zl-title-weight); }
.top p { margin-top: 8px; max-width: 62ch; color: var(--muted); font-size: var(--zl-lead); line-height: var(--zl-lead-lh); }
.theme { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-fill); box-shadow: inset 0 0 0 1px var(--line); flex: none; }
.theme button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.theme button[aria-pressed="true"] { background: var(--surface-card); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }

.toc { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 28px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--ink); }

section { padding-top: 56px; }
section > h2 { font-size: var(--zl-title-2); line-height: var(--zl-title-2-lh); letter-spacing: var(--zl-title-2-track); font-weight: var(--zl-title-weight); }
section > .intro { margin-top: 6px; max-width: 68ch; color: var(--muted); }

.rules { margin: 20px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 40px; }
.rules li { padding: 14px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 28px 1fr; }
.rules b { font-weight: var(--zl-label-weight); }
.rules span { color: var(--muted); }
.rules .n { color: var(--subtle); }

/* A real snippet beside its blueprint. */
.pair { margin-top: 32px; }
.pair h3 { font-size: var(--zl-title-3); line-height: var(--zl-title-3-lh); letter-spacing: var(--zl-title-3-track); font-weight: var(--zl-title-weight); }
.notes { margin-top: 6px; display: grid; gap: 2px; max-width: 80ch; }
.notes p { color: var(--muted); }
.notes b { color: var(--ink); font-weight: var(--zl-label-weight); }
.cols { margin-top: 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.cols.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cell > .lbl { display: block; margin-bottom: 10px; color: var(--subtle); }
.cell.not > .lbl { color: var(--ink); }
.cell.not > .lbl::before { content: "Not \00B7  "; font-weight: var(--zl-label-weight); }

/* ---------- primitives (drawn by hand, to the walker's spec) ---------- */
.prims { margin-top: 20px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.prim .stage { height: 120px; border-radius: var(--r-card); background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--line); position: relative; display: grid; place-items: center; }
.prim h3 { margin-top: 12px; font-size: var(--zl-body); font-weight: var(--zl-label-weight); }
.prim p { color: var(--muted); }
.bp { background: var(--skeleton); display: block; }
.bp.bar { height: 0.72em; border-radius: 999px; }
.bp.pill { border-radius: 999px; }
.bp.disc { border-radius: 50%; }
.bp.hair { height: 1px; background: var(--line); }
.bp.frame { background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--line); border-radius: var(--r-card); }
.prim .stage.bare { background: var(--surface-canvas); }

/* The hand-drawn wrong case: frames in frames, a mark in a mark. Built from the same tokens so only the depth differs. */
.deep { padding: 16px; display: grid; gap: 10px; }
.deep .well { background: var(--surface-sunken); box-shadow: inset 0 0 0 1px var(--line); border-radius: 12px; padding: 10px; display: grid; gap: 8px; }
.deep .row { background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--line); border-radius: 10px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.deep .chip { background: var(--surface-sunken); box-shadow: inset 0 0 0 1px var(--line); border-radius: 999px; padding: 5px 8px; display: flex; gap: 6px; }

/* ---------- palette ---------- */
.swatches { margin-top: 20px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.sw .chip { height: 72px; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--line); }
.sw b { display: block; margin-top: 10px; font-weight: var(--zl-label-weight); }
.sw span { display: block; color: var(--muted); }
.sw code { display: block; color: var(--subtle); font-family: var(--zl-font-dusk); }
.maps { margin-top: 24px; width: 100%; border-collapse: collapse; }
.maps th, .maps td { text-align: left; padding: 12px 16px 12px 0; border-top: 1px solid var(--line); vertical-align: top; }
.maps th { color: var(--subtle); font-weight: var(--zl-weight); }
.maps td:last-child { color: var(--muted); }

/* ---------- product snippets (stand-in data, the product's look) ---------- */
.snip { background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--line); border-radius: var(--r-card); }
.pad { padding: 20px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.mut { color: var(--muted); }
.sub { color: var(--subtle); }
.gain { color: var(--gain); }
.num { font-variant-numeric: tabular-nums; }
.t18 { font-size: var(--zl-title-3); line-height: var(--zl-title-3-lh); letter-spacing: var(--zl-title-3-track); }
.t24 { font-size: var(--zl-title-2); line-height: var(--zl-title-2-lh); letter-spacing: var(--zl-title-2-track); font-weight: var(--zl-title-weight); }
.t32 { font-size: var(--zl-title-1); line-height: var(--zl-title-1-lh); letter-spacing: var(--zl-title-1-track); font-weight: var(--zl-title-weight); }
.lab { font-weight: var(--zl-label-weight); }

.coin { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; background: oklch(var(--zl-accent)); color: oklch(var(--zl-inv-ink)); font-weight: var(--zl-label-weight); }
.coin.b { background: oklch(var(--zl-positive)); color: oklch(var(--zl-raised)); }
.coin.sm { width: 24px; height: 24px; }

.btn { border: 0; cursor: pointer; height: 40px; padding: 0 18px; border-radius: 999px; background: oklch(var(--zl-accent)); color: oklch(var(--zl-inv-ink)); font-weight: var(--zl-label-weight); }
.btn.soft { background: var(--surface-fill); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.wide { width: 100%; height: 48px; }

/* dock */
.dock { display: flex; align-items: center; gap: 16px; padding: 6px 6px 6px 16px; border-radius: 999px; }
.dock .brand { font-weight: var(--zl-label-weight); }
.seg { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-fill); }
.seg a { padding: 7px 14px; border-radius: 999px; color: var(--muted); text-decoration: none; }
.seg a[aria-current="page"] { background: var(--surface-card); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.dock .sum { margin-left: auto; display: flex; gap: 14px; align-items: center; }

/* needs-you */
.need { display: flex; align-items: center; gap: 14px; padding: 14px 14px 14px 20px; }
.need .meter { width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--surface-sunken); box-shadow: inset 0 0 0 1px var(--line); font-weight: var(--zl-label-weight); }

/* activity */
.list { padding: 8px 0; }
.list .hd { padding: 12px 20px 8px; display: flex; justify-content: space-between; }
.list .it { padding: 10px 20px; display: flex; align-items: center; gap: 12px; }
.list .it + .it { border-top: 1px solid var(--line); }
.list .it .r { text-align: right; }

/* stat */
.stat .foot { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; gap: 24px; }

/* chart */
.chart svg { display: block; width: 100%; height: 150px; }
.chart .axis { display: flex; justify-content: space-between; color: var(--subtle); margin-top: 6px; }

/* field + CTA */
.field { margin-top: 10px; display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; border-radius: 14px; background: var(--surface-sunken); box-shadow: inset 0 0 0 1px var(--line); }
.field input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; font-size: var(--zl-title-2); color: var(--ink); outline: none; }
.field .tok { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--line); }
.field-meta { display: flex; justify-content: space-between; margin: 10px 2px 16px; }

/* table */
.tbl { overflow: hidden; }
.tbl table { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; color: var(--subtle); font-weight: var(--zl-weight); padding: 14px 20px 10px; }
.tbl td { padding: 12px 20px; border-top: 1px solid var(--line); }
.tbl th:not(:first-child), .tbl td:not(:first-child) { text-align: right; }
.tbl .mk { display: flex; align-items: center; gap: 10px; }

/* tabs */
.tabs { display: flex; gap: 22px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 14px 0 12px; color: var(--muted); cursor: pointer; box-shadow: inset 0 -2px 0 transparent; }
.tabs button[aria-selected="true"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.range { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-fill); }
.range button { border: 0; background: none; padding: 5px 12px; border-radius: 999px; color: var(--muted); cursor: pointer; }
.range button[aria-selected="true"] { background: var(--surface-card); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }

/* token row */
.token { display: flex; align-items: center; gap: 12px; padding: 14px 20px; }
.token + .token { border-top: 1px solid var(--line); }
.token .r { text-align: right; }

/* levels: the real deep card */
.failed .grp { margin-top: 14px; padding: 6px; border-radius: 14px; background: var(--surface-sunken); box-shadow: inset 0 0 0 1px var(--line); display: grid; gap: 6px; }
.failed .ord { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--line); }
.failed .tag { padding: 2px 10px; border-radius: 999px; background: var(--surface-fill); box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); }
.failed .cnt { padding: 0 9px; border-radius: 999px; background: var(--surface-fill); color: var(--muted); }

/* visuals */
.media img { display: block; width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; border-radius: 12px; }
.empty { text-align: center; padding: 28px 24px 24px; }
.empty img { width: 96px; height: 96px; display: block; margin: 0 auto 14px; border-radius: 22px; }
.empty .btn { margin-top: 16px; }
:root[data-theme="dark"] .ill-light, :root:not([data-theme="dark"]) .ill-dark { display: none !important; }

/* palette: what a part may paint, and what its blueprint paints */
.tint { background: oklch(var(--zl-positive) / 0.12); box-shadow: none; }
.island { background: oklch(var(--zl-inv)); color: oklch(var(--zl-inv-ink)); box-shadow: none; }
.island .mut { color: oklch(var(--zl-inv-muted)); }
.island .btn { background: oklch(var(--zl-inv-ink)); color: oklch(var(--zl-inv)); }

/* ---------- narrow ---------- */
@media (max-width: 900px) {
  .page { padding: 28px 20px 64px; }
  .top { flex-direction: column; }
  .rules, .cols, .cols.three, .prims { grid-template-columns: minmax(0, 1fr); }
  .swatches { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dock .sum { display: none; }
  .tbl .hide { display: none; }
  /* a thumb's reach: every page control is 44px tall on a phone */
  .toc { gap: 0 4px; margin-left: -8px; }
  .toc a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; }
  .theme button { min-height: 44px; padding: 0 18px; }
}
.failed .btn { height: 32px; padding: 0 14px; }
.failed .row { gap: 8px; }
@media (max-width: 480px) {
  .dock { padding-left: 6px; }
  .dock .brand { display: none; }
  .seg a { padding: 7px 10px; }
}
