/* Interleave — a Logical Art nibble.
 *
 * Shell first, neutral accent. A CD's rainbow is diffraction rather than
 * pigment, so there is no colour on the object to sample and the machine takes
 * the studio neutral through --machine. Damage is the one thing that earns a
 * hue, and it is the only one on the page.
 */
* { margin: 0; padding: 0; box-sizing: border-box; }

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;
}

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; }

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



/* ---- Stage labels -------------------------------------------------------- */
.il { margin-top: var(--la-space-5); }

.il-steplabel {
  display: flex;
  align-items: center;
  gap: var(--la-space-2);
  margin-top: var(--la-space-4);
  margin-bottom: var(--la-space-2);
  font-family: var(--la-font-mono);
  font-size: var(--la-text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--la-ink-faint);
}

.il-stepno {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border: 1px solid var(--la-hairline-strong);
  border-radius: 50%;
  color: var(--la-ink-dim);
}

/* ---- 1. The track -------------------------------------------------------- */
.il-track {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(48, 1fr);
  gap: 2px;
  padding: var(--la-space-2);
  border: 1px solid var(--la-hairline);
  border-radius: var(--la-radius);
  background: var(--la-sunken);
  touch-action: none;
}

.il-frame {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 3.2;
  padding: 0;
  border: 0;
  border-radius: 1px;
  background: var(--la-hairline-strong);
  cursor: crosshair;
  transition: background var(--la-transition);
}

.il-frame:hover { background: var(--la-ink-faint); }

/* The one earned colour on the page: this is damage, not decoration. */
.il-frame.is-scratched { background: #8c1d16; }

.il-frame:focus-visible { outline: 2px solid var(--machine); outline-offset: 2px; }

.il-scratchline {
  margin-top: var(--la-space-2);
  font-family: var(--la-font-mono);
  font-size: var(--la-text-sm);
  color: var(--la-ink-dim);
}

.il-controls {
  margin-top: var(--la-space-3);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--la-space-3);
}

.il-widthlabel {
  font-family: var(--la-font-mono);
  font-size: var(--la-text-xs);
  color: var(--la-ink-faint);
}

#il-width { flex: 1 1 12rem; min-width: 8rem; accent-color: #8c1d16; }

.il-presets { list-style: none; display: flex; flex-wrap: wrap; gap: var(--la-space-2); }

.il-preset {
  font: inherit;
  font-size: var(--la-text-sm);
  color: var(--la-ink);
  background: var(--la-raised);
  border: 1px solid var(--la-hairline-strong);
  border-radius: var(--la-radius-sm);
  padding: 0.35em 0.8em;
  cursor: pointer;
  transition: border-color var(--la-transition), color var(--la-transition);
}

.il-preset:hover { border-color: var(--machine); color: var(--machine); }
.il-preset:focus-visible { outline: 2px solid var(--machine); outline-offset: 3px; }

/* ---- 2. De-interleaved codewords ----------------------------------------- */
.il-words {
  list-style: none;
  display: grid;
  gap: 3px;
  padding: var(--la-space-2);
  border: 1px solid var(--la-hairline);
  border-radius: var(--la-radius);
  background: var(--la-sunken);
}

.il-word { display: flex; align-items: center; gap: var(--la-space-2); }

.il-wordlabel {
  flex: 0 0 3.4rem;
  font-family: var(--la-font-mono);
  font-size: 0.62rem;
  color: var(--la-ink-faint);
  text-align: right;
}

.il-symbols {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(28, 1fr);
  gap: 2px;
  min-width: 0;
}

.il-sym {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 1px;
  background: var(--la-hairline-strong);
  transition: background var(--la-transition);
}

