/* Field Notes: the blog's own look. Copied to site/blog/blog.css by
   scripts/build-blog.mjs. The shared header and footer theme themselves off
   html.dark; everything here reads the tokens below, so light and dark are
   one set of rules. --accent is set per post (its node category colour). */

.fn {
  --paper: #f4f3ef;
  --dot: rgba(20, 20, 26, .09);
  --surface: #fdfcfa;
  --ink: #16161a;
  --ink-2: #4d4d57;
  --ink-3: #7a7a85;
  --rule: rgba(20, 20, 26, .11);
  --wire: #bdbdc6;
  --code-bg: #ebeae5;
  --shadow: 0 1px 0 rgba(20, 22, 27, .04), 0 10px 30px -18px rgba(20, 22, 27, .35);
  --display: "Bricolage Grotesque", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --accent: #487cde;
  background: var(--paper) radial-gradient(circle, var(--dot) 1px, transparent 1.2px) 0 0 / 22px 22px;
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}
html.dark .fn {
  --paper: #0a0a0d;
  --dot: rgba(255, 255, 255, .085);
  --surface: #141418;
  --ink: #ececf1;
  --ink-2: #a7a7b2;
  --ink-3: #75757f;
  --rule: rgba(255, 255, 255, .09);
  --wire: #3b3b45;
  --code-bg: #18181d;
  --shadow: 0 1px 0 rgba(0, 0, 0, .2), 0 14px 34px -20px rgba(0, 0, 0, .8);
}
html:has(.fn) { background: #f4f3ef; }
html.dark:has(.fn) { background: #0a0a0d; }

.fn :where(main) a { color: inherit; }
.fn :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.fn-index, .fn-post { padding: 112px 24px 56px; }

/* ───────────── shared bits ───────────── */

.kicker {
  display: inline-block;
  font: 600 15px/1 var(--display);
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 18px;
}
.kicker:hover { text-decoration: underline; text-underline-offset: 4px; }

.tag {
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  color: var(--ink-2);
}

/* The wire: a flow's nodes as small canvas cards joined by wires. */
.wire { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; row-gap: 14px; }
.wire li { position: relative; display: flex; align-items: center; }
.wire li + li::before {
  content: "";
  width: 28px;
  height: 2px;
  background: linear-gradient(90deg, var(--wire), var(--c));
}
.wire a, .wire span {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 14px 9px 13px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--c);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.wire small { font-size: 11px; font-weight: 600; color: var(--c); letter-spacing: .02em; }
/* ports */
.wire a::before, .wire a::after, .wire span::before, .wire span::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--c);
}
.wire a::before, .wire span::before { left: -5px; }
.wire a::after, .wire span::after { right: -5px; }
.wire li:first-child a::before, .wire li:first-child span::before { display: none; }
.wire li:last-child a::after, .wire li:last-child span::after { display: none; }
.wire a:hover { border-color: var(--c); }

.wire.is-mini { row-gap: 8px; }
.wire.is-mini li + li::before { width: 14px; }
.wire.is-mini span { padding: 4px 8px; font-size: 12px; font-weight: 500; border-top-width: 2px; box-shadow: none; border-radius: 6px; }
.wire.is-mini span::before, .wire.is-mini span::after { width: 6px; height: 6px; margin-top: -3px; border-width: 1.5px; }
.wire.is-mini span::before { left: -4px; }
.wire.is-mini .more-n { font-size: 12px; color: var(--ink-3); padding-left: 8px; }
.wire.is-mini .more-n::before { display: none; }
.wire.is-mini span::after { right: -4px; }

/* ───────────── index ───────────── */

.fn-index { max-width: 1200px; margin: 0 auto; }
.masthead {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px 48px;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 48px;
}
.masthead h1 {
  font: 800 clamp(40px, 5.2vw, 64px)/1 var(--display);
  letter-spacing: -.035em;
  margin: 0;
  font-variation-settings: "opsz" 96;
}
/* The title and the topic filters share one row; the filters wrap to their own
   line only on a narrow screen. */
