/* The page is a column: the screen area (#tv), the question bar (#ask, page 101 only) and the
   remote (#remote). The screen is 40 columns by 25 rows, one cell 24x30 px, so 960x750 px; it is
   laid out at that fixed size and scaled as one unit by app.js to fit #tv. */

@font-face {
  font-family: Tekstari;
  src: url(fonts/tekstari.woff2) format('woff2');
  font-display: block;
}

html, body {
  margin: 0;
  background: #000;
}

body {
  height: 100vh;
  height: 100svh; /* the small viewport: fits with the phone's toolbars shown */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#tv {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}

#screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 960px;
  height: 750px;
  background: #000;
  color: #fff;
  font: 30px/30px Tekstari;
  font-kerning: none;
  font-variant-ligatures: none;
  transform-origin: 0 0;
  user-select: none;
}

/* Whitespace is significant inside a row only, not between rows. */
.row { height: 30px; white-space: pre; }

/* The eight colours, as text and as background. */
.k { color: #000; }
.r { color: #f00; }
.g { color: #0f0; }
.y { color: #ff0; }
.b { color: #00f; }
.m { color: #f0f; }
.c { color: #0ff; }
.w { color: #fff; }

.bg-r { background: #f00; }
.bg-g { background: #0f0; }
.bg-y { background: #ff0; }
.bg-b { background: #00f; }
.bg-m { background: #f0f; }
.bg-c { background: #0ff; }
.bg-w { background: #fff; }

/* Double height: the glyphs of one row stretched over that row and the next. */
.dh {
  display: inline-block;
  transform: scaleY(2);
  transform-origin: 0 0;
}

/* Rows that open something: a tap or click opens them. Hover and keyboard focus show their text
   in inverse video as a bonus. The area runs from the first text segment to the right edge, so a
   suggestion row keeps its colour cell. */
.row.link { cursor: pointer; }
.row:focus { outline: none; }
.area { display: inline-block; }
.row.link:focus .area, .row.picked .area { background: #fff; }
.row.link:focus .area span, .row.picked .area span { color: #000; }
@media (hover: hover) {
  .row.link:hover .area { background: #fff; }
  .row.link:hover .area span { color: #000; }
}

/* Row 24: the four colour keys, black text except on blue. */
.keys { color: #000; }
.keys .bg-b { color: #fff; }
.key { cursor: pointer; }

/* The question bar, page 101. Font at least 16 px so phones do not zoom into it. */
#ask { flex: none; padding: 4px 6px; }
#ask[hidden] { display: none; }
#question {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  padding: 0 10px;
  border: 2px solid #fff;
  border-radius: 4px;
  background: #00f;
  color: #fff;
  font: 18px/1.2 system-ui, sans-serif;
  outline: none;
}
#question::placeholder { color: #9bf; }

/* The remote. Every button is at least 44 px tall and wide. */
#remote {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 100%;
  max-width: 480px;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 6px;
}
#colours { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.rk, .pk {
  min-height: 44px;
  min-width: 44px;
  border: 0;
  border-radius: 4px;
  font: bold 16px/1 system-ui, sans-serif;
  color: #000;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 4px;
}
.rk { font-size: clamp(11px, 3.6vw, 16px); } /* nine-letter labels fit at 320 px */
.rk.bg-b { color: #fff; }
.pk { background: #222; color: #fff; font-size: 20px; }
.rk:active, .pk:active { filter: brightness(0.8); }

/* A phone on its side: the remote stands as a column on the right and scrolls if it must. */
@media (orientation: landscape) and (max-height: 520px) {
  body { flex-direction: row; }
  #ask { position: absolute; left: 0; right: 168px; bottom: 0; z-index: 1; }
  #remote {
    width: 168px;
    max-width: none;
    margin: 0;
    grid-template-columns: 1fr;
    align-content: start;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .rk { font-size: 14px; }
}

/* A wide screen with no room under the full-size picture: the keyboard does the remote's job. */
@media (min-width: 900px) and (max-height: 949px) {
  #remote { display: none; }
}
