/* Lab activities (life): grow magnify dig (site/js/science/lab-life.js). */

/* ---- Grow: two pots, a fair test ---- */

.lab-grow { grid-template-columns: minmax(0, 1fr); align-content: center; gap: 14px; width: 100%; }
.grow-bench {
  position: relative;
  padding: 8px 18px 14px;
  border-radius: 26px;
  background: linear-gradient(#cfeaff, #eef8ff 58%, #eadcc0 58%, #dccaa6);
  box-shadow: var(--shadow);
}
.grow-sky { display: flex; justify-content: space-between; align-items: center; padding: 0 4px 4px; }
.grow-sun { display: inline-block; font: 44px/1 var(--emoji); }
.grow-days { padding: 4px 14px; border-radius: 999px; background: #fff; box-shadow: var(--shadow); font: 700 22px/1.2 var(--ui); font-variant-numeric: tabular-nums; }
.grow-pots { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.grow-pot { position: relative; display: grid; justify-items: center; gap: 4px; }
.grow-tag {
  position: absolute;
  top: 0;
  right: 2px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font: 800 24px/1 var(--ui);
}
.grow-view { position: relative; height: clamp(170px, 32vh, 330px); aspect-ratio: 100 / 156; }
.grow-art { display: block; width: 100%; height: 100%; overflow: visible; }
.g-pot { fill: #c8693a; }
.g-rim { fill: #dd8250; }
.g-ruler rect { fill: #fff6d2; stroke: #c9b26a; stroke-width: 0.6; }
.g-ruler line { stroke: #8a7740; stroke-width: 0.7; }
.g-ruler text { fill: #6b5a2a; font: 700 5px var(--ui); }
.g-mark { stroke: var(--accent); stroke-width: 1.1; stroke-dasharray: 2.5 1.5; }
.grow-box {
  position: absolute;
  left: 21%;
  top: -2%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 70%;
  height: 69%;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(90deg, #b9824b, #d8a76e 40%, #c38c52);
  box-shadow: inset 0 -8px 0 #9c6a39, 0 8px 14px rgb(0 0 0 / 0.22);
}
.grow-box::before { content: ''; position: absolute; left: 0; right: 0; top: 14%; height: 3px; background: #9c6a39; }
.grow-box::after { content: ''; position: absolute; left: 47%; top: 0; width: 6%; height: 14%; background: #e8c27a; }
.grow-box span { font: 40px/1 var(--emoji); }
.grow-drops { position: absolute; left: 30%; width: 50%; top: 0; height: 70%; z-index: 3; pointer-events: none; }
.grow-drop { position: absolute; left: 40%; top: 0; font: 22px/1 var(--emoji); }
.grow-reading { min-height: 1.3em; margin: 0; color: var(--accent); font: 700 20px/1.3 var(--ui); }
.grow-toggles { display: flex; gap: 10px; }
.grow-toggle {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 78px;
  min-height: 66px;
  padding: 6px 10px 5px;
  border: 3px solid var(--accent);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 3px 0 rgb(29 36 51 / 0.12);
}
.grow-toggle:disabled { opacity: 0.6; }
.gt-emoji { position: relative; font: 30px/1 var(--emoji); }
.gt-word { color: var(--accent); font: 800 15px/1 var(--ui); text-transform: uppercase; }
.grow-toggle[aria-pressed="false"] { border-color: #c3cbd8; background: #eef0f4; }
.grow-toggle[aria-pressed="false"] .gt-emoji { filter: grayscale(1); opacity: 0.6; }
.grow-toggle[aria-pressed="false"] .gt-emoji::after {
  content: '';
  position: absolute;
  left: -5px;
  right: -5px;
  top: 45%;
  height: 4px;
  border-radius: 2px;
  background: var(--wrong);
  transform: rotate(-35deg);
}
.grow-toggle[aria-pressed="false"] .gt-word { color: var(--muted); }
.grow-side { display: grid; justify-items: center; align-content: center; gap: 12px; min-width: 0; }
.grow-note { max-width: 620px; min-height: 2.6em; font-size: 22px; }
.grow-note.right { color: #13643a; }
.grow-note.nudge { color: #8a5300; }
.grow-table {
  width: min(100%, 560px);
  border-spacing: 0;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
  font: 16px/1.25 var(--ui);
}
.grow-table th, .grow-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: center; }
.grow-table th { background: var(--accent-soft); font-weight: 700; }
.grow-table tbody tr:last-child td { border-bottom: 0; }
.grow-table tbody tr:nth-child(n + 4) { display: none; } /* the three latest runs */
.g-empty td { padding: 10px; color: var(--muted); }
.g-run { color: var(--muted); font-weight: 700; }
.gi { font-family: var(--emoji); }
.gi.off { filter: grayscale(1); opacity: 0.3; text-decoration: line-through; }
.g-result { display: block; color: var(--muted); font-size: 14px; }
.g-fair { font-weight: 700; white-space: nowrap; }
tr.fair .g-fair { color: #13643a; }
tr.unfair .g-fair { color: #8a5300; }

/* ---- Magnify: a magnifying glass over a garden bed ---- */

.lab-magnify { grid-template-columns: minmax(0, 1fr); align-content: center; justify-items: center; gap: 14px; width: 100%; }
.mag-garden { position: relative; width: min(100%, 760px, 52vh * 1.6); aspect-ratio: 16 / 10; touch-action: none; }
.mag-world {
  position: absolute;
  inset: 0;
  overflow: hidden;
  container-type: size;
  border-radius: 24px;
  background:
    radial-gradient(circle at 20% 60%, rgb(255 255 255 / 0.06) 0 2px, transparent 3px) 0 0 / 22px 22px,
    radial-gradient(circle at 70% 30%, rgb(0 0 0 / 0.12) 0 2px, transparent 3px) 0 0 / 30px 30px,
    linear-gradient(#7a5234, #5d3d24);
  box-shadow: var(--shadow);
}
.mag-world.clone { inset: auto; left: 0; top: 0; border-radius: 0; box-shadow: none; }
.mag-grass { position: absolute; left: 0; right: 0; top: 0; height: 20%; background: linear-gradient(#9ad874, #6db14c); border-radius: 0 0 50% 50% / 0 0 18% 18%; }
.mag-log {
  position: absolute;
  left: 4%;
  top: 52%;
  width: 34%;
  height: 15%;
  border-radius: 6cqh;
  background: repeating-linear-gradient(90deg, #8f5d34 0 1.2cqw, #7a4d2a 1.2cqw 2cqw);
  box-shadow: inset 0 -1.2cqh 0 rgb(0 0 0 / 0.2), 0 1cqh 2cqh rgb(0 0 0 / 0.3);
}
.mag-log::after {
  content: '';
  position: absolute;
  right: -2%;
  top: 0;
  height: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, #e2b376 0 18%, #b98048 19% 34%, #e2b376 35% 52%, #b98048 53% 68%, #d9a86a 69%);
}
.mag-bit { position: absolute; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)); font: calc(var(--s) * 1cqw)/1 var(--emoji); pointer-events: none; }
.mag-cover { z-index: 2; }
.mag-beast { position: absolute; z-index: 1; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)); font: 4cqw/1 var(--emoji); pointer-events: none; }
.mag-beast.spotted { filter: drop-shadow(0 0 0.5cqw #fff) drop-shadow(0 0 0.8cqw #ffe58a); }
.mag-beast.found::after {
  content: '✓';
  position: absolute;
  right: -1.4cqw;
  top: -1.4cqw;
  display: grid;
  place-items: center;
  width: 2.4cqw;
  height: 2.4cqw;
  border-radius: 50%;
  background: var(--right);
  color: #fff;
  font: 800 1.6cqw/1 var(--ui);
}
.mag-lens { position: absolute; left: 0; top: 0; z-index: 5; width: var(--lens, 140px); height: var(--lens, 140px); touch-action: none; cursor: grab; }
.mag-glass { position: absolute; inset: 0; overflow: hidden; border-radius: 50%; background: #5d3d24; }
.mag-glare { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 30% 26%, rgb(255 255 255 / 0.5), transparent 32%); pointer-events: none; }
.mag-ring {
  position: absolute;
  inset: -9px;
  border: 11px solid #2f3646;
  border-radius: 50%;
  box-shadow: 0 10px 22px rgb(0 0 0 / 0.35), inset 0 0 0 2px rgb(255 255 255 / 0.25), 0 0 0 2px rgb(255 255 255 / 0.4);
}
.mag-handle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 17%;
  height: 112%;
  border-radius: 10px;
  background: linear-gradient(90deg, #6f3818, #c06a2f 45%, #6f3818);
  box-shadow: 0 6px 12px rgb(0 0 0 / 0.3);
  transform: translateX(-50%) rotate(-45deg);
  transform-origin: top center;
}
.mag-panel { display: grid; justify-items: center; align-content: center; gap: 10px; width: 100%; }
.mag-look { display: grid; place-items: center; min-height: 160px; }
.mag-find { font: 72px/1 var(--emoji); opacity: 0.35; }
.mag-card { min-width: 150px; }
.mag-card .card-emoji { font-size: 104px; }
.mag-card .card-label { font-size: 24px; }
.mag-ask { font-size: 26px; }
.mag-ask.hint { color: #8a5300; }
.mag-legs { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.mag-leg {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 132px;
  padding: 10px 12px 8px;
  border: 3px solid #b9c6dc;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 4px 0 rgb(29 36 51 / 0.12);
}
.mag-leg:active { transform: translateY(2px); }
.leg-icon { width: 76px; height: 48px; }
.li-leg { stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.li-body { fill: #3a3f4d; }
.li-worm { fill: none; stroke: #e38b8b; stroke-width: 8; stroke-linecap: round; }
.mag-leg-word { font: 400 21px/1.1 var(--book); }
.mag-tray { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.mag-tray-head { color: #13643a; font: 700 20px/1 var(--ui); }
.mag-slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.mag-slot { display: grid; place-items: center; width: 98px; height: 112px; border: 3px dashed #b9c6dc; border-radius: 18px; }
.mag-slot .card { min-width: 0; padding: 4px 6px; box-shadow: none; }
.mag-slot .card-emoji { font-size: 38px; }
.mag-slot .card-label { font-size: 15px; }
.mag-chip { padding: 2px 6px; border-radius: 999px; background: var(--right-soft); color: #13643a; font: 700 12px/1.2 var(--ui); white-space: nowrap; }

/* ---- Dig: brush the sand away, sort the fossils ---- */

.lab-dig { grid-template-columns: minmax(0, 1fr); align-content: center; justify-items: center; gap: 12px; width: 100%; }
.dig-pit {
  position: relative;
  width: min(100%, 720px, 46vh * 1.6);
  aspect-ratio: 16 / 10;
  overflow: hidden;
  container-type: inline-size;
  border: 10px solid #8a5a32;
  border-radius: 24px;
  background: repeating-linear-gradient(176deg, #b99a6b 0 18px, #a98a5c 18px 30px, #c7a978 30px 44px);
  box-shadow: var(--shadow), inset 0 0 0 3px #6f4626;
  touch-action: none;
}
.dig-bed { position: absolute; inset: 0; }
.dig-fossil {
  position: absolute;
  display: grid;
  place-items: center;
  width: 17cqw;
  aspect-ratio: 1;
  border-radius: 46% 54% 50% 50%;
  background: radial-gradient(circle at 40% 35%, #eadcbf, #bda67c 72%);
  box-shadow: inset 0 0 0 3px rgb(120 90 50 / 0.35), inset 0 -6px 12px rgb(90 60 30 / 0.3);
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
}
.dig-fossil-emoji { font: 10cqw/1 var(--emoji); filter: sepia(0.6) saturate(0.75) drop-shadow(0 1px 0 rgb(255 255 255 / 0.6)); }
.dig-fossil.lifted .dig-fossil-emoji { opacity: 0.2; filter: grayscale(1); }
.dig-sand { position: absolute; inset: 0; width: 100%; height: 100%; }
.dig-grains { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.dig-grain { position: absolute; left: 0; top: 0; width: 5px; height: 5px; border-radius: 50%; background: #d4ad6c; }
.dig-brush { position: absolute; left: 0; top: 0; z-index: 3; font: 58px/1 var(--emoji); pointer-events: none; }
.dig-brush.resting { pointer-events: auto; }
.dig-side {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  grid-template-areas: "tray tray" "bins notes";
  gap: 12px;
  width: min(100%, 760px);
}
.lab-dig .dig-tray { grid-area: tray; align-items: center; min-height: 104px; padding: 8px; border: 3px dashed #d9c39a; border-radius: 20px; background: rgb(255 255 255 / 0.5); }
.dig-tray-hint { color: var(--muted); font: 400 22px/1.2 var(--book); }
.lab-dig .bins { grid-area: bins; }
.lab-dig .bin { min-height: 140px; }
.dig-notes {
  grid-area: notes;
  min-height: 140px;
  padding: 8px 12px 10px 34px;
  border-radius: 6px 16px 16px 6px;
  background:
    linear-gradient(90deg, transparent 24px, #eba3a3 24px 26px, transparent 26px),
    repeating-linear-gradient(#fffdf3 0 27px, #cfe0f5 27px 28px);
  box-shadow: var(--shadow);
  font: 400 19px/28px var(--book);
}
.dig-notes-head { margin: 0; font-weight: 700; }
.dig-notes-list { margin: 0; padding-left: 1.1em; }
.dn-emoji { font-family: var(--emoji); }
.dn-bin { color: #13643a; }

/* Wide screens: the experiment on the left, the record on the right. */
@media (min-aspect-ratio: 5 / 4) {
  .lab-grow { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 24px; }
  .lab-magnify { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: center; }
  .mag-garden { width: min(100%, 64vh * 1.6); }
  .lab-dig { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: center; }
  .dig-pit { width: min(100%, 62vh * 1.6); }
  .dig-side { grid-template-columns: minmax(0, 1fr); grid-template-areas: "tray" "bins" "notes"; }
  .lab-dig .bin, .dig-notes { min-height: 110px; }
}

/* iPad: the activity fills the space under the words, so it sizes itself by it. */
@media (min-width: 601px) and (min-height: 501px) {
  .lab-grow, .lab-magnify, .lab-dig { container-type: size; }
  .grow-view { height: clamp(150px, 100cqh - 450px, 330px); }
  .grow-table tbody tr:nth-child(n + 3) { display: none; }
  .mag-garden { width: min(100%, 760px, (100cqh - 300px) * 1.6); }
  .mag-panel { grid-template-columns: auto auto; grid-template-areas: "look ask" "look legs" "tray tray"; justify-content: center; column-gap: 24px; row-gap: 8px; }
  .mag-look { grid-area: look; min-height: 0; }
  .mag-ask { grid-area: ask; align-self: end; }
  .mag-legs { grid-area: legs; align-self: start; }
  .mag-tray { grid-area: tray; }
  .mag-panel:not(:has(.mag-legs:not([hidden]))) .mag-ask { grid-row: 1 / 3; align-self: center; }
  .dig-pit { width: min(100%, 720px, (100cqh - 290px) * 1.6); }
}
@media (min-width: 601px) and (min-height: 501px) and (min-aspect-ratio: 5 / 4) {
  .grow-view { height: clamp(150px, 100cqh - 200px, 330px); }
  .grow-table tbody tr:nth-child(3) { display: table-row; }
  .mag-garden { width: min(100%, 100cqh * 1.6); }
  .mag-panel { grid-template-columns: minmax(0, 1fr); grid-template-areas: "look" "ask" "legs" "tray"; }
  .mag-panel:not(:has(.mag-legs:not([hidden]))) .mag-ask { grid-row: auto; }
  .mag-ask { align-self: center; }
  .mag-look { min-height: 130px; }
  .mag-card { min-width: 120px; }
  .mag-card .card-emoji { font-size: 80px; }
  .mag-legs { gap: 8px; }
  .mag-leg { min-width: 100px; padding: 6px 6px 5px; }
  .leg-icon { width: 62px; height: 38px; }
  .mag-leg-word { font-size: 18px; }
  .mag-slots { flex-wrap: nowrap; gap: 6px; }
  .mag-slot { width: 78px; height: 96px; }
  .mag-slot .card-emoji { font-size: 30px; }
  .mag-tray-head { display: none; }
  .dig-pit { width: min(100%, (100cqh - 10px) * 1.6); }
}

@media (max-width: 600px), (max-height: 500px) {
  .lab-grow, .lab-magnify, .lab-dig { gap: 10px; }
  .grow-bench { padding: 6px 10px 10px; border-radius: 20px; }
  .grow-sun { font-size: 32px; }
  .grow-days { font-size: 17px; }
  .grow-pots { gap: 10px; }
  .grow-tag { width: 32px; height: 32px; font-size: 18px; }
  .grow-view { height: clamp(150px, 30vh, 220px); }
  .grow-reading { font-size: 16px; }
  .grow-toggles { gap: 6px; }
  .grow-toggle { min-width: 62px; min-height: 56px; padding: 4px 6px; border-radius: 14px; }
  .gt-emoji { font-size: 24px; }
  .gt-word { font-size: 12px; }
  .grow-note { font-size: 17px; }
  .grow-table { font-size: 13px; }
  .grow-table th, .grow-table td { padding: 4px 4px; }
  .g-result { font-size: 12px; }

  .mag-garden { width: min(100%, 60vh * 1.6); }
  .mag-look { min-height: 110px; }
  .mag-find { font-size: 48px; }
  .mag-card { min-width: 110px; }
  .mag-card .card-emoji { font-size: 66px; }
  .mag-card .card-label { font-size: 18px; }
  .mag-ask { font-size: 19px; }
  .mag-legs { gap: 8px; }
  .mag-leg { min-width: 98px; padding: 6px 6px 5px; border-radius: 16px; }
  .leg-icon { width: 60px; height: 38px; }
  .mag-leg-word { font-size: 16px; }
  .mag-slot { width: 74px; height: 88px; border-radius: 14px; }
  .mag-slot .card-emoji { font-size: 28px; }
  .mag-slot .card-label { font-size: 12px; }
  .mag-chip { font-size: 10px; }
  .mag-tray-head { font-size: 16px; }

  .dig-pit { width: min(100%, 60vh * 1.6); border-width: 7px; border-radius: 18px; }
  .dig-brush { font-size: 40px; }
  .dig-side { gap: 8px; }
  .lab-dig .dig-tray { min-height: 76px; }
  .dig-tray-hint { font-size: 17px; }
  .lab-dig .bin, .dig-notes { min-height: 96px; }
  .dig-notes { padding-left: 30px; font-size: 15px; line-height: 22px; background:
    linear-gradient(90deg, transparent 20px, #eba3a3 20px 22px, transparent 22px),
    repeating-linear-gradient(#fffdf3 0 21px, #cfe0f5 21px 22px); }
}

@media (max-width: 600px) {
  .dig-side { grid-template-columns: minmax(0, 1fr); grid-template-areas: "tray" "bins" "notes"; }
  .dig-notes { min-height: 0; }
}

/* Every fossil is out and sorted: the empty tray steps aside. */
.lab-dig .dig-tray.empty { display: none; }
.lab-dig .bin-list .card-emoji { font-size: 30px; }

/* A phone on its side: the experiment at the top, the record scrolls beside it. */
@media (max-height: 500px) {
  .lab-grow, .lab-magnify, .lab-dig { align-items: start; }
  .mag-look { min-height: 0; }
  .mag-tray-head { display: none; }
}
