/* The dashboard: a shared screen, read from across a room. Always dark (a
   bright screen glares in a dim party room), with type sized to the screen
   rather than to a desk. Colours, the pixel font and the 8-bit look follow
   the dark theme of ../shared/style.css, with thicker borders for the
   distance. */

/* The same font file as ../shared/style.css; see there. */
@font-face {
  font-family: "Pixelify Sans";
  src: url("../shared/fonts/PixelifySans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #14073a;
  --surface: #241647;
  --text: #f3e6f7;
  --muted: #b579b6;
  --border: #402e95;
  --accent: #c76be0;
  /* The pumpkins' glow. */
  --accent-strong: #f2aa7d;
  --danger: #ec6068;
  --shadow: #07021a;
  --radius: 0;
  --font-pixel: "Pixelify Sans", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Grows with the screen: about 16px on a laptop, about 30px on a 1080p TV. */
  font-size: clamp(16px, 1.6vw, 40px);
  line-height: 1.35;
}

main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 3vh 4vw;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
  font-family: var(--font-pixel);
  font-weight: 600;
}

h1 {
  font-size: 2.6em;
}

h2 {
  font-size: 2em;
}

.muted {
  color: var(--muted);
}

/* The owl sprite (shared/sprites/), the dashboard's own: big above the
   sign-in form, and before the name in the board's header. */
.eyebrow .sprite {
  width: 1.5em;
  height: 1.5em;
  margin-right: 0.4em;
  vertical-align: middle;
}

/* An empty board: the ghost sprite above the words. */
.empty::before {
  content: "";
  display: block;
  width: 3em;
  height: 3em;
  margin-bottom: 0.4em;
  background: url("../shared/sprites/ghost.svg") center / contain no-repeat;
}

.eyebrow {
  margin: 0 0 0.3em;
  color: var(--accent);
  font-family: var(--font-pixel);
  font-size: 0.85em;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lead {
  font-size: 1.4em;
  max-width: 40em;
  margin: 0.6em 0 0;
  /* Descriptions keep the line breaks the admin typed. */
  white-space: pre-line;
}

button {
  font: inherit;
  font-family: var(--font-pixel);
  border-radius: var(--radius);
  border: 0;
  padding: 0.5em 1.2em;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  box-shadow: 0.2em 0.2em 0 var(--shadow);
  cursor: pointer;
}

/* Pressed: down into its shadow, in one step. */
button:not(:disabled, .link):active {
  transform: translate(0.1em, 0.1em);
  box-shadow: 0.1em 0.1em 0 var(--shadow);
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

button.link {
  background: none;
  color: var(--muted);
  font-weight: 400;
  padding: 0;
  font-size: 0.8em;
  text-decoration: underline;
  box-shadow: none;
}

/* Signing in with the access code. */

.sign-in {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8em;
  text-align: center;
  max-width: 100%;
}

.sign-in p {
  margin: 0;
}

.code-input {
  font: inherit;
  font-size: 2.4em;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3em;
  text-align: center;
  /* Six digits, each followed by its spacing, plus the padding; and no
     wider than the screen. */
  width: calc(6 * (1ch + 0.3em) + 0.6em);
  max-width: 100%;
  padding: 0.2em 0 0.2em 0.3em;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius);
}

.code-input:focus {
  outline: none;
  border-color: var(--accent);
}

.error {
  color: var(--danger);
  min-height: 1.35em;
}

/* The board. */

.board {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3vh;
  min-height: 0;
}

/* The game's name on the left, its code on the right, for the room to read
   and enter on the player page. */
.board > header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.5em 2em;
}

/* The QR code to the left of the code. */
.game-code {
  display: flex;
  align-items: flex-end;
  gap: 0.8em;
}

/* About as tall as the code beside it, to scan from close by. The code's own
   white border (its quiet zone) sets it off from the dark page. */
.game-code svg {
  flex: none;
  width: 4em;
  height: 4em;
}

.game-code .scan {
  margin: 0.2em 0 0;
  font-size: 0.8em;
}

/* In the system font, as the sign-in box's digits are, not the pixel font:
   from across a room the pixel font's 5 is hard to tell apart. */
.game-code .code {
  margin: 0;
  font-size: 2.6em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: 0.12em;
}

/* The stage on the left; the players, announcements and the message board
   stacked on the right. One column on narrow screens. */
.panels {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 2vw;
  /* The panels fill the screen; a long board is cut off at the bottom
     rather than growing the page (see .posts). */
  min-height: 0;
}

.feed {
  display: flex;
  flex-direction: column;
  gap: 2vw;
  min-height: 0;
}

.panel {
  background: var(--surface);
  border: 4px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0.35em 0.35em 0 var(--shadow);
  padding: 3vh 2.4vw;
}

/* A person's profile photo, or their initials without one (shared/photo.js),
   as in ../shared/style.css. */
.avatar {
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
}

.avatar.initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-weight: 600;
}

