/* Self-hosted so the game works offline and behind school web filters.
   Variable font, SIL Open Font License, latin subset. */
@font-face {
  font-family: 'Baloo 2';
  font-weight: 400 800;
  font-display: swap;
  src: url(../fonts/baloo2.woff2) format('woff2');
}

:root {
  --barn: #b8452f;
  --ink: #2b2118;
  --cream: #fff8e8;
  --panel: rgba(43, 33, 24, 0.55);
  font-family: 'Baloo 2', 'Comic Sans MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fbf5a; color: var(--ink); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.5; }
kbd {
  font: 700 0.85em/1 ui-monospace, monospace;
  padding: 0.15em 0.4em;
  border-radius: 0.3em;
  background: rgba(43, 33, 24, 0.08);
  border: 1px solid rgba(43, 33, 24, 0.25);
}
[hidden] { display: none !important; }
body.in-setup #top, body.in-setup #cards { visibility: hidden; }

/* ---------- The farm and the labels pinned to it ---------- */
#farm { position: fixed; inset: 0; }
#farm canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.labels > div { position: absolute; left: 0; top: 0; font-weight: 800; white-space: nowrap; }
/* How many animals have arrived, above each column */
.tally {
  transform: translate(-50%, -100%);
  min-width: 5.4vh; padding: 0 1.2vh;
  border-radius: 2.7vh;
  background: #fff; border: 0.4vh solid var(--ink);
  font-size: 3.6vh; line-height: 4.8vh; text-align: center;
}
/* It grows a little each time an animal arrives */
.tally.bump { animation: bump 0.3s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes bump { from { scale: 1.35; } }
/* Numbers up the side of the bar graph */
.axis {
  transform: translate(-100%, -50%);
  padding-right: 0.8vh;
  font-size: 3vh; color: #fff;
  -webkit-text-stroke: 0.3vh rgba(43, 33, 24, 0.75); paint-order: stroke fill;
}

/* ---------- Top bar ---------- */
#top {
  position: fixed; top: 0; left: 0; right: 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 2vw;
  padding: 2vh 2vw;
  pointer-events: none;
}
#top > * { pointer-events: auto; }
#toolbar { display: flex; gap: 0.6vh; }
#toolbar button {
  width: 5.6vh; height: 5.6vh;
  display: grid; place-items: center;
  border: none; border-radius: 1.4vh;
  background: var(--panel); color: #fff;
  font-size: 2.7vh;
}
#toolbar button:hover { background: rgba(43, 33, 24, 0.75); }
#heading {
  text-align: center;
  padding: 0.6vh 3.5vh 0.8vh;
  border-radius: 2vh;
  background: var(--cream);
  border: 0.45vh solid var(--ink);
  box-shadow: 0 0.6vh 0 var(--ink);
  max-width: 64vw;
}
#question { margin: 0; font-size: 4.4vh; line-height: 1.1; }
#total { margin: 0; font-size: 2.3vh; font-weight: 700; color: #6b5a48; }
#views { display: flex; justify-content: flex-end; gap: 1vh; }
#views button {
  padding: 0.8vh 1.8vh;
  border-radius: 1.4vh;
  border: 0.4vh solid var(--ink);
  background: #fff;
  font-size: 2.6vh; font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 0.5vh 0 var(--ink);
}
#views button:active { translate: 0 0.4vh; box-shadow: 0 0.1vh 0 var(--ink); }
#mode-button { background: #ffd35c !important; }

