/* Errors Lab (errors-have-prices post, "Try It: The 99.5% Detector"): 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, labels and counts; the serif for
   what the reader reads (the readouts' values and the note). Two weights (400, 600), no italic, sentence case.
   Loaded by the post itself.
   Every outcome is a shape, a colour and a word (the key names each, with its count). Frauds are ink and drawn larger
   than a cell: caught a solid square, missed an open ring. A false alarm is a gold square filling its cell. A genuine
   payment not flagged is a small faint dot. Ink and gold differ in hue and in lightness in both themes, so the code reads
   in greyscale. The cheapest stop is marked in neutral ink, an outline and the word "Cheapest": never green, never a
   verdict colour. Until the reader has tried every stop at the price the mark is hidden and a plain line in its row
   says how many stops are left; a tried stop's number is underlined. Both sit in the same fixed row, so nothing moves. */
.errors-lab {
  --ehl-target: 2.75rem; /* 44 CSS px touch target (WCAG 2.5.5) */
  --ehl-line: 0.0625rem; /* a hairline */
  --ehl-mid: 0.125rem; /* the cheapest mark's outline */
  --ehl-thumb: 1.375rem; /* the threshold's thumb */
  --ehl-ink: var(--color-text); /* frauds */
  --ehl-alarm: var(--color-pop-gold-text); /* false alarms */
  --ehl-passed: var(--color-text-muted); /* genuine, not flagged (drawn at half strength) */
  container-type: inline-size;
  margin: var(--space-lg) 0;
  padding: var(--space-md);
  border: var(--ehl-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-ui);
  font-weight: 400;
  font-style: normal;
  line-height: 1.4;
  max-width: 100%;
  min-width: 0;
}
.errors-lab[hidden], .errors-lab [hidden] { display: none !important; }
@media (max-width: 35.99em) { .errors-lab { padding: var(--space-sm); } }
.errors-lab :where(p, dl, dd, fieldset, legend) { margin: 0; padding: 0; }
.errors-lab fieldset { border: 0; min-width: 0; }
.errors-lab ul, .errors-lab li { margin: 0; padding: 0; list-style: none; }
.errors-lab li::marker { content: none; }
.ehl__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 content in the same grid cell, so nothing moves between states. */
.ehl__stop, .ehl__read-head, .ehl__big, .ehl__note, .ehl__key-n { display: grid; }
.ehl__stop > *, .ehl__read-head > *, .ehl__big > *, .ehl__note > *, .ehl__key-n > * { grid-area: 1 / 1; min-width: 0; }
.ehl__ghost { visibility: hidden; }

.ehl__intro { font-weight: 600; }
.ehl__illus { color: var(--color-text-muted); margin-bottom: var(--space-sm); }

/* One column on a phone: controls, then the readouts and note they change, then the grid (a lab may be taller than a
   phone window; the control and its readouts are not apart). Where the lab is wide: the controls across the top, the
   grid under them on the left and the readouts and note on the right, all in one window at 1280x800. The grid is the
   same 18rem square in both layouts, so the wide drawing is never smaller than the narrow one. */
.ehl__body { display: grid; gap: var(--space-sm); grid-template-columns: minmax(0, 1fr); grid-template-areas: "controls" "out" "side"; }
.ehl__controls { grid-area: controls; display: grid; gap: var(--space-xs); min-width: 0; }
.ehl__out { grid-area: out; display: grid; gap: var(--space-sm); align-content: start; min-width: 0; }
.ehl__side { grid-area: side; display: grid; gap: var(--space-xs); align-content: start; justify-items: center; min-width: 0; }
.ehl__side > * { width: 100%; max-width: 18rem; }

.ehl__label { display: block; font-weight: 600; margin-bottom: 0.2em; }

/* Price of a false alarm: two named prices, one pressed. */
.ehl__price-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-xs); }
.ehl__price { position: relative; display: flex; min-width: 0; cursor: pointer; }
.ehl__price input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.ehl__price-word {
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: var(--ehl-target); padding: 0.25em 0.5em;
  border: var(--ehl-line) solid var(--color-text-muted); border-radius: 0.35em;
  background: var(--color-bg); color: var(--color-text); line-height: 1.2; overflow-wrap: break-word;
}
.ehl__price:hover .ehl__price-word { border-color: var(--color-text); }
.ehl__price input:checked + .ehl__price-word { border: var(--ehl-mid) solid var(--color-text); font-weight: 600; background: var(--color-bg-alt); }
.ehl__price input:focus-visible + .ehl__price-word { outline: 0.125rem solid var(--color-accent); outline-offset: 0.125rem; }

