/* ============================================================
   interactive.css — the lab and drill vocabulary for this lesson,
   then the shared sorting game / quiz / flashcards / toast block that
   every lesson in this workspace uses unchanged.
   ============================================================ */

/* ---------------- Lab shell ---------------- */

.lab {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  margin-top: var(--s-5);
}

.lab__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
  margin-bottom: var(--s-4);
}

.lab__head h3 {
  margin: 0;
  font-size: var(--t-md);
}

.lab__hint {
  font-size: var(--t-sm);
  color: var(--ink-3);
  margin: 0 0 var(--s-4);
}

.lab__canvas {
  width: 100%;
  display: block;
  background: var(--plane-bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  touch-action: none; /* the puzzle needs the drag, not the page scroll */
}

/* A map whose window is taller than it is wide must not be stretched across
   a wide panel — it would be height-bound and mostly empty. Cap it and
   centre it instead. */
.lab__canvas--portrait {
  max-width: 430px;
  margin-inline: auto;
}

.lab__controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: center;
  margin-top: var(--s-4);
}

.lab__foot {
  margin-top: var(--s-4);
}

.btn--sm {
  padding: 6px 12px;
  font-size: var(--t-sm);
}

/* ---------------- Sliders ---------------- */

.ctl {
  flex: 1 1 220px;
  min-width: 200px;
}

.ctl__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--t-sm);
  color: var(--ink-2);
  margin-bottom: 6px;
}

.ctl__top b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  height: 26px;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

/* ---------------- Readouts ---------------- */

.readouts {
  display: grid;
  gap: var(--s-2);
  margin-top: var(--s-4);
}

.readout {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-3);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: var(--t-sm);
}

.readout span {
  color: var(--ink-3);
}

.readout b {
  color: var(--ink);
  text-align: right;
}

.readout--flat {
  background: transparent;
  border: 0;
  padding: 2px 0;
}

/* ---------------- Legend ---------------- */

.legend {
  display: grid;
  gap: 6px;
  margin-top: var(--s-3);
  font-size: var(--t-sm);
  color: var(--ink-2);
}

.legend__item {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  line-height: 1.5;
}

.legend__item i {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-top: 5px;
}

/* ---------------- Layer switches ---------------- */

.layers {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.layer {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 7px 13px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-3);
  font: inherit;
  font-size: var(--t-sm);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}

.layer:hover {
  border-color: var(--line-strong);
  color: var(--ink-2);
}

.layer.is-on {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--surface-2);
}

/* Off is genuinely off: the dot loses its colour, not just some opacity.
   A faint-but-coloured swatch reads as "on but dim". */
.layer__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  filter: grayscale(1);
  opacity: 0.5;
}

.layer.is-on .layer__dot {
  filter: none;
  opacity: 1;
}

/* ---------------- Segmented control ---------------- */

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
}

.seg__btn {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font: inherit;
  font-size: var(--t-sm);
  padding: 6px 14px;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}

.seg__btn:hover {
  color: var(--ink-2);
}

.seg__btn.is-on {
  background: var(--accent);
  color: #fff;
}

/* ---------------- Chips that are buttons ---------------- */

.chip--btn {
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}

.chip--btn:hover {
  border-color: var(--accent);
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.chip.is-on {
  border-color: var(--accent);
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}

/* ---------------- Drill frame ---------------- */

.drill__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
  font-size: var(--t-sm);
  color: var(--ink-3);
  margin-bottom: var(--s-3);
}

.drill__ask {
  font-weight: 650;
  color: var(--ink);
  margin: var(--s-4) 0 var(--s-3);
}

.drill__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
  margin-top: var(--s-4);
}

.claim {
  margin: var(--s-3) 0 0;
  padding: var(--s-4) var(--s-5);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  background: var(--surface);
  font-size: var(--t-md);
  line-height: var(--leading);
  color: var(--ink);
}

.claim footer {
  margin-top: var(--s-3);
  font-size: var(--t-sm);
  color: var(--ink-3);
  font-style: normal;
}

/* ---------------- Pickers ---------------- */

.picks {
  display: grid;
  gap: var(--s-2);
}

.pick {
  display: grid;
  gap: 3px;
  text-align: left;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}

.pick b {
  color: var(--ink);
  font-size: var(--t-base);
}

.pick span {
  font-size: var(--t-sm);
  color: var(--ink-3);
  line-height: 1.5;
}

.pick:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.pick.is-on {
  border-color: var(--accent);
}

.pick.is-right {
  border-color: var(--ok);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
}

.pick.is-wrong {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, transparent);
}

/* ---------------- Verdicts ---------------- */

.verdict {
  display: grid;
  gap: var(--s-3);
  margin-top: var(--s-4);
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
}

.verdict--ok {
  border-color: color-mix(in srgb, var(--ok) 50%, transparent);
  background: color-mix(in srgb, var(--ok) 10%, transparent);
}

