/* Figure kit drawings. Loaded after atlas-beat.css, which owns the palette (light and dark),
   the caption, the controls, the limit line, and the text version.
   Type is HTML at 13px or larger. Every state has a shape or a mark as well
   as a colour. Heights hold over all steps because each changing value sits
   in a stack with its other values. src/lib/figure-kit.mjs writes the markup. */

/* Without JavaScript the page is the text version in <noscript>. */
html:not(.js) #kit,
html:not(.js) .kit-example,
html:not(.js) #say,
html:not(.js) #controls { display: none; }
.kit-text { font-size: 15px; line-height: 1.5; }
.kit-text p { margin: 0 0 10px; }
.kit-text ol { margin: 0 0 10px; padding-left: 22px; }
.kit-text li { margin: 0 0 6px; }
.steps-text > p { margin: 0 0 8px; }

.kit-example {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 2px 10px;
  margin: 0;
  padding: 8px 10px;
  border-left: 4px solid var(--ink);
  background: var(--tint);
  font-size: 14px;
  line-height: 1.4;
}
.kit-example dt { font-size: 13px; line-height: 1.5; font-weight: 700; color: var(--muted); }
.kit-example dd { margin: 0; overflow-wrap: anywhere; }

.kit { display: grid; gap: 8px; min-width: 0; }
.kit .kicker { margin: 0; }
.kit-stack { display: grid; min-width: 0; }
.kit-stack > * { grid-area: 1 / 1; min-width: 0; visibility: hidden; }
.kit-stack > [data-on] { visibility: visible; }

/* One box language for all six templates.
   idle: dashed and empty. now: the thing this step changed. done: settled. */
.kit-box {
  min-width: 0;
  padding: 8px 10px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--card);
}
.kit-box[data-s="idle"] { border-style: dashed; border-color: var(--idle); background: transparent; }
.kit-box[data-s="now"] { border-color: var(--act); box-shadow: 0 0 0 3px var(--glow); }
.kit-wait { display: block; min-height: 20px; }
.kit-cell {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.kit-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 99px;
  background: var(--pass);
  color: var(--on-act);
  font-size: 12px;
  line-height: 1;
  font-weight: 800;
}
[data-tone="fail"] > .kit-mark { background: var(--fail); }
[data-tone="warn"] > .kit-mark { background: var(--warn); border-radius: 4px; }
.kit-label { font-size: 15px; line-height: 1.3; font-weight: 700; }
.kit-sub { font-size: 13px; line-height: 1.35; color: var(--muted); }

/* compare */
.kit-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.kit-pair > .kit-both { grid-column: 1 / -1; }
.kit-cols { padding-bottom: 6px; border-bottom: 2px solid var(--ink); }
.kit-col { margin: 0; }
.kit-col b { display: block; font-size: 16px; line-height: 1.3; }
.kit-col span { display: block; font-size: 13px; line-height: 1.35; color: var(--muted); }
.kit-row { display: grid; gap: 4px; }

/* flow */
.kit-flow { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.kit-node { display: grid; gap: 2px; align-content: start; }
.kit-node .kit-stack { margin-top: 4px; }
.kit-node .kit-cell, .kit-check { font-size: 14px; line-height: 1.35; }
.kit-check { color: var(--muted); }
.kit-token {
  justify-self: start;
  margin-bottom: 2px;
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--act);
  color: var(--on-act);
  font-size: 13px;
  line-height: 1.4;
  font-weight: 700;
  visibility: hidden;
}
.kit-token[data-on] { visibility: visible; }
.kit-edge { position: relative; flex: none; height: 18px; }
.kit-edge::before {
  content: '';
  position: absolute;
  left: 22px;
  top: 0;
  bottom: 0;
  border-left: 2px solid var(--ink);
}
.kit-edge::after {
  content: '';
  position: absolute;
  left: 18px;
  bottom: 1px;
  border: 5px solid transparent;
  border-top: 7px solid var(--ink);
  border-bottom: 0;
}
@media (min-width: 640px) {
  .kit-flow { flex-direction: row; }
  .kit-node { flex: 1 1 0; }
  .kit-edge { width: 22px; height: auto; }
  .kit-edge::before { left: 0; right: 0; top: 30px; bottom: auto; border-left: 0; border-top: 2px solid var(--ink); }
  .kit-edge::after {
    left: auto;
    right: 0;
    top: 26px;
    bottom: auto;
    border: 5px solid transparent;
    border-left: 7px solid var(--ink);
    border-right: 0;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .kit-token[data-on] { animation: kit-arrive 0.2s ease-out; }
  [data-dir="back"] .kit-token[data-on] { animation-name: kit-return; }
}
@keyframes kit-arrive { from { opacity: 0; transform: translate(-10px, -10px); } }
@keyframes kit-return { from { opacity: 0; transform: translate(10px, 10px); } }

/* ledger */
.kit-record { display: grid; gap: 8px; }
.kit-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; justify-content: space-between; }
.kit-status { padding: 2px 8px; border: 2px solid var(--ink); border-radius: 99px; }
.kit-status[data-s="now"] { border-color: var(--act); box-shadow: 0 0 0 3px var(--glow); }
.kit-status .kit-cell { justify-content: center; font-size: 13px; line-height: 1.5; font-weight: 700; }
.kit-status .kit-mark { margin-top: 1px; }
.kit-fields { display: grid; gap: 6px; margin: 0; }
.kit-field {
  display: grid;
  gap: 2px 10px;
  padding: 6px 8px;
  border: 2px solid var(--line);
  border-radius: 6px;
}
.kit-field[data-s="idle"] { border-style: dashed; border-color: var(--idle); }
.kit-field[data-s="now"] { border-color: var(--act); box-shadow: 0 0 0 3px var(--glow); }
.kit-field dt { font-size: 13px; line-height: 1.5; font-weight: 700; color: var(--muted); }
.kit-field dd { margin: 0; min-width: 0; }
@media (min-width: 480px) {
  .kit-field { grid-template-columns: 118px minmax(0, 1fr); }
}

