/* Pebble picks engine (bq-kn-). Uses the site tokens from brook.css. */

.bq-kn {
  container-type: inline-size;
  width: 100%;
  max-width: 1000px;
}

.bq-kn-in {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--bq-s3);
}

.bq-kn-board,
.bq-kn-pays {
  border-radius: var(--bq-r-l);
  border: 1px solid var(--bq-line-2);
  backdrop-filter: blur(6px);
}

.bq-kn-board {
  padding: clamp(10px, 2.4cqw, 20px);
  background:
    radial-gradient(70% 50% at 30% 10%, rgba(150, 240, 255, 0.12), transparent 70%),
    linear-gradient(170deg, rgba(16, 72, 80, 0.88), rgba(7, 34, 41, 0.92));
  box-shadow: var(--bq-shadow-2), inset 0 0 60px rgba(0, 0, 0, 0.3);
}

.bq-kn-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--bq-s3);
}

.bq-kn-count {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--bq-r-pill);
  background: rgba(0, 0, 0, 0.3);
  font-family: var(--bq-font-display);
  font-size: 14px;
  font-weight: 800;
  color: var(--bq-muted);
  font-variant-numeric: tabular-nums;
}

.bq-kn-count.is-hits { color: var(--bq-gold); }
.bq-kn-pop { animation: bq-kn-pop 320ms var(--bq-ease-out); }

@keyframes bq-kn-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

.bq-kn-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: clamp(4px, 1.1cqw, 10px);
}

/* A pebble */
.bq-kn-peb {
  --stone-a: #8aa7a8;
  --stone-b: #4f6d70;
  position: relative;
  aspect-ratio: 1.08;
  padding: 0;
  border: 0;
  border-radius: 48% 52% 46% 54% / 55% 47% 53% 45%;
  background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.45), transparent 38%),
    linear-gradient(160deg, var(--stone-a), var(--stone-b));
  box-shadow: inset 0 -5px 8px rgba(0, 0, 0, 0.28), 0 4px 8px rgba(0, 0, 0, 0.35);
  color: #0d2326;
  transform: rotate(var(--tilt, 0deg));
  transition: transform var(--bq-fast) var(--bq-ease-out), box-shadow var(--bq-med) var(--bq-ease-out),
    filter var(--bq-med) var(--bq-ease-out), opacity var(--bq-med) var(--bq-ease-out);
  -webkit-tap-highlight-color: transparent;
}

.bq-kn-peb.is-shape1 { border-radius: 55% 45% 52% 48% / 46% 54% 46% 54%; }
.bq-kn-peb.is-shape2 { border-radius: 44% 56% 58% 42% / 52% 44% 56% 48%; }
.bq-kn-peb.is-shape3 { border-radius: 50% 50% 44% 56% / 58% 50% 50% 42%; }