.verdict--bad {
  border-color: color-mix(in srgb, var(--bad) 50%, transparent);
  background: color-mix(in srgb, var(--bad) 9%, transparent);
}

.verdict__head {
  font-weight: 700;
  color: var(--ink);
}

.verdict__body {
  font-size: var(--t-sm);
  line-height: var(--leading);
  color: var(--ink-2);
}

/* The named misconception. It only appears when the student actually walked
   into the anticipated wrong answer, so it must look different from the
   general explanation underneath it. */
.verdict__trap {
  font-size: var(--t-sm);
  line-height: var(--leading);
  color: var(--ink);
  padding: var(--s-3) var(--s-4);
  border-left: 3px solid var(--warn);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}

/* ---------------- Boundary-kind picker ---------------- */

.bkinds {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}

.bkind {
  --kc: var(--accent);
  display: grid;
  align-content: start; /* a stretched grid button centres its own content */
  gap: 3px;
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  border-left: 4px solid var(--kc);
  background: var(--surface);
  font: inherit;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}

.bkind b {
  color: var(--ink);
}

.bkind span {
  font-size: var(--t-xs);
  color: var(--ink-3);
}

.bkind:hover {
  background: var(--surface-2);
}

.bkind.is-on {
  background: color-mix(in srgb, var(--kc) 16%, transparent);
  border-color: var(--kc);
}

/* ---------------- Detail panels ---------------- */

.detail {
  margin-top: var(--s-4);
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
}

.detail p:last-child {
  margin-bottom: 0;
}

.detail__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
  margin-bottom: var(--s-3);
}

.detail__head h4 {
  margin: 0;
  font-size: var(--t-md);
}

ul.tight {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: var(--t-sm);
  color: var(--ink-2);
  line-height: 1.65;
}

/* ---------------- Worked steps ---------------- */

.steps {
  display: grid;
  gap: var(--s-3);
  margin-top: var(--s-4);
}

.step {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: var(--s-3);
  align-items: start;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
}

.step__n {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: var(--t-sm);
  font-weight: 700;
}

.step b {
  color: var(--ink);
}

.step__body {
  margin-top: 4px;
  font-size: var(--t-sm);
  color: var(--ink-2);
  line-height: var(--leading);
}

.step__body code,
.calc__result code {
  font-family: var(--mono);
  font-size: var(--t-sm);
  color: var(--ink);
  background: var(--surface-2);
  padding: 3px 7px;
  border-radius: 6px;
  display: inline-block;
  margin-top: 2px;
}

.calc__result {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-3);
  margin-top: var(--s-4);
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.calc__result span {
  color: var(--ink-3);
  font-size: var(--t-sm);
}

.calc__result b {
  font-size: var(--t-lg);
  color: var(--ink);
}

/* ---------------- Check-my-answer ---------------- */

.check-panel {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: flex-end;
  margin-top: var(--s-4);
}

.field {
  display: grid;
  gap: 5px;
  flex: 1 1 220px;
}

.field span {
  font-size: var(--t-sm);
  color: var(--ink-3);
}

.field input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-family: var(--mono);
}

.field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------------- Force bars (§07) ---------------- */

.fbars {
  display: grid;
  gap: var(--s-3);
  margin-top: var(--s-4);
}

.fbar__top {
  display: flex;
  justify-content: space-between;
  font-size: var(--t-sm);
  color: var(--ink-2);
  margin-bottom: 5px;
}

.fbar__top b {
  color: var(--ink);
}

.fbar__track {
  height: 10px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
}

.fbar__track span {
  display: block;
  height: 100%;
}

/* Off means inert, not merely faint — the same rule the motion lesson
   learned the hard way with its sliders. */
.fbar.is-off {
  opacity: 0.34;
}

.fbar.is-off .fbar__track span {
  filter: grayscale(1);
}

/* ---------------- Feature list (§10) ---------------- */

.feat-group {
  margin-top: var(--s-3);
}

.feat-group .chip-row {
  margin-top: 6px;
}

/* ---------------- Timeline caption (§09) ---------------- */

.tl-head {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  flex-wrap: wrap;
  margin-top: var(--s-4);
}

.tl-head h4 {
  margin: 0;
  font-size: var(--t-lg);
  color: var(--accent);
}

.tl-head span {
  font-size: var(--t-sm);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.tl-say {
  margin: var(--s-2) 0 0;
  color: var(--ink-2);
  line-height: var(--leading);
  min-height: 3.4em; /* the caption changes length; the map must not jump */
}

/* ---------------- Sorting board additions ---------------- */

.bin__sub {
  font-size: var(--t-xs);
  color: var(--ink-3);
  line-height: 1.5;
  margin-bottom: var(--s-2);
}

/* A class, not an inline style, so clearing the selection cannot leave a
   stray outline behind. */
.token.is-picked {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

/* ---------------- Sorting game ---------------- */

.sort-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-4);
  margin-top: var(--s-4);
}

