/* =========================================================================
   MatrixLab — page identity on top of kit.css.

   Indigo, and it is the second stop on the Mathematics track: VectorLab is
   the track's gold, and a second gold lab would make the two indis-
   tinguishable on the map at 40 px. Indigo keeps the warm-track feeling in
   the background (the squared paper is still gold-tinted) while giving the
   card an accent of its own.

   Inside the figures the roles carry over unchanged from VectorLab, which
   is the point of sharing kit/mathdraw.js: gold is the first column and the
   image of x̂, blue the second, mint whatever was just computed, pink the
   leftover, red what breaks.
   ========================================================================= */
:root {
  --bp-cyan: #9d8cff;          /* primary accent */
  --bp-blue: #b8adff;          /* secondary */
  --bp-mark: #9d8cff;
  --note-accent: #9d8cff;
  --calc-col: 360px;
  --page-max: 1440px;
}

/* The same squared paper as VectorLab, in the track's gold rather than this
   lab's indigo — the grid belongs to the track, the accent to the lab. */
body {
  background-image:
    linear-gradient(rgba(255, 201, 77, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 201, 77, 0.026) 1px, transparent 1px);
  background-size: 34px 34px, 34px 34px;
}

.hint { font-size: 0.76rem; color: var(--bp-ink-dim); line-height: 1.55; margin-top: 0.5rem; }
.hint b { color: var(--bp-cyan); }

.results-col { min-width: 0; }
.results-col svg { max-width: 100%; }

/* ------------------------------- the matrix ------------------------------ */
/* Entered as a grid, not as a list of fields. A matrix typed into nine
   separate labelled boxes stops looking like one object, which is the exact
   misconception chapter 1 spends its length undoing. */
.mat-grid { display: grid; gap: 0.28rem; margin-bottom: 0.2rem; }
.mat-grid input {
  width: 100%; font-family: var(--mono); font-size: 0.85rem;
  background: var(--bp-bg); color: var(--bp-ink);
  border: 1px solid var(--bp-line); border-radius: 6px;
  padding: 0.32rem 0.35rem; text-align: right; min-width: 0;
}
.mat-grid input:focus { outline: none; border-color: var(--bp-cyan); }
/* The first two columns keep the colours the figures give them, so the
   input and the drawing are visibly the same thing. */
.mat-grid input.c0 { border-left: 2px solid #ffc94d; }
.mat-grid input.c1 { border-left: 2px solid #4dabf7; }

.b-grid { display: grid; gap: 0.28rem; }
.b-grid input {
  width: 100%; font-family: var(--mono); font-size: 0.85rem;
  background: var(--bp-bg); color: var(--bp-ink);
  border: 1px solid var(--bp-line); border-left: 2px solid #5fe3a1;
  border-radius: 6px; padding: 0.32rem 0.35rem; text-align: right; min-width: 0;
}
.b-grid input:focus { outline: none; border-color: var(--bp-cyan); }
.b-grid[hidden] { display: none !important; }

/* ------------------------------ result cards ----------------------------- */
.vres {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem; margin-bottom: 0.9rem;
}
.vres .card {
  border: 1px solid var(--bp-line); border-radius: 9px;
  background: var(--bp-panel); padding: 0.55rem 0.7rem;
}
.vres .card .k {
  font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--bp-ink-dim);
}
.vres .card .v {
  font-family: var(--mono); font-size: 1.12rem; font-weight: 700;
  color: var(--bp-cyan); margin-top: 0.15rem; overflow-wrap: anywhere;
}
.vres .card .x {
  font-family: var(--mono); font-size: 0.68rem; color: var(--bp-ink-dim);
  margin-top: 0.15rem; overflow-wrap: anywhere;
}

.vnote {
  border: 1px solid var(--bp-line); border-left-width: 4px;
  border-left-color: #ffd43b; border-radius: 9px;
  background: var(--bp-panel); padding: 0.5rem 0.8rem; margin-bottom: 0.8rem;
  font-size: 0.8rem; line-height: 1.55; color: var(--bp-ink-dim);
}
.vnote b { color: #ffd43b; }

/* ------------------------- matrices in the output ------------------------ */
/* A result matrix is printed as a real grid with brackets, because a matrix
   flattened into "1, 2; 3, 4" is unreadable the moment it is 4×4. */
.mout { display: flex; flex-wrap: wrap; gap: 1.2rem; align-items: flex-start; }
.mout figure { margin: 0; }
.mout figcaption {
  font-family: var(--mono); font-size: 0.7rem; color: var(--bp-ink-dim);
  margin-bottom: 0.25rem; text-align: left;
}
.mbox {
  display: inline-grid; gap: 0.1rem 0.7rem;
  font-family: var(--mono); font-size: 0.8rem;
  padding: 0.4rem 0.6rem; border-left: 2px solid var(--bp-line2);
  border-right: 2px solid var(--bp-line2); border-radius: 3px;
  background: var(--bp-bg); text-align: right;
}
.mbox span.zero { color: var(--bp-ink-dim); opacity: 0.45; }
.mbox span.piv { color: var(--bp-cyan); font-weight: 700; }

/* ------------------------------ elimination ------------------------------ */
.elim-list { display: flex; flex-direction: column; gap: 0.5rem; }
.elim-row {
  display: grid; grid-template-columns: 8.5rem 1fr; gap: 0.7rem;
  align-items: center; border-top: 1px solid var(--bp-line); padding-top: 0.5rem;
}
.elim-row:first-child { border-top: none; padding-top: 0; }
.elim-op {
  font-family: var(--mono); font-size: 0.74rem; color: var(--bp-cyan);
}

/* --------------------------------- toggles ------------------------------- */
.seg { display: inline-flex; border: 1px solid var(--bp-line); border-radius: 7px; overflow: hidden; }
.seg button {
  font-family: var(--mono); font-size: 0.72rem; cursor: pointer;
  background: transparent; color: var(--bp-ink-dim);
  border: none; padding: 0.3rem 0.65rem; transition: 0.16s;
}
.seg button.active { background: var(--bp-cyan); color: var(--bp-bg); font-weight: 700; }
.seg button:not(.active):hover { color: var(--bp-ink); }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }

.res-table td.num { text-align: right; font-family: var(--mono); }

@media (max-width: 720px) {
  .mat-grid input, .b-grid input { font-size: 0.76rem; padding: 0.28rem 0.22rem; }
  .elim-row { grid-template-columns: 1fr; gap: 0.3rem; }
}
