/* Sink or Float Lab: a bright, clean school lab. Mint walls and white
   glass; the one loud thing is the tank. The guesses are colour coded
   everywhere: buoy yellow for float, deep indigo for sink. Quicksand is the
   printed lab label; Mali is the handwriting in the lab notebook. */

:root {
  --mint-50: #f1fbf6;
  --mint-100: #dff5ea;
  --mint-200: #c3ead6;
  --mint-400: #6fcca4;
  --mint-600: #2c8f6b;
  --ink: #123f38;
  --ink-soft: #3f6b62;
  --paper: #ffffff;
  --rule: #cfe7f3;
  --float: #ffbf2e;
  --float-deep: #c98500;
  --float-ink: #3d2900;
  --sink: #3d50c3;
  --sink-deep: #26338a;
  --star: #b97400;

  --hand: "Mali", "Comic Sans MS", cursive;
  --body: "Quicksand", "Avenir Next", system-ui, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--mint-100);
  color: var(--ink);
  font: 600 1.0625rem/1.5 var(--body);
}

.lab {
  max-width: 78rem;
  margin: 0 auto;
  padding: clamp(0.5rem, 1.6vw, 1.2rem) clamp(1rem, 2.6vw, 2rem) 2rem;
}

/* ---- header */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.25rem;
  margin-bottom: 0.75rem;
}
.back { color: var(--ink-soft); font-weight: 700; text-underline-offset: 3px; white-space: nowrap; }
.back:hover { color: var(--ink); }
h1 {
  margin: 0;
  flex: 1;
  font: 700 clamp(1.45rem, 3.2vw, 2.2rem)/1.05 var(--hand);
  color: var(--ink);
  white-space: nowrap;
}

.levels {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 0.9rem;
  background: var(--mint-200);
}
.levels button {
  min-height: 2.75rem;
  font: 700 1rem/1.1 var(--body);
  padding: 0.35rem 0.8rem;
  border: 0;
  border-radius: 0.7rem;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}
.levels button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 2px 0 var(--mint-400); }
.levels button:hover:not([aria-pressed="true"]) { color: var(--ink); background: rgba(255, 255, 255, 0.45); }

/* ---- the bench: tank on the left, clipboard and notebook on the right */

.bench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 21.5rem;
  grid-template-areas: "stage clip" "below note" "notes note";
  gap: 0.9rem 1.1rem;
  align-items: start;
}
.stage { grid-area: stage; }
.clipboard { grid-area: clip; }
.below { grid-area: below; }
.notebook { grid-area: note; }
.notes { grid-area: notes; }

.stage {
  border-radius: 1.1rem;
  overflow: hidden;
  background: var(--mint-50);
  border: 1px solid rgba(18, 63, 56, 0.1);
  box-shadow: 0 0.9rem 2.2rem rgba(18, 63, 56, 0.16);
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  max-height: calc(100svh - 9.5rem);
  min-height: 17rem;
  touch-action: none;
  background: #e9f8f0;
}
canvas.grab { cursor: grab; }
canvas.dragging { cursor: grabbing; }