/* Everyone in the game, in as many columns as fit, above the announcements
   and the message board, which takes what height is left. A long list is
   cut off at the bottom, like the message board, rather than growing the
   page. */
.players {
  flex: none;
  max-height: 35vh;
  overflow: hidden;
  /* Only the bottom padding fades, so a list that fits shows no fade. */
  mask-image: linear-gradient(to bottom, black calc(100% - 3vh), transparent);
}

.players .muted {
  margin: 0;
  font-size: 0.8em;
}

.roster {
  list-style: none;
  margin: 0.6em 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10em, 1fr));
  gap: 0.5em 1.2em;
}

.roster li {
  display: flex;
  align-items: center;
  gap: 0.5em;
  min-width: 0;
}

.roster .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roster .sprite,
.outcomes .sprite {
  width: 1.1em;
  height: 1.1em;
  flex: none;
}

/* What a completed stage did to each player. */
.outcome-title {
  margin-top: 1em;
}

.outcomes {
  list-style: none;
  margin: 0 0 0.8em;
  padding: 0;
  font-size: 1.3em;
  font-family: var(--font-pixel);
}

.outcomes li {
  display: flex;
  align-items: center;
  gap: 0.4em;
}

.outcomes li.out {
  color: var(--accent-strong);
}

/* Announcements and posts: a list of short items. */

.items {
  list-style: none;
  margin: 0.4em 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9em;
}

.items h3 {
  margin: 0;
  font-family: var(--font-pixel);
  font-size: 1.15em;
  font-weight: 600;
}

.items .text {
  margin: 0.15em 0 0;
  /* Keeps the line breaks people typed, and breaks a long word rather than
     widening the page. */
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.items .meta {
  margin: 0.15em 0 0;
  color: var(--muted);
  font-size: 0.8em;
}

.posts .meta {
  margin: 0;
}

.posts .meta strong,
.votes .meta strong {
  color: var(--text);
}

/* Who voted, while the stage is voting: one line each, larger than a post's
   meta line, to read across the room. */
.items.votes {
  gap: 0.4em;
}

.votes .meta {
  margin: 0;
  font-size: 1.1em;
}

/* The board shows its newest posts at the top and fades out at the bottom
   where older ones no longer fit. */
.posts {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, black 80%, transparent);
}

/* A post that arrived while the screen showed the board. It settles in six
   frames, like a sprite, rather than a smooth fade. */
.items li.new {
  animation: arrive 1.2s steps(6);
}

@keyframes arrive {
  from {
    background: color-mix(in srgb, var(--accent) 35%, transparent);
    transform: translateY(-0.4em);
  }
  to {
    background: transparent;
    transform: none;
  }
}

/* On a wide screen, such as a TV, the board fits the screen exactly and never
   scrolls: the message board takes what height is left, and older posts fade
   out at its bottom. */
@media (min-width: 901px) {
  main {
    height: 100vh;
  }

  .panel.stage {
    overflow: hidden;
  }
}

@media (max-width: 900px) {
  .panels {
    grid-template-columns: minmax(0, 1fr);
  }

  .posts {
    flex: none;
    max-height: 70vh;
  }

  /* A narrow screen is a phone or a small window, not a screen that a room
     scans from. */
  .game-code svg,
  .game-code .scan {
    display: none;
  }
}

.board footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.8em;
}

/* The vote chart: a row per option of label, bar and count. */

.chart {
  list-style: none;
  margin: 1.2em 0 0.8em;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, max-content) 1fr auto;
  gap: 0.6em 1em;
  align-items: center;
  font-size: 1.3em;
}

.chart li {
  display: contents;
}

.chart .label {
  font-family: var(--font-pixel);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 35vw;
}

.chart .track {
  height: 1.1em;
  background: var(--bg);
  border-radius: var(--radius);
  overflow: hidden;
}

/* A bar grows in eight steps, like a game's health bar. */
.chart .bar {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius);
  transition: width 0.8s steps(8);
}

/* The option(s) with the most votes; every one of them when tied. */
.chart li.leading .bar {
  background: var(--accent-strong);
}

.chart .count {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  min-width: 2ch;
  text-align: right;
}

@media (prefers-reduced-motion: reduce) {
  .chart .bar {
    transition: none;
  }

  .items li.new {
    animation: none;
  }
}

/* The stage timer's time left (shared/countdown.js), large enough to read
   across the room. Digits of one width, so the time doesn't shift. */
.timer {
  margin: 4px 0 12px;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.1;
}

.countdown {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* The candle sprite, its flame moving, before the time. */
.countdown::before {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 0.25em;
  background: url("../shared/sprites/candle.svg") center / contain no-repeat;
}

.countdown.paused {
  color: var(--muted);
}

/* "left to vote" beside the time, smaller. */
.countdown .words {
  font-size: 0.4em;
  font-weight: 500;
  color: var(--muted);
}

/* The last seconds, and once the time is up. */
.countdown.ending,
.countdown.up {
  color: var(--danger);
}
