/* The Middle Square — a Logical Art nibble.
 *
 * Everything on this page is a four-digit number, so the mono face does most
 * of the work and colour is spent on exactly two distinctions: which digits
 * of the square survive, and which values a sequence can never leave. Neither
 * is decoration; both are the subject.
 *
 * The machine takes the studio neutral. la-accent-pick.py reports no colour
 * left that clears both the distance and contrast floors against the 52
 * accents already published, and inventing one below the floor would make two
 * machines on the timeline read as one. Ten live machines are in the same
 * position. The topic-accent scheme in the tracker is the fix.
 */

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

/* Without this the browser paints a dark canvas from color-scheme and the
   page looks right while having no background colour at all, which a contrast
   checker is correct to fail. */
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;
}

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

.ms-steplabel { margin: var(--la-space-5) 0 var(--la-space-2); font-weight: 600; color: var(--la-ink); }
.ms-stepno {
  display: inline-block; min-width: 1.6rem; margin-right: 0.5rem;
  padding: 0.05rem 0.5rem; border: 1px solid var(--la-hairline-strong);
  border-radius: 999px; font-family: var(--la-font-mono);
  font-size: var(--la-text-xs); color: var(--la-ink-dim); text-align: center;
}
.ms-hint { margin: 0 0 var(--la-space-3); color: var(--la-ink-dim); }

/* The seed, and the stepping controls. */
.ms-controls {
  display: flex; flex-wrap: wrap; align-items: end;
  gap: var(--la-space-2); margin: var(--la-space-3) 0;
}
.ms-field label { display: block; margin-bottom: 0.35rem; color: var(--la-ink-dim); font-size: var(--la-text-sm); }
.ms-input {
  box-sizing: border-box;
  width: 7rem; padding: 0.45rem 0.6rem;
  border: 1px solid var(--la-hairline-strong); border-radius: var(--la-radius-sm, 4px);
  background: var(--la-sunken); color: var(--la-ink);
  font-family: var(--la-font-mono); font-size: var(--la-text-base);
  letter-spacing: 0.08em;
}
.ms-input:focus-visible { outline: 2px solid var(--la-instrument); outline-offset: 2px; }
.ms-btn {
  padding: 0.45rem 0.9rem; border: 1px solid var(--la-hairline-strong);
  border-radius: var(--la-radius-sm, 4px); background: var(--la-raised);
  color: var(--la-ink); font-family: var(--la-font-mono); font-size: var(--la-text-sm);
  cursor: pointer;
}
.ms-btn:hover { border-color: var(--la-instrument); }
.ms-btn:focus-visible { outline: 2px solid var(--la-instrument); outline-offset: 2px; }

/* One step, drawn. The square is one number; the middle four are the only
   part that survives, and the other four are shown rather than hidden because
   discarding them IS the algorithm. */
.ms-sum {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 0.5rem; margin: var(--la-space-3) 0;
  font-family: var(--la-font-mono); font-size: var(--la-text-lg);
}
.ms-sum .ms-op { color: var(--la-ink-dim); font-size: var(--la-text-sm); }
.ms-square { letter-spacing: 0.12em; }
.ms-drop { color: var(--la-ink-dim); }
/* Marked by weight and by a rule under it, not by colour alone: this has to
   survive forced colours and a monochrome print. */
.ms-keep {
  color: var(--la-instrument); font-weight: 700;
  border-bottom: 2px solid var(--la-instrument); padding-bottom: 1px;
}

/* A run, and the whole space, are both grids of four-digit values. */
.ms-vals {
  display: flex; flex-wrap: wrap; gap: 0.3rem;
  margin: var(--la-space-3) 0;
  font-family: var(--la-font-mono); font-size: var(--la-text-sm);
}
.ms-val {
  padding: 0.15rem 0.35rem; border: 1px solid transparent;
  border-radius: var(--la-radius-sm, 4px); color: var(--la-ink-dim);
}
/* The values a sequence can never leave. Border, not colour, carries it. */
.ms-val[data-in="cycle"] {
  border-color: var(--la-hairline-strong); color: var(--la-ink);
}
.ms-val[data-in="repeat"] {
  border-color: var(--la-instrument); color: var(--la-instrument); font-weight: 700;
}
.ms-val[data-in="again"] {
  border: 1px dashed var(--la-instrument); color: var(--la-instrument);
}
.ms-val[data-in="again"]::before { content: "again "; font-size: var(--la-text-xs); }

.ms-said { margin: var(--la-space-3) 0 0; color: var(--la-ink-dim); font-size: var(--la-text-sm); }

.ms-table { width: 100%; border-collapse: collapse; font-size: var(--la-text-sm); }
.ms-table th, .ms-table td {
  text-align: left; padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--la-hairline);
}
.ms-table thead th {
  font-size: var(--la-text-xs); letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--la-ink-dim); font-weight: 600;
}
.ms-table td { font-family: var(--la-font-mono); font-size: 0.8rem; color: var(--la-ink-dim); }
/* The cycle the seed on screen ends in. A rule on the left as well as colour,
   for the same reason the middle digits get an underline. */
.ms-table tr[data-here="yes"] td { color: var(--la-ink); }
.ms-table tr[data-here="yes"] td:first-child {
  border-left: 3px solid var(--la-instrument); padding-left: 0.45rem;
}

.ms-checks { width: 100%; border-collapse: collapse; font-size: var(--la-text-sm); }
.ms-checks th, .ms-checks td {
  text-align: left; padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--la-hairline);
  vertical-align: top;
}
.ms-checks thead th {
  font-size: var(--la-text-xs); letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--la-ink-dim); font-weight: 600;
}
.ms-checks td { color: var(--la-ink-dim); }
.ms-checks td:last-child { font-family: var(--la-font-mono); font-size: 0.8rem; }
.ms-checks tr[data-mark="bad"] td { color: var(--la-warn, #e0b341); }