/* The threshold: seven stops, its name above, the stop numbers and the cheapest mark under it. */
.ehl__thr-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; column-gap: var(--space-sm); }
.ehl__thr-head .ehl__label { margin-bottom: 0; }
.ehl__stop { flex: 1 1 12em; text-align: right; font-variant-numeric: tabular-nums; }
.ehl__range {
  -webkit-appearance: none; appearance: none; display: block;
  width: 100%; height: var(--ehl-target); margin: 0; background: transparent; cursor: pointer;
}
.ehl__range::-webkit-slider-runnable-track { height: 0.25rem; border-radius: 0.125rem; background: var(--color-text-muted); }
.ehl__range::-moz-range-track { height: 0.25rem; border-radius: 0.125rem; background: var(--color-text-muted); }
.ehl__range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: var(--ehl-thumb); height: var(--ehl-thumb); margin-top: calc((0.25rem - var(--ehl-thumb)) / 2);
  border: var(--ehl-mid) solid var(--color-bg); border-radius: 50%; background: var(--color-text);
}
.ehl__range::-moz-range-thumb { width: var(--ehl-thumb); height: var(--ehl-thumb); border: var(--ehl-mid) solid var(--color-bg); border-radius: 50%; background: var(--color-text); }
.ehl__range:focus-visible { outline: 0.125rem solid var(--color-accent); outline-offset: 0.125rem; }

/* Tick numbers sit under the thumb's centre at each stop; the cheapest mark sits under its stop. */
.ehl__tick.is-seen { text-decoration: underline; text-decoration-thickness: var(--ehl-mid); text-underline-offset: 0.2em; }
.ehl__left { position: absolute; top: 1.55em; left: calc(var(--ehl-thumb) / -2); white-space: nowrap; color: var(--color-text-muted); line-height: 1.35; }
.ehl__ticks { position: relative; height: 3.1em; margin: 0 calc(var(--ehl-thumb) / 2); }
.ehl__tick, .ehl__best { position: absolute; left: calc(var(--at) * 100%); transform: translateX(-50%); white-space: nowrap; }
.ehl__tick { top: 0; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.ehl__tick.is-on { color: var(--color-text); font-weight: 600; }
.ehl__best {
  top: 1.45em; padding: 0 0.35em; line-height: 1.35;
  border: var(--ehl-mid) solid var(--color-text); border-radius: 0.25em; background: var(--color-bg);
}
.ehl__best::before {
  content: ""; position: absolute; left: 50%; top: -0.4em; width: 0; height: 0; transform: translateX(-50%);
  border-left: 0.35em solid transparent; border-right: 0.35em solid transparent; border-bottom: 0.35em solid var(--color-text);
}

/* Readouts: accuracy and cost side by side, at every width. */
.ehl__reads { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-xs); }
.ehl__read {
  display: grid; align-content: start; gap: 0.15em; min-width: 0;
  padding: var(--space-xs) var(--space-sm); border: var(--ehl-line) solid var(--color-border); border-radius: 0.5em; background: var(--color-bg);
}
.ehl__read.is-low { border: var(--ehl-mid) solid var(--color-text); padding: calc(var(--space-xs) - var(--ehl-line)) calc(var(--space-sm) - var(--ehl-line)); }
.ehl__read-head { color: var(--color-text-muted); line-height: 1.25; }
.ehl__big { font-family: var(--font-serif); font-size: var(--text-lg); font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums lining-nums; }
.ehl__tag { line-height: 1.3; }
.ehl__tag-word { display: inline-block; padding: 0 0.35em; border: var(--ehl-mid) solid var(--color-text); border-radius: 0.25em; font-weight: 600; visibility: hidden; }
.ehl__tag.is-on .ehl__tag-word { visibility: visible; }
.ehl__refs { display: grid; grid-template-columns: auto auto; justify-content: space-between; column-gap: var(--space-xs); color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.ehl__refs dd { text-align: right; }

/* The note: one written sentence for the state on screen, in the reading face. */
.ehl__note { font-family: var(--font-serif); font-size: var(--text-sm); line-height: 1.4; }

/* The grid: 10,000 payments, square, as wide as its column. */
.ehl__grid { width: 100%; aspect-ratio: 1 / 1; }
.ehl__canvas { display: block; width: 100%; height: 100%; }

/* The key: each outcome's mark, word and count. */
.ehl__key { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.2em var(--space-sm); }
.ehl__key-item { display: flex; align-items: center; gap: 0.45em; min-width: 0; }
.ehl__key-word { flex: 1 1 auto; min-width: 0; }
.ehl__key-n { flex: none; font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; }
.ehl__glyph { flex: none; width: 0.8em; height: 0.8em; box-sizing: border-box; }
.ehl__glyph--3 { background: var(--ehl-ink); }
.ehl__glyph--2 { border: 0.2em solid var(--ehl-ink); }
.ehl__glyph--1 { width: 0.6em; height: 0.6em; margin: 0 0.1em; background: var(--ehl-alarm); }
.ehl__glyph--0 { width: 0.3em; height: 0.3em; margin: 0 0.25em; background: var(--ehl-passed); opacity: 0.5; }

.errors-lab-fallback { margin: var(--space-md) 0; }

/* The wide layout (see the body rule above); last, so it wins over the phone rules it changes. */
@container (min-width: 32rem) {
  .ehl__body { grid-template-columns: 18rem minmax(0, 1fr); grid-template-areas: "controls controls" "side out"; column-gap: var(--space-sm); }
  .ehl__side { justify-items: start; }
  .ehl__out .ehl__reads { grid-template-columns: minmax(0, 1fr); }
  .ehl__tag.is-never { display: none; }
  .ehl__key { grid-template-columns: minmax(0, 1fr); }
}
