/* Extra hands-on controls for the core mini-games. This loads after
   styles.css, so keep the overrides narrow. */

.game-board.has-game-action {
  animation: game-board-action-glow 360ms ease-out both;
}

.game-action-spark {
  position: absolute;
  z-index: 8;
  top: var(--game-action-y, 50%);
  left: var(--game-action-x, 50%);
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.game-action-spark i {
  --spark-color: #fff7a8;
  --spark-x: 0px;
  --spark-y: -46px;
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  margin: -11px;
  color: var(--spark-color);
  font: 950 0.84rem/1 var(--font-rounded);
  font-style: normal;
  opacity: 0;
  filter: drop-shadow(0 2px 2px rgba(48, 16, 38, 0.28));
  animation: game-action-spark 460ms cubic-bezier(0.16, 0.78, 0.34, 1)
    both;
}

.game-action-spark i:nth-child(2) {
  --spark-color: #d8fbff;
  --spark-x: 42px;
  --spark-y: -24px;
  animation-delay: 18ms;
}

.game-action-spark i:nth-child(3) {
  --spark-color: #ffe0f2;
  --spark-x: 44px;
  --spark-y: 28px;
  animation-delay: 36ms;
}

.game-action-spark i:nth-child(4) {
  --spark-x: 0px;
  --spark-y: 48px;
  animation-delay: 54ms;
}

.game-action-spark i:nth-child(5) {
  --spark-color: #d8fbff;
  --spark-x: -43px;
  --spark-y: 25px;
  animation-delay: 72ms;
}

.game-action-spark i:nth-child(6) {
  --spark-color: #ffe0f2;
  --spark-x: -42px;
  --spark-y: -25px;
  animation-delay: 90ms;
}

.game-action-phase-1 .game-action-spark {
  rotate: 18deg;
}

.game-action-phase-2 .game-action-spark {
  rotate: -18deg;
}

@keyframes game-board-action-glow {
  0% {
    box-shadow:
      0 0 0 0 color-mix(in srgb, var(--game-support) 68%, transparent),
      var(--shadow-lg);
  }

  42% {
    box-shadow:
      0 0 0 6px color-mix(in srgb, var(--game-support) 36%, transparent),
      var(--shadow-lg);
  }

  100% {
    box-shadow:
      0 0 0 0 transparent,
      var(--shadow-lg);
  }
}

@keyframes game-action-spark {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.2) rotate(0deg);
  }

  24% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(var(--spark-x), var(--spark-y)) scale(1.1)
      rotate(110deg);
  }
}

.bridge-support-palette {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0.9rem 0 1.1rem;
  padding: 0.75rem;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 244, 226, 0.92)),
    var(--cream);
  border: 3px solid var(--plum);
  border-radius: 18px;
  box-shadow: 0 7px 0 rgba(81, 16, 57, 0.12);
}

.bridge-support-tool {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 86px;
  align-content: center;
  gap: 0.12rem;
  padding: 0.55rem 0.45rem;
  color: var(--plum);
  background: white;
  border: 2px solid rgba(81, 16, 57, 0.28);
  border-radius: 13px;
  box-shadow: 0 4px 0 rgba(81, 16, 57, 0.16);
  font: inherit;
  text-align: center;
  transform: translateY(0);
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    border-color 150ms ease,
    background 150ms ease;
}

.bridge-support-tool > span {
  font-size: 1.65rem;
  line-height: 1;
}

.bridge-support-tool strong {
  font-family: var(--font-rounded);
  font-size: 0.84rem;
}

.bridge-support-tool small {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.2;
}

.bridge-support-tool:is(:hover, :focus-visible) {
  border-color: var(--pink);
  box-shadow: 0 6px 0 rgba(206, 0, 159, 0.2);
  transform: translateY(-2px);
}

.bridge-support-tool.is-selected {
  color: #5c0c43;
  background: linear-gradient(160deg, #fff8c9, #ffd8ea);
  border-color: var(--pink);
  box-shadow:
    0 0 0 3px white,
    0 0 0 6px rgba(206, 0, 159, 0.25),
    0 5px 0 rgba(114, 22, 77, 0.2);
}

.bridge-bay {
  cursor: cell;
}

.bridge-bay:is(:hover, :focus-visible) {
  z-index: 2;
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.9),
    0 0 0 7px rgba(206, 0, 159, 0.45);
  transform: translateY(-4px);
}

.circuit-build-line {
  align-items: stretch;
  overflow-x: auto;
  padding: 0.75rem 0.3rem 0.95rem;
  scrollbar-width: thin;
}

.circuit-build-line .circuit-part-card {
  position: relative;
  display: grid;
  min-width: 136px;
  flex: 1 0 136px;
  align-content: space-between;
  gap: 0.55rem;
  padding: 0.8rem 0.55rem 0.55rem;
  color: #203e64;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.96), rgba(224, 244, 252, 0.95));
  border: 3px solid #52758a;
  border-radius: 15px;
  box-shadow: 0 5px 0 rgba(32, 62, 100, 0.2);
  text-align: center;
}

.circuit-build-line .circuit-part-card::after {
  content: none;
}

.circuit-part-number {
  position: absolute;
  top: -0.55rem;
  left: -0.35rem;
  display: grid;
  width: 1.7rem;
  height: 1.7rem;
  place-items: center;
  color: white;
  background: #203e64;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 0 rgba(32, 62, 100, 0.22);
  font-size: 0.72rem;
  font-weight: 950;
}

.circuit-part-actions {
  display: grid;
  gap: 0.28rem;
  grid-template-columns: repeat(3, 1fr);
}

.circuit-part-actions button {
  display: grid;
  min-width: 44px;
  min-height: 44px;
  place-items: center;
  padding: 0.2rem;
  color: #203e64;
  background: white;
  border: 2px solid #91b9cc;
  border-radius: 9px;
  font: 900 1rem/1 var(--font-rounded);
}

.circuit-part-actions button:is(:hover, :focus-visible):not(:disabled) {
  color: white;
  background: #203e64;
  border-color: #203e64;
}

.circuit-part-actions button:disabled {
  opacity: 0.3;
}

.circuit-game.has-tripped .circuit-build-line .circuit-part-card {
  animation: circuit-card-check 380ms ease-out both;
}

@keyframes circuit-card-check {
  0%,
  100% {
    transform: translateX(0);
  }
  35% {
    transform: translateX(-3px);
  }
  70% {
    transform: translateX(3px);
  }
}

@media (max-width: 680px) {
  .bridge-support-palette {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bridge-support-tool {
    min-height: 78px;
  }

  .circuit-build-line {
    justify-content: flex-start;
  }

  .circuit-build-line > b {
    align-self: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-board.has-game-action,
  .game-action-spark i,
  .bridge-support-tool,
  .bridge-bay,
  .circuit-game.has-tripped .circuit-build-line .circuit-part-card {
    animation: none;
    transition: none;
  }

  .game-action-spark {
    display: none;
  }
}

@media (forced-colors: active) {
  .game-action-spark {
    display: none;
  }

  .bridge-support-tool.is-selected,
  .circuit-build-line .circuit-part-card {
    border-color: Highlight;
  }

  .bridge-support-tool.is-selected {
    outline: 3px solid Highlight;
  }
}
