/* Huffman.
 *
 * The accent comes from la-machines.css, generated from the roster. Nothing
 * here declares --machine or --accent: a custom property set on the element
 * that reads it overrides the inherited value.
 *
 * Measures in rem, never ch: ch resolves against the element's own font-size.
 */

/* The page frame. Floating Point shipped without these and ran the full width
   of the browser, which no gate saw and an operator did. */
* { margin: 0; padding: 0; box-sizing: border-box; }

main.nibble {
  max-width: var(--la-measure);
  margin: 0 auto;
  padding: 3rem 1.25rem 3rem;
}

main.nibble p, main.nibble ul, main.nibble ol, main.nibble dl,
main.nibble h1, main.nibble h2 { max-width: none; }

body {
  font-family: var(--la-font-ui);
  background: var(--la-page);
  color: var(--la-ink);
  line-height: var(--la-leading-body);
  -webkit-font-smoothing: antialiased;
}

.hu-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- the stage labels, which are what makes this a nibble ------------- */

.hu-steplabel {
  display: flex;
  align-items: baseline;
  gap: var(--la-space-2);
  margin-top: var(--la-space-6);
  margin-bottom: var(--la-space-2);
  font-weight: 600;
  color: var(--la-ink);
}

.hu-steplabel:first-of-type { margin-top: var(--la-space-3); }

.hu-stepno {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--la-font-mono);
  font-size: var(--la-text-xs);
}

.hu-hint,
.hu-note {
  color: var(--la-ink-dim);
  font-size: var(--la-text-sm);
  margin-top: var(--la-space-2);
}

.hu-code {
  font-family: var(--la-font-mono);
  color: var(--accent);
}

/* ---- controls --------------------------------------------------------- */

.hu-knob { margin-top: var(--la-space-3); }

.hu-knob label {
  display: block;
  font-family: var(--la-font-mono);
  font-size: var(--la-text-xs);
  color: var(--la-ink-dim);
  margin-bottom: var(--la-space-1, 0.35rem);
}

.hu-input {
  display: block;
  width: 100%;
  font-family: var(--la-font-mono);
  font-size: var(--la-text-sm);
  line-height: 1.5;
  color: var(--la-ink);
  background: color-mix(in srgb, var(--la-ink) 6%, transparent);
  border: 1px solid var(--la-hairline-strong);
  border-radius: var(--la-radius, 6px);
  padding: 0.55em 0.7em;
  resize: vertical;
}

.hu-presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--la-space-2);
  margin-top: var(--la-space-3);
}

.hu-btn {
  font-family: var(--la-font-mono);
  font-size: var(--la-text-sm);
  color: var(--la-ink);
  background: color-mix(in srgb, var(--la-ink) 6%, transparent);
  border: 1px solid var(--la-hairline-strong);
  border-radius: var(--la-radius, 6px);
  padding: 0.4em 0.9em;
  cursor: pointer;
  /* 2.5.8 asks for 24 CSS pixels. */
  min-height: 2.25rem;
  min-width: 2.25rem;
}

.hu-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.hu-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.hu-btn:focus-visible,
.hu-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---- the tables ------------------------------------------------------- */

.hu-counts,
.hu-codes {
  width: 100%;
  margin-top: var(--la-space-4);
  border-collapse: collapse;
  font-size: var(--la-text-sm);
}

.hu-counts th,
.hu-codes th {
  text-align: left;
  font-family: var(--la-font-mono);
  font-size: var(--la-text-xs);
  font-weight: 400;
  color: var(--la-ink-dim);
  padding: 0 0 var(--la-space-2) 0;
  border-bottom: 1px solid var(--la-hairline-strong);
}

.hu-counts td,
.hu-codes td {
  padding: var(--la-space-2) var(--la-space-2) var(--la-space-2) 0;
  border-bottom: 1px solid var(--la-hairline);
  color: var(--la-ink);
}

.hu-counts th:not(:first-child),
.hu-counts td:not(:first-child),
.hu-codes th:not(:first-child),
.hu-codes td:not(:first-child) { text-align: right; }

.hu-sym {
  font-family: var(--la-font-mono);
  color: var(--la-ink);
}

.hu-num { font-family: var(--la-font-mono); }

.hu-codes .hu-code {
  font-family: var(--la-font-mono);
  color: var(--accent);
  text-align: right;
}

/* ---- the pool, which is the picture ----------------------------------- */

.hu-pool {
  display: flex;
  flex-wrap: wrap;
  gap: var(--la-space-2);
  align-items: center;
  margin-top: var(--la-space-4);
  padding: var(--la-space-3) 0;
  border-top: 1px solid var(--la-hairline-strong);
  border-bottom: 1px solid var(--la-hairline-strong);
  min-height: 4.5rem;
}

.hu-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: var(--la-space-2) 0.6rem;
  border: 1px solid var(--la-hairline);
  border-radius: var(--la-radius, 6px);
  background: color-mix(in srgb, var(--la-ink) 4%, transparent);
  font-family: var(--la-font-mono);
  font-size: var(--la-text-sm);
}

/* A bundle is not a symbol. Distinguished by border style as well as colour,
   so the two kinds stay apart in greyscale. */
.hu-chip[data-leaf="no"] {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.hu-chip-label { color: var(--la-ink); }
.hu-chip[data-leaf="no"] .hu-chip-label { color: var(--accent); }
.hu-chip-n { color: var(--la-ink-dim); font-size: var(--la-text-xs); }

/* ---- the readout ------------------------------------------------------ */

.hu-readout {
  margin-top: var(--la-space-4);
  border-top: 1px solid var(--la-hairline);
}

.hu-row {
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: var(--la-space-3);
  padding: var(--la-space-2) 0;
  border-bottom: 1px solid var(--la-hairline);
}

.hu-row dt {
  font-family: var(--la-font-mono);
  font-size: var(--la-text-xs);
  color: var(--la-ink-dim);
}

.hu-row dd {
  font-size: var(--la-text-sm);
  color: var(--la-ink);
  overflow-wrap: anywhere;
}

.hu-strong dd { color: var(--accent); font-weight: 600; }

.hu-why { margin-top: var(--la-space-6); }

.hu-why h2 {
  margin-top: var(--la-space-5);
  margin-bottom: var(--la-space-2);
}

.hu-why p { margin-top: var(--la-space-3); color: var(--la-ink-dim); }

.hu-why q { color: var(--la-ink); }
.hu-why strong { color: var(--la-ink); font-weight: 600; }

@media (max-width: 34rem) {
  .hu-row { grid-template-columns: 1fr; }
  .hu-row dt { color: var(--la-ink-faint); }
}