.bq-kn-peb.is-slate { --stone-a: #9db3b5; --stone-b: #55707a; }
.bq-kn-peb.is-sand { --stone-a: #e6d3ad; --stone-b: #a88c5f; }
.bq-kn-peb.is-moss { --stone-a: #a9c99b; --stone-b: #5d8559; }
.bq-kn-peb.is-river { --stone-a: #9fd0e0; --stone-b: #4b8aa1; }
.bq-kn-peb.is-rose { --stone-a: #dcb8b2; --stone-b: #9b6f6c; }

.bq-kn-num {
  position: relative;
  font-family: var(--bq-font-display);
  font-size: clamp(13px, 2.6cqw, 21px);
  font-weight: 900;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.bq-kn-peb:hover { transform: rotate(var(--tilt, 0deg)) translateY(-2px); }
.bq-kn-peb:active { transform: rotate(var(--tilt, 0deg)) scale(0.94); }

.bq-kn-peb.is-picked {
  box-shadow: 0 0 0 3px var(--bq-coral), 0 0 18px rgba(255, 123, 92, 0.55), inset 0 -5px 8px rgba(0, 0, 0, 0.28);
  transform: rotate(var(--tilt, 0deg)) translateY(-2px);
}

.bq-kn-peb.is-picked::after {
  content: "";
  position: absolute;
  right: 6%;
  top: 6%;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: var(--bq-coral);
  box-shadow: 0 0 0 2px #fff4ee;
}

.bq-kn-peb.is-bounce { animation: bq-kn-bounce 300ms var(--bq-ease-out); }

@keyframes bq-kn-bounce {
  0% { transform: rotate(var(--tilt, 0deg)) scale(0.95); }
  50% { transform: rotate(var(--tilt, 0deg)) translateY(-4px) scale(1.06); }
  100% { transform: rotate(var(--tilt, 0deg)) translateY(-2px); }
}

.bq-kn.is-full .bq-kn-peb:not(.is-picked):not(.is-drawn) { opacity: 0.62; }
.bq-kn.has-draw .bq-kn-peb:not(.is-drawn) { filter: saturate(0.35) brightness(0.62); }
.bq-kn.has-draw .bq-kn-peb.is-picked:not(.is-drawn) { filter: saturate(0.6) brightness(0.8); }

/* Turned over by the draw */
.bq-kn-peb.is-drawn { animation: bq-kn-flip 380ms var(--bq-ease-out); }

.bq-kn-peb.is-miss {
  --stone-a: #bfe9ff;
  --stone-b: #3d86b3;
  box-shadow: 0 0 0 2px rgba(108, 200, 255, 0.9), 0 0 16px rgba(108, 200, 255, 0.45), inset 0 -5px 8px rgba(0, 0, 0, 0.25);
}

.bq-kn-peb.is-hit {
  --stone-a: #fff1b8;
  --stone-b: #f2b33d;
  color: #2b1d00;
  box-shadow: 0 0 0 3px #fffbe8, 0 0 26px rgba(255, 207, 90, 0.9), inset 0 -5px 8px rgba(0, 0, 0, 0.2);
  animation: bq-kn-hit 520ms var(--bq-ease-out);
}

.bq-kn-peb.is-hit::after { background: var(--bq-mint); }

@keyframes bq-kn-flip {
  0% { transform: rotate(var(--tilt, 0deg)) scaleX(0.2); }
  60% { transform: rotate(var(--tilt, 0deg)) scaleX(1.06); }
  100% { transform: rotate(var(--tilt, 0deg)) scaleX(1); }
}

@keyframes bq-kn-hit {
  0% { transform: rotate(var(--tilt, 0deg)) scaleX(0.2); }
  45% { transform: rotate(var(--tilt, 0deg)) scale(1.18); }
  100% { transform: rotate(var(--tilt, 0deg)) scale(1); }
}

/* Pay table */
.bq-kn-pays {
  padding: var(--bq-s3) var(--bq-s4);
  background: rgba(6, 23, 25, 0.8);
}

.bq-kn-pays__title {
  margin: 0 0 var(--bq-s2);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bq-faint);
}

.bq-kn-pays__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bq-kn-pay {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0 8px;
  align-items: baseline;
  padding: 6px 10px;
  border-radius: var(--bq-r-s);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--bq-line);
  transition: border-color var(--bq-fast) var(--bq-ease-out), background-color var(--bq-fast) var(--bq-ease-out),
    transform var(--bq-fast) var(--bq-ease-out);
}

.bq-kn-pay__hits { font-size: 13px; color: var(--bq-muted); white-space: nowrap; }

.bq-kn-pay__mult {
  font-family: var(--bq-font-display);
  font-weight: 900;
  color: var(--bq-gold);
  font-variant-numeric: tabular-nums;
}

.bq-kn-pay__back { display: none; font-size: 12px; color: var(--bq-faint); font-variant-numeric: tabular-nums; }

.bq-kn-pay.is-lit {
  border-color: var(--bq-gold);
  background: rgba(255, 207, 90, 0.14);
  transform: scale(1.03);
}

.bq-kn-pays__note {
  margin: var(--bq-s2) 0 0;
  font-size: 12.5px;
  color: var(--bq-faint);
}

.bq-kn.is-happy .bq-kn-board { animation: bq-kn-glow 900ms var(--bq-ease-out); }

@keyframes bq-kn-glow {
  0% { box-shadow: var(--bq-shadow-2), 0 0 0 0 rgba(255, 207, 90, 0.5); }
  40% { box-shadow: var(--bq-shadow-2), 0 0 0 6px rgba(255, 207, 90, 0.35); }
  100% { box-shadow: var(--bq-shadow-2), 0 0 0 0 rgba(255, 207, 90, 0); }
}

/* Wide: the pay table becomes a column beside the board */
@container (min-width: 800px) {
  .bq-kn-in { grid-template-columns: minmax(0, 1fr) 260px; align-items: start; gap: var(--bq-s4); }
  .bq-kn-pays { padding: var(--bq-s4); }
  .bq-kn-pays__list { flex-direction: column; flex-wrap: nowrap; }
  .bq-kn-pay { grid-template-columns: 1fr auto auto; padding: 8px 12px; }
  .bq-kn-pay__hits { font-size: 14px; }
  .bq-kn-pay__mult { font-size: 17px; }
  .bq-kn-pay__back { display: inline; min-width: 52px; text-align: right; }
}

@media (prefers-reduced-motion: reduce) {
  .bq-kn-peb.is-drawn,
  .bq-kn-peb.is-hit,
  .bq-kn-peb.is-bounce,
  .bq-kn-pop,
  .bq-kn.is-happy .bq-kn-board { animation: none; }
}
