/* How it goes (#how): the pipeline that forks after the warning, the warning translated, licensed AI products
   paying the way the publisher chooses, and the record. Every rule here draws the finished picture.
   how-graphics.js holds parts at their start and plays each once, so without JavaScript or with reduced
   motion this is what shows. */

#how .stage { position: relative; }

/* ---------- the pipeline, sticky under the install note beside the stages ---------- */
/* The line runs down the left edge through Observe and Warn, and forks just after Warn:
   straight down to License, across and down to Enforce. Lines are 2px boxes, so drawing them is a scale. */
.pipeline { margin-top: 48px; }
.pipeline__map { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding-top: 156px; }
.pipe-seg { position: absolute; left: 13px; width: 2px; transform-origin: top; }
.pipe-seg--warn { top: 34px; height: 36px; background: var(--yellow); }
.pipe-seg--stem { top: 110px; height: 19px; background: var(--yellow); }
.pipe-seg--license { top: 128px; height: 22px; background: var(--green); }
.pipe-seg--enforce-h { top: 127px; width: calc(50% + 2px); height: 2px; background: var(--vermillion); transform-origin: left; }
.pipe-seg--enforce-v { top: 127px; left: calc(50% + 13px); height: 23px; background: var(--vermillion); }
.pipe-node { display: flex; align-items: center; gap: 12px; font-size: 1.125rem; font-weight: 700; line-height: 28px; color: var(--ink); }
.pipe-node--observe, .pipe-node--warn { position: absolute; left: 0; }
.pipe-node--observe { top: 0; }
.pipe-node--warn { top: 76px; }
.pipe-dot { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border: 2px solid currentColor; border-radius: 50%; }
.pipe-fill { width: 14px; height: 14px; border-radius: 50%; background: currentColor; }
.pipe-end { display: block; padding-right: 16px; }
.pipe-note { display: block; max-width: 22ch; margin: 8px 0 0 40px; font-size: 1rem; line-height: 1.45; color: var(--ink-muted); }

/* ---------- the warning, translated ---------- */
.terms { display: grid; gap: 14px; }
.code-fragment .term__code { display: block; font: 500 0.875rem/1.75 var(--font-code); white-space: pre-wrap; overflow-wrap: break-word; color: var(--ink); }
.code-fragment .tok-allow { color: var(--green); }
.term__chip {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; padding: 2px 10px;
  border-radius: 4px; background: var(--spot-gray);
  font-size: 0.875rem; font-weight: 600; line-height: 1.6; color: var(--ink);
}
.term__chip::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--chip); }
.term__chip--free { --chip: var(--green); }
.term__chip--paid { --chip: var(--yellow); }
.term__chip--deny { --chip: var(--vermillion); }
/* The script adds a caret to each line while the terms type in; at rest it is hidden. Zero width, so no line rewraps. */
.term__caret { position: relative; display: inline-block; width: 0; height: 1.2em; vertical-align: -0.25em; opacity: 0; }
.term__caret::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 0.55em; background: var(--yellow); }