/* timeline */
.kit-timeline { display: grid; margin: 0; padding: 0; list-style: none; }
.kit-event {
  position: relative;
  display: grid;
  grid-template-columns: 76px 14px minmax(0, 1fr);
  gap: 0 10px;
  padding-bottom: 12px;
}
.kit-event:last-child { padding-bottom: 0; }
.kit-time { display: grid; gap: 2px; justify-items: end; align-content: start; text-align: right; }
.kit-time b { font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.kit-now {
  padding: 0 7px;
  border-radius: 99px;
  background: var(--act);
  color: var(--on-act);
  font-size: 13px;
  line-height: 1.4;
  font-weight: 700;
  visibility: hidden;
}
.kit-now[data-on] { visibility: visible; }
.kit-dot {
  position: relative;
  z-index: 1;
  width: 14px;
  height: 14px;
  margin-top: 3px;
  border: 2px solid var(--ink);
  border-radius: 99px;
  background: var(--ink);
}
.kit-event::before {
  content: '';
  position: absolute;
  left: 92px;
  top: 3px;
  bottom: -3px;
  border-left: 2px solid var(--ink);
}
.kit-event:last-child::before { content: none; }
.kit-event[data-s="idle"] .kit-dot { border-style: dashed; border-color: var(--idle); background: var(--paper); }
.kit-event[data-s="idle"] .kit-label { color: var(--muted); }
.kit-event[data-s="now"] .kit-dot { border-color: var(--act); background: var(--act); box-shadow: 0 0 0 4px var(--glow); }
.kit-body { display: grid; gap: 2px; min-width: 0; }
.kit-body .kit-label { overflow-wrap: anywhere; }
.kit-body .kit-cell { font-size: 14px; }

/* tree */
.kit-tree, .kit-tree ul { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.kit-tree ul { margin: 6px 0 0 9px; padding-left: 11px; border-left: 2px solid var(--ink); }
.kit-tnode { display: grid; gap: 1px; padding: 6px 10px; }
.kit-tnode[data-s="idle"] { color: var(--muted); }
.kit-answer { font-size: 13px; line-height: 1.4; font-weight: 700; color: var(--muted); }

/* matrix */
.kit-matrix { display: grid; gap: 6px; }
.kit-mrow { display: grid; gap: 4px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
[data-cols="2"] > .kit-mrow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kit-mrow > span { font-size: 13px; line-height: 1.35; font-weight: 700; overflow-wrap: anywhere; }
.kit-mhead > span { align-self: end; padding: 0 2px; color: var(--muted); }
.kit-rowhead { grid-column: 1 / -1; padding: 2px 2px 0; }
.kit-corner {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
/* A 12-letter word such as Minimization fits a 3-column cell at 320px. */
.kit-matrix .kit-box { padding: 6px 4px; }
.kit-matrix .kit-cell { flex-direction: column; gap: 3px; font-size: 13px; }
.kit-matrix .kit-mark { margin-top: 0; }
@media (min-width: 480px) {
  .kit-mrow { grid-template-columns: minmax(0, 1.3fr) repeat(3, minmax(0, 1fr)); }
  [data-cols="2"] > .kit-mrow { grid-template-columns: minmax(0, 1.3fr) repeat(2, minmax(0, 1fr)); }
  .kit-rowhead { grid-column: auto; align-self: center; padding: 0 2px; }
  .kit-corner { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; }
  .kit-matrix .kit-box { padding: 8px 10px; }
  .kit-matrix .kit-cell { flex-direction: row; gap: 6px; font-size: 14px; }
}
