/*
 * IceMiss: the page's rules. One canvas over the whole window (the game draws everything on it),
 * the night sky's colour around it, and every gesture left to the game: no scrolling, no zoom,
 * no pull-to-refresh or bounce, no selection, no callout on a long press. (The canvas itself says
 * touch-action: pan-x pan-y; a gesture takes the intersection with its ancestors', so the none
 * below wins.) Then the loading picture, the page's two sentences and the frame meter.
 */

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b1e3f;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* The window as it is now, the browser's bars included where they come and go. */
body {
  height: 100dvh;
}

/* The element the game draws in: the whole window. After the browser took the game's graphics
   away, the game is drawn in a new one in its place; the old one stays below it, its size
   unchanged, out of sight and touch (GameView.kt). */
.game {
  width: 100%;
  height: 100%;
}

.game.lost {
  visibility: hidden;
  pointer-events: none;
}

/* The loading picture: over everything until the game's first frame, then gone (boot.js). */
#loading {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b1e3f;
}

#loading svg {
  width: min(42vw, 30vh);
  height: auto;
  overflow: visible;
}

.flake {
  animation: fall 3.6s linear infinite;
}

.f1 { animation-delay: -0.2s; }
.f2 { animation-duration: 4.4s; animation-delay: -2.1s; }
.f3 { animation-duration: 3.2s; animation-delay: -1.4s; }
.f4 { animation-duration: 4.1s; animation-delay: -3.0s; }
.f5 { animation-duration: 3.4s; animation-delay: -0.9s; }
.f6 { animation-duration: 4.8s; animation-delay: -2.6s; }
.f7 { animation-duration: 3.9s; animation-delay: -1.8s; }
.f8 { animation-duration: 4.6s; animation-delay: -3.5s; }

@keyframes fall {
  from { transform: translate(0, -12px); }
  50% { transform: translate(6px, 135px); }
  to { transform: translate(0, 282px); }
}

.bar {
  animation: slide 1.4s ease-in-out infinite alternate;
}

@keyframes slide {
  from { transform: translateX(0); }
  to { transform: translateX(38px); }
}

/* A second tab of the game while another one plays (SingleInstance.kt): the picture stays, nothing
   loads, so the bar is gone. A click or a key there means "play here" (until the card of Phase B). */
#loading.waiting {
  cursor: pointer;
}

#loading.waiting .track,
#loading.waiting .bar {
  visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .flake,
  .bar {
    animation: none;
  }
}

/* A sentence of the page instead of the game: inside another site's frame, or a browser too old. */
.note {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  color: #eef4ff;
  font: 18px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
}

.note p {
  margin: 0 0 12px;
  max-width: 32em;
}

.note a {
  color: #9cc8ff;
  word-break: break-all;
}

/*
 * The frame meter (frames.js: Phase 0 and test builds, shown with #frames in the address). Its
 * lines are 45 characters, about 310 px: it fits a phone held upright. Should a figure grow wider,
 * a line wraps inside the window instead of running off its edge.
 */
.frames {
  position: fixed;
  top: max(4px, env(safe-area-inset-top));
  left: max(4px, env(safe-area-inset-left));
  z-index: 4;
  max-width: calc(100vw - 20px);
  padding: 4px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.62);
  color: #e8fff0;
  font: 11px/1.35 ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  pointer-events: none;
}
