/* Exercise pages (js/learn.js). Sits on top of site.css and explain.css: a lesson is
   a .problem card with a practice panel inside it. */

/* one colour per vector, kept through a lesson: a, b, the answer, and a ghost */
.la-a { --v: #d6336c; }
.la-b { --v: #1971c2; }
.la-r { --v: #e8590c; }
.la-g { --v: rgba(28, 20, 64, 0.5); }

/* ---- progress strip under the headline ---- */

.learn-strip {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 14px;
  max-width: 560px;
  margin: 0 0 22px;
}
.learn-strip-line { margin: 0; font-weight: 700; color: var(--chalk-dim); font-size: 15px; }
.learn-bar { grid-column: 1; height: 10px; border-radius: 999px; background: rgba(255, 248, 236, 0.16); overflow: hidden; }
.learn-bar-fill { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--jot); transition: width 500ms var(--spring); }
.learn-carry { grid-column: 2; grid-row: 1 / span 2; background: var(--jot); color: var(--ink); text-decoration: none; font-size: 15px; }

.jump-pill.done::before { content: "\2713\00a0"; }

/* ---- lesson card ---- */

.lesson .problem-text p { max-width: 62ch; }
.lesson-extras { min-width: 0; }
.lesson-extras h3 {
  margin: 22px 0 8px;
  font-size: 15px;
  font-weight: 800;
}
.lesson-figure { margin: 6px 0 0; }
.lesson-figure figcaption { text-align: center; }

.worked, .explore {
  margin-top: 4px;
}

.working {
  margin: 10px 0 0;
  padding: 0 0 0 22px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
}
.working li { margin: 0 0 4px; padding-left: 2px; }
.working li::marker { font-weight: 800; color: var(--ink-soft); }

/* ---- matrices ---- */

.expr {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin: 10px 0;
}
.expr .op { font-weight: 800; font-size: 19px; align-self: center; }
.expr .op sub, .mx-label sub { font-size: 0.7em; }

.mx { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.mx-label { font-weight: 800; font-size: 14px; line-height: 1.1; color: var(--v, var(--ink)); }
.mx-wrap { display: inline-flex; align-items: stretch; gap: 6px; }
.mx-rows { display: grid; grid-auto-rows: 1fr; align-items: center; justify-items: end; font-size: 12px; font-weight: 700; color: var(--ink-soft); padding: 3px 0; }
.mx-body {
  display: inline-grid;
  gap: 2px 4px;
  padding: 3px 6px;
  border: solid var(--v, var(--ink));
  border-width: 0 3px;
  border-radius: 9px;
}
.mx-cell {
  min-width: 26px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0 3px;
  font-weight: 700;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* answer boxes */
.mx-fill .mx-body { gap: 5px; padding: 5px 7px; }
.mx-fill .mx-rows { padding: 5px 0; }
.box {
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  min-width: 46px;
  height: 40px;
  padding: 0 4px;
  border: 2px solid rgba(28, 20, 64, 0.35);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.box.on { border-color: var(--ink); box-shadow: 0 0 0 3px var(--pc); }
.box.on:empty::after { content: ""; width: 2px; height: 18px; background: var(--ink); animation: caret 1s steps(2) infinite; }
.box.bad { border-color: #c92a2a; background: #ffe3e0; animation: shake 320ms; }
.box.good { border-color: #2b8a3e; background: #e3f7d0; }
.box:disabled { cursor: default; color: var(--ink); opacity: 1; }

@keyframes caret { 50% { opacity: 0; } }
@keyframes shake {
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

/* ---- keypad ---- */

.keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-width: 300px;
  margin: 12px 0 4px;
}
.key {
  font: inherit;
  font-weight: 800;
  font-size: 19px;
  height: 46px;
  border: 0;
  border-radius: 12px;
  background: var(--ink);
  color: var(--chalk);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.28);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.key:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.28); }
.key-wide { grid-column: span 2; font-size: 16px; background: var(--pc); color: var(--ink); }

/* ---- practice panel ---- */

.practice {
  margin-top: 26px;
  padding: 14px 14px 16px;
  border-radius: 14px;
  background: rgba(28, 20, 64, 0.055);
  border: 2px dashed rgba(28, 20, 64, 0.28);
}
.practice-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.practice .practice-title { margin: 0; font-family: "Permanent Marker", cursive; font-weight: 400; font-size: 22px; }
.dots { display: inline-flex; gap: 6px; }
.dot-mark { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); }
.dot-mark.on { background: var(--pc); }
.dot-mark.pop { animation: pop 420ms var(--spring); }
@keyframes pop { from { transform: scale(2.2); } to { transform: scale(1); } }

.intro { margin: 10px 0 0; font-weight: 600; }
.stage { padding-top: 10px; scroll-margin: 16px; }
.stage + .stage { margin-top: 16px; border-top: 2px dashed rgba(28, 20, 64, 0.2); }
.prompt { margin: 0 0 4px; font-weight: 700; font-size: 17px; line-height: 1.4; }
.note-line { margin: 2px 0 8px; font-size: 14px; font-weight: 600; color: var(--ink-soft); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 12px; }
.actions.after { margin-top: 16px; }
.text-btn {
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 8px 0;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  cursor: pointer;
}
.feedback { margin: 10px 0 0; font-weight: 700; font-size: 15px; min-height: 1px; }
.feedback:empty { margin: 0; }
.feedback.yes { color: #2b8a3e; }
.feedback.no { color: #b02a2a; }
.mastered-line { margin: 0; flex-basis: 100%; font-family: "Permanent Marker", cursive; font-size: 20px; }
.mastered-line.quiet { font-family: inherit; font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.finale { margin: 16px 0 10px; font-weight: 600; }

/* shape steppers */
.shape-bar { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 6px 0 2px; }
.stepper { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; }
.step {
  font: inherit; font-weight: 800; font-size: 18px; line-height: 1;
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--ink); background: #fff; color: var(--ink); cursor: pointer;
  touch-action: manipulation;
}
.step-num { min-width: 14px; text-align: center; font-size: 17px; font-weight: 800; }

/* choices */
.options { display: grid; gap: 8px; margin-top: 10px; }
.option {
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  text-align: left;
  padding: 11px 14px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
}
.option:disabled { cursor: default; box-shadow: none; color: var(--ink); opacity: 0.6; }
.option.right { background: #d9f5b8; border-color: #2b8a3e; opacity: 1; }
.option.wrong { background: #ffe3e0; border-color: #c92a2a; opacity: 1; text-decoration: line-through; }

/* ---- the grid ---- */

.gridbox { max-width: 340px; margin: 8px auto 0; }
.grid {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background: #fff;
  border-radius: 12px;
  border: 2px solid rgba(28, 20, 64, 0.2);
  -webkit-user-select: none;
  user-select: none;
}
.grid .gl { stroke: rgba(28, 20, 64, 0.11); stroke-width: 0.03; }
.grid .ax { stroke: rgba(28, 20, 64, 0.45); stroke-width: 0.06; }
.grid .tick { font-size: 0.42px; font-weight: 700; fill: rgba(28, 20, 64, 0.5); }
.arrow line { stroke: var(--v); stroke-width: 0.16; stroke-linecap: round; }
.arrow polygon, .arrow circle { fill: var(--v); }
.arrow.la-g line { stroke-width: 0.08; stroke-dasharray: 0.22 0.2; }
.arrow.la-g polygon { fill: none; }
.arrow .name { font-size: 0.6px; font-weight: 800; fill: var(--v); paint-order: stroke; stroke: #fff; stroke-width: 0.2px; stroke-linejoin: round; }
.grid .dot { fill: var(--v); }
.grid .handle { fill: var(--v); fill-opacity: 0.16; stroke: var(--v); stroke-width: 0.06; stroke-dasharray: 0.2 0.16; cursor: grab; touch-action: none; outline: none; }
.grid .handle:focus-visible { stroke-width: 0.14; stroke-dasharray: none; }
.grid.dragging .handle { cursor: grabbing; fill-opacity: 0.3; }
.grid.locked .handle { display: none; }
.grid-readout { margin: 6px 0 0; text-align: center; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; white-space: pre-wrap; }

/* ---- toys ---- */

.toy { max-width: 340px; margin: 0 auto; }
.toy .gridbox { margin-top: 4px; }
.toy-grid .ml { stroke: var(--pc); stroke-width: 0.05; filter: brightness(0.82); }
.toy-grid .unit { fill: var(--jot); fill-opacity: 0.55; stroke: var(--ink); stroke-width: 0.04; }
.toy-grid .arrow line { stroke-width: 0.12; }
.toy-read { display: flex; justify-content: center; }
.toy-sliders { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.slide { width: 100%; height: 32px; accent-color: var(--ink); touch-action: pan-y; }
.toy-presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.toy-note, .toy-lead { margin: 8px 0 0; font-size: 14px; font-weight: 600; line-height: 1.45; }
.toy-lead { margin: 0 0 10px; font-size: 15px; }

.bars { display: grid; grid-template-columns: auto 1fr 40px; align-items: center; gap: 8px 10px; margin-bottom: 10px; }
.bar-name { font-weight: 800; }
.bar-track { height: 22px; border-radius: 6px; background: #fff; border: 2px solid rgba(28, 20, 64, 0.2); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--pc); filter: brightness(0.9); transition: width 160ms; }
.bar-num { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }

/* ---- attention heat map ---- */

.heat-table { display: grid; gap: 4px; align-items: stretch; max-width: 340px; }
.heat-corner, .heat-col { font-size: 12px; font-weight: 700; color: var(--ink-soft); text-align: center; align-self: end; }
.heat-corner { text-align: left; }
.heat-row {
  font: inherit; font-weight: 800; font-size: 14px; text-align: left;
  padding: 0 10px; border: 2px solid transparent; border-radius: 8px; background: none; color: var(--ink); cursor: pointer;
}
.heat-row.on { border-color: var(--ink); background: #fff; }
.heat-cell {
  height: 44px; display: grid; place-items: center; border-radius: 8px;
  font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums;
  background: rgba(232, 89, 12, calc(var(--w, 0) * 0.85 + 0.06));
  opacity: 0.5;
}
.heat-cell.on { opacity: 1; box-shadow: inset 0 0 0 2px var(--ink); }
.heat-cell.off { background: repeating-linear-gradient(45deg, rgba(28, 20, 64, 0.08) 0 5px, transparent 5px 10px); color: var(--ink-soft); }
.heat-line { margin: 10px 0; font-weight: 700; font-size: 15px; }
.heat-note { margin: 10px 0 0; font-size: 14px; color: var(--ink-soft); font-weight: 600; }

/* ---- foot ---- */

.stamp-row { flex-direction: column; align-items: center; gap: 14px; }
div.stamp-btn { cursor: default; text-align: center; }
.wipe { color: var(--chalk-dim); font-size: 14px; }

@media (max-width: 760px) {
  .practice { margin-left: -6px; margin-right: -6px; padding: 12px 10px 14px; }
  .keypad { max-width: none; }
}

/* buttons that are links, inside a card whose links are otherwise underlined */
.practice a.pin-btn { color: var(--chalk); text-decoration: none; }
