/* ============================================================================
   A practice round: the item, what went wrong, and the summary.
   common.css has the tokens and says what each color is allowed to mean.
   ========================================================================= */

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

/* ----------------------------------------------------------------- progress */

.progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.count { font-weight: 700; font-size: 1.05rem; }

.count-line { display: inline-flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }

/* An item that came off the review pile. Said quietly: it is not a warning. */
.again { color: var(--dim); font-size: 0.9rem; }

.pips { display: flex; gap: 5px; list-style: none; margin: 0; padding: 0; }

.pip {
  width: 24px;
  height: 24px;
  border: 2px solid var(--rule);
  background: var(--panel);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}
.pip.now { border-color: var(--amber); background: var(--amber-fill); }
.pip.right { border-color: var(--green); background: var(--green-fill); color: var(--green); }
.pip.wrong { border-color: var(--red); background: var(--red-fill); color: var(--red); }

/* --------------------------------------------------------- right and wrong */

/* .marked, the mark and the word, is in common.css: both pages use it. */

.note { min-height: 1.5em; }
.status { color: var(--dim); }

/* --------------------------------------------------------------------- code */

.code-slab {
  font-family: var(--mono);
  font-size: clamp(1.4rem, 5.5vw, 2.2rem);
  font-weight: 700;
  background: var(--paper);
  border: 2px solid var(--rule-hot);
  padding: 16px 20px;
  text-align: center;
  overflow-wrap: anywhere;
}

