/* The game's four colours (documents/style.md) and nothing else. */
:root {
  --dark: #381c2e;
  --medium: #696d6d;
  --neutral: #ffa654;
  --highlight: #ffd765;
  /* One game pixel. page.js sets it to a whole number of screen pixels; */
  /* every length below is a count of these. */
  --px: 2px;
  /* The stage's width in game pixels (page.js: as wide as the screen takes,
     up to 232; until it has run, what the narrowest phone holds). */
  --w: 152;
}

/* The game's font (assets/images/alphabet.png, by build.mjs). An em is 8 of
   its pixels, a line 5 tall with 2 under it - BitmapText's spacing. */
@font-face {
  font-family: 'Crypt Hotel';
  src: url('media/crypt-hotel.woff') format('woff');
  font-display: block;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--dark);
  color: var(--neutral);
  font: calc(8 * var(--px)) / calc(7 * var(--px)) 'Crypt Hotel', monospace;
  font-kerning: none;
  font-variant-ligatures: none;
  font-synthesis: none;
  text-transform: uppercase;
  /* Pixels, not smoothed outlines. */
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  font-smooth: never;
  text-rendering: optimizeSpeed;
  -webkit-tap-highlight-color: transparent;
}

/* Too small a window to hold it all: scroll rather than cut off. */
body.tall {
  overflow: auto;
}

/* On a layer of its own: a browser then smooths letters in grey rather than
   per colour stripe of the screen, and with every edge on a whole pixel -
   all of them are - that leaves the four colours and nothing between. */
.stage {
  width: calc(var(--w) * var(--px));
  will-change: transform;
}

/* page.js puts the stage's corner on a screen pixel (and, where a game
   pixel is not a length a browser can hold, lays the stage out in screen
   pixels and scales it back down): all of it in this one transform. */
body.placed .stage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

/* --- RoundedPanel (src/game/ui/RoundedPanel.js) ---------------------------
   A 2px border with one pixel off each corner, and the same pixel off the
   corners of the dark inside it. Each shape is two crossed rectangles - one
   a pixel short at both ends, one a pixel short top and bottom - so there
   is nothing here for a browser to smooth. */
.panel {
  --edge: var(--medium);
  position: relative;
  display: block;
  background:
    linear-gradient(var(--edge), var(--edge)) center / calc(100% - 2 * var(--px)) 100% no-repeat,
    linear-gradient(var(--edge), var(--edge)) center / 100% calc(100% - 2 * var(--px)) no-repeat;
}

.panel::before {
  content: '';
  position: absolute;
  inset: calc(2 * var(--px));
  background:
    linear-gradient(var(--dark), var(--dark)) center / calc(100% - 2 * var(--px)) 100% no-repeat,
    linear-gradient(var(--dark), var(--dark)) center / 100% calc(100% - 2 * var(--px)) no-repeat;
}

/* One line of text: 5 tall, the 2 under it left to whatever comes next. */
.text {
  display: block;
  height: calc(5 * var(--px));
  white-space: nowrap;
  font: inherit;
}

/* Centred text sits on a whole pixel, as the game's Math.round puts it:
   page.js gives each of these its left margin. */
.centred {
  display: inline-block;
}

/* --- ShopDialogBox (src/game/ui/ShopDialogBox.js) ------------------------- */
.dialog {
  height: calc(var(--dialog-height, 76) * var(--px));
  cursor: pointer;
  outline: 0;
  user-select: none;
  -webkit-user-select: none;
}

.dialog:focus-visible {
  --edge: var(--highlight);
}

.dialog > * {
  position: absolute;
}

.portrait {
  left: calc(6 * var(--px));
  top: calc(6 * var(--px));
  width: calc(56 * var(--px));
  height: calc(64 * var(--px));
  image-rendering: pixelated;
}

.name {
  left: calc(70 * var(--px));
  top: calc(8 * var(--px));
  white-space: nowrap;
}

/* A dot every other pixel. */
.rule {
  left: calc(70 * var(--px));
  right: calc(8 * var(--px));
  top: calc(16 * var(--px));
  height: var(--px);
  background: linear-gradient(to right, var(--medium) 50%, transparent 50%) 0 0 / calc(2 * var(--px)) 100% repeat-x;
}

/* The game's wrap width: there too a word fits while it and the pixel of
   spacing after its last glyph do (BitmapText's wrapTokens). */
.line {
  left: calc(70 * var(--px));
  top: calc(21 * var(--px));
  width: calc((var(--w) - 78) * var(--px));
  color: var(--highlight);
}

/* Typed out: every glyph is in its place from the start, and shown in turn. */
.line span {
  visibility: hidden;
}

