/* Block Builder: a grid of squares to fill with blocks. */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem 0;
}

:root {
  --cell-empty: #FFFFFF;
  --cell-line: #6F808C;
  --board-bg: #E8EEF2;
  --block-edge: rgba(0, 0, 0, 0.45);
}

:root[data-theme="contrast"] {
  --cell-empty: #000000;
  --cell-line: #A0A0A0;
  --board-bg: #000000;
  --block-edge: #FFFFFF;
}

.mode-picker {
  margin-bottom: 0.5rem;
}

.goal-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.25rem 1rem;
}

.goal {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  font-weight: 800;
}

.count {
  margin: 0;
  padding: 0.25rem 0.9rem;
  border: 2px solid var(--panel-border);
  border-radius: 999px;
  font-weight: 700;
}

.count[hidden] {
  display: none;
}

/* Colors to choose from in Free build */
.palette {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.5rem 0 0;
}

.palette[hidden] {
  display: none;
}

.swatch {
  min-height: 52px;
  padding: 0.25rem 0.75rem 0.25rem 0.4rem;
  gap: 0.4rem;
  font-size: 1rem;
}

.swatch .chip {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 2px solid var(--block-edge);
  background: var(--chip);
}

.swatch[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent);
}

/* The building area */
.board-area {
  position: relative;
  /* A fixed height, so the squares are sized to fit the screen rather than the other way round */
  height: clamp(300px, calc(100vh - 280px), 760px);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.5rem;
  padding: 0.75rem;
  border: 3px solid var(--panel-border);
  border-radius: 20px;
  background: var(--board-bg);
  overflow: hidden;
}

.board {
  display: grid;
  gap: var(--gap, 3px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.cell {
  width: var(--cell, 48px);
  height: var(--cell, 48px);
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: default;
}

/* Free build: every square can take a block, so every square shows its edge */
.board.free .cell,
.cell.outline {
  cursor: pointer;
}

.board.free .cell {
  border-color: var(--cell-line);
  background: var(--cell-empty);
}

/* Copy a picture: the squares to fill have a dark dashed edge and a pale fill in the block's color */
.cell.outline {
  border: 3px dashed #3F4F5A;
  background: color-mix(in srgb, var(--want) 35%, var(--cell-empty));
}

:root[data-theme="contrast"] .cell.outline {
  border-color: #FFFFFF;
  background: #000000;
}

.board .cell.filled {
  border: 2px solid var(--block-edge);
  background: var(--color);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.18), inset 0 4px 0 rgba(255, 255, 255, 0.35);
}

.cell.pop {
  animation: pop 0.25s ease-out;
}

@keyframes pop {
  from { transform: scale(0.6); }
  to { transform: scale(1); }
}

.cell:focus-visible {
  outline: 5px solid var(--focus);
  outline-offset: 1px;
  position: relative;
  z-index: 1;
}

/* A finished picture comes to life for a few seconds */
.board.done-sail { animation: sail 3s ease-in-out; }
.board.done-fly { animation: fly 3s ease-in-out; }
.board.done-beat { animation: beat 1s ease-in-out 3; }
.board.done-sway { animation: sway 1.5s ease-in-out 2; transform-origin: 50% 100%; }
.board.done-drive { animation: drive 3s ease-in-out; }
.board.done-spin { animation: spin 3s ease-in-out; }
.board.done-bounce { animation: bounce 1s ease-in-out 3; }

@keyframes sail {
  0%, 100% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(6%) rotate(3deg); }
  75% { transform: translateX(-6%) rotate(-3deg); }
}
@keyframes fly {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12%); }
}
@keyframes beat {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.08); }
}
@keyframes sway {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(4deg); }
  75% { transform: rotate(-4deg); }
}
@keyframes drive {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(10%); }
}
@keyframes spin {
  from { transform: rotate(0); }
  to { transform: rotate(360deg); }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6%); }
}

/* With reduce motion a finished picture gets a glowing frame instead */
.board.done-still {
  border-radius: 12px;
  box-shadow: 0 0 0 6px var(--bg), 0 0 0 12px var(--accent);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0 0.25rem;
}

.controls[hidden] {
  display: none;
}

/* Undo / Clear all with nothing to do: shown faded but still reachable by keyboard */
.btn[aria-disabled="true"] {
  opacity: 0.55;
}

.row-help {
  flex-basis: 100%;
  margin: 0;
  text-align: center;
}