.code-line {
  font-size: clamp(0.95rem, 3.6vw, 1.25rem);
  font-weight: 500;
  background: var(--paper);
  border: 2px solid var(--rule-hot);
  padding: 12px 16px;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.console {
  font-size: clamp(0.9rem, 3.4vw, 1.1rem);
  line-height: 1.5;
  background: var(--console);
  color: var(--console-ink);
  border: 2px solid var(--console);
  padding: 12px 16px;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* A traceback is drawn in columns: the caret has to sit under the name it
   points at. So the lines above the last never wrap; they scroll sideways if
   they must. The last line is the message itself, and it wraps, so the whole
   of it can be read on a phone. forms/write.js splits the two. */
.console.python-says { white-space: normal; overflow: hidden; }
.python-says .says-above {
  display: block;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}
.python-says .says-last {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.label {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--dim);
  margin-bottom: 6px;
}

/* ----------------------------------------------------------------- the taps */

.ask { margin: 0 0 12px; color: var(--dim); }

.tile-rows { display: grid; gap: 18px; margin-top: 24px; }

.tiles {
  display: flex;
  justify-content: center;
  gap: 6px;
  /* A drag across the row picks tiles; it must not select text or scroll. */
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.tile {
  flex: 1 1 0;
  min-width: 0;
  max-width: 58px;
  height: 64px;
  padding: 0;
  font-family: var(--mono);
  font-size: clamp(1.15rem, 5vw, 1.9rem);
  font-weight: 500;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--rule-hot);
  border-bottom-width: 5px;
  cursor: pointer;
  touch-action: none;
  position: relative;
  top: 0;
  transition: top 60ms, background 80ms;
}

.tile:hover { background: var(--panel-lo); }

/* Picked: what you are acting on. Amber, and also heavier and pressed in,
   so it reads without the color. */
.tile.on {
  background: var(--amber-fill);
  border-color: var(--amber);
  font-weight: 800;
  top: 3px;
  border-bottom-width: 2px;
  margin-bottom: 3px;
  height: 61px;
}

/* Tiles of more than one character (numbers, say) get a smaller face, so a
   row of them still fits a phone. */
.tiles.roomy .tile { font-size: clamp(0.8rem, 3.5vw, 1.6rem); }

.locked .tile { cursor: default; }
.locked .tile:not(.on) { color: var(--dimmer); background: var(--panel); }

/* A small copy of a row, for showing an answer back. */
.strip { display: inline-flex; gap: 2px; font-family: var(--mono); vertical-align: middle; }

.strip .cell {
  min-width: 1.35em;
  padding: 2px 0 1px;
  text-align: center;
  color: var(--dimmer);
  border: 1px solid var(--rule);
  border-bottom: 3px solid var(--rule);
  background: var(--panel);
}

.strip .cell.on { font-weight: 800; color: var(--ink); }
.strip.roomy { flex-wrap: wrap; row-gap: 3px; }
.strip.roomy .cell { min-width: 1.7em; }
.strip.right .cell.on { background: var(--green-fill); border-color: var(--green); }
.strip.wrong .cell.on { background: var(--red-fill); border-color: var(--red); }

/* ---------------------------------------------------------------- the write */

.form-write { display: grid; gap: 14px; }
.form-write > * { min-width: 0; }

.says { font-size: 1.3rem; font-weight: 700; line-height: 1.35; margin: 4px 0 0; }
.promise { margin: -8px 0 0; color: var(--dim); }

.example .console { display: inline-block; min-width: min(100%, 320px); vertical-align: top; }
.typed-in { font-weight: 700; }

.form-write > .label { margin: 6px 0 -8px; }

.answer {
  width: 100%;
  font-family: var(--mono);
  font-size: clamp(1.05rem, 4.4vw, 1.5rem);
  font-weight: 500;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 0;
  padding: 12px 14px;
}

.answer:focus-visible { outline-offset: 0; }
.answer[readonly] { background: var(--paper); }

/* ------------------------------------------------------------ what went wrong */

.miss {
  background: var(--panel);
  border: 2px solid var(--red);
  border-left-width: 8px;
  padding: 16px 18px;
}

.miss-head { margin: 0 0 12px; }
.miss-timeout .miss-head { margin: 0; }
.typed-line { font-weight: 700; overflow-wrap: anywhere; }

.table-wrap { overflow-x: auto; }

.runs { border-collapse: collapse; width: 100%; font-size: 1.05rem; }

.runs th {
  text-align: left;
  font-size: 0.85rem;
  color: var(--dim);
  padding: 4px 12px 6px;
  border-bottom: 2px solid var(--rule-hot);
  white-space: nowrap;
}

.runs td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

.runs code { font-size: 1.1rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.runs .nothing { color: var(--dimmer); font-style: italic; }
.runs .verdict-cell { white-space: nowrap; text-align: right; }

/* The rows that differ are the lesson, so they are the loud ones. */
.runs tr.bad td { background: var(--red-fill); border-bottom-color: var(--red); }
.runs tr.bad td:first-child { box-shadow: inset 5px 0 0 var(--red); }
.runs tr.bad td:nth-child(3) code { font-weight: 800; }

.compare {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 16px;
  align-items: center;
  margin: 0;
  font-size: 1.1rem;
}
.compare + .compare { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--rule); }
.compare dt { color: var(--dim); font-size: 0.95rem; }
.compare dt code { color: var(--ink); font-weight: 700; }
.compare dd { margin: 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ summary */

#summary-body h2 { margin: 0 0 16px; font-size: 1.3rem; }
#summary-body h2:focus-visible { outline: none; }
#summary-body h3 { margin: 26px 0 10px; font-size: 1rem; color: var(--dim); }

.stats { display: flex; gap: 12px; flex-wrap: wrap; }

.stat {
  flex: 1 1 150px;
  border: 2px solid var(--rule);
  background: var(--paper);
  padding: 12px 16px;
}
.stat:first-child { border-color: var(--rule-hot); flex-grow: 2; }
.stat .v { font-family: var(--mono); font-size: 2rem; font-weight: 700; line-height: 1.1; white-space: nowrap; }
.stat .k { color: var(--dim); font-size: 0.95rem; }

.missed-list { list-style: none; margin: 0 0 4px; padding: 0; display: grid; gap: 8px; }

.missed-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  border-left: 4px solid var(--rule-hot);
  background: var(--paper);
  padding: 10px 14px;
}

.recap { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; min-width: 0; }
.recap-code { font-weight: 700; font-size: 1.1rem; overflow-wrap: anywhere; }
.recap-gives { color: var(--dim); font-size: 0.95rem; }
.why { color: var(--dim); font-size: 0.9rem; white-space: nowrap; }

/* What the round did, then where to go. The first button is the next thing
   to do and the only dark one. */
.outcome { margin-top: 18px; display: grid; gap: 4px; }
.outcome p { margin: 0; font-size: 1.1rem; }

/* A round of several parts (a mix of belts, or Read and Write together):
   how each part went. */
.part-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.part-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  border-left: 4px solid var(--rule-hot);
  background: var(--paper);
  padding: 8px 14px;
}
.part-score { font-weight: 700; }

.next-row { margin-top: 20px; }
.next-row .label { margin-bottom: 8px; }

.pile-note { margin: 10px 0 0; color: var(--dim); font-size: 0.95rem; }

/* A belt asked for by its address before it is open. */
.locked-head { font-size: 1.3rem; font-weight: 700; }
#stage > p { margin: 0 0 14px; }

@media (max-width: 768px) {
  .pip { width: 20px; height: 20px; line-height: 16px; font-size: 0.75rem; }
  .pips { gap: 4px; }
  .tiles { gap: 3px; }
  .tile { height: 52px; border-bottom-width: 4px; }
  .tile.on { height: 50px; margin-bottom: 2px; top: 2px; }
  .says { font-size: 1.15rem; }
  .miss { padding: 12px; border-left-width: 6px; }
  .runs { font-size: 0.95rem; }
  .runs code { font-size: 0.95rem; }
  .runs th, .runs td { padding-left: 7px; padding-right: 7px; }
  .runs tr.bad td:first-child { padding-left: 10px; }
  .compare { grid-template-columns: 1fr; gap: 4px; }
  .compare dd { margin-bottom: 8px; }
  .strip .cell { min-width: 1.2em; }
  .stat:first-child { flex-basis: 100%; }
  .next-row .btn-row .btn, #stage > .btn-row .btn { flex: 1 1 100%; text-align: center; }
  .strip.roomy { font-size: 0.9rem; }
  .strip.roomy .cell { min-width: 1.45em; }
}

/* =========================================================================
   The forms past tap and write (js/shell/forms/).
   ========================================================================= */

.form-typed, .form-always, .form-pickall { display: grid; gap: 14px; }
.form-typed > *, .form-always > *, .form-pickall > * { min-width: 0; }
.form-typed .ask, .form-always .ask, .form-pickall .ask { margin: 0; }
.form-typed > .label { margin: 6px 0 -8px; }

/* ------------------------------------------------------- tiles that are words */

/* A list's items are whole words. They take the room they need and wrap. */
.tiles.wordy { flex-wrap: wrap; gap: 8px; }

.tiles.wordy .tile {
  flex: 0 1 auto;
  max-width: none;
  height: 54px;
  padding: 0 14px;
  font-size: clamp(1rem, 3.8vw, 1.3rem);
}
.tiles.wordy .tile.on { height: 51px; }

.strip.wordy { gap: 4px; }
.strip.wordy .cell { padding-left: 6px; padding-right: 6px; }

/* Tiles to read and not to press: the typed form lays the word out. */
.tiles.still { touch-action: auto; margin-top: 4px; }
.tiles.still .tile {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  border-bottom-width: 2px;
  height: 56px;
}
.tiles.still .tile:hover { background: var(--panel); }

/* ----------------------------------------------------------------- choices */

/* Buttons that stay pressed. Pressed is amber, what you are acting on, and
   it is also a filled box and a heavier face, so it reads without the color. */
.choices { display: flex; gap: 10px; flex-wrap: wrap; }
.choices.stacked { display: grid; gap: 8px; }

.choice {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--read);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--rule-hot);
  border-bottom-width: 4px;
  padding: 10px 16px;
  cursor: pointer;
  text-align: left;
}
.choice:hover { background: var(--panel-lo); }

