/* Long reads (front matter `longform: on`), loaded after blog.css: the kinetic title and pull lines, counters, data
   charts (drawn at build time by scripts/charts.py into the blog's .bars, plus a stacked bar), data tables, the request
   path, the guard ladder, the claim-and-record card, the before/after cards and the end note. Colour keeps the blog's
   meanings: copper = what failed or needs attention, slate = the fix, the system working, the subject; graphite and
   stone = structure. Selectors start with .prose where they must beat .prose defaults. Motion: inside
   prefers-reduced-motion: no-preference and html:not(.motion-paused); scroll-started states also need html.lf-js (set
   by longform.js), so the page reads in full, in its final state, with no script, reduced motion or the motion switch. */

/* kinetic lines: a pull line set large; longform.js splits it into words that rise in turn */
.prose .lf-kinetic { max-width: 26ch; margin-block: 0.5rem; padding-left: 1rem; border-left: 3px solid var(--accent-line); font: 400 clamp(1.75rem, 4.6vw, 2.75rem)/1.1 var(--serif); letter-spacing: -0.03em; color: var(--fg); text-wrap: balance; }
.lf-kinetic .w { display: inline-block; }

/* counters and charts */
.stat strong[data-count], .lf-chart [data-count] { font-variant-numeric: lining-nums tabular-nums; }
.lf-num { display: inline-grid; }  /* the final figure, invisible, holds the width while the count runs: no reflow */
.lf-num > span { grid-area: 1 / 1; }
.lf-num-final { visibility: hidden; }
.stat strong span { font-size: inherit; line-height: inherit; color: inherit; }  /* blog.css styles every .stat span as the caption */
.lf-chart { display: grid; gap: 0.55rem; margin: 0.5rem 0; }
.prose .lf-chart-title { font: 600 1.0625rem/1.35 var(--sans); color: var(--fg); }
.prose .lf-group { margin-top: 0.35rem; font: 500 0.8125rem/1.35 var(--mono); letter-spacing: 0.05em; text-transform: uppercase; color: var(--fg-3); }
.lf-chart .fill, .lf-stackbar .seg { transform-box: fill-box; transform-origin: left center; }
.lf-stackbar { width: 100%; height: 30px; border-top: 1px solid var(--fg); padding-top: 0.5rem; box-sizing: content-box; }
.lf-stackbar .seg { fill: var(--fg-2); stroke: var(--bg); stroke-width: 2; vector-effect: non-scaling-stroke; }
.lf-stackbar .seg.fix { fill: var(--tech-line); }
.lf-stackbar .seg.muted { fill: var(--line-2); }
.lf-stackbar .seg.free { fill: var(--bg); stroke: var(--line-2); stroke-dasharray: 3 3; }
.prose .lf-legend { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.4rem 1.5rem; }
.prose .lf-legend li { display: grid; grid-template-columns: 0.8rem minmax(0, 1fr) auto; gap: 0.6rem; align-items: baseline; max-width: none; font-size: 0.9375rem; }
.lf-legend .sw { width: 0.8rem; height: 0.8rem; align-self: center; background: var(--fg-2); }
.lf-legend .sw.fix { background: var(--tech-line); }
.lf-legend .sw.muted { background: var(--line-2); }
.lf-legend .sw.free { background: transparent; border: 1px dashed var(--line-2); }
.lf-legend b { font-weight: 500; color: var(--fg); }
.lf-legend span { font: 500 0.875rem/1.5 var(--mono); color: var(--fg-2); font-variant-numeric: tabular-nums; }

/* the author's data tables */
.lf-table-wrap { overflow-x: auto; }
.lf-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; line-height: 1.45; }
.lf-table th, .lf-table td { padding: 0.65rem 0.75rem 0.65rem 0; border-top: 1px solid var(--line); text-align: left; vertical-align: top; font-weight: 400; }
.lf-table thead th { border-top: 1px solid var(--fg); font: 500 0.8125rem/1.35 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-3); }
.lf-table tbody th { font-weight: 500; color: var(--fg); }
.lf-table td { color: var(--fg-2); font-variant-numeric: tabular-nums; }