/* ---------- licensed AI products pay the way you choose ---------- */
.licflow { grid-column: 2; margin-top: 24px; padding: 22px 24px; background: var(--dark-slate); border-radius: 8px; container-type: inline-size; }
.licflow__card { position: relative; display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 6px; background: var(--spot-gray); font-weight: 700; line-height: 1.3; }
.licflow__icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border: 2px solid currentColor; border-radius: 50%; color: var(--ink); }
.licflow__card--ai .licflow__icon { color: var(--green); }
.licflow__icon svg, .licflow__token svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.licflow__pulse { position: absolute; top: 50%; left: 16px; width: 36px; height: 36px; margin-top: -18px; border: 2px solid var(--green); border-radius: 50%; opacity: 0; }
/* Clean copy runs down the left lane to the AI product, and the payment runs up the right lane to you. */
.licflow__mid { position: relative; padding: 16px 44px; }
.licflow__lane { position: absolute; top: 0; bottom: 0; width: 28px; }
.licflow__lane--copy { left: 6px; }
.licflow__lane--pay { right: 6px; }
.licflow__line { position: absolute; top: 4px; bottom: 4px; left: 13px; width: 2px; background: var(--green); }
.licflow__head { position: absolute; left: 8px; width: 12px; height: 8px; fill: none; stroke: var(--green); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.licflow__lane--copy .licflow__head { bottom: 2px; }
.licflow__lane--pay .licflow__head { top: 2px; }
.licflow__token { position: absolute; left: 1px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; }
.licflow__token svg { width: 14px; height: 14px; stroke-width: 2.2; }
.licflow__token--copy { bottom: 14px; border: 2px solid var(--green); background: var(--dark-slate); color: var(--green); }
.licflow__token--pay { top: 14px; background: var(--green); color: var(--frog-black); }
.licflow__lanes { display: flex; justify-content: space-between; gap: 12px; font-size: 0.875rem; line-height: 1.4; color: var(--ink-muted); }
.licflow__routes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.licflow__routes li { display: grid; place-items: center; padding: 10px 12px; border-radius: 6px; background: var(--frog-black); font-size: 1rem; font-weight: 600; line-height: 1.35; text-align: center; }
.licflow figcaption { margin-top: 16px; font-size: 0.875rem; line-height: 1.55; color: var(--ink-muted); }
@container (max-width: 400px) {
  .licflow__mid { padding-inline: 34px; }
  .licflow__lane--copy { left: 0; }
  .licflow__lane--pay { right: 0; }
  .licflow__routes li { padding: 8px; font-size: 0.875rem; }
}

/* ---------- the record ---------- */
/* The entry on top, then the caption with the stamp across the bottom right corner. */
.record {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; align-items: end;
  grid-column: 2; margin-top: 24px; padding: 22px 24px; background: var(--dark-slate); border-radius: 8px;
  container-type: inline-size;
}
.record__entry { grid-column: 1 / -1; display: grid; gap: 10px; }
.record__row { display: grid; grid-template-columns: 9.5em minmax(0, 1fr); column-gap: 16px; align-items: baseline; }
.record__row dt { font-size: 0.875rem; line-height: 1.6; color: var(--ink-muted); }
.record samp { font: 500 0.875rem/1.6 var(--font-code); color: var(--ink); overflow-wrap: anywhere; }
.record__stamp {
  grid-area: 2 / 2; margin: 20px -6px -4px 0;
  padding: 4px 12px; border: 3px solid var(--vermillion); border-radius: 6px;
  color: var(--vermillion-text); font-size: 1.125rem; font-weight: 800; line-height: 1.3;
  rotate: -6deg;
}
.record figcaption { grid-area: 2 / 1; margin-top: 16px; font-size: 0.875rem; line-height: 1.55; color: var(--ink-muted); }
.stage .record-paper { grid-column: 2; margin-top: 16px; font-size: 1rem; line-height: 1.5; }
/* A narrow card puts each label above its value, and the stamp above the caption. */
@container (max-width: 500px) {
  .record__row { grid-template-columns: minmax(0, 1fr); }
}
@container (max-width: 380px) {
  .record__stamp { grid-area: 2 / 1; justify-self: start; margin: 20px 0 0; }
  .record figcaption { grid-area: 3 / 1 / 4 / -1; }
}

/* ---------- the rail and the fork, once the stages run full width ---------- */
.stage-rail, .how-fork { display: none; }

@media (max-width: 1100px) {
  .pipeline { display: none; }
  /* The rail runs from orb to orb, and from the Warn orb into the fork's stem at the end of the stage. */
  .stage-rail { position: absolute; left: 23px; display: block; width: 2px; background: var(--yellow); transform-origin: top; }
  .stage-rail--observe { top: 56px; bottom: -44px; }
  .stage-rail--warn { top: 56px; bottom: 128px; }
  #how .code-fragment { position: relative; z-index: 1; }
  .how-fork { grid-column: 1 / -1; display: grid; grid-template-columns: 48px minmax(0, 1fr); column-gap: 24px; height: 128px; margin-top: 32px; }
  .how-fork__lines { width: 48px; height: 128px; overflow: visible; fill: none; stroke-width: 2; stroke-dasharray: 1; }
  .how-fork__stem { stroke: var(--yellow); }
  .how-fork__branch--license { stroke: var(--green); }
  .how-fork__branch--enforce { stroke: var(--vermillion); }
  .how-fork__chips { position: relative; display: grid; grid-template-rows: 56px 56px; row-gap: 16px; justify-items: start; }
  .fork-chip {
    display: flex; flex-direction: column; justify-content: center; min-width: min(100%, 220px); height: 56px; padding: 0 16px;
    border-left: 3px solid var(--chip); border-radius: 0 6px 6px 0; background: var(--dark-slate);
    font-size: 0.875rem; line-height: 1.35; color: var(--ink-muted); text-decoration: none;
  }
  .fork-chip strong { font-size: 1rem; color: var(--ink); }
  .fork-chip:hover strong { color: var(--yellow); }
  .fork-chip--license { --chip: var(--green); }
  .fork-chip--enforce { --chip: var(--vermillion); }
}

@media (max-width: 760px) {
  /* At 28px the heading takes three lines on a phone; this size keeps it to two from 320px up. */
  .how-title { font-size: min(5.9vw, 1.75rem); }
  .stage-rail { left: 19px; }
  .stage-rail--observe, .stage-rail--warn { top: 48px; }
  .how-fork { grid-template-columns: 40px minmax(0, 1fr); column-gap: 16px; }
  .how-fork__lines { margin-left: -4px; }
  .licflow, .record, .stage .record-paper { grid-column: 1 / -1; }
  .licflow, .record { padding-inline: 18px; }
  .licflow__mid { padding-inline: 36px; }
  .licflow__lane--copy { left: 0; }
  .licflow__lane--pay { right: 0; }
}
