/* Project pages: the layer on top of ../styles.css.
   Fonts, palette, the paper card, links, the footer and the dither field all come
   from the site stylesheet. This file adds the terminal demos, diagrams and the
   project-page typography, and is loaded only by pages in this folder. */

:root {
  --sheet: #fbfaf6;
  --dim: #625e56;
  --bar-text: #d6d1c4;
  --serif: 'Newsreader', Georgia, serif;
  --mono: ui-monospace, 'Cascadia Mono', 'SF Mono', Consolas, 'Liberation Mono', monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

html {
  caret-color: var(--ink);
}

body {
  line-height: 1.5;
}

button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

p {
  margin: 0;
}

[hidden] {
  display: none !important;
}

.dim {
  color: var(--dim);
}

/* ---------- page head ---------- */

h1 {
  max-width: 24ch;
  margin: 1.75rem 0 0.6rem;
  font-family: var(--serif);
  font-size: 1.9rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-wrap: balance;
}

.status-line {
  margin-bottom: 1.6rem;
  color: var(--dim);
  font-size: 0.8125rem;
}

.tag {
  display: inline-block;
  margin-right: 0.5rem;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--ink);
  color: var(--ink);
  font-size: 0.75rem;
  white-space: nowrap;
}

.summary {
  margin: 0;
  border-top: 1px dotted var(--rule);
}

.summary div {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px dotted var(--rule);
}

.summary dt {
  padding-top: 0.1rem;
  color: var(--dim);
  font-size: 0.8125rem;
}

.summary dd {
  max-width: 34rem;
  margin: 0;
  font-size: 0.9375rem;
}

/* ---------- sections and prose ---------- */

.section {
  margin-top: 3.25rem;
}

.section h2 {
  margin: 0 0 1rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px dotted var(--rule);
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 500;
}

h3 {
  margin: 1.7rem 0 0.3rem;
  font-size: 0.9375rem;
  font-weight: 600;
}

h2 + h3 {
  margin-top: 0;
}

.prose p,
.prose li {
  max-width: 34rem;
  font-size: 0.9375rem;
}

.prose p + p {
  margin-top: 0.7rem;
}

.prose ul {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
}

.prose li + li {
  margin-top: 0.3rem;
}

code {
  font-family: var(--mono);
  font-size: 0.86em;
}

.prose .stack {
  display: flex;
  flex-wrap: wrap;
  row-gap: 0.2rem;
  margin: 0.4rem 0 0 -1.2rem;
  padding: 0;
  list-style: none;
  clip-path: inset(0 0 0 1.2rem);
}

.prose .stack li {
  position: relative;
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.875rem;
}

.prose .stack li::before {
  content: '·';
  position: absolute;
  left: 0.45rem;
  color: var(--dim);
}

/* ---------- terminal window, drawn in ink ---------- */

figure {
  margin: 0;
}

.win {
  border: 1px solid var(--ink);
  background: var(--sheet);
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.6;
}

.win-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  background: var(--ink);
  color: var(--bar-text);
  font-size: 0.75rem;
}

.win-bar i {
  width: 0.6rem;
  height: 0.6rem;
  border: 1px solid var(--bar-text);
  border-radius: 50%;
}

.win-bar span {
  flex: 1;
  margin-right: 2.6rem;
  text-align: center;
}

.win-body {
  padding: 1rem 1.1rem 1.1rem;
}

.input {
  display: flex;
  gap: 0.6rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--ink);
}

.input + .event,
.event + .input {
  margin-top: 0.9rem;
}

.input .gt {
  color: var(--dim);
}

.caret {
  display: inline-block;
  visibility: hidden;
  width: 0.55em;
  height: 1.05em;
  margin-left: 1px;
  background: var(--ink);
  vertical-align: -0.18em;
}

.is-live .caret {
  visibility: visible;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* content is visible by default; the script arms the window, then reveals in order */
.reveal {
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}

.armed .reveal {
  opacity: 0;
  transform: translateY(4px);
}

.armed .reveal.on,
.armed .win-body > .input:first-child {
  opacity: 1;
  transform: none;
}

.event {
  display: grid;
  grid-template-columns: 1.15rem minmax(0, 1fr);
  margin-top: 0.9rem;
}

.event > .dot {
  font-size: 0.7em;
  line-height: 2.3;
}

.event strong {
  font-weight: 700;
}

.warn {
  color: var(--visited);
  font-weight: 700;
}

.kv {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  column-gap: 0.75rem;
  margin: 0.3rem 0 0;
}

.kv dt {
  color: var(--dim);
}

.kv dd {
  margin: 0;
}

.steps {
  margin: 0.35rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: s;
}

.steps li {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr);
  counter-increment: s;
}