/* the request path: three stops light, the lamp goes off, the rest are never reached */
.lf-path { display: grid; gap: 0.6rem; margin: 0.6rem 0; }
.prose .lf-hops { list-style: none; padding: 0; gap: 0; }
.prose .lf-hops .hop { position: relative; display: grid; gap: 0.05rem; padding: 0.5rem 0 0.75rem 2.25rem; max-width: none; }
.hop::before { content: ""; position: absolute; left: 0.4rem; top: 0.8rem; width: 0.8rem; height: 0.8rem; border-radius: 50%; border: 2px solid var(--tech-line); background: var(--bg); box-sizing: border-box; }
.hop::after { content: ""; position: absolute; left: calc(0.8rem - 1px); top: 1.6rem; bottom: -0.8rem; width: 2px; background: var(--tech-line); transform-origin: top; }
.hop:last-child::after { display: none; }
.hop.on::before { background: var(--tech-line); }
.hop.exit::after, .hop.unused::after { width: 0; background: none; border-left: 2px dashed var(--line-2); }
.hop.unused::before { border-color: var(--line-2); }
.hop b { font-weight: 600; color: var(--fg); }
.hop span { font-size: 0.9375rem; color: var(--fg-2); }
.hop.unused b, .hop.unused span { color: var(--fg-3); font-weight: 400; }
.hop .lf-lamp { justify-self: start; display: inline-flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem; padding: 0.3rem 0.6rem; border: 1px solid var(--tech-line); font: 500 0.8125rem/1.2 var(--mono); letter-spacing: 0.05em; text-transform: uppercase; color: var(--tech); }
.lf-lamp::before { content: ""; width: 0.75rem; height: 0.75rem; border-radius: 50%; border: 1.5px solid currentColor; box-sizing: border-box; }

/* the guard ladder: each rung asks more */
.lf-guard { display: grid; gap: 0.6rem; margin: 0.6rem 0; }
.prose .lf-rungs { list-style: none; padding: 0; gap: 0.45rem; }
.prose .lf-rungs li { display: grid; grid-template-columns: 5.25rem minmax(0, 1fr); grid-template-areas: "b s" "b e"; gap: 0.1rem 0.9rem; max-width: none; padding: 0.7rem 0.9rem; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line-2); }
.prose .lf-rungs li:nth-child(2) { margin-left: 4%; border-left-color: var(--tech-line); }
.prose .lf-rungs li:nth-child(3) { margin-left: 8%; border-left-color: var(--tech); }
.prose .lf-rungs li:nth-child(4) { margin-left: 12%; border-left-color: var(--accent-line); }
.lf-rungs b { grid-area: b; font: 600 1rem/1.4 var(--sans); color: var(--fg); }
.lf-rungs span { grid-area: s; font-size: 0.9375rem; color: var(--fg-2); }
.lf-rungs em { grid-area: e; font: 500 0.8125rem/1.45 var(--mono); font-style: normal; letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-3); }
.lf-rungs li:nth-child(4) em { color: var(--accent); }

/* claim and record: what Fred said beside what the task record showed */
.lf-claim { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); margin: 0.6rem 0; border-top: 1px solid var(--fg); border-left: 1px solid var(--line); }
.lf-said, .lf-record { display: grid; gap: 0.6rem; align-content: start; padding: 1rem 1.15rem 1.2rem; background: var(--surface); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.prose .lf-quote { font: 400 clamp(1.5rem, 3.6vw, 2rem)/1.15 var(--serif); letter-spacing: -0.02em; color: var(--fg); }
.lf-record dl { margin: 0; display: grid; gap: 0.4rem; }
.lf-record dl div { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--line); }
.lf-record dt { color: var(--fg-2); }
.lf-record dd { margin: 0; font: 600 1.125rem/1.3 var(--mono); color: var(--accent); }
.prose .lf-stamp { justify-self: start; margin-top: 0.3rem; padding: 0.35rem 0.65rem; border: 2px solid var(--accent-line); font: 600 0.875rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); transform: rotate(-3deg); }

/* before and after (blog.css .compare) */
.lf-ba { overflow-x: clip; }  /* the boxes slide in from the sides; never a sideways scroll */
.lf-ba strong { font-size: clamp(1.75rem, 4vw, 2.25rem); line-height: 1.05; }
.prose .lf-ba p { font-size: 1rem; }

