/* gamekit.css — layout and theme tokens. The canvas reads only the --gk-*
   tokens. They are declared with zero specificity, so a course's
   `.gamekit { --gk-accent: … }` always wins regardless of stylesheet order. */
:where(.gamekit) {
  --gk-accent: var(--bs-link-color, var(--r-link-color, #9e2b2b));
  --gk-neutral: var(--bs-primary, var(--r-main-color, #537e8f));
  --gk-text: var(--bs-body-color, var(--r-main-color, #363d45));
  --gk-muted: var(--bs-secondary-color, #6c757d);
  --gk-bg: var(--bs-body-bg, var(--r-background-color, #fffdfc));
  --gk-good: var(--bs-success, #2e7d5b);
  --gk-bad: var(--bs-danger, #b3261e);
}

.gamekit {
  color: var(--gk-text);
  margin: 1rem 0;
  font-size: 1rem;
  line-height: 1.4;
}
.gamekit-task { margin: 0 0 0.5rem; }
.gamekit-main { display: flex; flex-direction: column; gap: 0.5rem; }
.gamekit-play { display: flex; flex-direction: column; min-width: 0; }
.gamekit-stage { position: relative; }
.gamekit canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.gamekit-card {
  position: absolute;
  inset: 8% 6%;
  overflow: auto;
  padding: 0.8rem 1rem;
  background: var(--gk-bg);
  border: 2px solid var(--gk-accent);
  box-shadow: 0 0.3rem 1.2rem rgb(0 0 0 / 0.18);
}
.gamekit-card[hidden] { display: none; }
.gamekit-card.gk-think {
  inset: auto 6% 38% 6%;
  text-align: center;
}
.gamekit-card p { margin: 0 0 0.6rem; }
/* One text size for the whole game (task, scores, status, buttons, and the
   canvas via view.em); emphasis only through color and weight.
   Below the board (pages) or beside it (slides): first everything that
   reports state (scores, status), then the buttons, always at the bottom right. */
.gamekit-side { display: flex; flex-direction: column; gap: 0.6rem; }
.gamekit-info { display: flex; flex-direction: column; gap: 0.2rem; }
.gamekit-scores { display: flex; flex-wrap: wrap; gap: 0.2rem 1.5rem; font-variant-numeric: tabular-nums; }
.gamekit-score { display: flex; align-items: baseline; gap: 0.4em; white-space: nowrap; }
.gamekit-score[hidden] { display: none; }
.gamekit-score .gk-label { color: var(--gk-muted); }
.gamekit-score .gk-value { font-weight: 600; }
.gamekit-score.gk-opt .gk-value { color: var(--gk-accent); }
.gamekit-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.4rem; }
.gamekit button {
  font: inherit;
  min-height: 44px;
  padding: 0.3em 0.9em;
  color: var(--gk-text);
  background: var(--gk-bg);
  border: 1px solid var(--gk-neutral);
  border-radius: 0; /* square, like the course style */
  cursor: pointer;
}
.gamekit button.gk-primary {
  color: var(--gk-bg);
  background: var(--gk-accent);
  border-color: var(--gk-accent);
}
.gamekit button:disabled { opacity: 0.45; cursor: not-allowed; }
.gamekit button[hidden] { display: none; }
.gamekit-status { min-height: 1.4em; margin: 0; color: var(--gk-muted); }
.gamekit-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.gamekit-qr { color: var(--gk-text); }
.gamekit-qr svg { display: block; width: 100%; height: auto; }

/* Slides: a wide left column with the task text above the board, a lane with
   a thin divider, and a narrow right column: QR code, then the game's state
   (scores, status), then the buttons pinned to the bottom. reveal.js sets the
   height to what the slide has left below its heading (r-stretch) and writes
   the stage width with it. The height here holds where reveal sets none: a
   game nested in another block. No min-height and no padding on this box:
   reveal measures the slide with the game at height 0, and both would count
   as content. */
.reveal .gamekit-slide {
  font-size: 22px;
  height: 575px;
  margin: 0;
  display: flex;
  flex-direction: column;
}
.reveal .gamekit-slide.r-stretch { max-width: 100%; } /* reveal's own rule lifts the limit */
/* reveal's scroll view (decks on a narrow phone) stretches nothing and sets the height to 0 */
.reveal-scroll .gamekit-slide { height: 575px !important; }
.reveal .gamekit-slide p { line-height: 1.3; }
.reveal .gamekit-slide .gamekit-task { flex: none; margin-bottom: 0.4rem; }
/* the padding keeps board and buttons off the slide's bottom edge */
.reveal .gamekit-slide .gamekit-main { flex: 1; min-height: 0; flex-direction: row; gap: 1.25rem; box-sizing: border-box; padding-bottom: 12px; }
.reveal .gamekit-slide .gamekit-play { flex: 1; height: 100%; }
.reveal .gamekit-slide .gamekit-stage { flex: 1; min-height: 0; }
.reveal .gamekit-slide canvas { width: 100%; height: 100%; }
.reveal .gamekit-slide .gamekit-side {
  flex: 0 0 210px;
  min-width: 0; /* a long score wraps instead of widening the column and shrinking the board */
  gap: 0.5rem;
  padding-left: 1.25rem;
  border-left: 1px solid color-mix(in srgb, var(--gk-muted) 35%, transparent);
}
.reveal .gamekit-slide .gamekit-qr { margin: 0.3em 0 0.4rem; } /* top in line with the task text's first line */
.reveal .gamekit-slide .gamekit-status:empty { display: none; }
.reveal .gamekit-slide .gamekit-scores { flex-direction: column; }
.reveal .gamekit-slide .gamekit-score { flex-wrap: wrap; white-space: normal; }
/* the value keeps to the right edge, also on a line of its own (a long score wraps) */
.reveal .gamekit-slide .gamekit-score .gk-value { margin-left: auto; text-align: right; }
.reveal .gamekit-slide .gamekit-buttons { margin-top: auto; flex-direction: column; }
.reveal .gamekit-slide .gamekit-buttons button { width: 100%; min-height: 40px; }

/* Phones (compact): scores and status, then the buttons in equal columns
   across the full width. This block stays at the bottom of the screen while
   the game is in view; on the game's own phone page it is fixed to the bottom
   edge (the runtime reserves its height below the game). */
.gamekit-compact .gamekit-side {
  position: sticky;
  bottom: 0;
  z-index: 2;
  gap: 0.4rem;
  padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom, 0px));
  background: var(--gk-bg);
  border-top: 1px solid color-mix(in srgb, var(--gk-muted) 35%, transparent);
}
.gamekit-compact .gamekit-buttons {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(max-content, 1fr); /* equal while every word fits, never narrower than its word */
  gap: 0.4rem;
}
.gamekit-compact .gamekit-buttons button { padding: 0.3em 0.2em; line-height: 1.15; }
.gamekit-solo.gamekit-compact .gamekit-side {
  position: fixed;
  left: 0;
  right: 0;
  padding-left: 1rem;
  padding-right: 1rem;
}
/* On the phone page the site's top bar already shows the page title. */
body:has(.gamekit-solo.gamekit-compact) #title-block-header { display: none; }