.steps li::before {
  content: counter(s) '.';
  color: var(--dim);
}

.gap {
  margin-top: 0.5rem;
}

/* under the hood: a solid ink bar that folds the machinery away */
.hood-toggle {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--sheet);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s var(--ease);
}

.hood-toggle span {
  color: var(--bar-text);
  font-weight: 400;
}

.hood-toggle::after {
  content: 'show';
  margin-left: auto;
  font-weight: 400;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.14em;
}

.hood-toggle[aria-expanded="true"]::after {
  content: 'hide';
}

.hood-toggle:hover {
  background: #3d3b35;
}

.hood-toggle:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.hood-toggle.nudge {
  animation: nudge 1.1s ease 2;
}

@keyframes nudge {
  50% {
    background: var(--dim);
  }
}

.hood {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.5s var(--ease);
}

.js .hood:not(.open) {
  grid-template-rows: 0fr;
}

.hood > div {
  min-height: 0;
  overflow: hidden;
}

/* a shut panel is out of reach for keyboards and screen readers too */
.js .hood:not(.open) > div {
  visibility: hidden;
  transition: visibility 0s 0.5s;
}

.hood-inner {
  padding: 0.7rem 0.8rem 0.75rem;
  border: 1px solid var(--ink);
  border-top: 0;
  background: var(--paper);
}

.cmd {
  white-space: pre-wrap;
  word-break: break-word;
}

.hood-inner > * + * {
  margin-top: 0.55rem;
}

.note-line {
  color: var(--dim);
  font-size: 0.75rem;
}

/* ranked search results */
.hits {
  margin: 0;
  padding: 0;
  list-style: none;
}

.hit {
  display: grid;
  grid-template-columns: 5.6rem 2.4rem minmax(0, 1fr);
  column-gap: 0.6rem;
  align-items: center;
  padding: 0.08rem 0;
}

.hit .meta {
  grid-column: 3;
  color: var(--dim);
  font-size: 0.75rem;
}

.hit .score {
  color: var(--dim);
}

.hit:first-child .title {
  font-weight: 700;
}

.bar {
  position: relative;
  height: 0.62rem;
  background: repeating-linear-gradient(90deg, var(--rule) 0 2px, transparent 2px 4px);
}

.bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--w);
  background: var(--ink);
  transition: width 0.8s var(--ease) 0.15s;
}

.js .hood:not(.open) .bar i {
  width: 0;
}

/* terminal tables */
.tt {
  width: 100%;
  border-collapse: collapse;
}

.tt th,
.tt td {
  padding: 0.05rem 0.75rem 0.05rem 0;
  text-align: left;
  vertical-align: top;
  font-weight: 400;
}

.tt th {
  color: var(--dim);
  font-size: 0.75rem;
}

.tt .num {
  padding-right: 0;
  padding-left: 0.75rem;
  text-align: right;
  white-space: nowrap;
}

.tt-steps td:first-child {
  white-space: nowrap;
}

.tt .rule td {
  padding-top: 0.3rem;
  border-top: 1px dotted var(--dim);
}

.tt tr.rule ~ tr.rule td {
  border-top: 0;
  padding-top: 0.05rem;
}

.tt .total td {
  font-weight: 700;
}

figcaption {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.6rem;
  color: var(--dim);
  font-size: 0.8125rem;
}

.linkish {
  all: unset;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.14em;
}

.linkish:hover {
  color: var(--ink);
}

.linkish:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* ---------- how it works ---------- */

.flow {
  display: grid;
  gap: 0.9rem;
  margin-bottom: 1.25rem;
  font-size: 0.8125rem;
  line-height: 1.3;
}

.flow-lane {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.6rem 0;
}

.flow-lane-name {
  flex: none;
  width: 4.75rem;
  padding-top: 0.38rem;
  color: var(--dim);
  font-size: 0.75rem;
}

/* an arrow travels with the chip it points at, so a row never ends on one */
.flow-unit {
  --lead: 0rem;
  position: relative;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
}

.flow-unit.has-arrow {
  --lead: 1.15rem;
}

/* room for the stub that hangs below this unit */
.flow-unit.has-stub {
  margin-bottom: 2.1rem;
}

