/* Match the cube — the board and its controls. Shared chrome: artifact.css */

:root {
  --cube-size: 23rem;
  --column-gap: clamp(1.5rem, 5vw, 3rem);
}

/*
 * The board and the controls share one pair of columns: the cube's track and
 * everything beside it. That is what keeps the pad under the cube and the
 * buttons under the target, at every width.
 */
.stage,
.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--column-gap);
}

.controls {
  row-gap: 1rem;
  align-items: start;
}

.stage {
  align-items: center;
}

.stage__cube {
  width: min(100%, var(--cube-size));
  aspect-ratio: 1;
  margin-inline: auto;
  touch-action: pan-y;
  cursor: grab;
}

.stage__cube:active {
  cursor: grabbing;
}

.stage__cube canvas,
.target__frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.stage__side {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--column-gap);
  width: min(100%, var(--cube-size));
  margin-inline: auto;
}

.target {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.target__frame {
  width: clamp(5.5rem, 20vw, 7rem);
  aspect-ratio: 1;
}

.target figcaption {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* Controls --------------------------------------------------------------- */

.pad {
  display: grid;
  grid-template-columns: repeat(3, 3rem);
  grid-template-rows: repeat(3, 3rem);
  gap: 0.5rem;
  justify-content: center;
}

.pad__key--up {
  grid-area: 1 / 2;
}
.pad__key--left {
  grid-area: 2 / 1;
}
.pad__key--right {
  grid-area: 2 / 3;
}
.pad__key--down {
  grid-area: 3 / 2;
}
.pad__key--roll-ccw {
  grid-area: 3 / 1;
}
.pad__key--roll-cw {
  grid-area: 3 / 3;
}

/* Square keys rather than labelled buttons, so they carry their own base. */
.pad__key {
  display: grid;
  place-items: center;
  padding: 0;
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  cursor: pointer;
  transition:
    border-color 0.2s var(--ease),
    background-color 0.2s var(--ease),
    transform 0.12s var(--ease),
    opacity 0.2s var(--ease);
}

.pad__key:hover:not(:disabled) {
  border-color: var(--ink-faint);
  background: #fff;
  color: var(--ink);
}

.pad__key:active:not(:disabled) {
  transform: translateY(1px);
}

.pad__key:disabled {
  opacity: 0.4;
  cursor: default;
}

/*
 * Phones: the cube is capped against the viewport height rather than its width,
 * so the board and the controls stay on one screen instead of a long scroll.
 */
@media (max-width: 47.99rem) {
  .game {
    gap: 1.25rem;
  }

  .stage,
  .controls {
    gap: 1rem;
  }

  .status {
    min-height: 1.4em;
  }

  .stage__cube {
    width: min(100%, var(--cube-size), 34vh);
  }

  /*
   * Target and score read as a status bar above the board, which puts the cube
   * and the controls next to each other within reach of a thumb.
   */
  .stage__side {
    order: -1;
  }

  .actions {
    justify-content: center;
  }
}

/* Side by side once there is room for the cube and a column beside it. */
@media (min-width: 48rem) {
  .stage,
  .controls {
    grid-template-columns: var(--cube-size) minmax(0, 1fr);
  }

  .stage__side {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    width: auto;
    margin-inline: 0;
    gap: 2.25rem;
  }

  .scores {
    gap: 2.5rem;
  }
}
