/* The touch keyboard of the browser terminal, for phones and tablets. webterm.js fills #keys with the keys the BBS
   is waiting for. It adds the class "touch" to the page on a touch screen (the terminal fills the screen) and
   "keys-on" while the keys show (the keyboard button turns them on or off); without "keys-on" the keys stay hidden.
   The page holds:  .termwrap > .termbox > #t (the terminal)   and   .termwrap > #keys
   Upright, the keys sit under the terminal; on its side, in a column on the right. The keyboard keeps one size
   whatever keys it shows, so the terminal never changes size (and the BBS never redraws) when the keys change. */

.termwrap { display: flex; flex-direction: column; gap: 4px; }
.termbox { position: relative; flex: 1; min-height: 0; min-width: 0; }
#keys { display: none; }
/* the keyboard button on the terminal, bottom right: shows or hides the keys (webterm.js adds it) */
#keystoggle { position: absolute; right: 22px; bottom: 6px; z-index: 6; width: 2.4rem; height: 2.4rem; padding: 0; border: 1px solid #555;
  border-radius: 6px; background: rgba(40, 40, 40, .75); color: #ddd; font: 20px/1 system-ui, sans-serif; cursor: pointer; opacity: .6; }
#sitetoggle { position: absolute; right: calc(22px + 2.4rem + 6px); bottom: 6px; z-index: 6; width: 2.4rem; height: 2.4rem; padding: 0;
  border: 1px solid #555; border-radius: 6px; background: rgba(40, 40, 40, .75); color: #ddd; font: 20px/1 system-ui, sans-serif; cursor: pointer; }
/* the full screen button, left of the menu button (webterm.js adds it where the browser allows full screen) */
#fulltoggle { position: absolute; right: calc(22px + 2 * (2.4rem + 6px)); bottom: 6px; z-index: 6; width: 2.4rem; height: 2.4rem; padding: 0;
  border: 1px solid #555; border-radius: 6px; background: rgba(40, 40, 40, .75); color: #ddd; font: 20px/1 system-ui, sans-serif; cursor: pointer; }
#fulltoggle.on { background: #0a7a50; color: #fff; }
#keystoggle:hover, .touch #keystoggle { opacity: 1; }
/* the scroll bar only when there is something to scroll back to, and dark to match (the button sits clear of it) */
.termbox .xterm .xterm-viewport { overflow-y: auto; scrollbar-color: #444 transparent; }

.keys-on #keys { display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; flex: none; height: min(300px, 42vh); padding: 2px;
  user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.krow { display: flex; gap: 4px; flex: 1; min-height: 30px; max-height: 56px; }
/* a menu's keys share what room is left above the bottom row, shrinking on a short screen (an iPhone SE on its side) */
.kgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.8rem, 1fr)); grid-auto-rows: minmax(0, 56px); gap: 4px;
  flex: 1 1 0; min-height: 0; align-content: end; overflow-y: auto; }
#keys button { flex: 1 1 0; min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 6px; cursor: pointer;
  font: 600 17px/1 system-ui, -apple-system, "Segoe UI", sans-serif; color: #e8e8e8; background: #2c2c2c; }
#keys button:active, #keys button.on { background: #0a7a50; color: #fff; }
#keys button.k-fn { background: #1b1b1b; color: #8fc8ff; font-size: 14px; }
#keys button.k-wide { flex-grow: 1.6; }
#keys button.k-space { flex-grow: 4; }
#keys .kgrid button { font-size: 20px; }

/* on its side: the terminal on the left at full height, the keys in a column on the right */
@media (orientation: landscape) {
  .keys-on .termwrap { flex-direction: row; }
  .keys-on #keys { height: auto; width: min(36%, 320px); }
  #keys button { font-size: 15px; }
  #keys .kgrid button { font-size: 17px; }
}
/* a short screen (a small phone on its side): smaller key names so they fit */
@media (max-height: 420px) { #keys button { font-size: 14px; } #keys .kgrid button { font-size: 16px; } .krow { min-height: 26px; } }
