/* Tabellerna – only what is special to this game: the task line with its answer square, the groups of dots and the
   table so far. The game box, menu, number pad, result, effects, red-pen rings and the hologram around the task are
   every school game's: css/skolspel.css. */

/* At least as wide as the groups of dots with the table beside them, so the task's column keeps one width through a
   round ("2 · 5" and "10 · 5" are not the same width) – the pad and "Svara" never move (owner, 2026-10-14) */
.tb-holo {
  min-width: 20rem;
}

/* The task: big, with the answer square right in it ("4 · 5 = ▢", "▢ · 5 = 35", "35 = 7 · ▢") */
.tb-fact {
  margin: 0.2rem 0 0.3rem;
  text-align: center;
  font-size: clamp(2.4rem, 7vw, 4rem);
  font-weight: 800;
  line-height: 1.25;
  color: #f2feff;                /* hologram white: a touch of cyan, like Ställ upp!'s digits */
  text-shadow: 0 0 1px currentColor, 0 0 0.45em rgba(94, 240, 255, 0.4);
  white-space: nowrap;
}

.tb-box {
  display: inline-block;
  min-width: 3.4ch;              /* room for three digits (10 · 10 = 100) from the start: the square never grows while
                                    the child types, so "10 · 5 =" never slides sideways (owner, 2026-10-14) */
  padding: 0 0.12em;
  color: var(--yellow);          /* the child's own answer is yellow, like in Ställ upp! */
  text-align: center;
  vertical-align: baseline;
  border: 3px solid rgba(94, 240, 255, 0.45);
  cursor: default;
}

.tb-box.is-empty::after {
  content: "\00a0";              /* keeps the square's height before anything is typed */
}

.tb-box.is-active {
  border-color: var(--yellow);
  box-shadow: 0 0 14px rgba(255, 233, 77, 0.6);
}

/* Nothing typed yet: the square breathes (type here) */
.tb-box.is-active.is-empty {
  animation: tb-breathe 1.1s ease-in-out infinite;
}

@keyframes tb-breathe {
  50% { box-shadow: 0 0 24px rgba(255, 233, 77, 1); }
}

.tb-box.is-right {
  color: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 14px rgba(94, 240, 255, 0.7);
}

.tb-box.is-wrong {
  color: var(--magenta);
  border-color: rgba(255, 63, 180, 0.6);
}

/* ---------- The groups (in order, and when the missed facts are practised again) ----------
   a · b = a rows of b dots: the first factor = how many groups (the book). Rows are split like the book's pictures
   (tabeller.js ROW_PARTS: the second part yellow, a dashed line between), and 9 = ten dots with the last one rubbed
   out (9 = 10 − 1). */
.tb-model {
  display: none;
}

/* --dot = the size of a dot; the table beside the dots is sized by it too, so ten facts are as tall as ten rows.
   A low window (a Chromebook; or fullscreen on a low screen) gets smaller dots, so the task and the pad beside them can
   stay big (owner, 2026-10-13: everything on one screen); never bigger than normal – big screens zoom the whole screen
   instead (css/skolspel.css --skol-zoom). */
.tb-holo.has-model .tb-model {
  --dot: clamp(0.7rem, min(2.1vw, 2.6vh), 1.15rem);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 0.4rem;
}

.tb-groups {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: calc(var(--dot) * 0.45);
}

/* In order the table grows to ten rows: their room is kept from the first task, so nothing under the task (the number
   pad, "Svara") moves down task by task – and in fullscreen the screen keeps its size through the round */
.tb-holo.is-order .tb-groups {
  min-height: calc(var(--dot) * 10 + var(--dot) * 0.45 * 9);
}

.tb-row {
  display: flex;
  align-items: center;
  gap: calc(var(--dot) * 0.35);
}

.tb-dot {
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 6px rgba(94, 240, 255, 0.7);
}

.tb-dot.tb-part-1 {
  background: var(--yellow);
  box-shadow: 0 0 6px rgba(255, 233, 77, 0.7);
}

