/* Fit-and-shift lab (the-model-that-tested-well post, "Try It: Next Year's Invoices"): token-driven only. Every colour is
   a site token, so light and dark follow the tokens and no theme-specific rule is needed (none is written; a dark rule
   added later is written twice, per docs/STYLE.md). Faces as the other labs: the site sans for controls, counts and marks;
   the serif for what the reader reads (the illustrative note, the stop's change and the caption). Two weights (400,
   600), no italic, sentence case. Loaded by the post itself.
   Every state is a shape, a word and a colour, and the colour is never the only cue: routed is a filled square in muted
   ink (with the outcomes shown, routed right keeps it: nothing about a right route changes when you look); routed wrong
   is an open square crossed by an X, in coral; sent to a person is an open circle, in violet. Not known is a dashed
   box holding "?". Each counter row carries the same mark, its number and the post's word. */
.fit-shift-lab {
  --fsl-target: 2.75rem; /* 44 CSS px touch target (WCAG 2.5.5) */
  --fsl-line: 0.0625rem;
  --fsl-mid: 0.125rem;
  --fsl-gap: 0.125rem; /* between squares */
  --fsl-cols: 20; /* squares per row: 20 x 10 for 200 at full width */
  --fsl-routed: var(--color-text-muted);
  --fsl-wrong: var(--color-pop-coral-text);
  --fsl-person: var(--color-pop-violet-text);
  --fsl-change: 480ms; /* docs/FIGURES.md 4.4: reveal */
  margin: var(--space-lg) 0;
  padding: var(--space-md);
  border: var(--fsl-line) solid var(--color-border);
  border-radius: 0.5em;
  background: var(--color-bg-alt);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 400;
  font-style: normal;
  line-height: 1.45;
  max-width: 100%;
  min-width: 0;
}
.fit-shift-lab[hidden], .fit-shift-lab [hidden] { display: none !important; }
.fit-shift-lab :where(p) { margin: 0; padding: 0; }
.fit-shift-lab strong { font-weight: 600; }
.fsl__sr { position: absolute; width: 0.0625rem; height: 0.0625rem; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* A ghost reserves the room of the longest version in the same grid cell, so nothing below a control moves. */
.fsl__switch-state, .fsl__count-cell, .fsl__change, .fsl__cap { display: grid; }
.fsl__switch-state > *, .fsl__count-cell > *, .fsl__change > *, .fsl__cap > * { grid-area: 1 / 1; min-width: 0; }
.fsl__ghost { visibility: hidden; }

.fsl__top { margin-bottom: var(--space-sm); }
.fsl__intro { font-size: var(--text-ui); font-weight: 600; }
.fsl__note { color: var(--color-text-muted); font-family: var(--font-serif); font-size: var(--text-sm); line-height: 1.4; }

/* The controls: the slider and its stop names, then the switch; side by side from 36em. */
.fsl__controls { display: grid; gap: var(--space-xs) var(--space-md); align-items: center; margin-bottom: var(--space-sm); }
@media (min-width: 36em) { .fsl__controls { grid-template-columns: minmax(0, 1fr) auto; } }
.fsl__slider { min-width: 0; }
.fsl__range {
  display: block; width: 100%; height: var(--fsl-target); margin: 0;
  background: transparent; accent-color: var(--color-text); cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.fsl__range::-webkit-slider-runnable-track { height: 0.25rem; border-radius: 0.125rem; background: var(--color-border); }
.fsl__range::-moz-range-track { height: 0.25rem; border-radius: 0.125rem; background: var(--color-border); }
.fsl__range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 1.375rem; height: 1.375rem; margin-top: -0.5625rem;
  border: var(--fsl-mid) solid var(--color-bg); border-radius: 50%; background: var(--color-text);
  box-shadow: 0 0 0 var(--fsl-line) var(--color-text);
}
.fsl__range::-moz-range-thumb {
  width: 1.25rem; height: 1.25rem; border: var(--fsl-mid) solid var(--color-bg); border-radius: 50%; background: var(--color-text);
  box-shadow: 0 0 0 var(--fsl-line) var(--color-text);
}
.fsl__range:focus-visible, .fsl__switch:focus-visible { outline: 0.125rem solid var(--color-accent); outline-offset: 0.125rem; }
/* The stop names sit under the track at the thumb's four places: the outer two flush with the ends. */
.fsl__ticks { display: flex; justify-content: space-between; margin-top: -0.35rem; font-size: var(--text-ui); color: var(--color-text-muted); }
.fsl__tick { padding: 0.15em 0; cursor: pointer; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fsl__tick.is-at { color: var(--color-text); font-weight: 600; text-decoration: underline; text-decoration-thickness: var(--fsl-mid); text-underline-offset: 0.3em; }

.fsl__switch {
  display: inline-flex; align-items: center; gap: 0.55em; justify-self: start;
  min-height: var(--fsl-target); padding: 0.3em 0.8em 0.3em 0.5em;
  border: var(--fsl-line) solid var(--color-text-muted); border-radius: 0.35em;
  background: var(--color-bg); color: var(--color-text);
  font: inherit; font-size: var(--text-ui); font-weight: 600; line-height: 1.2; cursor: pointer;
}
.fsl__switch:hover { border-color: var(--color-text); }
.fsl__track {
  position: relative; display: inline-block; flex: none; width: 2.25rem; height: 1.25rem; box-sizing: border-box;
  border: var(--fsl-mid) solid var(--color-text-muted); border-radius: 0.625rem; background: var(--color-bg-alt);
}
.fsl__knob {
  position: absolute; top: 0.125rem; left: 0.125rem; width: 0.75rem; height: 0.75rem; border-radius: 50%;
  background: var(--color-text-muted);
}
.fsl__switch.is-on .fsl__track { border-color: var(--color-text); background: var(--color-text); }
.fsl__switch.is-on .fsl__knob { left: auto; right: 0.125rem; background: var(--color-bg); }
.fsl__switch-state { min-width: 1.8em; color: var(--color-text-muted); font-weight: 400; }
.fsl__switch.is-on .fsl__switch-state { color: var(--color-text); font-weight: 600; }

/* The two columns, side by side at every width: the same square in both is the same invoice. */
.fsl__cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md); }
.fsl__col { min-width: 0; }
.fsl__head {
  margin-bottom: var(--space-xs); padding-bottom: 0.2em; border-bottom: var(--fsl-line) solid var(--color-text);
  font-size: var(--text-ui); font-weight: 600;
}
.fsl__grid { display: grid; grid-template-columns: repeat(var(--fsl-cols), minmax(0, 1fr)); gap: var(--fsl-gap); }
/* A phone reflows the squares into taller grids instead of shrinking them: 12 a row (17 rows), 10 under 22em. */
@media (max-width: 35.99em) {
  .fit-shift-lab { padding: var(--space-sm); --fsl-cols: 12; }
  .fsl__cols { gap: var(--space-sm); }
}
@media (max-width: 21.99em) { .fit-shift-lab { --fsl-cols: 10; } }