.choice-box {
  flex: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--rule-hot);
  background: #fff;
}

.choice.on { background: var(--amber-fill); border-color: var(--amber); font-weight: 800; }
.choice.on .choice-box { border-color: var(--ink); background: var(--ink); box-shadow: inset 0 0 0 3px #fff; }

.code-choice { width: 100%; }
.code-choice code { font-size: clamp(0.95rem, 3.8vw, 1.25rem); overflow-wrap: anywhere; }
.choice.on code { font-weight: 800; }

.locked .choice { cursor: default; }
.locked .choice:not(.on) { color: var(--dimmer); }
.locked .choice:hover { background: var(--panel); }
.locked .choice.on:hover { background: var(--amber-fill); }

/* The two choices that stand beside a row of tiles. */
.said { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.said-word { color: var(--dim); font-weight: 700; }
.said-back { font-weight: 700; }

/* What an expression gives, or what print() shows of it, said back in code. */
.shows { font-weight: 700; font-size: 1.1rem; overflow-wrap: anywhere; }
.compare .row-error, .why-not .row-error { font-size: 0.95rem; overflow-wrap: anywhere; }

/* ----------------------------------------------- a line somebody else wrote */

.offered .label { margin-bottom: 6px; }
.code-line.statement { font-weight: 700; border-color: var(--ink); }

/* ------------------------------------------------------- pick every one */

.option-marks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.option-marks li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  align-items: baseline;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-left: 5px solid var(--rule-hot);
  background: var(--paper);
}
.option-marks li.bad { background: var(--red-fill); border-color: var(--red); }
.option-marks .typed-line { grid-column: 1 / -1; font-size: 1.05rem; }
.option-marks .does { font-weight: 700; }
.option-marks .you { text-align: right; white-space: nowrap; }
.option-marks .why-not { grid-column: 1 / -1; color: var(--dim); font-size: 0.95rem; }
.why-not code { color: var(--ink); }
.why-not .nothing, .console .nothing { font-style: italic; }
.why-not .nothing { color: var(--dimmer); }
.console .nothing { color: #b9b09c; }

/* ------------------------------------------------- every example at once */

.example.every .runs-shown { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.example.every .console { display: block; min-width: 0; }

@media (max-width: 768px) {
  .tiles.wordy { gap: 6px; }
  .tiles.wordy .tile { height: 46px; padding: 0 10px; }
  .tiles.wordy .tile.on { height: 44px; }
  .tiles.still .tile { height: 48px; }
  .choice { padding: 9px 12px; font-size: 1rem; }
  .choices:not(.stacked) .choice { flex: 1 1 100%; }
  .said { margin-top: 16px; }
  .option-marks li { grid-template-columns: 1fr; }
  .option-marks .you { text-align: left; }
  .example.every .runs-shown { grid-template-columns: 1fr; }
}

/* With room to spare, what was wanted and what was printed are not broken
   through the middle of a word; what was typed in gives way first. */
@media (min-width: 769px) {
  .runs td:nth-child(2) code, .runs td:nth-child(3) code { overflow-wrap: break-word; }
}

/* =========================================================================
   A program that goes on after the answered line, and runs that print more
   than one line.
   ========================================================================= */

/* The program with a gap in it: the first line, the box, the lines after.
   All three are set alike so the indent of the last one can be read. */
.program { display: grid; }
.program > * { min-width: 0; }
.program .code-line, .program .answer {
  font-size: clamp(1.05rem, 4.4vw, 1.5rem);
  padding: 12px 14px;
}
.program .code-line:first-child { border-bottom: 0; }
.code-line.after { border-top: 0; color: var(--dim); }
.offered .code-line.after { font-weight: 500; }

/* Finished runs that are several lines each stand side by side. */
.example .runs-shown.tall { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.example .runs-shown.tall .console { display: block; min-width: 0; padding: 10px 12px; line-height: 1.35; }
.example:not(.every) .runs-shown.tall { grid-template-columns: minmax(0, 320px); }

/* What a line did, one card per run, where a run is too tall for a row. */
.run-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; align-items: start; }
.run-cards:has(> .run-card:nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0, 260px)); }

.run-card { border: 1px solid var(--rule); border-top: 5px solid var(--rule-hot); background: var(--paper); min-width: 0; }
.run-card.bad { background: var(--red-fill); border-color: var(--red); }

.run-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 8px;
  flex-wrap: wrap;
  padding: 8px 10px 6px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--rule);
}
.run-card.bad .run-card-head { border-bottom-color: var(--red); }
.run-card-head code { font-size: 1.1rem; font-weight: 700; }

