/* Fall in line — the dark, its tallies and its controls. Shared chrome: artifact.css */

.board {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/*
 * The one dark thing on a paper page. Wide, the way a runner is, and rounded
 * like the buttons. The canvas draws the mist itself; the colour here only
 * shows until it does.
 */
.board__stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 0.9rem;
  background: #0c0d10;
  /* A tap anywhere on it jumps, so no tap may scroll or select. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

/* Out of the flow, so the size of its drawing can never feed back into the box's. */
.board__stage canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* The edges fall away into black, as if seen through a lens. */
.board__stage::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 48%, rgba(0, 0, 0, 0.62) 100%);
}

/*
 * Film grain: noise three times the size of the box, shifted to a new place
 * a few times a second. The stepping is what makes it grain rather than a
 * drifting texture.
 */
.board__stage::after {
  content: '';
  position: absolute;
  inset: -100%;
  width: 300%;
  height: 300%;
  z-index: 1;
  pointer-events: none;
  opacity: 0.11;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 220px 220px;
  animation: grain 0.7s steps(7) infinite;
}

@keyframes grain {
  0% {
    transform: translate(0, 0);
  }
  14% {
    transform: translate(-4%, 6%);
  }
  28% {
    transform: translate(5%, -7%);
  }
  42% {
    transform: translate(-8%, -2%);
  }
  56% {
    transform: translate(7%, 8%);
  }
  70% {
    transform: translate(-3%, -9%);
  }
  84% {
    transform: translate(9%, 3%);
  }
  100% {
    transform: translate(0, 0);
  }
}

/*
 * The site shortens every animation to nothing under reduced motion, but an
 * endless stepped one still lands on a new step every frame; it has to be
 * turned off, not sped up. The grain then simply stands still.
 */
@media (prefers-reduced-motion: reduce) {
  .board__stage::after {
    animation: none;
  }
}

/*
 * A hit is a flash to white: up in an instant, and gone again almost as
 * fast once the run is under way again. Above the grain, so the white is
 * clean. The box itself goes white with it, or its dark shows through the
 * rounded corners' soft edge as four dark specks in the white.
 */
.board__flash {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: var(--paper);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.board__stage {
  transition: background-color 0.3s var(--ease);
}

.game.is-hit .board__flash {
  opacity: 1;
  transition-duration: 0.08s;
}

.game.is-hit .board__stage {
  background-color: var(--paper);
  transition-duration: 0.08s;
}

.board__side {
  order: -1;
}

.board__side .scores {
  justify-content: space-between;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
}

.controls .status {
  flex-basis: 100%;
}

/* Legend ------------------------------------------------------------------ */

.legend__heading {
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.75rem;
}

.legend__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.5rem 1.5rem;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* A tile of the dark, with the thing drawn on it the way it stands there. */
.glyph {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0.12rem;
  border-radius: 0.3rem;
  background: #16181c;
}

.glyph__solid {
  fill: #6b717a;
}

.glyph__halo {
  fill: #dce2ea;
  opacity: 0.16;
}

.glyph__light {
  fill: #dce2ea;
}

/* An option under the legend: a plain switch, in the page's own ink. */
.option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
  font-size: 0.8125rem;
  color: var(--ink-soft);
  cursor: pointer;
}

.option__switch {
  flex: none;
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  accent-color: var(--ink);
  cursor: pointer;
}

.hint--touch {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .hint--touch {
    display: block;
  }
}

/* Record ------------------------------------------------------------------ */

.record__seed {
  display: block;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

@media (max-width: 47.99rem) {
  .game {
    gap: 1.25rem;
  }

  .board {
    gap: 1rem;
  }

  /* Squarer, so the cube and the buttons share a phone's screen. */
  .board__stage {
    aspect-ratio: 4 / 3;
  }

  .controls {
    justify-content: center;
  }

  .status {
    min-height: 1.4em;
    text-align: center;
  }

  .actions {
    justify-content: center;
  }

  .legend__list {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
}
