/* Design and Technologies lab activities (energy and forces): circuit and lever
   (site/js/science/design-power.js). They share the lab layout of lab-motion.css (.mo-*):
   on the iPad each fills the space under the instruction; on a phone the step scrolls. */

.lab-circuit .mo-in, .lab-lever .mo-in { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto minmax(0, 1fr); grid-template-areas: "world" "kit" "note" "side"; }
.ci-world, .lv-world {
  grid-area: world;
  justify-self: center;
  position: relative;
  width: min(100%, (100dvh - 750px) * 2);
  aspect-ratio: 2;
  overflow: hidden;
  container-type: inline-size;
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.mo-side [hidden] { display: none; }

/* ---- Circuit ---- */

.ci-world { background: #f3efe4; }
.ci-board { position: absolute; inset: 0; background: radial-gradient(circle at 1.2cqw 1.2cqw, #d9d1bd 0 0.18cqw, transparent 0.22cqw) 0 0 / 2.4cqw 2.4cqw, linear-gradient(#faf7ef, #efe8d6); }
.ci-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ci-wires { fill: none; stroke: #d6453d; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ci-flow { fill: none; stroke: #ffd400; stroke-width: 2.6; stroke-linecap: round; stroke-dasharray: 0.01 7; filter: drop-shadow(0 0 1px #ffb300); }
.ci-post { fill: #e2b13c; stroke: #8a6a1a; stroke-width: 0.8; }

/* The sockets: where a part goes (top left) and the gap to close (top right), on the top wire at 36 %
   (LOOP in design-power.js). */
.ci-socket { position: absolute; top: 36%; width: 18cqw; height: 19cqw; translate: -50% -84%; border: 0.3cqw dashed transparent; border-radius: 2cqw; cursor: pointer; touch-action: manipulation; }
.ci-out { left: 30%; }
.ci-gap { left: 70%; }
.ci-socket.empty { border-color: #b9ad8f; background: rgb(255 255 255 / 0.55); }
.ci-hint { position: absolute; left: 0; right: 0; top: 18%; font: 3.6cqw/1 var(--emoji); text-align: center; opacity: 0.4; pointer-events: none; }
.ci-gap .ci-hint { color: #8a7d5c; font: 700 6cqw/1 var(--ui); opacity: 0.6; }
.ci-socket:not(.empty) .ci-hint { display: none; }
.ci-in { position: absolute; left: 50%; bottom: 16%; translate: -50% 0; display: block; line-height: 0; font-size: 2.6cqw; pointer-events: none; }
.ci-gap .ci-in { bottom: auto; top: 84%; translate: -50% -50%; }
.ci-gap .ci-switch { pointer-events: auto; cursor: pointer; }

/* The battery: an AA cell lying in the bottom wire, minus on the left, plus on the right. */
.ci-cell { position: absolute; left: 50%; top: 82%; width: 21cqw; height: 7cqw; translate: -50% -50%; display: flex; }
.ci-cell-body { position: relative; flex: 7; border-radius: 1cqw 0 0 1cqw; background: linear-gradient(#4a5160, #1f2430 55%, #3a404e); }
.ci-cell-top { position: relative; flex: 3; border-radius: 0 0.6cqw 0.6cqw 0; background: linear-gradient(#ffd77a, #e0a52c 55%, #f1c25a); }
.ci-nub { position: absolute; right: -1.1cqw; top: 30%; width: 1.2cqw; height: 40%; border-radius: 0 0.4cqw 0.4cqw 0; background: linear-gradient(#e9eef3, #9ba6b4); }
.ci-sign { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font: 800 4.4cqw/1 var(--ui); }
.ci-cell-top .ci-sign { color: #6b4a00; }
.ci-tag { position: absolute; left: 50%; top: 94%; translate: -50% -50%; padding: 0 0.8em; border-radius: 999px; background: rgb(255 255 255 / 0.85); font: 400 max(11px, 2cqw)/1.35 var(--book); white-space: nowrap; }

/* The parts, drawn in em: 1em is 2.6cqw on the board and a few px on a card. Those that close the
   gap are 6.2em long, from terminal to terminal (16 % of the board). */
.ci-part { position: relative; display: inline-block; }
.ci-globe { width: 3.2em; height: 4.4em; }
.ci-glass { position: absolute; left: 0; top: 0; width: 3.2em; height: 3.2em; box-sizing: border-box; border: 0.14em solid #9aa6b5; border-radius: 50%; background: radial-gradient(circle at 34% 30%, #fff 0 14%, #e9eef4 16% 100%); transition: background 0.2s, box-shadow 0.2s; }
.ci-fil { position: absolute; left: 32%; right: 32%; top: 44%; height: 0.7em; border: 0.14em solid #7a5a2a; border-top: 0; border-radius: 0 0 0.6em 0.6em; }
.ci-base { position: absolute; left: 0.85em; width: 1.5em; top: 3em; height: 1.4em; border-radius: 0.2em 0.2em 0.6em 0.6em; background: repeating-linear-gradient(#c3cad3 0 0.24em, #8d96a3 0.24em 0.38em); }
.ci-globe.on .ci-glass { border-color: #e0a800; background: radial-gradient(circle at 50% 55%, #fffdf0 0 22%, #ffe45c 58%, #ffc400 100%); box-shadow: 0 0 1em 0.45em rgb(255 214 0 / 0.75), 0 0 2.6em 1.2em rgb(255 232 120 / 0.45); }
.ci-globe.on .ci-fil { border-color: #ff7a00; }

.ci-motor { width: 3.6em; height: 5.6em; }
.ci-fan { position: absolute; left: 50%; top: 0; width: 3em; height: 3em; translate: -50% 0; }
.ci-fan svg { display: block; width: 100%; height: 100%; overflow: visible; }
.ci-blades ellipse { fill: #4ecdc4; stroke: #1f8f88; stroke-width: 0.5; }
.ci-fan circle { fill: #55606f; }
.ci-shaft { position: absolute; left: 50%; top: 2.9em; width: 0.32em; height: 0.8em; translate: -50% 0; background: #8d96a3; }
.ci-body { position: absolute; left: 0; right: 0; bottom: 0; height: 2em; border-radius: 0.5em; background: linear-gradient(#c9d0d9, #8d96a3 60%, #b3bcc7); }
.ci-body-end { position: absolute; left: 0.3em; right: 0.3em; top: 0.35em; height: 0.35em; border-radius: 0.2em; background: #e5484d; }

.ci-buzzer { width: 3.4em; height: 2.6em; }
.ci-bz-body { position: absolute; left: 0; bottom: 0; width: 3.4em; height: 2.2em; border-radius: 0.6em; background: linear-gradient(90deg, #2a2f38, #4a5160 45%, #2a2f38); }
.ci-bz-top { position: absolute; left: 0.5em; right: 0.5em; top: 0.3em; height: 0.9em; border-radius: 50%; background: radial-gradient(circle, #111 0 0.16em, transparent 0.2em) 0 0 / 0.55em 0.45em, #3a404e; }
.ci-bz-waves { position: absolute; left: 100%; bottom: 0.2em; width: 1.6em; height: 2em; opacity: 0; }
.ci-bz-waves i { position: absolute; top: 50%; left: 0; width: 0.9em; height: 0.9em; translate: 0 -50%; border: 0.18em solid #e5484d; border-color: transparent #e5484d transparent transparent; border-radius: 50%; }
.ci-bz-waves i:nth-child(2) { left: 0.3em; width: 1.5em; height: 1.5em; }
.ci-bz-waves i:nth-child(3) { left: 0.6em; width: 2.1em; height: 2.1em; }
.ci-buzzer.on .ci-bz-waves { opacity: 1; animation: ci-waves 0.5s ease-in-out infinite; }
.ci-buzzer.on .ci-bz-body { animation: ci-shake 0.09s linear infinite; }
@keyframes ci-waves { 50% { opacity: 0.35; } }
@keyframes ci-shake { 25% { translate: -0.08em 0; } 75% { translate: 0.08em 0; } }

.ci-wire { width: 6.2em; height: 0.55em; border-radius: 0.3em; background: #d6453d; }
.ci-wire-core { position: absolute; left: -0.25em; right: -0.25em; top: 0.15em; height: 0.25em; border-radius: 0.15em; background: linear-gradient(90deg, #c98a2b 0 0.5em, transparent 0.5em calc(100% - 0.5em), #c98a2b 0); }

.ci-switch { width: 6.2em; height: 1.4em; }
.ci-sw-base { position: absolute; left: -0.4em; right: -0.4em; bottom: -0.45em; height: 0.9em; border-radius: 0.3em; background: linear-gradient(#e2b77d, #c08a4a); }
.ci-sw-post { position: absolute; bottom: 0.1em; width: 0.8em; height: 0.8em; border-radius: 50%; background: #e2b13c; box-shadow: inset 0 0 0 0.12em #8a6a1a; }
.ci-sw-post.a { left: 0; }
.ci-sw-post.b { right: 0; }
.ci-sw-blade { position: absolute; left: 0.4em; bottom: 0.35em; width: 5.4em; height: 0.36em; border-radius: 0.18em; background: linear-gradient(#f4f6f8, #9ba6b4); transform-origin: 0.1em 50%; rotate: -32deg; transition: rotate 0.25s cubic-bezier(0.34, 1.6, 0.64, 1); }
.ci-sw-knob { position: absolute; right: -0.5em; top: 50%; width: 1em; height: 1em; translate: 0 -50%; border-radius: 50%; background: #e5484d; box-shadow: inset 0 -0.15em 0 rgb(0 0 0 / 0.2); }
.ci-switch.on .ci-sw-blade { rotate: 0deg; }
.ci-board .ci-switch::after { content: ''; position: absolute; inset: -3em -1em -1.4em; } /* a big target for a finger */

.ci-item { width: 6.2em; height: 4em; display: flex; align-items: center; justify-content: center; }
.ci-item-e { font: 3.6em/1 var(--emoji); }
.ci-clip { position: absolute; top: 50%; width: 1.4em; height: 0.5em; translate: 0 -50%; border-radius: 0.2em; background: #3a404e; }
.ci-clip.a { left: 0; }
.ci-clip.b { right: 0; }

/* The kit's cards show the parts small. */
.mo-kit .ci-icon { display: flex; align-items: center; justify-content: center; height: 50px; font: 9px/1 var(--ui); }
.ci-card.in-use { border-color: var(--subject, var(--accent)); background: var(--subject-soft, #fff); }
.mo-kit .ci-thing .card-emoji { font-size: 40px; }
/* The circuit's tables have a result to read, not an amount to compare: no bars. */
.lab-circuit .mo-row.card { grid-template-areas: "e l v"; padding-block: 6px; }
.lab-circuit .mo-bar { display: none; }
.ci-test .mo-row.ci-yes .mo-val { color: #8a6400; }
.ci-jobs .mo-row.right .mo-val { color: var(--right); font-size: 24px; }

/* ---- Lever ---- */

.lv-sky { position: absolute; inset: 0 0 14% 0; background: linear-gradient(#dcefff, #fbf8f1); }
.lv-ground { position: absolute; inset: 86% 0 0 0; background: linear-gradient(#8ccf6a, #6fb24e 30%, #b79a6a 30%, #a2865a); }
.lv-spot { position: absolute; top: 93%; width: 5cqw; height: 5cqw; translate: -50% -50%; box-sizing: border-box; border: 0.4cqw dashed rgb(255 255 255 / 0.9); border-radius: 50%; cursor: pointer; touch-action: manipulation; }
.lv-spot.picked { border-style: solid; background: rgb(255 255 255 / 0.5); }
.lv-spot::after { content: ''; position: absolute; inset: -12px; } /* a finger-sized target */
.lv-pivot { position: absolute; top: 58%; width: 10cqw; height: 28%; translate: -50% 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); background: linear-gradient(90deg, #7a8494, #aeb6c2 50%, #7a8494); }
.lv-plank { position: absolute; top: calc(58% - 2.2cqw); height: 2.2cqw; border-radius: 0.6cqw; background: repeating-linear-gradient(90deg, #d9a35f 0 9cqw, #c48b48 9cqw 9.3cqw), #d9a35f; box-shadow: inset 0 -0.4cqw 0 rgb(0 0 0 / 0.15); }
.lv-load { position: absolute; left: 0.5cqw; bottom: 100%; display: grid; justify-items: center; }
.lv-load-e { order: 2; font: 10cqw/1 var(--emoji); }
.lv-kg { order: 1; padding: 0 0.7em; border-radius: 999px; background: #1d2433; color: #fff; font: 700 max(11px, 2.1cqw)/1.5 var(--ui); white-space: nowrap; }
.lv-push-at { position: absolute; right: 0.5cqw; bottom: 100%; display: grid; justify-items: center; width: 7cqw; }
.lv-hand-wrap { line-height: 0; }
.lv-hand { display: inline-block; font: 6cqw/1 var(--emoji); }
.lv-spring { display: block; width: 3cqw; height: 6cqw; transform-origin: 50% 100%; background: repeating-linear-gradient(160deg, transparent 0 0.5cqw, #5d6676 0.5cqw 0.9cqw, transparent 0.9cqw 1.3cqw); border-block: 0.5cqw solid #5d6676; }

/* The scale's dial, top middle: how heavy the load feels to your push. */
.lv-dial { position: absolute; left: 50%; top: 2%; width: 23cqw; translate: -50% 0; display: grid; justify-items: center; padding: 0.8cqw 1cqw 0.6cqw; border-radius: 2cqw; background: rgb(255 255 255 / 0.92); box-shadow: 0 0.3cqw 1cqw rgb(29 36 51 / 0.15); }
.lv-dial-title { color: var(--muted); font: 700 max(10px, 1.7cqw)/1.2 var(--ui); white-space: nowrap; }
.lv-face { position: relative; width: 18cqw; aspect-ratio: 100 / 56; }
.lv-dial-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.lv-arc { fill: none; stroke: #e7e1d3; stroke-width: 7; }
.lv-tick { stroke: #5d6676; stroke-width: 1.6; }
.lv-needle { position: absolute; left: calc(50% - 0.35cqw); bottom: 7%; width: 0.7cqw; height: 66%; border-radius: 0.35cqw; background: var(--wrong); }
.lv-hub { position: absolute; left: 50%; bottom: 7%; width: 2cqw; height: 2cqw; translate: -50% 50%; border-radius: 50%; background: #1d2433; }
.lv-read { font: 800 max(15px, 3.4cqw)/1.15 var(--ui); font-variant-numeric: tabular-nums; }
.lv-scale-n { display: flex; justify-content: space-between; width: 100%; margin-top: -1.2em; color: var(--muted); font: 700 max(9px, 1.5cqw)/1 var(--ui); }
/* A small view (a phone): the dial's words keep their size, so the dial takes more room. */
@container (max-width: 560px) {
  .lv-dial { top: 1%; width: 34cqw; padding-block: 0.4cqw; }
  .lv-face { width: 22cqw; }
}

.lv-icon { width: 54px; height: 30px; }
.lv-icon rect { fill: #d9a35f; }
.lv-icon polygon { fill: #7a8494; }
.lv-icon-load { fill: #8d96a3; }
.lab-lever .lv-push { min-width: 170px; }
.lv-table .mo-row .card-emoji { line-height: 0; }
.lv-table .lv-icon { width: 46px; height: 26px; }

/* ---- iPad on its side: the results go to the right ---- */

@container (min-aspect-ratio: 3 / 2) {
  .lab-circuit .mo-in, .lab-lever .mo-in { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); grid-template-areas: "world side" "kit side" "note side"; align-content: start; }
  .ci-world, .lv-world { width: min(100%, (100dvh - 520px) * 2); }
}

/* ---- Phones: everything at its own height; the step scrolls ---- */

@media (max-width: 600px), (max-height: 500px) {
  .ci-world, .lv-world { width: 100%; border-radius: 16px; }
  .mo-kit .ci-icon { height: 40px; font-size: 7px; }
  .mo-kit .ci-thing .card-emoji { font-size: 30px; }
  .lv-icon { width: 44px; height: 24px; }
  .lab-lever .big, .lab-circuit .big { min-height: 52px; }
  .lab-lever .lv-push { min-width: 0; }
}

/* A phone on its side: picture on the left, the rest on the right. */
@media (max-height: 500px) {
  .lab-circuit .mo-in, .lab-lever .mo-in { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); grid-template-rows: auto auto auto; grid-template-areas: "world side" "kit side" "note side"; align-items: start; }
}

@media (prefers-reduced-motion: reduce) {
  .ci-buzzer.on .ci-bz-waves, .ci-buzzer.on .ci-bz-body { animation: none; }
}