/* the clipboard: a white sheet clipped to a mint board */
.clipboard {
  position: relative;
  padding: 1.35rem 1.1rem 1rem;
  border-radius: 1rem;
  background: var(--paper);
  border: 0.35rem solid var(--mint-400);
  box-shadow: 0 0.6rem 1.6rem rgba(18, 63, 56, 0.14);
}
.clipboard::before {
  content: "";
  position: absolute;
  top: -0.95rem;
  left: 50%;
  width: 5.5rem;
  height: 1.2rem;
  margin-left: -2.75rem;
  border-radius: 0.4rem;
  background: linear-gradient(#b9c6c3, #8fa29e);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15);
}
.clipboard p { margin: 0; }

.tray { font-size: 1.05rem; color: var(--ink-soft); }
.tray strong { display: block; font: 700 1.6rem/1.15 var(--hand); color: var(--ink); }

.water { margin-top: 0.3rem !important; font-size: 1rem; color: var(--ink-soft); }
.water[hidden], .shape[hidden], .salt[hidden] { display: none; }

.shape { display: flex; gap: 0.3rem; margin-top: 0.6rem; }
.shape button {
  flex: 1;
  min-height: 2.75rem;
  font: 700 1rem/1.1 var(--body);
  border: 2px solid var(--mint-200);
  border-radius: 0.7rem;
  background: var(--mint-50);
  color: var(--ink);
  cursor: pointer;
}
.shape button[aria-pressed="true"] { border-color: #b4664a; background: #f6dfd5; }

.guess, .act { display: flex; gap: 0.5rem; margin-top: 0.7rem; }
.guess button, .act button {
  flex: 1;
  min-height: 3.1rem;
  font: 700 1.05rem/1.1 var(--body);
  padding: 0.5rem 0.6rem;
  border: 0;
  border-radius: 0.8rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.guess .float { background: #fff1c9; color: var(--float-ink); box-shadow: inset 0 0 0 2px var(--float); }
.guess .sink { background: #e3e7fb; color: var(--sink-deep); box-shadow: inset 0 0 0 2px #8f9ce4; }
.guess .float[aria-pressed="true"] { background: var(--float); box-shadow: 0 3px 0 var(--float-deep); }
.guess .sink[aria-pressed="true"] { background: var(--sink); color: #fff; box-shadow: 0 3px 0 var(--sink-deep); }
.guess button:hover:not(:disabled) { transform: translateY(-1px); }

.act .go { background: var(--ink); color: #fff; box-shadow: 0 3px 0 #06231f; }
.act .go:hover:not(:disabled) { background: #1b564c; }
.act .salt { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink-soft); }
.act .salt:hover:not(:disabled) { background: var(--mint-50); }
button:disabled { opacity: 0.45; cursor: default; }

.say {
  margin-top: 0.75rem !important;
  min-height: 4.6em;
  font-size: 1.02rem;
  line-height: 1.45;
  color: var(--ink);
}

/* ---- progress and stars */

.below {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1.4rem;
}
.progress {
  display: grid;
  grid-template-columns: repeat(8, 2.5rem);
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.progress li {
  height: 2.3rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--mint-200);
  color: var(--star);
  font-size: 1.15rem;
  line-height: 1;
}
.progress li.now { box-shadow: inset 0 0 0 3px var(--mint-600); }
.progress li.done { background: var(--paper); color: var(--ink-soft); }
.progress li.star { color: var(--star); }

.tally { display: flex; gap: 1.25rem; margin: 0 0 0 auto; }
.tally div { display: flex; align-items: baseline; gap: 0.4rem; }
.tally dt { font-size: 1rem; color: var(--ink-soft); }
.tally dd { margin: 0; font-weight: 700; font-size: 1.4rem; font-variant-numeric: tabular-nums; }

.again {
  min-height: 2.75rem;
  font: 700 1rem/1 var(--body);
  padding: 0.7rem 1.2rem;
  border: 0;
  border-radius: 0.8rem;
  background: #1f7354;
  color: #fff;
  cursor: pointer;
}
.again:hover { background: #18604a; }

/* ---- the lab notebook: squared paper, handwritten entries */

.notebook {
  padding: 0.9rem 1rem 1rem 1.6rem;
  border-radius: 0.3rem 1rem 1rem 0.3rem;
  background-color: #fffef8;
  background-image:
    linear-gradient(90deg, transparent 0.9rem, #f3b6b6 0.9rem, #f3b6b6 calc(0.9rem + 2px), transparent calc(0.9rem + 2px)),
    linear-gradient(var(--rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule) 1px, transparent 1px);
  background-size: 100% 100%, 1.1rem 1.1rem, 1.1rem 1.1rem;
  box-shadow: -0.35rem 0 0 var(--ink-soft), 0 0.5rem 1.4rem rgba(18, 63, 56, 0.12);
}
.notebook h2 { margin: 0 0 0.35rem; font: 700 1.35rem/1.2 var(--hand); }
.notebook .columns { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.notebook h3 {
  margin: 0 0 0.25rem;
  font: 700 1.05rem/1.2 var(--hand);
  padding-bottom: 0.15rem;
  border-bottom: 3px solid var(--float);
}
.notebook .columns > div:last-child h3 { border-bottom-color: var(--sink); }
.notebook ul { margin: 0; padding: 0; list-style: none; }
.notebook li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2rem;
  font: 600 1rem/1.15 var(--hand);
}
.notebook li img { width: 1.8rem; height: 1.8rem; flex: none; }
.notebook .empty { margin: 0.4rem 0 0; font: 600 1rem/1.4 var(--hand); color: var(--ink-soft); }
.notebook .empty[hidden] { display: none; }

.notes { max-width: 48rem; margin-top: 0.6rem; }
.notes p { margin: 0 0 0.8rem; font-size: 1rem; color: var(--ink-soft); }
.notes strong { color: var(--ink); }

/* ---- focus */

button:focus-visible,
.back:focus-visible { outline: 3px solid var(--sink); outline-offset: 2px; }
.guess .sink[aria-pressed="true"]:focus-visible,
.act .go:focus-visible { outline-color: var(--float-deep); }

/* ---- one column below 900 px */

@media (max-width: 900px) {
  .bench {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "stage" "clip" "below" "note" "notes";
    gap: 0.7rem;
  }
  canvas { aspect-ratio: 4 / 3; max-height: 52svh; min-height: 13rem; }
  .clipboard { margin-top: 0.3rem; }
}

@media (max-width: 560px) {
  .lab { padding-top: 0.4rem; }
  .top { gap: 0.3rem 0.8rem; margin-bottom: 0.5rem; }
  h1 { font-size: 1.75rem; }
  .levels { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .levels button { padding: 0.3rem 0.4rem; font-size: 1rem; }
  canvas { aspect-ratio: 1 / 1; max-height: 40svh; min-height: 12rem; }
  .bench { gap: 0.6rem; }
  .clipboard { padding: 1rem 0.8rem 0.75rem; }
  .tray { display: flex; align-items: baseline; gap: 0.45rem; flex-wrap: wrap; font-size: 1rem; }
  .tray strong { display: inline; font-size: 1.3rem; }
  .guess, .act { margin-top: 0.5rem; }
  .guess button, .act button { min-height: 2.9rem; font-size: 1rem; }
  .say { margin-top: 0.5rem !important; min-height: 4.4em; font-size: 1rem; }
  .progress { grid-template-columns: repeat(8, 1fr); width: 100%; }
  .progress li { height: auto; aspect-ratio: 1; }
  .tally { margin: 0; }
  .again { margin-left: auto; }
}

/* a phone on its side, or a short iframe: tank and clipboard side by side */
@media (max-height: 560px) and (min-width: 640px) and (orientation: landscape) {
  .lab { padding-top: 0.3rem; }
  .top { margin-bottom: 0.4rem; flex-wrap: nowrap; }
  h1 { font-size: 1.6rem; }
  .levels button { min-height: 2.75rem; padding: 0.25rem 0.55rem; }
  .bench {
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 19rem);
    grid-template-areas: "stage clip" "below below" "note note" "notes notes";
    gap: 0.6rem 0.8rem;
  }
  canvas { aspect-ratio: auto; height: calc(100svh - 4.4rem); max-height: none; min-height: 11rem; }
  .clipboard { padding: 0.8rem 0.75rem 0.6rem; border-width: 0.25rem; }
  .clipboard::before { display: none; }
  .tray { display: flex; align-items: baseline; gap: 0.4rem; flex-wrap: wrap; }
  .tray strong { display: inline; font-size: 1.2rem; }
  .guess, .act, .shape { margin-top: 0.4rem; }
  .guess button, .act button { min-height: 2.75rem; }
  .say { margin-top: 0.4rem !important; min-height: 0; font-size: 1rem; line-height: 1.35; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .guess button:hover:not(:disabled) { transform: none; }
}