.filters { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.filters button {
  font: 500 14px/1 var(--body);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.filters button:hover { color: var(--ink); border-color: var(--ink-3); }
.filters button.is-on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  text-decoration: none;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: border-color .2s ease, transform .2s ease;
}
.card::before { content: ""; height: 5px; background: var(--accent); flex: none; }
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card-cover { aspect-ratio: 16 / 9; overflow: hidden; background: #0f0f12; border-bottom: 1px solid var(--rule); display: grid; place-items: center; padding: 14px; }
.card-cover img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card-body { padding: 26px 28px 30px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.card time { font-size: 13px; color: var(--ink-3); }
.card h3 { font: 700 23px/1.18 var(--display); letter-spacing: -.02em; margin: 0; }
.card p { font-size: 15.5px; line-height: 1.62; color: var(--ink-2); margin: 0; }
.card .wire { margin-top: auto; padding-top: 14px; }
.card[hidden] { display: none; }

.lead { margin-bottom: 40px; }
.card.is-lead { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
.card.is-lead::before { position: absolute; left: 0; right: 0; top: 0; }
.card.is-lead .card-cover { aspect-ratio: auto; min-height: 340px; border-bottom: 0; border-right: 1px solid var(--rule); }
.card.is-lead .card-body { padding: 44px 44px 40px; justify-content: center; }
.card.is-lead h3 { font-size: clamp(30px, 3.4vw, 44px); letter-spacing: -.03em; }
.card.is-lead p { font-size: 17px; }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px 36px; align-items: stretch; grid-auto-flow: dense; }
/* Every third card spans two columns with a banner-shaped cover: flows are wide. */
.grid .card.is-wide { grid-column: span 2; }
.grid .card.is-wide .card-cover { aspect-ratio: 21 / 8; }
.grid .card.is-full { grid-column: 1 / -1; }
.grid .card.is-full .card-cover { aspect-ratio: 21 / 7; }

/* ───────────── post ───────────── */

.fn-post { max-width: 1200px; margin: 0 auto; }
.post-hero { max-width: 976px; margin: 0 auto 80px; padding-top: 12px; }
.post-hero h1 {
  font: 800 clamp(28px, 3.3vw, 40px)/1.12 var(--display);
  letter-spacing: -.03em;
  margin: 0 0 20px;
  text-wrap: pretty;
}
/* One axis: the title, lede and meta sit in the body's column; only the hero
   video and wide figures break out, symmetrically, to the full 976px. */
.post-hero > :not(.hero-media) { max-width: 720px; margin-left: auto; margin-right: auto; }
.post-hero .kicker { display: block; }
.post-hero .lede { font-size: clamp(18px, 1.8vw, 21px); line-height: 1.5; color: var(--ink-2); margin-bottom: 22px; text-wrap: pretty; }
.byline { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; font-size: 14px; color: var(--ink-3); }
.byline .tag { font-size: 12px; }
.hero-media .fig.is-wide { margin: 44px 0 0; }
.hero-media .fig.is-wide figcaption { margin-left: 0; }

/* What's in this flow: one lane per trigger, read from the flow file. */
.flow-map { max-width: 976px; margin: 104px auto 0; padding: 36px 34px 38px; border-radius: 16px; background: var(--surface); border: 1px solid var(--rule); }
.flow-map-head { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 30px; }
.flow-map h2 { font: 700 24px/1.2 var(--display); letter-spacing: -.02em; margin: 0 0 6px; }
.flow-map-head p { margin: 0; font-size: 14px; color: var(--ink-3); }
.wire.is-lane { row-gap: 18px; }
.wire.is-lane + .wire.is-lane { margin-top: 26px; padding-top: 26px; border-top: 1px dashed var(--rule); }
.wire.is-lane li + li::before { width: 32px; }
.wire.is-lane a { font-size: 15px; padding: 10px 15px 10px 14px; }
.wire.is-lane small { font-weight: 500; color: var(--c); opacity: .9; }
.wire .joins span { display: block; padding: 8px 14px; border: 1px dashed var(--c); border-radius: 10px; font-size: 13px; color: var(--ink-3); background: transparent; box-shadow: none; }
.wire .joins span::before, .wire .joins span::after { display: none; }

.get-flow {
  flex: none;
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff !important;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.get-flow:hover { filter: brightness(1.1); }

.prose { max-width: 720px; margin: 0 auto; font-size: 18px; line-height: 1.78; color: var(--ink); }
.prose > * { margin: 0 0 1.4em; }
.prose h2 { font: 700 30px/1.2 var(--display); letter-spacing: -.025em; margin: 2.8em 0 .8em; scroll-margin-top: 90px; }
.prose h3 { font: 700 21px/1.3 var(--display); letter-spacing: -.01em; margin: 2.2em 0 .6em; scroll-margin-top: 90px; }
.prose h2:first-child { margin-top: 0; }
.prose p { text-wrap: pretty; }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
html.dark .prose a { filter: brightness(1.25); }
.prose strong { font-weight: 650; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .6em 0; }
.prose li::marker { color: var(--accent); }
.prose code { font: .86em/1 var(--mono); background: var(--code-bg); padding: .15em .4em; border-radius: 5px; }
.prose pre { background: var(--code-bg); border: 1px solid var(--rule); border-radius: 12px; padding: 18px 20px; overflow-x: auto; font-size: 14px; line-height: 1.6; }
.prose pre code { background: none; padding: 0; font-size: inherit; line-height: inherit; }

.note {
  border-left: 3px solid var(--accent);
  margin-top: 2em;
  margin-bottom: 2em;
  padding: 6px 0 6px 22px;
  color: var(--ink-2);
  font-size: 17px;
}
.note p { margin: 0; }
.note strong { color: var(--ink); }

.prompt {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.prompt-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px 10px 18px;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
}
.prompt-head button {
  font: 600 13px/1 var(--body);
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
.prompt-head button:hover { border-color: var(--accent); }
.prompt p { margin: 0; padding: 20px 22px 22px; font-size: 17px; line-height: 1.6; }

.table-wrap { overflow-x: auto; }
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.45; }
.prose th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: 13px; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--rule); }
.prose td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }

/* figures */
.fig { margin: 3.2em 0; }
/* Stacked figures get a clear gap so each caption belongs to its own image. */
.prose > .fig + .fig, .prose > .fig + .fig-pair, .prose > .fig-pair + .fig { margin-top: 4.4em; }
.fig .frame {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  background: var(--code-bg);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}
.fig.is-video .frame { cursor: default; }
/* Screenshots are shown no bigger than they were captured: a 440px inspector
   stays 440px, on the text axis, and a wide canvas fills the column. */
.fig:not(.is-video) .frame { width: fit-content; max-width: 100%; }
.fig img { display: block; width: auto; max-width: 100%; height: auto; }
/* Videos too: never upscaled, and never taller than the screen, so a portrait
   recording (a chat window) plays at its own size instead of filling the
   column. Before metadata loads, the poster gives the element its size. */
.fig.is-video .frame { width: fit-content; max-width: 100%; }
.fig video { display: block; width: auto; max-width: 100%; height: auto; max-height: min(76vh, 700px); }
.hero-media .fig.is-video { width: fit-content; max-width: 100%; margin-left: auto; margin-right: auto; }
.fig figcaption { margin-top: 16px; font-size: 14.5px; line-height: 1.6; color: var(--ink-2); max-width: 64ch; }
.fig-n { font-weight: 700; color: var(--accent); margin-right: 8px; }
.fig.is-wide { margin-left: -128px; margin-right: -128px; }
.fig.is-wide figcaption { margin-left: 128px; }
.fig-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; margin: 3.2em -128px; }
.fig-pair .fig { margin: 0; }