/* Nians tabell: the tenth dot is rubbed out – it is there, but taken away */
.tb-dot.is-gone {
  background: none;
  border: 2px dashed rgba(255, 63, 180, 0.75);
  box-shadow: none;
}

.tb-split {
  align-self: stretch;
  margin: 0 calc(var(--dot) * 0.15);
  border-left: 2px dashed rgba(242, 254, 255, 0.55);
}

/* The rows already counted are a little dimmer; the new group comes in dot by dot, 45 ms apart (= its pencil sound,
   js/skol-ui.js dots), and lights up when the answer is right */
.tb-holo.is-order .tb-row:not(.is-new):not(.is-lit) {
  opacity: 0.65;
}

.tb-row.is-new .tb-dot {
  animation: tb-dot-in 0.25s ease-out both;
  animation-delay: calc(var(--i) * 45ms);
}

@keyframes tb-dot-in {
  from { opacity: 0; transform: scale(2.2); }
}

.tb-row.is-lit .tb-dot {
  animation: tb-lit 0.7s ease-out;
}

@keyframes tb-lit {
  30% { filter: brightness(1.7) drop-shadow(0 0 6px var(--yellow)); }
}

/* The same groups as an addition: 5 + 5 + 5 + 5. One line, and as WIDE as the whole table's sum from the first task
   (data-full = the ten terms, written as an invisible line of no height): in order the sum grows task by task, and the
   hologram grew with it – the pad beside it moved for every task (owner, 2026-10-14). */
.tb-adds {
  margin: 0.5rem 0 0;
  font-size: clamp(0.8rem, 2vw, 1.1rem);
  font-weight: 700;
  white-space: nowrap;
  color: var(--text-muted);
}

.tb-adds[data-full]::after {
  content: attr(data-full);
  display: block;
  height: 0;
  overflow: hidden;
  visibility: hidden;
}

/* ---------- The table so far (in order): one more fact for every right answer ---------- */
.tb-facts {
  display: none;
  min-width: 7.5em;
  margin: 0;
  padding: 0 0 0 1rem;
  list-style: none;
  font-size: calc(var(--dot) * 1.1);   /* follows the dots: ten facts as tall as ten rows */
  font-weight: 700;
  line-height: 1.28;
  color: #f2feff;
  border-left: 2px solid rgba(94, 240, 255, 0.25);
}

.tb-holo.is-order .tb-facts {
  display: block;
  min-height: 12.8em;            /* room for all ten facts from the start (10 x line-height 1.28) */
}

.tb-facts li.is-new {
  color: var(--yellow);
  animation: tb-fact-in 0.5s ease-out;
}

@keyframes tb-fact-in {
  from { opacity: 0; transform: translateX(-0.8em); }
}

/* Phones held upright: the table stays BESIDE the dots (under them it made the task too tall for the box), with
   smaller dots and a smaller task line; the hologram's least width follows the phone */
@media (max-width: 480px) {
  .tb-holo {
    min-width: min(20rem, 100%);
  }

  .tb-fact {
    margin: 0;
    font-size: clamp(2rem, 9vw, 2.4rem);
  }

  .tb-holo.has-model .tb-model {
    --dot: 0.5rem;
    gap: 0.8rem;
    margin-top: 0;
  }

  /* The table in two columns of five, readable on its own (the dots are too small to size it by) */
  .tb-facts {
    min-width: 0;
    padding-left: 0.5rem;
    columns: 2;
    column-gap: 0.6rem;
    font-size: 0.8rem;
    line-height: 1.3;
  }

  .tb-facts li {
    min-width: 5.6em;
  }

  .tb-holo.is-order .tb-facts {
    min-height: 6.5em;           /* ten facts in two columns */
  }

  .tb-adds {
    margin-top: 0.3rem;
    font-size: 0.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tb-box.is-active.is-empty, .tb-row.is-new .tb-dot, .tb-row.is-lit .tb-dot, .tb-facts li.is-new { animation: none; }
}