.line span.on {
  visibility: visible;
}

.line.measure {
  visibility: hidden;
}

/* "He has finished - click for more": a little arrow, bottom right - rows
   of 5, 3 and 1. */
.more {
  right: calc(8 * var(--px));
  bottom: calc(6 * var(--px));
  width: calc(5 * var(--px));
  height: calc(3 * var(--px));
  background:
    linear-gradient(var(--neutral), var(--neutral)) 0 0 / 100% var(--px) no-repeat,
    linear-gradient(var(--neutral), var(--neutral)) var(--px) var(--px) / calc(3 * var(--px)) var(--px) no-repeat,
    linear-gradient(var(--neutral), var(--neutral)) calc(2 * var(--px)) calc(2 * var(--px)) / var(--px) var(--px) no-repeat;
  visibility: hidden;
}

.dialog.done .more {
  visibility: visible;
  animation: blink 0.8s step-end infinite;
}

@keyframes blink {
  50% {
    visibility: hidden;
  }
}

.heard {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- The list: a Modal's padding and headline (src/game/ui/Modal.js) ------ */
.signup {
  margin-top: calc(6 * var(--px));
  padding: calc(8 * var(--px));
}

.signup > * {
  position: relative;
}

.headline,
.small {
  color: var(--medium);
}

/* The title screen's name box (StartScreen._buildNaming). */
.namebox {
  --edge: var(--highlight);
  height: calc(17 * var(--px));
  margin-top: calc(6 * var(--px));
  cursor: text;
}

.namebox input {
  position: absolute;
  left: calc(6 * var(--px));
  top: calc(6 * var(--px));
  width: calc(100% - 12 * var(--px));
  height: calc(7 * var(--px));
  border: 0;
  border-radius: 0;
  outline: 0;
  background: none;
  color: var(--highlight);
  caret-color: transparent;
  font: inherit;
  appearance: none;
}

.namebox input::placeholder {
  color: var(--medium);
  opacity: 1;
}

.namebox input::selection {
  background: var(--neutral);
  color: var(--dark);
}

.namebox input:-webkit-autofill {
  -webkit-text-fill-color: var(--highlight);
  box-shadow: 0 0 0 calc(20 * var(--px)) var(--dark) inset;
}

/* Its caret: one pixel wide, a pixel taller than the letters each way. */
.caret {
  position: absolute;
  top: calc(5 * var(--px));
  width: var(--px);
  height: calc(7 * var(--px));
  background: var(--neutral);
  animation: blink 0.9s step-end infinite;
}

.mirror {
  position: absolute;
  left: 0;
  top: 0;
  visibility: hidden;
  white-space: pre;
  text-transform: none;
}

/* --- PillButton (src/game/ui/PillButton.js) --------------------------------
   The game's action button - HIRE in his shop, KEEP PLAYING on the last
   screen (15 tall there too): a solid orange pill with dark lettering, its
   inside yellow under the pointer, the lettering a pixel down while pressed.
   The button is only what is pressed; the pill inside it is what is seen. */
.send {
  display: block;
  width: 100%;
  margin-top: calc(6 * var(--px));
  border: 0;
  border-radius: 0;
  outline: 0;
  background: none;
  font: inherit;
  text-transform: inherit;
  text-align: left;
  cursor: pointer;
  appearance: none;
}

.pill {
  --fill: var(--neutral);
  position: relative;
  display: block;
  height: calc(15 * var(--px));
  padding-top: calc(5 * var(--px));
  color: var(--dark);
  background:
    linear-gradient(var(--neutral), var(--neutral)) center / calc(100% - 2 * var(--px)) 100% no-repeat,
    linear-gradient(var(--neutral), var(--neutral)) center / 100% calc(100% - 2 * var(--px)) no-repeat;
}

.pill::before {
  content: '';
  position: absolute;
  inset: calc(2 * var(--px));
  background:
    linear-gradient(var(--fill), var(--fill)) center / calc(100% - 2 * var(--px)) 100% no-repeat,
    linear-gradient(var(--fill), var(--fill)) center / 100% calc(100% - 2 * var(--px)) no-repeat;
}

.pill .text {
  position: relative;
}

.send:hover .pill,
.send:focus-visible .pill {
  --fill: var(--highlight);
}

.send:active .pill .text {
  top: var(--px);
}

.small {
  margin-top: calc(6 * var(--px));
}

.trap {
  position: absolute !important;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* ?say=A LINE - only him, typing it: for recording clips and stills. */
body.clip .signup {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .dialog.done .more,
  .caret {
    animation: none;
  }
}
