/* Self-hosted so the page works 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 { --ink: #1d1a17; --green: #2f5d3a; --line: #d9d4cc; --paper: #f6f3ee; --c: #3b7dd8; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: 'Baloo 2', system-ui, sans-serif;
  display: flex; flex-direction: column;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.4; }
[hidden] { display: none !important; }

button {
  padding: 5px 12px; border: 2px solid var(--ink); border-radius: 9px; background: #fff;
  font-weight: 700; line-height: 1.2;
}
button.primary { background: var(--green); color: #fff; box-shadow: 2px 2px 0 var(--ink); }
button.danger { color: #a3262a; border-color: #a3262a; }
button.wide { width: 100%; margin-top: 10px; }

/* ---------- Top bar ---------- */

#top {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 18px; border-bottom: 3px solid var(--ink); background: #fff;
}
#top h1 { margin: 0; font-size: 1.6rem; line-height: 1; white-space: nowrap; }
.home { color: #666; font-weight: 700; text-decoration: none; font-size: 0.9rem; white-space: nowrap; }
#class { padding: 4px 8px; border: 2px solid var(--ink); border-radius: 9px; font-weight: 700; background: #fff; }
.tools { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }

/* ---------- Board ---------- */

#app { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) auto; min-height: 0; }
#board { padding: 14px 20px 20px; overflow-y: auto; display: flex; flex-direction: column; }
#ask { margin: 0 0 10px; font-size: clamp(1.3rem, 2.4vw, 2rem); font-weight: 800; text-align: center; }
#names {
  flex: 1; display: grid; gap: 10px; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(min(165px, 45%), 1fr));
}
.name {
  position: relative; min-height: 66px; padding: 6px 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: clamp(1.1rem, 1.9vw, 1.8rem); border: 3px solid var(--ink); border-radius: 14px;
  box-shadow: 3px 3px 0 var(--ink); background: #fff; touch-action: manipulation;
}
.name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.name:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.name.in { border-color: var(--c); box-shadow: 3px 3px 0 var(--c); background: color-mix(in srgb, var(--c) 14%, #fff); }
.name small {
  font-size: 0.55em; line-height: 1.1; padding: 1px 8px; border-radius: 99px;
  background: var(--c); color: #fff; white-space: nowrap;
}

#lines {
  display: flex; flex-direction: column; gap: 18px; padding: 14px; overflow-y: auto;
  background: #fff; border-left: 3px solid var(--ink);
}
.line { width: clamp(250px, 24vw, 340px); display: flex; flex-direction: column; }
.line h2 {
  margin: 0; padding: 4px 14px; border-radius: 12px 12px 0 0;
  background: var(--c); color: #fff; font-size: 1.5rem;
}
.now {
  padding: 8px 12px 12px; border: 3px solid var(--c); border-top: 0; border-radius: 0 0 12px 12px;
  background: color-mix(in srgb, var(--c) 10%, #fff); text-align: center;
}
.now p { margin: 0; }
.now .label { color: #555; font-weight: 700; }
.now .who { font-size: clamp(1.7rem, 2.6vw, 2.3rem); font-weight: 800; line-height: 1.1; overflow-wrap: anywhere; }
.buttons { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
button.big { font-size: 1.4rem; padding: 4px 24px; }
.line h3 { margin: 8px 2px 4px; font-size: 1.1rem; color: #555; }
.waiting { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.waiting li {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto auto; align-items: center; gap: 8px;
  padding: 4px 6px 4px 4px; border: 2px solid var(--line); border-radius: 10px; font-size: 1.2rem;
}
.waiting .n {
  min-width: 2.2em; text-align: center; border-radius: 7px; background: var(--c); color: #fff;
}
.waiting .who { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.waiting small { color: #777; font-size: 0.8rem; white-space: nowrap; }
button.icon { padding: 0 8px; border-width: 1.5px; border-color: #bbb; color: #555; font-size: 1.1rem; }
button.icon[hidden] { display: block !important; visibility: hidden; }

/* ---------- Dialogs ---------- */

.cover {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px;
  background: rgb(29 26 23 / 0.45);
}
.card {
  width: min(560px, 100%); max-height: 100%; overflow-y: auto; padding: 22px 26px;
  background: #fff; border: 3px solid var(--ink); border-radius: 18px; box-shadow: 6px 6px 0 var(--ink);
}
.card.wide { width: min(900px, 100%); }
.card h2 { margin: 0 0 6px; font-size: 2rem; line-height: 1.1; }
.card ol { font-size: 1.15rem; padding-left: 1.3em; }
#popup .card { text-align: center; }
#popup h2 { font-size: clamp(2rem, 4vw, 3rem); }
#popup p { font-size: 1.4rem; margin: 0; }
#popup .buttons button { font-size: 1.4rem; padding: 8px 22px; }
#popup .line-choice { background: var(--c); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.cols h3 { margin: 6px 0; }
.field { display: grid; gap: 2px; margin-bottom: 8px; font-weight: 700; }
.field input, textarea { padding: 6px 9px; border: 2px solid var(--ink); border-radius: 9px; font-weight: 500; width: 100%; }
textarea { resize: vertical; font-size: 0.95rem; }
.hint { color: #666; margin: 4px 0; font-size: 0.95rem; }
.row { display: flex; gap: 8px; }
.line-set { border: 3px solid var(--c); border-radius: 12px; margin: 0 0 12px; padding: 8px 12px; }
.line-set legend { font-weight: 800; padding: 0 6px; color: var(--c); }
.check { display: flex; gap: 8px; align-items: baseline; margin: 4px 0; }
@media (max-width: 700px) { .cols { grid-template-columns: 1fr; } }

/* A called child's name, big across the board */
#called {
  position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; text-align: center;
  background: var(--c); color: #fff; cursor: pointer; animation: pop 0.25s ease-out;
}
#called p { margin: 0; }
#called .line-name { font-size: clamp(1.5rem, 3vw, 2.5rem); font-weight: 700; }
#called .who { font-size: clamp(4rem, 12vw, 10rem); font-weight: 800; line-height: 1; }
#called .what { font-size: clamp(1.8rem, 4vw, 3.5rem); font-weight: 700; }
@keyframes pop { from { opacity: 0; transform: scale(0.94); } }

/* On a narrow screen the lines go under the names. */
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto auto; overflow-y: auto; }
  #lines { flex-direction: row; flex-wrap: wrap; border-left: 0; border-top: 3px solid var(--ink); }
  .line { flex: 1 1 250px; width: auto; }
}