.bin {
  min-height: 150px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  background: var(--surface);
  transition: all var(--dur) var(--ease);
}

.bin.is-over {
  border-color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 10%, var(--surface));
}

.bin__title {
  font-size: var(--t-sm);
  font-weight: 700;
  margin-bottom: var(--s-3);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.pool {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  min-height: 60px;
}

.token {
  padding: 8px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  font-size: var(--t-sm);
  font-weight: 600;
  cursor: grab;
  user-select: none;
  transition: all 180ms var(--ease);
}

.token:hover {
  border-color: var(--accent-2);
  transform: translateY(-2px);
}

.token.is-dragging {
  opacity: 0.4;
}

.token.is-right {
  border-color: var(--ok);
  background: color-mix(in srgb, var(--ok) 16%, transparent);
  color: var(--ok);
  cursor: default;
}

.token.is-wrong {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 16%, transparent);
  color: var(--bad);
  animation: shake 340ms var(--ease);
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

@media (max-width: 640px) {
  .sort-board {
    grid-template-columns: 1fr;
  }
}

/* ---------------- Quiz ---------------- */

.quiz {
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  padding: var(--s-5);
}

.quiz__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
  font-size: var(--t-sm);
  color: var(--ink-3);
  font-weight: 620;
}

.quiz__bar {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--line-strong);
  overflow: hidden;
  margin-bottom: var(--s-5);
}

.quiz__bar span {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--accent-grad);
  transition: width var(--dur) var(--ease);
}

.quiz__q {
  font-size: var(--t-lg);
  font-weight: 660;
  line-height: 1.4;
  margin-bottom: var(--s-4);
  max-width: none;
  color: var(--ink);
}

.choices {
  display: grid;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  width: 100%;
  padding: 13px var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--bg-2);
  text-align: left;
  font-size: var(--t-sm);
  color: var(--ink-2);
  transition: all 180ms var(--ease);
}

.choice:hover:not(:disabled) {
  border-color: var(--accent-2);
  color: var(--ink);
  transform: translateX(3px);
}

.choice__key {
  width: 24px;
  height: 24px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}

.choice.is-correct {
  border-color: var(--ok);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  color: var(--ink);
}

.choice.is-correct .choice__key {
  background: var(--ok);
  border-color: var(--ok);
  color: #04220d;
}

.choice.is-wrong {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, transparent);
}

.choice:disabled {
  cursor: default;
}

.feedback {
  padding: var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: var(--t-sm);
  margin-bottom: var(--s-4);
  animation: slideIn 240ms var(--ease);
}

.feedback b {
  display: block;
  margin-bottom: 4px;
}

.feedback--ok b {
  color: var(--ok);
}
.feedback--bad b {
  color: var(--bad);
}

.quiz__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
}

.score-hero {
  text-align: center;
  padding: var(--s-6) var(--s-4);
}

.score-hero__num {
  font-size: 4rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
}

/* ---------------- Flashcards ---------------- */

.flash-deck {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s-3);
}

.flash {
  perspective: 1100px;
  height: 178px;
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

.flash__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 520ms var(--ease);
  transform-style: preserve-3d;
}

.flash.is-flipped .flash__inner {
  transform: rotateY(180deg);
}

.flash__face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  padding: var(--s-4);
  display: grid;
  place-content: center;
  text-align: center;
  gap: var(--s-2);
}

.flash__front {
  background: var(--surface-2);
}

.flash__back {
  transform: rotateY(180deg);
  background: color-mix(in srgb, var(--accent) 16%, var(--surface-solid));
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.flash__term {
  font-size: var(--t-md);
  font-weight: 700;
  color: var(--ink);
}

.flash__def {
  font-size: var(--t-sm);
  color: var(--ink-2);
  line-height: 1.5;
}

.flash__hint {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 700;
}

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translate(-50%, 20px);
  z-index: 60;
  padding: 12px 22px;
  border-radius: var(--r-pill);
  background: var(--surface-solid);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-size: var(--t-sm);
  font-weight: 620;
  opacity: 0;
  pointer-events: none;
  transition: all var(--dur) var(--ease);
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* A revealed scene card grows and stretches its whole grid row. The cards
   are <button>s, and a stretched button centres its own content — leaving
   the un-revealed neighbours floating in the middle of a tall box. Pin
   their content to the top instead. */
#sceneGrid .tile {
  display: grid;
  align-content: start;
  text-align: left;
  width: 100%;
}

/* ---------------- Overrides for this lesson ----------------
   The shared block above assumes a two-bin sorting game. The three kinds
   of plate boundary need three bins, and they must collapse on a phone. */

.sort-board {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .sort-board {
    grid-template-columns: 1fr;
  }
}

.bin {
  align-content: start;
}