/* end note */
.prose hr { width: 100%; margin: 2.5rem 0 0.25rem; border: 0; border-top: 1px solid var(--line); }
.lf-endnote { padding: 1rem 1.15rem; background: var(--surface); border-left: 3px solid var(--tech-line); }
.prose .lf-endnote p { font-size: 0.9375rem; line-height: 1.6; color: var(--fg-2); }

@media (max-width: 34rem) {
  .prose .lf-rungs li { grid-template-columns: 1fr; grid-template-areas: "b" "s" "e"; }
}

/* motion: the title rises on arrival; the rest starts when it scrolls into view. Delays carry the same guard as the
   transitions: a delay alone still starts a zero-length transition, which would hold a paused page's final state back. */
@media (prefers-reduced-motion: no-preference) {
  html:not(.motion-paused) .post-title { animation: lf-rise 0.9s var(--ease) 0.05s both; }
  html:not(.motion-paused) .post-title .hi { animation: lf-rise 0.9s var(--ease) 0.4s both; }
  @keyframes lf-rise { from { clip-path: inset(0 0 100% 0); transform: translateY(0.3em); } to { clip-path: inset(-0.2em -0.2em -0.3em -0.2em); transform: none; } }

  html.lf-js:not(.motion-paused) [data-reveal] { transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
  html.lf-js:not(.motion-paused) [data-reveal]:not(.is-in) { opacity: 0; transform: translateY(28px); }

  html.lf-js:not(.motion-paused) .lf-kinetic .w { transition: opacity 0.55s var(--ease), transform 0.55s var(--ease); }
  html.lf-js:not(.motion-paused) .lf-kinetic:not(.is-in) .w { opacity: 0; transform: translateY(0.45em); }
  html.lf-js:not(.motion-paused) .lf-kinetic .w:nth-child(2) { transition-delay: 70ms; } html.lf-js:not(.motion-paused) .lf-kinetic .w:nth-child(3) { transition-delay: 140ms; }
  html.lf-js:not(.motion-paused) .lf-kinetic .w:nth-child(4) { transition-delay: 210ms; } html.lf-js:not(.motion-paused) .lf-kinetic .w:nth-child(5) { transition-delay: 280ms; }
  html.lf-js:not(.motion-paused) .lf-kinetic .w:nth-child(6) { transition-delay: 350ms; } html.lf-js:not(.motion-paused) .lf-kinetic .w:nth-child(7) { transition-delay: 420ms; }
  html.lf-js:not(.motion-paused) .lf-kinetic .w:nth-child(8) { transition-delay: 490ms; } html.lf-js:not(.motion-paused) .lf-kinetic .w:nth-child(9) { transition-delay: 560ms; }
  html.lf-js:not(.motion-paused) .lf-kinetic .w:nth-child(10) { transition-delay: 630ms; } html.lf-js:not(.motion-paused) .lf-kinetic .w:nth-child(11) { transition-delay: 700ms; }
  html.lf-js:not(.motion-paused) .lf-kinetic .w:nth-child(12) { transition-delay: 770ms; } html.lf-js:not(.motion-paused) .lf-kinetic .w:nth-child(13) { transition-delay: 840ms; }
  html.lf-js:not(.motion-paused) .lf-kinetic .w:nth-child(n+14) { transition-delay: 910ms; }

  html.lf-js:not(.motion-paused) .lf-chart .fill { transition: transform 1.1s var(--ease) 0.15s; }
  html.lf-js:not(.motion-paused) .lf-chart:not(.is-in) .fill { transform: scaleX(0); }
  html.lf-js:not(.motion-paused) .lf-stackbar .seg { transition: transform 0.6s var(--ease); }
  html.lf-js:not(.motion-paused) .lf-stack:not(.is-in) .seg { transform: scaleX(0); }
  html.lf-js:not(.motion-paused) .lf-stackbar .seg:nth-child(2) { transition-delay: 0.5s; } html.lf-js:not(.motion-paused) .lf-stackbar .seg:nth-child(3) { transition-delay: 1s; }
  html.lf-js:not(.motion-paused) .lf-stackbar .seg:nth-child(4) { transition-delay: 1.3s; } html.lf-js:not(.motion-paused) .lf-stackbar .seg:nth-child(5) { transition-delay: 1.6s; }

  /* the request path: dots fill and lines draw down to the hub, the lamp goes out, then the unused stops appear */
  html.lf-js:not(.motion-paused) .hop::before, html.lf-js:not(.motion-paused) .lf-lamp::before { transition: background-color 0.35s ease, box-shadow 0.35s ease; }
  html.lf-js:not(.motion-paused) .hop::after { transition: transform 0.35s linear; }
  html.lf-js:not(.motion-paused) .hop.unused { transition: opacity 0.5s ease; }
  html.lf-js:not(.motion-paused) .lf-path:not(.is-in) .hop.on::before { background: var(--bg); }
  html.lf-js:not(.motion-paused) .lf-path:not(.is-in) .hop.on::after { transform: scaleY(0); }
  html.lf-js:not(.motion-paused) .lf-path:not(.is-in) .lf-lamp::before { background: var(--accent-line); box-shadow: 0 0 0 5px rgba(189, 105, 71, 0.25); }
  html.lf-js:not(.motion-paused) .lf-path:not(.is-in) .hop.unused { opacity: 0; }
  html.lf-js:not(.motion-paused) .hop:nth-child(1)::after { transition-delay: 0.35s; }
  html.lf-js:not(.motion-paused) .hop:nth-child(2)::before { transition-delay: 0.7s; } html.lf-js:not(.motion-paused) .hop:nth-child(2)::after { transition-delay: 1s; }
  html.lf-js:not(.motion-paused) .hop:nth-child(3)::before { transition-delay: 1.35s; } html.lf-js:not(.motion-paused) .lf-lamp::before { transition-delay: 1.9s; }
  html.lf-js:not(.motion-paused) .hop:nth-child(4) { transition-delay: 2.4s; } html.lf-js:not(.motion-paused) .hop:nth-child(5) { transition-delay: 2.6s; }
  html.lf-js:not(.motion-paused) .hop:nth-child(6) { transition-delay: 2.8s; } html.lf-js:not(.motion-paused) .hop:nth-child(7) { transition-delay: 3s; }

  /* the guard ladder builds rung by rung */
  html.lf-js:not(.motion-paused) .lf-rungs li { transition: opacity 0.5s var(--ease), transform 0.5s var(--ease); }
  html.lf-js:not(.motion-paused) .lf-guard:not(.is-in) .lf-rungs li { opacity: 0; transform: translateY(14px); }
  html.lf-js:not(.motion-paused) .lf-rungs li:nth-child(1) { transition-delay: 0.25s; } html.lf-js:not(.motion-paused) .lf-rungs li:nth-child(2) { transition-delay: 0.5s; }
  html.lf-js:not(.motion-paused) .lf-rungs li:nth-child(3) { transition-delay: 0.75s; } html.lf-js:not(.motion-paused) .lf-rungs li:nth-child(4) { transition-delay: 1s; }

  /* claim and record: the sentence types out, the record answers, the stamp lands */
  html.lf-js:not(.motion-paused) .lf-quote { transition: clip-path 1.1s steps(24, end) 0.3s; }
  html.lf-js:not(.motion-paused) .lf-claim:not(.is-in) .lf-quote { clip-path: inset(0 100% 0 0); }
  html.lf-js:not(.motion-paused) .lf-record dl div { transition: opacity 0.4s ease; }
  html.lf-js:not(.motion-paused) .lf-claim:not(.is-in) .lf-record dl div { opacity: 0; }
  html.lf-js:not(.motion-paused) .lf-record dl div:nth-child(1) { transition-delay: 1.6s; } html.lf-js:not(.motion-paused) .lf-record dl div:nth-child(2) { transition-delay: 1.9s; }
  html.lf-js:not(.motion-paused) .lf-stamp { transition: opacity 0.25s ease 2.4s, transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1) 2.4s; }
  html.lf-js:not(.motion-paused) .lf-claim:not(.is-in) .lf-stamp { opacity: 0; transform: rotate(-3deg) scale(1.8); }

  /* before and after slide in from their sides */
  html.lf-js:not(.motion-paused) .lf-ba .box { transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); }
  html.lf-js:not(.motion-paused) .lf-ba:not(.is-in) .box.warn { opacity: 0; transform: translateX(-24px); }
  html.lf-js:not(.motion-paused) .lf-ba:not(.is-in) .box.good { opacity: 0; transform: translateX(24px); }
  html.lf-js:not(.motion-paused) .lf-ba .box.good { transition-delay: 0.45s; }
}