.run-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; padding: 8px 10px 10px; }
.run-col { min-width: 0; }
.run-col-head { font-size: 0.8rem; font-weight: 700; color: var(--dim); margin-bottom: 4px; }
.run-lines { list-style: none; margin: 0; padding: 0; }
.run-lines li { padding: 0 6px; line-height: 1.4; border-left: 4px solid transparent; }
.run-lines code { font-size: 1.05rem; }
.run-col .nothing { color: var(--dimmer); font-style: italic; font-size: 0.95rem; }
.run-col .row-error { font-size: 0.85rem; overflow-wrap: anywhere; }

/* A line with no partner on the other side: heavy, barred and boxed, so it
   is found without the color. */
.run-lines li.off { font-weight: 800; border-left-color: var(--red); background: var(--panel); outline: 1px solid var(--red); }

@media (max-width: 768px) {
  .example .runs-shown.tall { grid-template-columns: 1fr 1fr; }
  .run-cards { grid-template-columns: 1fr 1fr; gap: 6px; }
  .run-cards:has(> .run-card:nth-child(2):last-child) { grid-template-columns: 1fr 1fr; }
  .run-card-head { padding: 6px 8px 4px; }
  .run-cols { padding: 6px 8px 8px; gap: 0 4px; }
  .run-col-head { font-size: 0.75rem; }
  .run-lines li { padding: 0 4px; }
}