/* Parity is drawn differently because it is not your music. */
.il-sym.is-parity { background: var(--la-hairline); }
.il-sym.is-dead { background: #8c1d16; }

.il-note {
  margin-top: var(--la-space-2);
  font-family: var(--la-font-mono);
  font-size: var(--la-text-xs);
  color: var(--la-ink-faint);
}

/* ---- 3. Verdicts --------------------------------------------------------- */
.il-verdicts {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.3rem;
}

.il-verdict {
  font-family: var(--la-font-mono);
  font-size: var(--la-text-xs);
  color: var(--la-ink-faint);
  border-left: 2px solid var(--la-hairline);
  padding: 0.2em 0 0.2em 0.6em;
}

.il-verdict.is-fixed { color: var(--la-ink-dim); border-left-color: var(--machine); }
.il-verdict.is-failed { color: #e0736a; border-left-color: #8c1d16; }

/* ---- 4. Output ----------------------------------------------------------- */
.il-out {
  margin-top: var(--la-space-2);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: var(--la-space-3);
}

.il-out div { border-top: 1px solid var(--la-hairline); padding-top: var(--la-space-2); }

.il-out dt {
  font-family: var(--la-font-mono);
  font-size: var(--la-text-xs);
  color: var(--la-ink-faint);
}

.il-out dd {
  margin-top: 0.2rem;
  font-family: var(--la-font-mono);
  font-size: var(--la-text-base);
  color: var(--la-ink);
}

.il-verdictline {
  margin-top: var(--la-space-3);
  font-family: var(--la-font-mono);
  font-size: var(--la-text-sm);
  color: var(--la-ink-dim);
  border-left: 2px solid var(--la-hairline);
  padding-left: var(--la-space-2);
  min-height: 2.6em;
}

.il-verdictline.is-ok { border-left-color: var(--machine); color: var(--la-ink); }
.il-verdictline.is-failed { border-left-color: #8c1d16; color: #e0736a; }

/* ---- Prose --------------------------------------------------------------- */
.il-why { margin-top: var(--la-space-6); }

main.nibble section h2 {
  font-family: var(--la-font-display);
  font-size: var(--la-text-xl);
  line-height: var(--la-leading-tight);
  letter-spacing: -0.01em;
}

.il-why p { margin-top: var(--la-space-2); color: var(--la-ink-dim); }
.il-why strong { color: var(--la-ink); }
.il-why em { font-style: italic; }

main.nibble .la-faq,
main.nibble section { margin-top: var(--la-space-6); }
main.nibble .la-faq details { margin-top: var(--la-space-3); }
main.nibble footer { margin-top: var(--la-space-6); }

@media (max-width: 40rem) {
  main.nibble { padding-top: 2rem; }
  /* The column count stays at 48. Halving it would wrap the track onto two
     rows, and a track that wraps is no longer a track: the whole point is that
     the scratch is one contiguous run along one line. The frames get thin
     instead, and the gap shrinks to keep them draggable. */
  .il-track { gap: 1px; padding: var(--la-space-1); }
  .il-frame { aspect-ratio: 1 / 2.4; }
  .il-wordlabel { flex-basis: 2.6rem; font-size: 0.55rem; }
  .il-verdicts { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .il-frame, .il-sym, .il-preset { transition: none; }
}

/* ---- 6. The sound, which on this machine is the output ------------------- */
.il-subhead {
  margin-top: var(--la-space-5);
  font-size: var(--la-text-md);
  font-weight: 600;
}

.il-hint {
  margin-top: var(--la-space-1);
  font-size: var(--la-text-sm);
  color: var(--la-ink-dim);
}

.il-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--la-space-2);
  margin-top: var(--la-space-3);
}
.il-buttons[hidden] { display: none; }

.il-button {
  font: inherit;
  font-size: var(--la-text-sm);
  color: var(--la-ink);
  background: var(--la-page);
  border: 1px solid var(--la-hairline);
  border-radius: var(--la-radius-sm);
  /* WCAG 2.5.8 is 24 by 24 at AA; this is comfortably past it. */
  min-height: 2.75rem;
  padding: 0 var(--la-space-3);
  cursor: pointer;
}
.il-button:hover { border-color: var(--machine); color: var(--machine); }
.il-button:focus-visible { outline: 2px solid var(--machine); outline-offset: 2px; }

.il-said {
  margin-top: var(--la-space-2);
  font-family: var(--la-font-mono);
  font-size: var(--la-text-xs);
  color: var(--la-ink-dim);
  min-height: 1.5em;
}