.flow-unit.has-arrow::before {
  content: '';
  grid-row: 1;
  width: 1.15rem;
  height: 0.6rem;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 10'%3E%3Cpath d='M1 5h21M17.5 1.5 22 5l-4.5 3.5' fill='none' stroke='%2324231f'/%3E%3C/svg%3E") center / contain no-repeat;
}

.flow-chip {
  grid-column: 2;
  grid-row: 1;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--ink);
  background: var(--sheet);
  white-space: nowrap;
  cursor: default;
  transition: background 0.35s var(--ease), color 0.35s var(--ease);
}

/* a branch or a dependency hangs under its chip on a drawn elbow */
.flow-stub {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: calc(var(--lead) + 1rem);
  padding: 0.2rem 0.5rem;
  border: 1px dashed var(--ink);
  background: var(--paper);
  font-size: 0.75rem;
  white-space: nowrap;
  cursor: default;
  transition: background 0.35s var(--ease), color 0.35s var(--ease);
}

.flow-stub::before {
  content: '';
  position: absolute;
  top: -0.45rem;
  left: -0.6rem;
  width: 0.6rem;
  height: calc(50% + 0.45rem);
  border-bottom: 1px solid var(--ink);
  border-left: 1px solid var(--ink);
}

.flow-chip.is-active,
.flow-stub.is-active {
  background: var(--ink);
  color: var(--sheet);
}

.flow-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: f;
}

.flow-list li {
  display: grid;
  grid-template-columns: 1.6rem minmax(0, 34rem);
  padding: 0.4rem 0;
  counter-increment: f;
  font-size: 0.9375rem;
}

.flow-list li::before {
  content: counter(f);
  color: var(--dim);
  font-size: 0.8125rem;
  line-height: 1.75;
}

/* a branch is not a numbered step: it hangs off the step above */
.flow-list li[data-stub] {
  counter-increment: none;
}

.flow-list li[data-stub]::before {
  content: '';
  width: 0.5rem;
  height: 0.75rem;
  margin-left: 0.2rem;
  border-bottom: 1px solid var(--dim);
  border-left: 1px solid var(--dim);
}

.flow-list b {
  padding: 0 0.25rem;
  margin-left: -0.25rem;
  font-weight: 600;
  transition: background 0.35s var(--ease), color 0.35s var(--ease);
}

.flow-list li.is-active b {
  background: var(--ink);
  color: var(--sheet);
}

/* ---------- demo forms ---------- */
/* Each project's demo takes the form its users actually saw: a terminal,
   a website chat, a document, a pipeline, an edited article or a sequence
   diagram. All of them are drawn in the same two inks on paper. */

.form-label {
  margin-bottom: 0.4rem;
  color: var(--dim);
  font-size: 0.8125rem;
}

.sheet {
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--ink);
  background: var(--sheet);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.sheet-title {
  margin-bottom: 0.5rem;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.25;
}

/* support agent: a client website with its chat widget, and the HubSpot record beside it */
.sa {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.site {
  border: 1px solid var(--ink);
  background: var(--paper);
}

.site-bar {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--ink);
  background: var(--sheet);
}

.site-bar span {
  display: block;
  padding: 0.1rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.site-page {
  padding: 0.9rem;
}

.site-sk i {
  display: block;
  height: 0.45rem;
  margin-bottom: 0.45rem;
  background: var(--rule);
}

.site-sk i:nth-child(1) {
  width: 42%;
  height: 0.75rem;
  margin-bottom: 0.6rem;
}

.site-sk i:nth-child(2) {
  width: 88%;
}

.site-sk i:nth-child(3) {
  width: 70%;
}

.chat {
  width: min(100%, 22rem);
  margin: 1rem 0 0 auto;
  border: 1px solid var(--ink);
  background: var(--sheet);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.chat-head {
  padding: 0.45rem 0.7rem;
  background: var(--ink);
  color: var(--sheet);
  font-weight: 600;
}

.chat-head span {
  color: var(--bar-text);
  font-weight: 400;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.75rem;
}

.msg {
  max-width: 86%;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--ink);
}

.msg.them {
  align-self: flex-end;
  min-height: 2.05rem;
  background: var(--ink);
  color: var(--sheet);
}

.msg.agent {
  align-self: flex-start;
  background: var(--paper);
}

.crm {
  border: 1px solid var(--ink);
  background: var(--sheet);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.5;
}

.crm-head {
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid var(--ink);
  font-weight: 700;
}

.crm-head span {
  color: var(--dim);
  font-weight: 400;
}

.crm-rows {
  margin: 0;
  padding: 0.55rem 0.7rem;
}

.crm-rows div {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  column-gap: 0.6rem;
  padding: 0.15rem 0;
}

.crm-rows dt {
  color: var(--dim);
}

.crm-rows dd {
  margin: 0;
}

.crm-ticket {
  margin: 0 0.7rem 0.7rem;
  border: 1px solid var(--visited);
}

.crm-ticket-head {
  padding: 0.35rem 0.6rem;
  background: var(--visited);
  color: var(--sheet);
  font-weight: 700;
}

.crm-ticket-head span {
  font-weight: 400;
}

.crm-ticket .crm-rows {
  padding: 0.45rem 0.6rem;
}

/* quoting: the command, then the quote document it produced */
.doc {
  position: relative;
  margin: 1.25rem 0 0 1.5rem;
  padding: 1.4rem 1.5rem 1.3rem;
  border: 1px solid var(--ink);
  background: var(--sheet);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.doc::before {
  content: '';
  position: absolute;
  top: calc(-1.25rem - 1px);
  left: 1.25rem;
  height: 1.25rem;
  border-left: 1px dashed var(--ink);
}

.doc-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--ink);
}

