/* All in — the cube, its mirrors and its controls. Shared chrome: artifact.css */

/*
 * The cube and its mirrors take the whole column: three reflections beside a
 * cube leave the cube small in anything narrower. The tallies sit above it.
 */
.board {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.board__cube {
  width: 100%;
  aspect-ratio: 5 / 4;
  /* Every drag on the cube turns it, in any direction, so none of them scroll. */
  touch-action: none;
  cursor: grab;
}

.board__cube:active {
  cursor: grabbing;
}

.board__cube {
  position: relative;
}

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

.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%;
}

/* Turning ----------------------------------------------------------------- */

.turns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Square keys rather than labelled buttons, so they carry their own base. */
.pad__key {
  display: grid;
  place-items: center;
  min-width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  font: inherit;
  font-size: 1.1rem;
  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);
}

.pad__key--word {
  padding: 0 0.9rem;
  font-size: 0.8125rem;
}

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

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

/* Levels ------------------------------------------------------------------ */

.levels__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.levels__step {
  position: relative;
  min-width: 2.75rem;
  height: 2.75rem;
  padding: 0 0.5rem;
  font: inherit;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  background: none;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  cursor: pointer;
  transition:
    border-color 0.2s var(--ease),
    background-color 0.2s var(--ease),
    color 0.2s var(--ease);
}

.levels__step:hover {
  border-color: var(--ink-faint);
  color: var(--ink);
}

/* Solved: a small lit button in the corner, the way the cube ends up. */
.levels__step.is-solved::after {
  content: '';
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 0.1rem;
  background: var(--swatch-sage);
}

.levels__step[aria-current] {
  color: var(--paper);
  background: var(--ink);
  border-color: var(--ink);
}

.levels__step--endless {
  font-size: 1.05rem;
}

/* 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;
}

/* The mark as it is drawn on a cap: a key-shaped tile carrying it. */
.glyph {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0.12rem;
  border-radius: 0.3rem;
  background: var(--swatch-terracotta);
  fill: none;
  stroke: #fff;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.glyph__dot {
  fill: #fff;
  stroke: none;
}

/* 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;
  }
}

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

  .board {
    gap: 1rem;
  }

  .board__cube {
    /* Capped against the viewport height, so the cube and the buttons share a screen. */
    width: min(100%, 52vh);
    margin-inline: auto;
    aspect-ratio: 1;
  }

  .controls {
    justify-content: center;
  }

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

  .turns,
  .actions {
    justify-content: center;
  }

  .levels__list {
    justify-content: center;
  }

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