/* web/screen.css
   The game window: its colours, the game's fonts, and how the scrollback's lines
   are laid out. web/play.html links it, and so does the builder's preview
   (web/preview.html), so a preview is drawn in the window the game draws in. */

:root {
  --bg: #000000;
  --panel: #1a1d26;
  --line: #2c3140;
  --ink: #e6e8ef;
  --dim: #767c90;
  --cell: #232734;
  --cell-edge: #3a4054;
  --accent: #7fb2ff;
  --warn: #ffb454;
  --good: #7fd18e;
}
/* Set by play.js from localStorage, per device. Every font option is a
   STACK ending in monospace: bare Windows names resolve to nothing on iOS
   and the dropdown would look broken. */
:root {
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --mono-size: 14px;
  --wrap: none;
}
/* Every font is declared in web/font-list.js and web/looks/faces.js, and
   web/font-menu.js adds its @font-face rules. */

/* ---- the scrollback: the game's own text, wrapped by the browser ------- */
#screen {
  flex: 1; overflow-y: auto; padding: 14px 18px; scrollbar-color: #444 transparent;
  /* LONGHANDS, not the `font` shorthand. Safari does not re-substitute a
     var() inside the shorthand, so on iOS the font and size dropdowns did
     nothing while wrap -- a longhand -- worked. */
  font-family: var(--mono);
  font-size: var(--mono-size);
  --line-height: 1.5;
  line-height: var(--line-height);
  white-space: pre-wrap; word-break: break-word;
}
/* Every line of the transcript is its own block, so a line that wraps has
   somewhere to hang its continuations. web/lines.js measures the leading
   whitespace or gutter token and sets --hang: the padding pushes the whole
   block right by it, and the negative indent pulls the FIRST line back so
   that line's own literal prefix lands in the space. min-height is what
   gives a blank line height -- an empty block has no line box. The play page's
   room box (web/hud/room_box.css) and chat box (web/hud/chat_box.css) lay their lines
   out the same way. */
:is(#screen, #roombox, #chatbox) .line {
  padding-left: var(--hang, 0);
  text-indent: calc(-1 * var(--hang, 0));
  min-height: calc(var(--line-height) * 1em);
}
/* `ch` is the width of "0" in the current font, so an N-character wrap is
   exact AND rescales when the size changes. Applied to an inner box so the
   scrollbar stays at the window edge rather than following the text. */
#screen > .col { max-width: var(--wrap); }
/* The engine names a meaning and sends {slug|text}; the game tells the page
   every meaning's look as data, and web/meanings.js draws each tag with the
   looks library (web/looks/) -- no rule here draws a meaning. These three
   classes are the client's own -- your echoed input, a connection notice. */
#screen .said { color: var(--accent); }
#screen .note { color: var(--dim); font-style: italic; }
#screen .bad  { color: var(--warn); }
/* A web address the game marked (web/lines.js): a link, opening a new tab. */
#screen a.address {
  color: var(--accent); text-decoration: underline; text-underline-offset: .22em;
  border-radius: 3px;
}
#screen a.address:hover { background: rgba(127, 178, 255, .14); }
#screen a.address:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* The play page's Your input and Dim input (web/play.js puts data-commands and
   data-commands-dim on the page): Small, on the right gives your command a row of
   its own at the right, smaller; Hidden takes it away, with the line it alone
   held; Dim input shows it quieter. A change redraws every line already there. */
:root[data-commands="small"] #screen .said {
  display: block; text-align: right; text-indent: 0; font-size: .85em;
}
:root[data-commands="hidden"] #screen .said,
:root[data-commands="hidden"] #screen .line:has(> .said:only-child) { display: none; }
:root[data-commands-dim="on"] #screen .said { opacity: .55; }