.doc-title {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.doc-meta {
  color: var(--dim);
  text-align: right;
}

.doc-parties {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem 1.25rem;
  margin: 0.9rem 0 1rem;
}

.doc-parties dt {
  color: var(--dim);
  font-size: 0.75rem;
}

.doc-parties dd {
  margin: 0;
}

.doc-lines {
  width: 100%;
  border-collapse: collapse;
}

.doc-lines th {
  padding: 0.25rem 0.6rem 0.25rem 0;
  border-bottom: 1px solid var(--ink);
  color: var(--dim);
  font-size: 0.75rem;
  font-weight: 400;
  text-align: left;
}

.doc-lines td {
  padding: 0.3rem 0.6rem 0.3rem 0;
  border-bottom: 1px dotted var(--rule);
  vertical-align: top;
}

.doc-lines .num {
  padding-right: 0;
  text-align: right;
  white-space: nowrap;
}

.doc-lines .sub td {
  color: var(--dim);
}

.doc-lines .total td {
  font-weight: 700;
}

.doc-lines .grand td {
  border-top: 1px solid var(--ink);
  border-bottom: 0;
  padding-top: 0.5rem;
  font-size: 0.9375rem;
}

.doc-stamp {
  display: inline-block;
  margin-top: 1.1rem;
  padding: 0.35rem 0.65rem;
  border: 1.5px solid var(--visited);
  color: var(--visited);
  font-weight: 600;
}

.doc-foot {
  margin-top: 0.9rem;
  padding-top: 0.6rem;
  border-top: 1px dotted var(--rule);
  color: var(--dim);
  font-size: 0.75rem;
}

/* secure search: each run drawn as the pipeline it passes through */
.pipe {
  display: grid;
  gap: 1.5rem;
}

.run + .run {
  padding-top: 1.4rem;
  border-top: 1px dotted var(--rule);
}

.pipe .input {
  background: var(--sheet);
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.stages {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 0;
  margin: 0.9rem 0 0;
  padding: 0;
  list-style: none;
}

.stage {
  display: flex;
  align-items: center;
}

.stage + .stage::before {
  content: '';
  flex: none;
  width: 1.15rem;
  height: 0.6rem;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 10'%3E%3Cpath d='M1 5h21M17.5 1.5 22 5l-4.5 3.5' fill='none' stroke='%2324231f'/%3E%3C/svg%3E") center / contain no-repeat;
}

.stage-box {
  min-width: 8rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--ink);
  background: var(--sheet);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.4;
}

.stage-name {
  font-weight: 700;
}

.stage-by {
  color: var(--dim);
}

.stage-out {
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  border-top: 1px dotted var(--rule);
}

.stage-out.is-stop {
  color: var(--visited);
  font-weight: 700;
}

.stage.is-skipped .stage-box {
  border-style: dashed;
  color: var(--dim);
}

.pages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  gap: 0.5rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.pg {
  padding: 0.4rem 0.55rem;
  border: 1px dashed var(--ink);
  background: var(--paper);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.pg-verdict {
  display: block;
  margin-top: 0.25rem;
  color: var(--dim);
}

.pg-verdict.is-bad {
  color: var(--visited);
  font-weight: 700;
}

/* the flagged page takes the warning colour once its verdict is in */
.pg:has(.is-bad) {
  border: 1.5px solid var(--visited);
  transition: border-color 0.4s var(--ease);
}

.armed .pg:has(.is-bad:not(.on)) {
  border: 1px dashed var(--ink);
}

.pipe-answer {
  margin-top: 0.9rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--ink);
  background: var(--sheet);
  font-size: 0.875rem;
}

.pipe-answer.is-stop {
  border-color: var(--visited);
}

/* curation: one article becomes four */
.xform {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.mark {
  text-decoration: underline;
  text-decoration-color: var(--ink);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
  transition: text-decoration-color 0.4s var(--ease);
}

.mark::before,
.xf-card::before {
  content: attr(data-n);
  display: inline-block;
  min-width: 1.15em;
  margin-right: 0.3em;
  padding: 0 0.2em;
  background: var(--ink);
  color: var(--sheet);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.4;
  text-align: center;
  transition: opacity 0.4s var(--ease);
}

.armed .mark:not(.on) {
  text-decoration-color: transparent;
}

.armed .mark:not(.on)::before {
  opacity: 0;
}

.xf-cards {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.xf-card {
  position: relative;
  padding: 0.55rem 0.7rem 0.6rem 2.2rem;
  border: 1px solid var(--ink);
  background: var(--sheet);
  font-size: 0.8125rem;
}

.xf-card::before {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  margin: 0;
}

.xf-title {
  font-family: var(--serif);
  font-size: 0.975rem;
  line-height: 1.25;
}

.xf-meta {
  margin-top: 0.15rem;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.xf-steps {
  margin-top: 0.15rem;
  color: var(--dim);
  font-size: 0.75rem;
}

.xf-status {
  margin-top: 0.7rem;
  font-size: 0.8125rem;
}

.xf-status + .xf-status {
  margin-top: 0.25rem;
}

/* portal402: the porting flow as a sequence diagram, drawn message by message */
.seq {
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.35;
}

.seq-lanes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 0.25rem;
}

.seq-lanes span {
  justify-self: center;
  padding: 0.35rem 0.55rem;
  background: var(--ink);
  color: var(--sheet);
  font-weight: 700;
  text-align: center;
}

.seq-body {
  position: relative;
}

.seq-lines i {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px dashed var(--muted);
}

.seq-lines i:nth-child(1) { left: 12.5%; }
.seq-lines i:nth-child(2) { left: 37.5%; }
.seq-lines i:nth-child(3) { left: 62.5%; }
.seq-lines i:nth-child(4) { left: 87.5%; }

.seq-msgs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  row-gap: 0.45rem;
  margin: 0;
  padding: 0.6rem 0;
  list-style: none;
}

/* a message spans the lanes it travels between; its line runs centre to centre */
.seq-msg {
  position: relative;
  padding: 0 0.25rem 0.55rem;
  text-align: center;
  overflow-wrap: anywhere;
}

.seq-msg span {
  padding: 0 0.3rem;
  background: var(--paper);
}

.seq-msg::before {
  content: '';
  position: absolute;
  right: calc(50% / var(--n));
  bottom: 0.2rem;
  left: calc(50% / var(--n));
  border-bottom: 1px solid var(--ink);
}

.seq-msg::after {
  content: '';
  position: absolute;
  right: calc(50% / var(--n));
  bottom: calc(0.2rem - 3px);
  width: 6px;
  height: 6px;
  border-top: 1px solid var(--ink);
  border-right: 1px solid var(--ink);
  transform: rotate(45deg);
}

.seq-msg.back::before {
  border-bottom-style: dashed;
}

.seq-msg.back::after {
  right: auto;
  left: calc(50% / var(--n));
  transform: rotate(-135deg);
}

/* a step a party runs on itself */
.seq-self {
  justify-self: start;
  margin-left: calc(50% / var(--n));
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--ink);
  border-left: 0;
  background: var(--paper);
  overflow-wrap: anywhere;
}

.seq-msg.is-bad,
.seq-self.is-bad {
  color: var(--visited);
  font-weight: 700;
}

.seq-self.is-bad,
.seq-msg.is-bad::before,
.seq-msg.is-bad::after {
  border-color: var(--visited);
}

.seq-run {
  margin: 0.9rem 0 0.4rem;
  padding-top: 0.8rem;
  border-top: 1px dotted var(--rule);
  color: var(--dim);
}

.seq-end {
  margin-top: 0.6rem;
  font-size: 0.8125rem;
}

@media (max-width: 40rem) {
  .sa,
  .xform {
    grid-template-columns: 1fr;
  }

  .chat {
    width: 100%;
  }

  /* stacked under the chat, the record would fill out of view: show the
     lookup straight away and keep only the ticket for the end of the story */
  .armed .crm-rows .reveal {
    opacity: 1;
    transform: none;
  }

  /* branch labels flow under their step instead of hanging past the edge */
  .flow-unit.has-stub {
    margin-bottom: 0;
  }

  .flow-chip {
    justify-self: start;
  }

  .flow-stub {
    position: relative;
    top: auto;
    left: auto;
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
    margin: 0.4rem 0 0 1rem;
  }

  .doc {
    margin-left: 0.75rem;
    padding: 1rem;
  }

  .doc-head {
    flex-direction: column;
    gap: 0.2rem;
  }

  .doc-meta {
    text-align: left;
  }

  .doc-parties {
    grid-template-columns: 1fr;
  }

  .doc-lines .opt {
    display: none;
  }

  .stage-box {
    min-width: 0;
  }

  .seq-lanes span {
    padding: 0.3rem 0.35rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mark,
  .mark::before {
    transition: none;
  }
}

/* ---------- lists of projects ---------- */

.project-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.project-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.2rem 1.5rem;
  align-items: baseline;
  padding: 0.85rem 0;
  border-bottom: 1px dotted var(--rule);
}

.project-name {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 400;
}

.project-item .state {
  color: var(--dim);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.project-item .job-note {
  grid-column: 1;
  margin: 0;
  max-width: 31rem;
  font-size: 0.875rem;
}

.project-list.is-compact .project-name {
  font-size: 1rem;
}

.project-list.is-compact .project-item {
  padding: 0.6rem 0;
}

/* ---------- small screens ---------- */

@media (max-width: 40rem) {
  h1 {
    font-size: 1.65rem;
  }

  .summary div {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }

  .win {
    font-size: 0.75rem;
  }

  .win-body {
    padding: 0.8rem 0.75rem 0.9rem;
  }

  .hit {
    grid-template-columns: 3rem 2.3rem minmax(0, 1fr);
    column-gap: 0.45rem;
  }

  .kv {
    grid-template-columns: 1fr;
  }

  .kv dd {
    margin-bottom: 0.3rem;
  }

  .tt .opt,
  .hood-toggle span {
    display: none;
  }

  .section {
    margin-top: 2.5rem;
  }

  .summary + .section {
    margin-top: 1.75rem;
  }

  .summary div {
    padding: 0.55rem 0;
  }

  .prose .stack {
    flex-direction: column;
    gap: 0.15rem;
  }

  .flow-lane-name {
    width: 100%;
    padding-top: 0;
  }

  .prose .stack {
    margin-left: 0;
    clip-path: none;
  }

  .prose .stack li {
    padding-left: 0;
  }

  .prose .stack li::before {
    content: none;
  }

  .project-item {
    grid-template-columns: 1fr;
  }

  figcaption {
    flex-direction: column;
    gap: 0.3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .bar i,
  .hood,
  .hood-toggle,
  .hood > div,
  .flow-chip,
  .flow-stub,
  .flow-list b {
    transition: none;
  }

  .is-live .caret,
  .hood-toggle.nudge {
    animation: none;
  }
}

/* ---------- code ---------- */

.code-bar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0.75rem;
  background: var(--ink);
  color: var(--bar-text);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.code pre {
  margin: 0;
  padding: 0.9rem 1rem 1rem;
  overflow-x: auto;
  border: 1px solid var(--ink);
  border-top: 0;
  background: var(--sheet);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.55;
  tab-size: 4;
}

.code pre:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.code code {
  font-size: inherit;
}

.code .cm {
  color: var(--dim);
  font-style: italic;
}

/* long files fold to their first lines; projects.js adds the button */
.code.is-folded pre {
  max-height: calc(0.9rem + var(--fold) * 1.55em);
  overflow-y: hidden;
}

.code-more {
  display: block;
  width: 100%;
  padding: 0.45rem 1rem;
  border: 1px solid var(--ink);
  border-top: 1px dashed var(--ink);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-family: var(--mono);
  font-size: 0.75rem;
  text-align: left;
  cursor: pointer;
}

.code-more:hover {
  background: var(--sheet);
}

.code pre:has(+ .code-more) {
  border-bottom: 0;
}