/* zoom */
.zoom {
  box-sizing: border-box;
  max-width: none;
  max-height: none;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 3vh 3vw;
  border: 0;
  background: transparent;
  display: none;
  cursor: zoom-out;
}
.zoom[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.zoom::backdrop { background: rgba(8, 10, 16, .88); backdrop-filter: blur(6px); }
.zoom img { width: min(92vw, calc(84vh * var(--ar, 1.6))); height: auto; border-radius: 10px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.zoom p { color: #d7dbe4; font-size: 15px; max-width: 80ch; text-align: center; margin: 0; }
@media (prefers-reduced-motion: no-preference) {
  .zoom[open] img { animation: zoom-in .22s ease-out; }
}
@keyframes zoom-in { from { transform: scale(.94); opacity: .4; } }

/* call to action + more */
.post-cta {
  max-width: 976px;
  margin: 112px auto 0;
  padding: 36px 40px;
  border-radius: 18px;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  gap: 24px 40px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.post-cta h2 { font: 700 28px/1.1 var(--display); letter-spacing: -.02em; margin: 0 0 8px; }
.post-cta p { margin: 0; max-width: 48ch; opacity: .75; line-height: 1.5; }
.cta-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn { display: inline-block; padding: 12px 20px; border-radius: 999px; background: var(--accent); color: #fff !important; font-weight: 600; font-size: 15px; text-decoration: none; }
.btn.ghost { background: transparent; border: 1px solid currentColor; color: inherit !important; }
.btn:hover { filter: brightness(1.1); }

.more { max-width: 1200px; margin: 112px auto 0; border-top: 1px solid var(--rule); padding-top: 32px; }
.more h2 { font: 700 26px/1 var(--display); letter-spacing: -.02em; margin: 0 0 24px; }
.more-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 36px; }
.card.is-small h3 { font-size: 20px; }
.card.is-small .card-cover { aspect-ratio: 2 / 1; }

/* ───────────── responsive ───────────── */

@media (max-width: 1100px) {
  .fig.is-wide, .fig-pair { margin-left: 0; margin-right: 0; }
  .fig.is-wide figcaption { margin-left: 0; }
}
@media (max-width: 900px) {
  .masthead { grid-template-columns: 1fr; }
  .filters { justify-content: flex-start; }
  .grid, .more-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card.is-lead { grid-template-columns: 1fr; }
  .card.is-lead .card-cover { min-height: 0; aspect-ratio: 16 / 9; border-right: 0; border-bottom: 1px solid var(--rule); }
}
@media (max-width: 620px) {
  .fn-index, .fn-post { padding: 84px 16px 32px; }
  .grid, .more-grid, .fig-pair { grid-template-columns: 1fr; }
  .grid .card.is-wide, .grid .card.is-full { grid-column: auto; }
  .grid .card.is-wide .card-cover, .grid .card.is-full .card-cover { aspect-ratio: 16 / 9; }
  .card.is-lead .card-body { padding: 24px 20px; }
  .prose { font-size: 17px; }
  .flow-map { padding: 24px 18px; }
  .wire.is-lane { flex-direction: column; align-items: flex-start; }
  .wire.is-lane li { flex-direction: column; align-items: flex-start; }
  .wire.is-lane li + li::before { width: 2px; height: 16px; margin-left: 24px; background: linear-gradient(180deg, var(--wire), var(--c)); }
  .wire.is-lane a::before, .wire.is-lane a::after { display: none; }
  .post-cta { padding: 28px 22px; }
}
