/* Lab activities (sky): phases shaker torch (site/js/science/lab-sky.js). */

/* Each fills the Try step's box and sizes its parts by that box (cq units). */
.lab-phases, .lab-shaker, .lab-torch { display: block; width: 100%; height: 100%; min-height: 0; container-type: size; }

/* Goal chips: what has been seen or made so far (shared by phases and torch). */
.ph-goals { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.6cqmin; }
.ph-goal {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.35em 0.9em 0.35em 0.5em;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font: 400 clamp(14px, 3.2cqmin, 22px)/1.1 var(--book);
  white-space: nowrap;
}
.ph-goal .ph-moon.mini { width: 1.7em; height: 1.7em; }
.ph-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); }
.ph-goal.seen { border-color: var(--right); background: var(--right-soft); color: #13643a; }
.ph-goal.seen .ph-tick { background: var(--right); }

/* ---- Phases: the Sun, Earth and Moon from above, and the Moon from Melbourne ---- */

.ph-wrap { display: flex; align-items: center; justify-content: center; gap: 3cqmin; width: 100%; height: 100%; }
.ph-orbit {
  flex: none;
  width: min(96cqh, 56cqw);
  aspect-ratio: 1;
  border-radius: 4cqmin;
  background: radial-gradient(circle at 58% 50%, #1f2c5c, #0b1230 75%);
  box-shadow: var(--shadow);
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.ph-orbit.held { cursor: grabbing; }
.ph-star { fill: #fff; opacity: 0.6; }
.ph-ray { stroke: #ffd860; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 16 22; opacity: 0.55; animation: ph-ray 1.6s linear infinite; }
.ph-ray.r1 { animation-delay: -0.5s; }
.ph-ray.r2 { animation-delay: -1.1s; }
@keyframes ph-ray { to { stroke-dashoffset: -38; } }
.ph-path { fill: none; stroke: rgb(255 255 255 / 0.45); stroke-width: 2; stroke-dasharray: 5 7; }
.ph-arrow { fill: none; stroke: rgb(255 255 255 / 0.7); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.ph-sight { stroke: #ff8b80; stroke-width: 2.5; stroke-dasharray: 4 6; opacity: 0.9; }
.ph-earth { fill: #3a86d8; }
.ph-land { fill: #6fd18a; }
.ph-night { fill: rgb(8 16 48 / 0.62); }
.ph-pin { fill: #e0453a; stroke: #fff; stroke-width: 2; }
.ph-hit { fill: transparent; }
.ph-moon-g { cursor: grab; }
.ph-moon-dark { fill: #454c6b; }
.ph-moon-lit { fill: #f6f1d8; }
.ph-word { fill: #d7e4ff; font: 600 15px var(--ui); text-anchor: middle; pointer-events: none; }
.ph-word.sun { fill: #ffe59a; text-anchor: start; }

.ph-side { display: flex; flex-direction: column; align-items: stretch; gap: 2.4cqmin; width: min(38cqw, 64cqh); }
.ph-view {
  display: grid;
  justify-items: center;
  gap: 1cqmin;
  padding: 2.4cqmin 2.4cqmin 2.8cqmin;
  border-radius: 4cqmin;
  background:
    radial-gradient(circle at 18% 22%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 82% 30%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 70% 82%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 26% 76%, #fff 0 1px, transparent 2px),
    linear-gradient(#0d1638, #23305e);
  color: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.ph-title { display: flex; align-items: center; gap: 0.4em; margin: 0; color: #cfe0ff; font: 600 clamp(14px, 3cqmin, 21px)/1.2 var(--ui); text-align: center; }
.ph-dot { flex: none; width: 0.7em; height: 0.7em; border: 2px solid #fff; border-radius: 50%; background: #e0453a; }
.ph-view .ph-moon:not(.mini) { width: min(100%, 44cqh); height: auto; aspect-ratio: 1; filter: drop-shadow(0 0 2cqmin rgb(255 250 220 / 0.35)); }
.ph-dark { fill: #2c3355; stroke: #3d4570; stroke-width: 1; }
.ph-lit { transition: none; }
.ph-seas circle { fill: #cfc6a2; opacity: 0.55; }
.ph-words { display: grid; justify-items: center; gap: 0.2em; }
.ph-name { margin: 0; font: 600 clamp(24px, 6cqmin, 44px)/1.1 var(--book); }
.ph-sub { margin: 0; min-height: 1.2em; color: #cfe0ff; font: 400 clamp(14px, 3cqmin, 20px)/1.2 var(--book); text-align: center; }

/* Upright: the model on top, what we see underneath. */
@container (max-aspect-ratio: 23/20) {
  .ph-wrap { flex-direction: column; gap: 2cqmin; }
  .ph-orbit { width: min(100cqw, 58cqh); }
  .ph-side { flex: 1; width: min(100cqw, 640px); min-height: 0; flex-direction: row; align-items: center; gap: 2cqw; }
  .ph-view { flex: 1; grid-template-columns: auto 1fr; align-items: center; height: 100%; max-height: 40cqh; padding: 2cqmin 3cqmin; }
  .ph-title { grid-column: 1 / -1; }
  .ph-view .ph-moon:not(.mini) { width: auto; height: min(26cqh, 40cqw); }
  .lab-phases .ph-goals { flex-direction: column; flex-wrap: nowrap; }
}
/* A narrow phone: the goals go in a row under what we see. */
@container (max-aspect-ratio: 23/20) and (max-width: 560px) {
  .ph-side { flex: none; flex-direction: column; align-items: stretch; gap: 2cqmin; }
  .ph-view { height: auto; max-height: none; padding: 2.4cqmin 3cqmin; }
  .ph-view .ph-moon:not(.mini) { height: min(22cqh, 34cqw); }
  .lab-phases .ph-goals { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .lab-phases .ph-goal { gap: 0.35em; padding: 0.3em 0.6em 0.3em 0.35em; font-size: 14px; }
}
/* Wide and short (a phone on its side): the model, what we see, and the goals side by side. */
@container (min-aspect-ratio: 2/1) {
  .ph-side { flex-direction: row; align-items: center; width: auto; }
  .ph-view { width: min(46cqh + 40px, 30cqw); }
  .ph-view .ph-moon:not(.mini) { width: min(100%, 50cqh); }
  .lab-phases .ph-goals { flex-direction: column; flex-wrap: nowrap; }
}

/* ---- Shaker: a jar, a shake, a sound meter and the results ---- */

.lab-shaker { --jw: min(19cqw, 40cqh); }
.lab-shaker { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 1cqh; }
.lab-shaker .sim-note { font-size: clamp(17px, 3.6cqmin, 26px); }
.sk-wrap { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 0.8fr); align-items: center; gap: 2.4cqw; min-height: 0; }
.sk-shelf { display: grid; grid-template-columns: repeat(2, auto); gap: 1.6cqmin; }
.sk-shelf .card { position: relative; min-width: 0; width: clamp(84px, 14cqw, 132px); cursor: pointer; }
.sk-shelf .card-emoji { font-size: clamp(34px, 7.5cqmin, 56px); }
.sk-shelf .card-label { font-size: clamp(14px, 2.8cqmin, 20px); }
.sk-shelf .card.done { border-color: var(--right); }
.sk-check { position: absolute; top: -8px; right: -8px; display: none; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--right); color: #fff; font: 800 15px/1 var(--ui); }
.card.done .sk-check { display: grid; }
.lab-shaker[data-filling] .sk-shelf .card[data-i] { transition: box-shadow 0.2s; }

.sk-bench { display: grid; justify-items: center; gap: 2cqmin; }
.sk-rig { display: flex; align-items: flex-end; gap: 3cqmin; }
.sk-zone { position: relative; display: grid; justify-items: center; padding-top: calc(var(--jw) * 0.45); }
.sk-jar { position: relative; z-index: 1; width: var(--jw); height: calc(var(--jw) * 1.25); touch-action: none; cursor: grab; }
.sk-lid { position: absolute; z-index: 2; left: 8%; right: 8%; top: 0; height: 12%; border-radius: 8px 8px 4px 4px; background: linear-gradient(#e86a4f, #b8432d); box-shadow: inset 0 -3px 0 rgb(0 0 0 / 0.15); }
.sk-glass {
  position: absolute;
  inset: 10% 0 0;
  border: 5px solid rgb(150 190 220 / 0.85);
  border-top-width: 3px;
  border-radius: 14px 14px 30% 30% / 14px 14px 18% 18%;
  background: linear-gradient(90deg, rgb(200 230 250 / 0.5), rgb(235 248 255 / 0.25) 40%, rgb(200 230 250 / 0.45));
  box-shadow: 0 6px 14px rgb(29 36 51 / 0.15);
}
.sk-fill { position: absolute; inset: 0; }
.sk-shine { position: absolute; left: 12%; top: 8%; width: 9%; height: 70%; border-radius: 999px; background: rgb(255 255 255 / 0.6); pointer-events: none; }
.sk-table { width: calc(var(--jw) * 1.45); height: 12px; margin-top: -2px; border-radius: 6px; background: #c89b6d; box-shadow: 0 4px 0 #a77a4f; }
.sk-scoop { position: absolute; z-index: 3; top: 0; left: 50%; margin-left: calc(var(--jw) * -0.3); font: calc(var(--jw) * 0.5)/1 var(--emoji); pointer-events: none; }

.sk-bit { position: absolute; aspect-ratio: 1; }
.sk-bit.k-pebble { border-radius: 46% 54% 42% 58% / 55% 45% 55% 45%; background: radial-gradient(circle at 35% 30%, #c9c6c0, #8a8780 70%, #6f6c66); box-shadow: inset -2px -2px 0 rgb(0 0 0 / 0.15); }
.sk-bit.k-rice { aspect-ratio: 2.4; border-radius: 50%; background: linear-gradient(#fffdf4, #ece4cc); box-shadow: 0 0 0 0.5px rgb(150 130 90 / 0.4); }
.sk-bit.k-sand { border-radius: 50%; background: #d9b56f; }
.sk-bit.k-sand:nth-child(3n) { background: #c99d55; }
.sk-bit.k-sand:nth-child(5n) { background: #e8cb8c; }
.sk-bit.k-cotton { border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff, #f1f1f4 60%, #dcdce4); box-shadow: 0 0 6px rgb(255 255 255 / 0.9), inset -2px -3px 4px rgb(0 0 0 / 0.08); }
.sk-bit.k-bean { aspect-ratio: 1.6; border-radius: 50% 50% 46% 54%; background: radial-gradient(circle at 35% 35%, #c86b4a, #8b3a22); }
.sk-bit.k-coin { aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe58a, #d1a32a); box-shadow: inset 0 0 0 2px #b3881d; }
.sk-bit.k-thing { display: grid; place-items: center; font: calc(var(--jw) * 0.13)/1 var(--emoji); }

.sk-meter { display: grid; justify-items: center; gap: 4px; padding: 6px; border-radius: 16px; background: #26304a; box-shadow: var(--shadow); }
.sk-meter-end { font: 20px/1 var(--emoji); }
.sk-bars { display: flex; flex-direction: column; gap: 3px; }
.sk-seg { width: clamp(26px, 5cqmin, 40px); height: calc(var(--jw) * 0.085); border-radius: 4px; background: #3c4766; transition: background 0.08s; }
.sk-seg.on.green { background: #5ad06d; box-shadow: 0 0 8px #5ad06d; }
.sk-seg.on.amber { background: #ffc93a; box-shadow: 0 0 8px #ffc93a; }
.sk-seg.on.red { background: #ff5a4d; box-shadow: 0 0 8px #ff5a4d; }
.sk-buttons .big { min-width: 0; }

.sk-chart { container-type: inline-size; display: grid; gap: 1cqmin; padding: 2cqmin; border: 3px solid transparent; border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.sk-chart.asking { border-color: var(--gold); animation: sk-glow 1.6s ease-in-out infinite; }
@keyframes sk-glow { 50% { box-shadow: 0 0 0 6px rgb(242 176 30 / 0.3), var(--shadow); } }
.sk-chart-title { margin: 0 0 0.2em; font: 600 clamp(16px, 3.4cqmin, 24px)/1.1 var(--book); text-align: center; }
.sk-row {
  display: grid;
  grid-template-columns: auto minmax(3.5em, auto) minmax(40px, 1fr) 4.6em;
  align-items: center;
  gap: 0.5em;
  min-height: 48px;
  padding: 2px 8px;
  border: 3px solid transparent;
  border-radius: 14px;
  background: none;
  color: var(--ink);
  font: 400 clamp(14px, 2.8cqmin, 19px)/1.1 var(--book);
  text-align: left;
}
.sk-row-emoji { font: clamp(24px, 5cqmin, 34px)/1 var(--emoji); }
.sk-track { height: 18px; border-radius: 9px; background: var(--accent-soft); overflow: hidden; }
.sk-bar { display: block; width: 0; height: 100%; border-radius: 9px; background: #5ad06d; }
.sk-word { color: var(--muted); font-size: 0.86em; }
.sk-row.tested .sk-word { color: var(--ink); }
.sk-chart.asking .sk-row { border-color: var(--line); background: #fffbea; cursor: pointer; }
.sk-row.right { border-color: var(--right) !important; background: var(--right-soft) !important; }
.sk-row.wrong { border-color: var(--wrong) !important; }

/* A narrow chart: the bar goes under the name. */
@container (max-width: 400px) {
  .sk-row { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: 'e l w' 'e b b'; row-gap: 4px; padding: 4px 8px; }
  .sk-row-emoji { grid-area: e; }
  .sk-row-label { grid-area: l; }
  .sk-word { grid-area: w; }
  .sk-track { grid-area: b; height: 14px; }
}

/* Upright: the fillings in a row, the jar and meter, then the results. */
@container (max-aspect-ratio: 23/20) {
  .lab-shaker { --jw: min(24cqw, 15cqh); }
  .sk-wrap { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; align-content: safe center; justify-items: center; gap: 1.6cqh; }
  .sk-shelf { grid-template-columns: repeat(4, auto); }
  .sk-shelf .card { width: clamp(80px, 19cqw, 130px); }
  .sk-shelf .card-emoji { font-size: clamp(32px, 5.4cqh, 48px); }
  .sk-row { min-height: 40px; }
  .sk-chart { width: min(100%, 600px); }
}

/* ---- Torch: a teddy between a torch and a wall ---- */

.tc-wrap { display: grid; grid-template-rows: auto auto auto; align-content: center; justify-items: center; gap: 1.4cqmin; width: 100%; height: 100%; }
.tc-scene { width: 100%; height: 100%; min-height: 0; border-radius: 3cqmin; touch-action: none; user-select: none; -webkit-user-select: none; }
.tc-room { fill: #3a4262; }
.tc-floor { fill: #9a7350; }
.tc-board { stroke: #87623f; stroke-width: 3; }
.tc-wall { fill: #8f8a7e; }
.tc-wall-edge { fill: #6e6a60; }
.tc-spot { opacity: 0.96; }
.tc-beam { pointer-events: none; mix-blend-mode: screen; }
.tc-wedge { fill: #1b1f36; opacity: 0.55; pointer-events: none; }
.tc-word { fill: #e8ecff; font: 600 22px var(--ui); text-anchor: middle; pointer-events: none; }
.tc-book.a { fill: #2f6fd6; }
.tc-book.b { fill: #e0453a; }
.tc-body { fill: #4a5568; }
.tc-button { fill: #f2b01e; }
.tc-head { fill: #2d3546; }
.tc-lens { fill: #fff8c8; }
.tc-lens-glow { fill: #fff3a0; opacity: 0.9; filter: blur(6px); pointer-events: none; }
.tc-torch { cursor: pointer; }
.tc-teddy { font-family: var(--emoji); pointer-events: none; }
.tc-shade { pointer-events: none; }
.tc-hit { fill: transparent; cursor: grab; }
.tc-scene.held .tc-hit { cursor: grabbing; }
.lab-torch .tc-note { min-height: 1.3em; font-size: clamp(18px, 4.4cqmin, 30px); }
.lab-torch[data-shadow="big"] .tc-note { color: #1d2433; font-weight: 600; }
.lab-torch[data-shadow="none"] .tc-note { color: var(--muted); }
.tc-goal-pic { position: relative; flex: none; width: 26px; height: 26px; border-radius: 6px; background: #f6e7b0; }
.tc-goal-pic::after { content: ''; position: absolute; left: 50%; bottom: 10%; translate: -50% 0; border-radius: 40% 40% 30% 30%; background: #1b1f36; }
.tc-goal-pic.pic-big::after { width: 80%; height: 80%; }
.tc-goal-pic.pic-small::after { width: 34%; height: 40%; }

/* The scene keeps its shape: as wide as fits under the words. */
.tc-scene { width: min(100%, calc((100cqh - 7em) * 1.786)); height: auto; aspect-ratio: 1000 / 560; align-self: center; }

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

@media (max-width: 600px), (max-height: 500px) {
  .lab-phases { min-height: 620px; }
  .lab-shaker { min-height: 640px; }
  .lab-torch { min-height: 330px; }
  .ph-goal { border-width: 2px; }
  .sk-row { min-height: 40px; }
  .sk-meter-end { font-size: 16px; }
}
@media (max-height: 500px) {
  .lab-phases { min-height: 320px; }
  .lab-shaker { min-height: 360px; }
  .lab-torch { min-height: 300px; }
}