/* ---------- Answer cards under the columns (js/main.js places them) ---------- */
#cards { position: fixed; left: 0; right: 0; bottom: 0; height: 20vh; pointer-events: none; }
.card {
  /* --u: a size unit that shrinks when columns are narrow (js/main.js sets it) */
  --u: 1vh;
  position: absolute; top: calc(var(--u) * 1.4); left: 0;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 0.6);
  pointer-events: auto;
}
.card .label {
  max-width: 100%;
  padding: calc(var(--u) * 0.2) calc(var(--u) * 1.4);
  border-radius: calc(var(--u) * 1.2);
  background: var(--colour); color: #fff;
  font-size: calc(var(--u) * 3); font-weight: 800; line-height: 1.15; text-align: center;
  text-shadow: 0 0.2vh 0 rgba(0, 0, 0, 0.35);
  border: 0.35vh solid var(--ink);
  overflow-wrap: break-word;
}
.card .count {
  display: flex; align-items: center;
  border-radius: calc(var(--u) * 1.4);
  background: #fff;
  border: 0.35vh solid var(--ink);
  overflow: hidden;
}
.card button {
  width: calc(var(--u) * 5.6); height: calc(var(--u) * 6.4);
  border: none; background: #f2ead6;
  font-size: calc(var(--u) * 4); font-weight: 800; line-height: 1;
}
.card button:hover { background: #e6dabd; }
.card input {
  width: calc(var(--u) * 7); height: calc(var(--u) * 6.4);
  padding: 0;
  border: none; border-inline: 0.35vh solid var(--ink);
  font-size: calc(var(--u) * 4.4); font-weight: 800; text-align: center;
  background: #fff;
}
.card input:focus { outline: none; background: #fff3c4; }

/* ---------- Panels: setup and questions ---------- */
#setup, #talk {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: 3vh;
  background: rgba(43, 33, 24, 0.35);
  overflow: auto;
}
.panel {
  width: min(760px, 100%);
  max-height: 100%; overflow: auto;
  padding: 22px 30px 20px;
  border-radius: 22px;
  background: var(--cream);
  border: 4px solid var(--ink);
  box-shadow: 0 8px 0 var(--ink);
}
.logo { margin: 0; font-size: 2.6rem; line-height: 1; color: var(--barn); }
.tagline { margin: 8px 0 0; font-size: 1.12rem; line-height: 1.4; }
.panel h2 { margin: 14px 0 6px; font-size: 1.2rem; }
#presets { display: flex; flex-wrap: wrap; gap: 8px; }
.preset {
  padding: 3px 10px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: #fff;
  font-size: 0.95rem; font-weight: 700;
}
.preset[aria-pressed="true"] { background: #ffd35c; }
.field { display: grid; gap: 2px; margin-top: 4px; font-weight: 800; }
.panel input, .panel select {
  padding: 3px 10px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: #fff;
  font-size: 1.05rem;
  min-width: 0;
}
.answers-head {
  display: grid; grid-template-columns: 22px 1fr 130px 40px; gap: 8px;
  margin-top: 10px; font-weight: 800;
}
.answers-head span:first-child { grid-column: 2; }
#answers { list-style: none; margin: 2px 0 8px; padding: 0; display: grid; gap: 4px; }
#answers li { display: grid; grid-template-columns: 22px 1fr 130px 40px; gap: 8px; align-items: center; }
#answers i { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--ink); }
.small {
  padding: 4px 10px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: #fff;
  font-weight: 700;
}
.buttons { display: flex; gap: 12px; margin-top: 14px; }
.buttons button, #talk .primary {
  padding: 10px 22px;
  border-radius: 14px;
  border: 3px solid var(--ink);
  background: #fff;
  font-size: 1.25rem; font-weight: 800;
  box-shadow: 0 4px 0 var(--ink);
}
.buttons .primary, #talk .primary { background: var(--barn); color: #fff; }
.buttons button:active, #talk .primary:active { translate: 0 3px; box-shadow: 0 1px 0 var(--ink); }
.error { color: #b3261e; font-weight: 700; }
#offline-status { color: #2f6b2f; font-size: 0.95rem; margin: 12px 0 0; }
.help { margin-top: 16px; }
.help summary { cursor: pointer; font-weight: 800; }
.help ul { padding-left: 20px; line-height: 1.45; }

#talk .panel { width: min(900px, 100%); }
#setup .panel {
  width: min(1040px, 100%);
  display: grid; grid-template-columns: 1fr 1.25fr; gap: 0 36px;
}
#setup .help { grid-column: 1 / -1; }
#presets { flex-direction: column; align-items: flex-start; }
@media (max-width: 800px) { #setup .panel { grid-template-columns: 1fr; } }
#talk h2 { margin-top: 0; font-size: 2rem; }
#talk-list { margin: 0 0 20px; padding-left: 1.6em; display: grid; gap: 10px; font-size: 1.5rem; font-weight: 800; }
#talk-list button {
  display: grid; width: 100%; text-align: left;
  padding: 6px 14px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: #fff;
}
#talk-list .a { display: none; color: #2f6b2f; font-weight: 700; font-size: 1.3rem; }
#talk-list [aria-expanded="true"] .a { display: block; }
#talk-list [aria-expanded="false"]::after { content: 'Tap to show the answer'; font-size: 1rem; font-weight: 600; color: #8a7a68; }
