/* The Year 5 and 6 labs' shared frame and results chart (site/js/science/lab-kit.js):
   mirrors coin orbit seasons squash undo, and lab-bench.js. Each lab's own drawing is in lab-light.css,
   lab-space.css and lab-change.css. */

/* Each fills the Try step's box and sizes its parts by that box (cq units). */
.lab-x { display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: stretch; align-content: stretch; gap: 1cqh; width: 100%; height: 100%; min-height: 0; container-type: size; }
.lab-x .sim-note { font-size: clamp(17px, 3.6cqmin, 26px); }
.lab-x .sim-note[data-kind="right"] { color: #13643a; font-weight: 600; }
.lx-wrap { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, 0.9fr); align-items: center; gap: 2.4cqw; width: 100%; height: 100%; min-height: 0; }
.lx-rig { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.4cqmin; height: 100%; min-width: 0; min-height: 0; }
.lx-scene { display: block; flex: 1 1 0; width: 100%; min-height: 0; border-radius: 3cqmin; touch-action: none; user-select: none; -webkit-user-select: none; }
.lab-x .sim-buttons { flex: none; flex-wrap: wrap; justify-content: center; }
.lab-x .sim-buttons .big { min-width: 0; }
.lab-x.busy .card.tap, .lab-x.busy .sim-buttons .big { opacity: 0.7; }

/* Picked things: a row or column of cards, ticked once tested. */
.lab-x .card.tap { position: relative; cursor: pointer; }
.lab-x .card.on { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
.lab-x .card.done::after { content: '✓'; position: absolute; top: -8px; right: -8px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--right); color: #fff; font: 800 14px/1 var(--ui); }

/* Steps done so far (the mirror puzzles). */
.lx-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.2cqmin; }
.lx-chip {
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.3em 0.5em 0.3em 0.9em;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font: 400 clamp(14px, 2.8cqmin, 20px)/1.1 var(--book);
  white-space: nowrap;
}
.lx-tick { display: grid; place-items: center; width: 1.3em; height: 1.3em; border-radius: 50%; background: var(--line); color: #fff; font: 800 0.8em/1 var(--ui); }
.lx-chip.done { border-color: var(--right); background: var(--right-soft); color: #13643a; }
.lx-chip.done .lx-tick { background: var(--right); }

/* The results: filled in as things are tested, tapped to answer. */
.lx-chart { container-type: inline-size; display: grid; gap: 0.8cqmin; align-self: center; padding: 2cqmin; border: 3px solid transparent; border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.lx-chart.asking { border-color: var(--gold); animation: lx-glow 1.6s ease-in-out infinite; }
@keyframes lx-glow { 50% { box-shadow: 0 0 0 6px rgb(242 176 30 / 0.3), var(--shadow); } }
.lx-chart-title { margin: 0 0 0.2em; font: 600 clamp(16px, 3.2cqmin, 23px)/1.15 var(--book); text-align: center; }
.lx-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5em;
  min-height: 48px;
  padding: 2px 10px;
  border: 3px solid transparent;
  border-radius: 14px;
  background: none;
  color: var(--ink);
  font: 400 clamp(14px, 2.7cqmin, 19px)/1.15 var(--book);
  text-align: left;
}
.lx-row-emoji { font: clamp(22px, 4.6cqmin, 32px)/1 var(--emoji); }
.lx-value { color: var(--muted); font-size: 0.92em; text-align: right; }
.lx-row.tested .lx-value { color: var(--ink); font-weight: 600; }
.lx-row[data-result="good"] .lx-value { color: #13643a; }
.lx-row[data-result="new"] .lx-value { color: #8a3cc2; }
.lx-chart.asking .lx-row { border-color: var(--line); background: #fffbea; cursor: pointer; }
.lx-row.right { border-color: var(--right) !important; background: var(--right-soft) !important; }
.lx-row.wrong { border-color: var(--wrong) !important; }

/* A narrow chart: the result goes under the name. */
@container (max-width: 200px) {
  .lx-row { grid-template-columns: auto minmax(0, 1fr); padding: 4px 8px; }
  .lx-value { grid-column: 2; text-align: left; }
}

/* Upright: the rig on top, the results underneath (and so for a wide drawing, sooner). */
@container (max-aspect-ratio: 23/20) {
  .lx-wrap { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; justify-items: center; gap: 1.6cqh; }
  .lx-rig { width: 100%; }
  .lx-chart { justify-self: center; width: min(100%, 620px); grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1.6cqmin; }
  .lx-chart-title { grid-column: 1 / -1; }
  .lx-row { min-height: 42px; }
}
@container (max-aspect-ratio: 3/2) {
  .lab-mirrors .lx-wrap, .lab-coin .lx-wrap { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; justify-items: center; gap: 1.6cqh; }
  .lab-mirrors .lx-rig, .lab-coin .lx-rig { width: 100%; }
  .lab-mirrors .lx-chart, .lab-coin .lx-chart { justify-self: center; width: min(100%, 620px); grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1.6cqmin; }
  .lab-mirrors .lx-chart-title, .lab-coin .lx-chart-title { grid-column: 1 / -1; }
}

/* ---- Phones ---- */

@media (max-width: 600px), (max-height: 500px) {
  .lab-x { min-height: 640px; }
  .lx-chip { border-width: 2px; }
}
@media (max-width: 600px) {
  .lx-chart { grid-template-columns: minmax(0, 1fr) !important; }
}
@media (max-height: 500px) {
  .lab-x { min-height: 360px; }
}