.fsl__t { position: relative; display: block; aspect-ratio: 1; box-sizing: border-box; border-radius: 0.0625rem; }
.fsl__t.is-routed, .fsl__t.is-right { background: var(--fsl-routed); }
.fsl__t.is-wrong, .fsl__mark.is-wrong {
  border: var(--fsl-mid) solid var(--fsl-wrong);
  background:
    linear-gradient(45deg, transparent calc(50% - 0.07rem), var(--fsl-wrong) calc(50% - 0.07rem), var(--fsl-wrong) calc(50% + 0.07rem), transparent calc(50% + 0.07rem)),
    linear-gradient(-45deg, transparent calc(50% - 0.07rem), var(--fsl-wrong) calc(50% - 0.07rem), var(--fsl-wrong) calc(50% + 0.07rem), transparent calc(50% + 0.07rem));
}
.fsl__t.is-person, .fsl__mark.is-person { border: var(--fsl-mid) solid var(--fsl-person); border-radius: 50%; background: transparent; }
@media (prefers-reduced-motion: no-preference) {
  .fsl__t.is-changed { animation: fsl-in var(--fsl-change) ease-out both; }
  @keyframes fsl-in { from { opacity: 0; transform: scale(0.4); } to { opacity: 1; transform: none; } }
}

/* The counters: one row per state, its mark, its number, the post's word. */
.fsl__counts { display: grid; gap: 0.15em; margin-top: var(--space-xs); }
/* Mark, number, words in three columns: the words wrap in their own column, under nothing. */
.fsl__count-row {
  display: grid; grid-template-columns: auto 2.1em minmax(0, 1fr); column-gap: 0.4em; align-items: baseline;
  font-size: var(--text-ui); line-height: 1.3;
}
.fsl__mark { display: inline-block; width: 0.8em; height: 0.8em; box-sizing: border-box; align-self: start; margin-top: 0.22em; }
.fsl__mark.is-routed, .fsl__mark.is-right { background: var(--fsl-routed); border-radius: 0.0625rem; }
/* Not known: the wrong route's shape in muted, dashed ink, beside a dashed "?". */
.fsl__mark.is-unknown {
  border: var(--fsl-line) dashed var(--color-text-muted); border-radius: 0.0625rem;
  background:
    linear-gradient(45deg, transparent calc(50% - 0.05rem), var(--color-text-muted) calc(50% - 0.05rem), var(--color-text-muted) calc(50% + 0.05rem), transparent calc(50% + 0.05rem)),
    linear-gradient(-45deg, transparent calc(50% - 0.05rem), var(--color-text-muted) calc(50% - 0.05rem), var(--color-text-muted) calc(50% + 0.05rem), transparent calc(50% + 0.05rem));
}
.fsl__num { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.fsl__num.is-unknown {
  box-sizing: border-box; padding: 0 0.3em; text-align: center; line-height: 1.15;
  border: var(--fsl-line) dashed var(--color-text-muted); border-radius: 0.25em; color: var(--color-text-muted); font-weight: 400;
}
.fsl__count-live .fsl__count-row:has(.is-unknown) .fsl__words { color: var(--color-text-muted); }
/* A phone keeps each counter to one line: the share of the batch shows from 36em up (the count is there at every width). */
@media (max-width: 35.99em) { .fsl__pct { display: none; } }

/* The stop's change (the post's table cell) and the caption. */
.fsl__out { margin-top: var(--space-sm); padding-top: var(--space-xs); border-top: var(--fsl-line) solid var(--color-border); }
.fsl__change { font-family: var(--font-serif); font-size: var(--text-sm); font-weight: 600; line-height: 1.35; }
.fsl__cap { margin-top: 0.2em; font-family: var(--font-serif); font-size: var(--text-sm); line-height: 1.42; }
